Raccoon animation and scene changes #415

Merged
glencelow merged 16 commits from PlayerController into main 2023-03-10 17:28:16 +08:00
27 changed files with 5887 additions and 425 deletions

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -297,6 +297,7 @@
Color: {x: 1, y: 1, z: 1, w: 1} Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295 Layer: 4294967295
Strength: 0 Strength: 0
Casting Shadows: false
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 3 - EID: 3
@ -337,7 +338,7 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: ~ Components: ~
Scripts: Scripts:
- Type: SHADE_Scripting.UI.TweenManager - Type: TweenManager
Enabled: true Enabled: true
- EID: 13 - EID: 13
Name: How To Play Canvas Name: How To Play Canvas

View File

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

View File

@ -156,7 +156,7 @@ public partial class LeafSearch : BehaviourTreeNode
//Draw a ray, succeed if ray is unobstructed //Draw a ray, succeed if ray is unobstructed
Vector3 eyePosition = transform.GlobalPosition + eyeOffset; Vector3 eyePosition = transform.GlobalPosition + eyeOffset;
BoxCollider playerCollider = player.GetValueOrDefault().GetComponent<Collider>().GetCollisionShape<BoxCollider>(0); Collider playerCollider = player.GetValueOrDefault().GetComponent<Collider>();
if (playerCollider == null) if (playerCollider == null)
{ {
//Debug.Log("Failure: Player has no collider"); //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 //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 //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); Ray sightRay = new Ray(eyePosition, rayDestination - eyePosition);
RaycastHit sightRayHit = Physics.Raycast(sightRay, false, (ushort)65535)[0]; RaycastHit sightRayHit = Physics.Raycast(sightRay, false, (ushort)65535)[0];
//As of November 2022, RaycastHit contains only the FIRST object hit by //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 (returnBack && !dontReturn)
{ {
if (rb)
{
rb.LinearVelocity = Vector3.Zero;
rb.AngularVelocity = Vector3.Zero;
rb.ClearForces();
rb.ClearTorque();
}
if(transform) if(transform)
transform.LocalPosition = firstPostion; transform.LocalPosition = firstPostion;
if (rb)
rb.LinearVelocity = Vector3.Zero;
returnBack = false; returnBack = false;
} }

View File

@ -3,13 +3,28 @@ using System;
public class PlayerIdleState : BaseState public class PlayerIdleState : BaseState
{ {
public PlayerIdleState(StateMachine stateMachine) : base(stateMachine) private bool holdItem;
public PlayerIdleState(StateMachine stateMachine, bool hi) : base(stateMachine)
{ {
stateName = "Idle State"; stateName = "Idle State";
holdItem = hi;
} }
public override void OnEnter() public override void OnEnter()
{ {
//Debug.Log("WALK ENTER"); //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() public override void update()
{ {

View File

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

View File

@ -1,18 +1,38 @@
using SHADE; using SHADE;
using SHADE_Scripting.Audio;
using System; using System;
public class PlayerWalkState : BaseState public class PlayerWalkState : BaseState
{ {
private float timer; private float timer;
private float delay = 0.5f; 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"; stateName = "Walk State";
holdItem = hi;
} }
public override void OnEnter() public override void OnEnter()
{ {
//Debug.Log("WALK ENTER"); //Debug.Log("WALK ENTER");
timer = delay; 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() public override void update()
{ {
@ -21,7 +41,7 @@ public class PlayerWalkState : BaseState
if (timer > delay) if (timer > delay)
{ {
Audio.PlaySFXOnce2D("event:/Raccoon/raccoon_footsteps"); AudioHandler.audioClipHandlers["footsteps"].Play();
timer = 0; timer = 0;
} }
} }

View File

@ -34,11 +34,6 @@ public class PickAndThrow : Script
[Tooltip("Height of ray")] [Tooltip("Height of ray")]
public float rayHeight = 0.1f; 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() protected override void awake()
{ {
pc = GetScript<PlayerController>(); pc = GetScript<PlayerController>();
@ -85,7 +80,7 @@ public class PickAndThrow : Script
pc.camArm.ArmLength = aimingLength; pc.camArm.ArmLength = aimingLength;
prevTargetOffSet = pc.camArm.TargetOffset; prevTargetOffSet = pc.camArm.TargetOffset;
pc.camArm.TargetOffset = cameraArmOffSet; pc.camArm.TargetOffset = cameraArmOffSet;
pc.cam.FOV = aimingFOV; pc.cam.FOV = Settings.cameraFOV + 5;
} }
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming) if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
@ -95,7 +90,7 @@ public class PickAndThrow : Script
itemCollider.GetCollisionShape(0).IsTrigger = false; itemCollider.GetCollisionShape(0).IsTrigger = false;
pc.isAiming = false; pc.isAiming = false;
pc.camArm.TargetOffset = prevTargetOffSet; pc.camArm.TargetOffset = prevTargetOffSet;
pc.cam.FOV = defaultFOV; pc.cam.FOV = Settings.cameraFOV;
if (tpc) if (tpc)
pc.camArm.ArmLength = tpc.armLength; pc.camArm.ArmLength = tpc.armLength;
pc.holdItem = false; pc.holdItem = false;
@ -116,7 +111,7 @@ public class PickAndThrow : Script
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming) if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming)
{ {
pc.isAiming = false; pc.isAiming = false;
pc.cam.FOV = defaultFOV; pc.cam.FOV = Settings.cameraFOV;
pc.camArm.TargetOffset = prevTargetOffSet; pc.camArm.TargetOffset = prevTargetOffSet;
if (tpc) if (tpc)
pc.camArm.ArmLength = tpc.armLength; 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 SHADE;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using SHADE_Scripting.Audio;
using static Item; using static Item;
public class PlayerController : Script public class PlayerController : Script
@ -32,7 +33,7 @@ public class PlayerController : Script
private float delayTimer = 0.0f; private float delayTimer = 0.0f;
[Tooltip("The current state fo the raccoon")] [Tooltip("The current state fo the raccoon")]
public RaccoonStates currentState = RaccoonStates.IDLE; public RaccoonStates currentState;
//Movement variables============================================================ //Movement variables============================================================
[Tooltip("Max vel for walking")] [Tooltip("Max vel for walking")]
@ -98,17 +99,17 @@ public class PlayerController : Script
//rigidbody check //rigidbody check
rb = GetComponent<RigidBody>(); rb = GetComponent<RigidBody>();
if (!rb) if (!rb)
Debug.LogError("RigidBody is NULL!"); Debug.LogError("RigidBody is MISSING!");
//Transform check //Transform check
tranform = GetComponent<Transform>(); tranform = GetComponent<Transform>();
if(!tranform) if(!tranform)
Debug.LogError("tranform is NULL!"); Debug.LogError("tranform is MISSING!");
stateMachine = AddScript<StateMachine>(); stateMachine = AddScript<StateMachine>();
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>(); Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine)); dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine, holdItem));
dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine)); dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine, holdItem));
dictionary.Add(typeof(PlayerRunState), new PlayerRunState(stateMachine)); dictionary.Add(typeof(PlayerRunState), new PlayerRunState(stateMachine));
dictionary.Add(typeof(PlayerJumpState), new PlayerJumpState(stateMachine)); dictionary.Add(typeof(PlayerJumpState), new PlayerJumpState(stateMachine));
dictionary.Add(typeof(PlayerFallState), new PlayerFallState(stateMachine)); dictionary.Add(typeof(PlayerFallState), new PlayerFallState(stateMachine));
@ -131,6 +132,14 @@ public class PlayerController : Script
silhouetteBagRend = silhouetteBag.GetComponent<Renderable>(); silhouetteBagRend = silhouetteBag.GetComponent<Renderable>();
silhouetteBagRend.Material.SetProperty<float>("data.offset", 0.1f); 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() protected override void lateUpdate()
@ -167,8 +176,8 @@ public class PlayerController : Script
if (!cam) if (!cam)
{ {
cam = GetComponentInChildren<Camera>(); cam = GetComponentInChildren<Camera>();
if(pat) if (pat)
cam.FOV = pat.defaultFOV; cam.FOV = Settings.cameraFOV;
} }
if(!camArm) if(!camArm)
camArm = GetComponentInChildren<CameraArm>(); camArm = GetComponentInChildren<CameraArm>();
@ -417,7 +426,7 @@ public class PlayerController : Script
if (isAiming) if (isAiming)
{ {
isAiming = false; isAiming = false;
cam.FOV = pat.defaultFOV; cam.FOV = Settings.cameraFOV;
camArm.TargetOffset = pat.prevTargetOffSet; camArm.TargetOffset = pat.prevTargetOffSet;
camArm.ArmLength = pat.tpc.armLength; camArm.ArmLength = pat.tpc.armLength;
} }

View File

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

View File

@ -2,15 +2,64 @@
using SHADE_Scripting.Audio; using SHADE_Scripting.Audio;
using System; using System;
public class JumpPad : Script 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() protected override void awake()
{ {
AudioHandler.audioClipHandlers["SFXJumpPad"] = Audio.CreateAudioClip("event:/Props/jumppad_boing"); 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() 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) protected override void onCollisionEnter(CollisionInfo info)
@ -20,7 +69,11 @@ public class JumpPad : Script
Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXJumpPad"], GameObject.EntityId); Audio.AttachAudioClipToObject(AudioHandler.audioClipHandlers["SFXJumpPad"], GameObject.EntityId);
AudioHandler.audioClipHandlers["SFXJumpPad"].Play(); AudioHandler.audioClipHandlers["SFXJumpPad"].Play();
info.GameObject.GetScript<PlayerController>().landedOnJumpPad = true; 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) if (listOfCamera.Count == 0)
Debug.LogError("EMPTY PREVIEW POINTS"); 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() protected override void start()
@ -52,6 +47,11 @@ namespace SHADE_Scripting.UI
if (gameplayCanvas) if (gameplayCanvas)
gameplayCanvas.SetActive(false); gameplayCanvas.SetActive(false);
listOfCamera[0].SetMainCamera(); 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() protected override void update()
@ -135,7 +135,7 @@ namespace SHADE_Scripting.UI
{ {
if (reset3) if (reset3)
{ {
moveToEndPoint3 = TweenManager.CreateTweenThreadVec3(duration, listOfCamera[2].GetComponent<Transform>().LocalPosition, endPoint3, EASING_METHOD.EASE_IN_SINE); moveToEndPoint3.Reset();
reset3 = false; reset3 = false;
} }
listOfCamera[2].GetComponent<Transform>().LocalPosition = moveToEndPoint3.GetValue(); listOfCamera[2].GetComponent<Transform>().LocalPosition = moveToEndPoint3.GetValue();

View File

@ -4,18 +4,14 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SHADE_Scripting static public class Settings
{ {
static public class Settings
{
static public float cameraSensitivity = 100.0f; 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 masterVolume = 100.0f;
static public float sfxVolume = 100.0f; static public float sfxVolume = 100.0f;
static public float bgmVolume = 100.0f; static public float bgmVolume = 100.0f;
}
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -4,12 +4,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
public class TweenThread
namespace SHADE_Scripting.UI
{ {
public class TweenThread
{
private float timer = 0.0f; private float timer = 0.0f;
public float duration = 1.0f; public float duration = 1.0f;
public EASING_METHOD method; public EASING_METHOD method;
@ -32,7 +28,7 @@ namespace SHADE_Scripting.UI
if (timer >= duration) if (timer >= duration)
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() public bool IsCompleted()
{ {
@ -60,11 +56,11 @@ namespace SHADE_Scripting.UI
{ {
return value; return value;
} }
} }
public class TweenThreadVec3 public class TweenThreadVec3
{ {
private float timer = 0.0f; private float timer = 0.0f;
public float duration = 1.0f; public float duration = 1.0f;
public EASING_METHOD method; public EASING_METHOD method;
@ -115,12 +111,12 @@ namespace SHADE_Scripting.UI
{ {
return value; return value;
} }
} }
public class TweenManager : Script public class TweenManager : Script
{ {
public static TweenManager Instance { get; private set; } public static TweenManager Instance { get; private set; }
[NonSerialized] [NonSerialized]
@ -167,7 +163,6 @@ namespace SHADE_Scripting.UI
if (Instance == null) if (Instance == null)
return null; return null;
TweenThread thread = new TweenThread(duration, startValue, endValue, method); TweenThread thread = new TweenThread(duration, startValue, endValue, method);
Instance.threadList.Add(thread); Instance.threadList.Add(thread);
thread.Reset(); 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 virtual void OnEnter()
{ {}
}
public abstract void update(); public abstract void update();
public abstract void fixedUpdate(); public abstract void fixedUpdate();
public virtual void OnExit() public virtual void OnExit()
{ {}
}
public string GetStateName() public string GetStateName()
{ {
@ -37,11 +34,6 @@ public abstract class BaseState
return animationName; return animationName;
} }
public virtual float GetAnimPercent()
{
return 1.0f;
}
public virtual void onCollisionEnter(CollisionInfo info) public virtual void onCollisionEnter(CollisionInfo info)
{ {
} }

View File

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

View File

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