Merge branch 'main' into SP3-20-UI-System

This commit is contained in:
maverickdgg 2023-03-10 19:01:20 +08:00
commit 56cda49ea7
33 changed files with 5907 additions and 439 deletions

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -3071,13 +3071,14 @@
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Box
Half Extents: {x: 0.400000006, y: 0.5, z: 0.300000012}
Collision Tag: 1
Type: Capsule
Radius: 0.300000012
Height: 0.300000012
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0.25, z: 0}
Position Offset: {x: 0, y: 0.300000012, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts:
@ -3107,8 +3108,6 @@
throwItem: false
rayDistance: 0.75
rayHeight: 0.100000001
aimingFOV: 50
defaultFOV: 45
- EID: 3
Name: HoldingPoint
IsActive: true
@ -14094,9 +14093,7 @@
IsActive: true
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
Enabled: true
Scripts: ~
- EID: 549
Name: StealFoodCanvas
IsActive: true
@ -14178,7 +14175,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 554
Name: CameraPoints

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@
Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295
Strength: 0
Casting Shadows: false
IsActive: true
Scripts: ~
- EID: 1
@ -152,7 +153,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 450
Name: TransitionCanvas

View File

@ -338,7 +338,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 13
Name: How To Play Canvas

View File

@ -10,6 +10,7 @@
Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295
Strength: 0
Casting Shadows: false
IsActive: true
Scripts: ~
- EID: 1
@ -152,7 +153,7 @@
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
- Type: TweenManager
Enabled: true
- EID: 450
Name: TransitionCanvas

View File

@ -156,7 +156,7 @@ public partial class LeafSearch : BehaviourTreeNode
//Draw a ray, succeed if ray is unobstructed
Vector3 eyePosition = transform.GlobalPosition + eyeOffset;
BoxCollider playerCollider = player.GetValueOrDefault().GetComponent<Collider>().GetCollisionShape<BoxCollider>(0);
Collider playerCollider = player.GetValueOrDefault().GetComponent<Collider>();
if (playerCollider == null)
{
//Debug.Log("Failure: Player has no collider");
@ -167,7 +167,7 @@ public partial class LeafSearch : BehaviourTreeNode
}
//Ray destination to target the centre of the player's collider instead of transform position
//Since transform position is often the raccoon's base and the ray needs to hit somewhere higher to be more reliable
Vector3 rayDestination = plrT.GlobalPosition + plrT.GlobalScale * playerCollider.PositionOffset;
Vector3 rayDestination = plrT.GlobalPosition + plrT.GlobalScale * playerCollider.GetCollisionShape(0).PositionOffset;
Ray sightRay = new Ray(eyePosition, rayDestination - eyePosition);
RaycastHit sightRayHit = Physics.Raycast(sightRay, false, (ushort)65535)[0];
//As of November 2022, RaycastHit contains only the FIRST object hit by

View File

@ -86,12 +86,17 @@ public class Item : Script
if (returnBack && !dontReturn)
{
if (rb)
{
rb.LinearVelocity = Vector3.Zero;
rb.AngularVelocity = Vector3.Zero;
rb.ClearForces();
rb.ClearTorque();
}
if(transform)
transform.LocalPosition = firstPostion;
if (rb)
rb.LinearVelocity = Vector3.Zero;
returnBack = false;
}

View File

@ -3,13 +3,28 @@ using System;
public class PlayerIdleState : BaseState
{
public PlayerIdleState(StateMachine stateMachine) : base(stateMachine)
private bool holdItem;
public PlayerIdleState(StateMachine stateMachine, bool hi) : base(stateMachine)
{
stateName = "Idle State";
holdItem = hi;
}
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
if (PlayerAnimations.Instance)
{
if (!holdItem)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
}
else
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
}
}
}
public override void update()
{

View File

@ -1,4 +1,5 @@
using SHADE;
using SHADE_Scripting.Audio;
using System;
public class PlayerRunState : BaseState
@ -13,6 +14,11 @@ public class PlayerRunState : BaseState
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
if (PlayerAnimations.Instance)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerRunClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerRunClip);
}
}
public override void update()
{
@ -21,7 +27,7 @@ public class PlayerRunState : BaseState
if (timer > delay)
{
Audio.PlaySFXOnce2D("event:/Raccoon/raccoon_footsteps");
AudioHandler.audioClipHandlers["footsteps"].Play();
timer = 0;
}
}

View File

@ -1,18 +1,38 @@
using SHADE;
using SHADE_Scripting.Audio;
using System;
public class PlayerWalkState : BaseState
{
private float timer;
private float delay = 0.5f;
public PlayerWalkState(StateMachine stateMachine) : base(stateMachine)
private bool holdItem;
public PlayerWalkState(StateMachine stateMachine, bool hi) : base(stateMachine)
{
stateName = "Walk State";
holdItem = hi;
}
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
timer = delay;
if (PlayerAnimations.Instance)
{
if (!holdItem)
{
if(PlayerAnimations.Instance.playerWalkClip)
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
if(PlayerAnimations.Instance.playerWalkClip)
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
}
else
{
if(PlayerAnimations.Instance.playerCarryWalkClip)
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
if(PlayerAnimations.Instance.playerCarryWalkClip)
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
}
}
}
public override void update()
{
@ -21,7 +41,7 @@ public class PlayerWalkState : BaseState
if (timer > delay)
{
Audio.PlaySFXOnce2D("event:/Raccoon/raccoon_footsteps");
AudioHandler.audioClipHandlers["footsteps"].Play();
timer = 0;
}
}

View File

@ -34,11 +34,6 @@ public class PickAndThrow : Script
[Tooltip("Height of ray")]
public float rayHeight = 0.1f;
[Tooltip("FOV when you aim")]
public float aimingFOV = 50;
[Tooltip("Default FOV")]
public float defaultFOV = 45;
protected override void awake()
{
pc = GetScript<PlayerController>();
@ -85,7 +80,7 @@ public class PickAndThrow : Script
pc.camArm.ArmLength = aimingLength;
prevTargetOffSet = pc.camArm.TargetOffset;
pc.camArm.TargetOffset = cameraArmOffSet;
pc.cam.FOV = aimingFOV;
pc.cam.FOV = Settings.cameraFOV + 5;
}
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
@ -95,7 +90,7 @@ public class PickAndThrow : Script
itemCollider.GetCollisionShape(0).IsTrigger = false;
pc.isAiming = false;
pc.camArm.TargetOffset = prevTargetOffSet;
pc.cam.FOV = defaultFOV;
pc.cam.FOV = Settings.cameraFOV;
if (tpc)
pc.camArm.ArmLength = tpc.armLength;
pc.holdItem = false;
@ -116,7 +111,7 @@ public class PickAndThrow : Script
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming)
{
pc.isAiming = false;
pc.cam.FOV = defaultFOV;
pc.cam.FOV = Settings.cameraFOV;
pc.camArm.TargetOffset = prevTargetOffSet;
if (tpc)
pc.camArm.ArmLength = tpc.armLength;

View File

@ -0,0 +1,81 @@
using SHADE;
using System;
using System.Collections.Generic;
public class PlayerAnimations : Script
{
#region Raccoon
[SerializeField]
public AnimationClipAsset playerIdleClip; // done
[SerializeField]
public AnimationClipAsset playerWalkClip; // done
[SerializeField]
public AnimationClipAsset playerRunClip; // done
[SerializeField]
public AnimationClipAsset playerPickUpClip;
[SerializeField]
public AnimationClipAsset playerCarryIdleClip; // done
[SerializeField]
public AnimationClipAsset playerCarryWalkClip; // done
[SerializeField]
public AnimationClipAsset playerThrowClip;
[SerializeField]
public AnimationClipAsset playerJumpStartClip;
[SerializeField]
public AnimationClipAsset playerJumpLoopClip;
[SerializeField]
public AnimationClipAsset playerJumpEndClip;
#endregion
#region Animator
public Animator playerAnimator { get; private set; }
public Animator BagAnimator { get; private set; }
public Animator silhoPlayerAnimator { get; private set; }
public Animator silhoBagAnimator { get; private set; }
#endregion
#region silhouette
public GameObject silhouettePlayer;
public GameObject silhouetteBag;
#endregion
public static PlayerAnimations Instance { get; private set; }
protected override void awake()
{
if (Instance != null && Instance != this)
RemoveScript<PlayerAnimations>();
else
Instance = this;
playerAnimator = GetComponent<Animator>();
if (!playerAnimator)
Debug.LogError("Player Animator is MISSING!");
BagAnimator = GetComponentInChildren<Animator>();
if (!BagAnimator)
Debug.LogError("Bag Animator is MISSING!");
if(!silhouettePlayer)
silhoPlayerAnimator = silhouettePlayer.GetComponent<Animator>();
else
Debug.LogError("Silho Player is MISSING!");
if (!silhoPlayerAnimator)
Debug.LogError("Silho Player Animator is MISSING!");
if(!silhouetteBag)
silhoBagAnimator = silhouetteBag.GetComponent<Animator>();
else
Debug.LogError("Silho bag is MISSING!");
if (!silhoBagAnimator)
Debug.LogError("Silho Player Animator is MISSING!");
}
protected override void onDestroy()
{
if (Instance == this)
Instance = null;
}
}

View File

@ -0,0 +1,3 @@
Name: SC_PlayerAnimations
ID: 159045981
Type: 9

View File

@ -1,6 +1,7 @@
using SHADE;
using System;
using System.Collections.Generic;
using SHADE_Scripting.Audio;
using static Item;
public class PlayerController : Script
@ -32,7 +33,7 @@ public class PlayerController : Script
private float delayTimer = 0.0f;
[Tooltip("The current state fo the raccoon")]
public RaccoonStates currentState = RaccoonStates.IDLE;
public RaccoonStates currentState;
//Movement variables============================================================
[Tooltip("Max vel for walking")]
@ -98,17 +99,17 @@ public class PlayerController : Script
//rigidbody check
rb = GetComponent<RigidBody>();
if (!rb)
Debug.LogError("RigidBody is NULL!");
Debug.LogError("RigidBody is MISSING!");
//Transform check
tranform = GetComponent<Transform>();
if(!tranform)
Debug.LogError("tranform is NULL!");
Debug.LogError("tranform is MISSING!");
stateMachine = AddScript<StateMachine>();
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine));
dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine));
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine, holdItem));
dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine, holdItem));
dictionary.Add(typeof(PlayerRunState), new PlayerRunState(stateMachine));
dictionary.Add(typeof(PlayerJumpState), new PlayerJumpState(stateMachine));
dictionary.Add(typeof(PlayerFallState), new PlayerFallState(stateMachine));
@ -131,6 +132,14 @@ public class PlayerController : Script
silhouetteBagRend = silhouetteBag.GetComponent<Renderable>();
silhouetteBagRend.Material.SetProperty<float>("data.offset", 0.1f);
}
AudioHandler.audioClipHandlers["footsteps"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_footsteps");
}
protected override void start()
{
currentState = RaccoonStates.IDLE;
stateMachine.SetState(typeof(PlayerIdleState));
}
protected override void lateUpdate()
@ -167,8 +176,8 @@ public class PlayerController : Script
if (!cam)
{
cam = GetComponentInChildren<Camera>();
if(pat)
cam.FOV = pat.defaultFOV;
if (pat)
cam.FOV = Settings.cameraFOV;
}
if(!camArm)
camArm = GetComponentInChildren<CameraArm>();
@ -417,7 +426,7 @@ public class PlayerController : Script
if (isAiming)
{
isAiming = false;
cam.FOV = pat.defaultFOV;
cam.FOV = Settings.cameraFOV;
camArm.TargetOffset = pat.prevTargetOffSet;
camArm.ArmLength = pat.tpc.armLength;
}

View File

@ -37,6 +37,7 @@ namespace SHADE_Scripting
protected override void start()
{
GetComponent<CameraArm>().ArmLength = armLength;
GetComponent<Camera>().FOV = Settings.cameraFOV;
}
protected override void update()

View File

@ -2,15 +2,64 @@
using SHADE_Scripting.Audio;
using System;
public class JumpPad : Script
{
private Transform tran;
private Vector3 defaultScale;
public float scaleYMaxSize = 2.0f;
private float scaleXZMaxSize;
public float scaleDuration = 0.25f;
private bool landed = false;
private bool scaleUpDone = false;
[NonSerialized]
private TweenThread scaleYUp;
[NonSerialized]
private TweenThread scaleXZUp;
[NonSerialized]
private TweenThreadVec3 scaleDown;
protected override void awake()
{
AudioHandler.audioClipHandlers["SFXJumpPad"] = Audio.CreateAudioClip("event:/Props/jumppad_boing");
tran = GameObject.GetComponent<Transform>();
if (!tran)
Debug.LogError("NO TRANSFORM");
defaultScale = tran.LocalScale;
scaleXZMaxSize = scaleYMaxSize * 0.3f;
}
protected override void start()
{
scaleYUp = TweenManager.CreateTweenThread(scaleDuration, tran.LocalScale.y, scaleYMaxSize, EASING_METHOD.EASE_IN_SINE);
scaleXZUp = TweenManager.CreateTweenThread(scaleDuration, tran.LocalScale.y, scaleXZMaxSize, EASING_METHOD.EASE_IN_SINE);
}
protected override void update()
{
if (landed && tran)
{
tran.LocalScale = new Vector3(scaleXZUp.GetValue(), scaleYUp.GetValue(), scaleXZUp.GetValue());
if (scaleYUp.IsCompleted() && scaleXZUp.IsCompleted())
{
landed = false;
scaleUpDone = true;
scaleDown = TweenManager.CreateTweenThreadVec3(scaleDuration, tran.LocalScale, defaultScale, EASING_METHOD.EASE_IN_SINE);
}
}
if (scaleUpDone && !landed)
{
tran.LocalScale = scaleDown.GetValue();
if (scaleDown.IsCompleted())
{
scaleUpDone = false;
}
}
}
protected override void onCollisionEnter(CollisionInfo info)
@ -20,7 +69,11 @@ public class JumpPad : Script
Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXJumpPad"], GameObject.EntityId);
AudioHandler.audioClipHandlers["SFXJumpPad"].Play();
info.GameObject.GetScript<PlayerController>().landedOnJumpPad = true;
landed = true;
scaleYUp.Reset();
scaleXZUp.Reset();
}
}
}

View File

@ -40,11 +40,6 @@ namespace SHADE_Scripting.UI
if (listOfCamera.Count == 0)
Debug.LogError("EMPTY PREVIEW POINTS");
moveToEndPoint1 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[0].GetComponent<Transform>().LocalPosition, endPoint1, EASING_METHOD.EASE_IN_SINE);
moveToEndPoint2 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[1].GetComponent<Transform>().LocalPosition, endPoint2, EASING_METHOD.EASE_IN_SINE);
moveToEndPoint3 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[2].GetComponent<Transform>().LocalPosition, endPoint3, EASING_METHOD.EASE_IN_SINE);
}
protected override void start()
@ -52,6 +47,11 @@ namespace SHADE_Scripting.UI
if (gameplayCanvas)
gameplayCanvas.SetActive(false);
listOfCamera[0].SetMainCamera();
moveToEndPoint1 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[0].GetComponent<Transform>().LocalPosition, endPoint1, EASING_METHOD.EASE_IN_SINE);
moveToEndPoint2 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[1].GetComponent<Transform>().LocalPosition, endPoint2, EASING_METHOD.EASE_IN_SINE);
moveToEndPoint3 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[2].GetComponent<Transform>().LocalPosition, endPoint3, EASING_METHOD.EASE_IN_SINE);
}
protected override void update()
@ -135,7 +135,7 @@ namespace SHADE_Scripting.UI
{
if (reset3)
{
moveToEndPoint3 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[2].GetComponent<Transform>().LocalPosition, endPoint3, EASING_METHOD.EASE_IN_SINE);
moveToEndPoint3.Reset();
reset3 = false;
}
listOfCamera[2].GetComponent<Transform>().LocalPosition = moveToEndPoint3.GetValue();

View File

@ -4,18 +4,14 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting
static public class Settings
{
static public class Settings
{
static public float cameraSensitivity = 100.0f;
static public float cameraFOV = 90.0f;
static public float cameraFOV = 45.0f;
static public float masterVolume = 100.0f;
static public float sfxVolume = 100.0f;
static public float bgmVolume = 100.0f;
}
}

View File

@ -4,9 +4,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public enum EASING_METHOD
{
EASE_IN_SINE,
@ -16,8 +13,8 @@ namespace SHADE_Scripting.UI
EASE_INOUT_BOUNCE
}
public static class EasingHelper
{
public static class EasingHelper
{
public static float EaseHelp(float value, EASING_METHOD method)
{
@ -26,15 +23,18 @@ namespace SHADE_Scripting.UI
case EASING_METHOD.EASE_IN_SINE:
{
return EaseInSine(value);
}break;
}
break;
case EASING_METHOD.EASE_OUT_SINE:
{
return EaseOutSine(value);
}break;
}
break;
case EASING_METHOD.EASE_OUT_BOUNCE:
{
return EaseOutBounce(value);
}break;
}
break;
case EASING_METHOD.EASE_IN_BOUNCE:
{
return EaseInBounce(value);
@ -53,13 +53,13 @@ namespace SHADE_Scripting.UI
private static float EaseInSine(float value)
{
return (float)(1.0f - Math.Cos((value * Math.PI / 2.0f) ));
return (float)(1.0f - Math.Cos((value * Math.PI / 2.0f)));
}
private static float EaseOutSine(float value)
{
return (float)(Math.Sin(value * Math.PI / 2.0f) );
return (float)(Math.Sin(value * Math.PI / 2.0f));
}
@ -71,7 +71,8 @@ namespace SHADE_Scripting.UI
if (value < 1.0f / d1)
{
return n1 * value * value;
} else if (value < 2.0f / d1)
}
else if (value < 2.0f / d1)
{
return n1 * (value -= 2.25f / d1) * value + 0.9375f;
}
@ -91,9 +92,9 @@ namespace SHADE_Scripting.UI
private static float EaseInOutBounce(float value)
{
return (value < 0.5f)
?(1.0f - EaseOutBounce(1.0f - 2.0f * value)) / 2.0f
? (1.0f - EaseOutBounce(1.0f - 2.0f * value)) / 2.0f
: (1.0f + EaseOutBounce(2.0f * value - 1.0f)) / 2.0f;
}
}
}

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public class Options:Script
public class Options : Script
{
public GameObject masterVolSlider;
public GameObject sfxVolSlider;
@ -66,17 +66,21 @@ namespace SHADE_Scripting.UI
Slider fov = fovSlider.GetComponent<Slider>();
Slider sens = sensitivitySlider.GetComponent<Slider>();
if(mv != null)
if (mv != null)
{
Settings.masterVolume = mv.ScaledValue;
Settings.masterVolume = mv.ScaledValue * 0.01f;
SHADE.Audio.SetVCAVolume("vca:/MASTER", Settings.masterVolume);
}
if (sfx != null)
{
Settings.sfxVolume = sfx.ScaledValue;
Settings.sfxVolume = sfx.ScaledValue * 0.01f;
SHADE.Audio.SetVCAVolume("vca:/SFX", Settings.sfxVolume);
SHADE.Audio.SetVCAVolume("vca:/UI", Settings.sfxVolume);
}
if (bgm != null)
{
Settings.bgmVolume = bgm.ScaledValue;
Settings.bgmVolume = bgm.ScaledValue * 0.01f;
SHADE.Audio.SetVCAVolume("vca:/MUSIC", Settings.bgmVolume);
}
if (fov != null)
{

View File

@ -50,6 +50,7 @@ public class PauseMenu : Script
if (canvas)
canvas.SetActive(false);
Application.FixDeltaTime = Time.DefaultFixDeltaTime;
AnimationSystem.TimeScale = AnimationSystem.DefaultTimeScale;
}
});
}
@ -106,6 +107,7 @@ public class PauseMenu : Script
if (canvas)
canvas.SetActive(true);
Application.FixDeltaTime = 0;
AnimationSystem.TimeScale = 0;
}
}

View File

@ -52,14 +52,17 @@ namespace SHADE_Scripting.UI
protected override void update()
{
if (!GameManager.Instance.PreviewLevelDone)
{
if (rot != null && scaleX != null && scaleY != null)
{
rot.Reset();
scaleX.Reset();
scaleY.Reset();
}
return;
}
if (!popInDone)
if (!popInDone && rot != null && scaleX != null && scaleY != null)
{
tran.LocalEulerAngles = new Vector3(0.0f, 0.0f, SHADE.Math.DegreesToRadians(rot.GetValue()));
tran.LocalScale = new Vector3(scaleX.GetValue(), scaleY.GetValue(), 1);
@ -71,7 +74,7 @@ namespace SHADE_Scripting.UI
stayDone = true;
}
if (rot.IsCompleted() && scaleX.IsCompleted() && scaleY.IsCompleted())
if (rot != null && scaleX != null && scaleY != null && rot.IsCompleted() && scaleX.IsCompleted() && scaleY.IsCompleted())
popInDone = true;
if (stayDone)
@ -82,8 +85,11 @@ namespace SHADE_Scripting.UI
scaleOutY = TweenManager.CreateTweenThread(popOutDuration, scaleAmtY, 0, EASING_METHOD.EASE_IN_SINE);
createThreadOnce = false;
}
if(scaleOutX != null && scaleOutY != null)
tran.LocalScale = new Vector3(scaleOutX.GetValue(), scaleOutY.GetValue(), 1);
if (scaleOutX.IsCompleted() && scaleOutY.IsCompleted())
if (scaleOutX != null && scaleOutY != null && scaleOutX.IsCompleted() && scaleOutY.IsCompleted())
{
GameObject.SetActive(false);
GameManager.Instance.stealFoodPopUpDone = true;

View File

@ -4,12 +4,8 @@ using System;
using System.Collections.Generic;
using System.Threading;
namespace SHADE_Scripting.UI
public class TweenThread
{
public class TweenThread
{
private float timer = 0.0f;
public float duration = 1.0f;
public EASING_METHOD method;
@ -32,7 +28,7 @@ namespace SHADE_Scripting.UI
if (timer >= duration)
timer = duration;
value = EasingHelper.EaseHelp(timer/duration, method) * (endValue - startValue) + startValue ;
value = EasingHelper.EaseHelp(timer / duration, method) * (endValue - startValue) + startValue;
}
public bool IsCompleted()
{
@ -60,11 +56,11 @@ namespace SHADE_Scripting.UI
{
return value;
}
}
}
public class TweenThreadVec3
{
public class TweenThreadVec3
{
private float timer = 0.0f;
public float duration = 1.0f;
public EASING_METHOD method;
@ -115,12 +111,12 @@ namespace SHADE_Scripting.UI
{
return value;
}
}
}
public class TweenManager : Script
{
public class TweenManager : Script
{
public static TweenManager Instance { get; private set; }
[NonSerialized]
@ -167,7 +163,6 @@ namespace SHADE_Scripting.UI
if (Instance == null)
return null;
TweenThread thread = new TweenThread(duration, startValue, endValue, method);
Instance.threadList.Add(thread);
thread.Reset();
@ -187,7 +182,4 @@ namespace SHADE_Scripting.UI
}
}
}

View File

@ -15,17 +15,14 @@ public abstract class BaseState
}
public virtual void OnEnter()
{
}
{}
public abstract void update();
public abstract void fixedUpdate();
public virtual void OnExit()
{
}
{}
public string GetStateName()
{
@ -37,11 +34,6 @@ public abstract class BaseState
return animationName;
}
public virtual float GetAnimPercent()
{
return 1.0f;
}
public virtual void onCollisionEnter(CollisionInfo info)
{
}

View File

@ -31,6 +31,6 @@ namespace SHADE
struct SH_API SHAnimClipContainerAsset final : SHAssetData
{
AssetID animRawDataAssetId;
std::vector<SHAnimClipAsset> clips{};
std::vector<SHAnimClipAsset*> clips{};
};
}

View File

@ -66,19 +66,19 @@ namespace SHADE
for (auto const& clip : anim.clips)
{
uint32_t charCount {static_cast<uint32_t>(clip.name.size())};
uint32_t charCount {static_cast<uint32_t>(clip->name.size())};
file.write(
reinterpret_cast<char const*>(&charCount),
sizeof(uint32_t)
);
file.write(
clip.name.data(),
clip->name.data(),
charCount
);
file.write(
reinterpret_cast<char const*>(&clip.firstIndex),
reinterpret_cast<char const*>(&clip->firstIndex),
sizeof(uint32_t) * 2
);
}
@ -99,28 +99,29 @@ namespace SHADE
reinterpret_cast<char*>(&size),
sizeof(uint32_t)
);
data->clips.resize(size);
for (auto i{0}; i < size; ++i)
for (auto& clip : data->clips)
{
auto& clip {data->clips.emplace_back()};
clip = new SHAnimClipAsset;
uint32_t charCount;
file.read(
reinterpret_cast<char*>(&charCount),
sizeof(uint32_t)
);
clip.name.resize(charCount);
clip->name.resize(charCount);
file.read(
clip.name.data(),
clip->name.data(),
charCount
);
file.read(
reinterpret_cast<char*>(&clip.firstIndex),
reinterpret_cast<char*>(&clip->firstIndex),
sizeof(uint32_t) * 2
);
clip.animRawDataAssetId = data->animRawDataAssetId;
clip->animRawDataAssetId = data->animRawDataAssetId;
}
result = data;

View File

@ -314,10 +314,10 @@ namespace SHADE
.parent = parent
};
auto& newClip {animContainer->clips.emplace_back()};
newClip.name = name;
newClip->name = name;
assetCollection.emplace(id, asset);
assetCollection[parent].subAssets.push_back(&assetCollection[id]);
assetData.emplace(id, &newClip);
assetData.emplace(id, newClip);
return id;
}
@ -639,6 +639,25 @@ namespace SHADE
assetData.emplace(asset.id, data);
}
switch (asset.type)
{
case AssetType::ANIM_CONTAINER:
{
auto container = reinterpret_cast<SHAnimClipContainerAsset*>(data);
for (auto i{0}; i < asset.subAssets.size(); ++i)
{
assetData.emplace(
asset.subAssets[i]->id,
container->clips[i]
);
}
}
break;
default:
break;
}
return data;
}
@ -646,7 +665,6 @@ namespace SHADE
{
auto const& parent = assetCollection[asset.parent];
auto parentData = loaders[static_cast<size_t>(parent.type)]->Load(parent.path);
if (parentData == nullptr)
{
SHLOG_ERROR("[Asset Manager] Unable to load asset into memory: {}\n", parent.path.string());
@ -676,7 +694,7 @@ namespace SHADE
{
assetData.emplace(
parent.subAssets[i]->id,
&parentContainer->clips[i]
parentContainer->clips[i]
);
}
}
@ -859,7 +877,7 @@ namespace SHADE
for(auto& clip : data->clips)
{
SHAsset subAsset{
.name = clip.name,
.name = clip->name,
.id = GenerateAssetID(AssetType::ANIM_CLIP),
.type = AssetType::ANIM_CLIP,
.isSubAsset = true,
@ -869,7 +887,7 @@ namespace SHADE
assetCollection.emplace(subAsset.id, subAsset);
assetCollection[newAsset.id].subAssets.push_back(&assetCollection[subAsset.id]);
assetData.emplace(subAsset.id, &clip);
assetData.emplace(subAsset.id, clip);
}
SHAssetMetaHandler::WriteMetaData(assetCollection[newAsset.id]);

View File

@ -280,7 +280,7 @@ namespace SHADE
if (arm->lookAtCameraOrigin)
CameraLookAt(camera, camera.position + arm->GetTargetOffset());
CameraLookAt(camera, camera.position + tOffset);
}

View File

@ -194,10 +194,10 @@ namespace SHADE
auto assetId = SHResourceManager::GetAssetID(animClip);
if (assetId.has_value())
{
auto animAsset = SHAssetManager::GetData<SHAnimClipAsset>(assetId.value());
auto const animAsset = SHAssetManager::GetData<SHAnimClipAsset>(assetId.value());
animAsset->firstIndex = firstIndex;
animAsset->lastIndex = endIndex;
SHAssetManager::SaveAsset(assetId.value());
SHAssetManager::SaveAsset(containerAsset->id);
}
}

View File

@ -113,14 +113,15 @@ namespace SHADE
SHEditorWindowManager::CreateEditorWindow<SHAssetBrowser>();
SHEditorWindowManager::CreateEditorWindow<SHMaterialInspector>();
SHEditorWindowManager::CreateEditorWindow<SHColliderTagPanel>();
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
SHEditorWindowManager::CreateEditorWindow<SHInputBindingsPanel>();
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
SHEditorWindowManager::CreateEditorWindow<SHAnimationControllerEditor>();
SHEditorWindowManager::CreateEditorWindow<SHRawAnimInspector>();
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
//Add popup windows
SHEditorWindowManager::CreatePopupWindow<SHSceneSavePrompt>();