add project files
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class AIHandler : MonoBehaviour
|
||||
{
|
||||
public event Action<AIBase> onAIDisable;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
AIBase ai = other.GetComponentInParent<AIBase>();
|
||||
if (ai != null)
|
||||
{
|
||||
this.onAIDisable?.Invoke(ai);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d6c4fe04751a4f234276d6d235bd968
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using OHM.UnityToolkit;
|
||||
using OHM.UnityToolkit.Vibration;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class CheckpointsHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("passCheckpoint")]
|
||||
private SFX _passCheckpoint;
|
||||
|
||||
public Checkpoints lastCheckpoint { get; private set; }
|
||||
|
||||
public event Action<Checkpoints> onCheckpoints;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
Checkpoints checkpoint = other.GetComponentInParent<Checkpoints>();
|
||||
if (!(checkpoint == null) && !checkpoint.isPass)
|
||||
{
|
||||
lastCheckpoint = checkpoint;
|
||||
checkpoint.PassCheckpoint();
|
||||
_passCheckpoint.Play(base.transform);
|
||||
VibrationManager.Vibrate(VibrationManager.VibrationType.MEDIUM);
|
||||
if (this.onCheckpoints != null)
|
||||
{
|
||||
this.onCheckpoints(checkpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UnPause(bool success)
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88827e7adae7c42cf333a70a34208ccf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ContinuePickUpHandler : MonoBehaviour
|
||||
{
|
||||
private List<ConutinuePickUpZone> _curZoneList;
|
||||
|
||||
private ConutinuePickUpZone _curZone;
|
||||
|
||||
public event Action<ConutinuePickUpZone> onEnterContinueItem;
|
||||
|
||||
public event Action onExitContinueItem;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
_curZoneList = new List<ConutinuePickUpZone>();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
ConutinuePickUpZone zone = other.GetComponentInParent<ConutinuePickUpZone>();
|
||||
if (zone != null)
|
||||
{
|
||||
_curZoneList.Add(zone);
|
||||
}
|
||||
UpdateZone();
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
ConutinuePickUpZone zone = other.GetComponentInParent<ConutinuePickUpZone>();
|
||||
if (zone != null)
|
||||
{
|
||||
zone.ActiveZone(active: false);
|
||||
_curZoneList.Remove(zone);
|
||||
}
|
||||
UpdateZone();
|
||||
}
|
||||
|
||||
private void UpdateZone()
|
||||
{
|
||||
if (_curZoneList.Count == 0)
|
||||
{
|
||||
if (_curZone != null)
|
||||
{
|
||||
_curZone.ActiveZone(active: false);
|
||||
_curZone = null;
|
||||
}
|
||||
if (this.onExitContinueItem != null)
|
||||
{
|
||||
this.onExitContinueItem();
|
||||
}
|
||||
return;
|
||||
}
|
||||
ConutinuePickUpZone last = _curZoneList[_curZoneList.Count - 1];
|
||||
if (_curZone != last)
|
||||
{
|
||||
if (_curZone != null)
|
||||
{
|
||||
_curZone.ActiveZone(active: false);
|
||||
}
|
||||
last.ActiveZone(active: true);
|
||||
_curZone = last;
|
||||
if (this.onEnterContinueItem != null)
|
||||
{
|
||||
this.onEnterContinueItem(last);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3afcc5ddff449a3d05b49b1a96951f10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EndAnimBool : StateMachineBehaviour
|
||||
{
|
||||
public List<string> listAnim;
|
||||
|
||||
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
||||
{
|
||||
foreach (string name in listAnim)
|
||||
{
|
||||
animator.SetBool(name, value: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b2fc13f7c5ae6d472ecd1d7a373970c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using OHM.UnityToolkit;
|
||||
|
||||
[Serializable]
|
||||
public class ItemOnPlayerElement
|
||||
{
|
||||
public bool none;
|
||||
|
||||
public bool canBeMultiItem;
|
||||
|
||||
public GameObject element;
|
||||
|
||||
public SkinnedMeshRenderer skinnedMeshRenderer;
|
||||
|
||||
public Mesh mesh;
|
||||
|
||||
public FX fxToPlay;
|
||||
|
||||
public float minRichLevel;
|
||||
|
||||
public float maxRichLevel;
|
||||
|
||||
public bool isActive;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afd68d911e36df04a8004ea357699fbb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[Serializable]
|
||||
public class ListOfTypeElement
|
||||
{
|
||||
public string type;
|
||||
|
||||
public List<ItemOnPlayerElement> listItem;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a9fc56ad08e3434391b5e2e194b24ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,288 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class MovePlayer : CoreBehaviour
|
||||
{
|
||||
public class XpositionWanted
|
||||
{
|
||||
public float xRef;
|
||||
|
||||
public float xOffset;
|
||||
}
|
||||
|
||||
public Rigidbody body;
|
||||
|
||||
public SwerveXInputHandler swerveInput;
|
||||
|
||||
public SwerveXSmoothMover swerveSmoothMove;
|
||||
|
||||
public GameObject toMove;
|
||||
|
||||
public GameObject umbrella;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("turnZoneHandler")]
|
||||
private TurnZoneHandler _turnZoneHandler;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("visualRotation")]
|
||||
private GameObject _visualRotation;
|
||||
|
||||
private float _lastPosY;
|
||||
|
||||
private float _speed;
|
||||
|
||||
private Player player;
|
||||
|
||||
private bool _isTurn;
|
||||
|
||||
private Section _curSectionTurn;
|
||||
|
||||
private float _curStartYTurn;
|
||||
|
||||
private float speedRatio = 1f;
|
||||
private float _desiredRotVisual;
|
||||
|
||||
private float _needWaitToMove;
|
||||
|
||||
private int LayerGround;
|
||||
|
||||
private float _prevSetX;
|
||||
|
||||
private XpositionWanted _xPositionWanted;
|
||||
|
||||
private Vector3 _targetPos;
|
||||
|
||||
private Vector3 _oldPosition;
|
||||
|
||||
public float smoothTimeY;
|
||||
|
||||
public float maxSpeedY;
|
||||
|
||||
private float _currentYSpeed;
|
||||
|
||||
public float curSpeed { get; private set; }
|
||||
|
||||
public bool verti { get; private set; } = true;
|
||||
|
||||
public float speed
|
||||
{
|
||||
get
|
||||
{
|
||||
return _speed;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_speed = value;
|
||||
player.anim.SetFloat("Speed", value);
|
||||
}
|
||||
}
|
||||
|
||||
public void Setup(Player p)
|
||||
{
|
||||
LayerGround = LayerMask.GetMask("Ground");
|
||||
player = p;
|
||||
SetUmbrellaParent(base.transform, (Transform t) => t.name == "mixamorig:RightHand");
|
||||
ActiveUmbrella(active: false);
|
||||
swerveInput.trackWidth = base.CoreDef.levelWidth;
|
||||
swerveSmoothMove.maxSpeed = base.CoreDef.player.lateralMaxSpeed;
|
||||
swerveSmoothMove.smoothTime = base.CoreDef.player.lateralSmoothTime;
|
||||
maxSpeedY = base.CoreDef.player.heightMaxSpeed;
|
||||
smoothTimeY = base.CoreDef.player.heightSmoothTime;
|
||||
_desiredRotVisual = _visualRotation.transform.localEulerAngles.y;
|
||||
_lastPosY = 0f;
|
||||
_turnZoneHandler.onTurn += OnTurn;
|
||||
}
|
||||
|
||||
private Transform SetUmbrellaParent(Transform parent, Func<Transform, bool> query)
|
||||
{
|
||||
Transform found = null;
|
||||
if (parent.childCount > 0)
|
||||
{
|
||||
for (int i = 0; i < parent.childCount; i++)
|
||||
{
|
||||
Transform child = parent.GetChild(i);
|
||||
if (query(child))
|
||||
{
|
||||
Vector3 localPosition = umbrella.transform.localPosition;
|
||||
Vector3 localEulerAngles = umbrella.transform.localEulerAngles;
|
||||
umbrella.transform.SetParent(child);
|
||||
umbrella.transform.localPosition = localPosition;
|
||||
umbrella.transform.localEulerAngles = localEulerAngles;
|
||||
return child;
|
||||
}
|
||||
found = SetUmbrellaParent(child, query);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
private void ActiveUmbrella(bool active)
|
||||
{
|
||||
umbrella.SetActive(active);
|
||||
player.anim.SetBool("Flying", active);
|
||||
}
|
||||
|
||||
public void Go()
|
||||
{
|
||||
curSpeed = base.CoreDef.player.RunningSpeed;
|
||||
swerveInput.activeControl(active: true);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (player.Win)
|
||||
{
|
||||
RotateWin();
|
||||
speed = 0f;
|
||||
return;
|
||||
}
|
||||
if (!player.Started || player.isDie)
|
||||
{
|
||||
speed = 0f;
|
||||
return;
|
||||
}
|
||||
speed = Vector3.Distance(_oldPosition, toMove.transform.position) / Time.deltaTime / base.CoreDef.player.RunningSpeed;
|
||||
_oldPosition = toMove.transform.position;
|
||||
if (_needWaitToMove > 0f)
|
||||
{
|
||||
_needWaitToMove -= Time.deltaTime;
|
||||
if (_needWaitToMove <= 0f)
|
||||
{
|
||||
swerveInput.activeControl(active: true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Vector3 pos = base.transform.position;
|
||||
Vector3 localPos = toMove.transform.localPosition;
|
||||
if (!player.winHandler.Won && !player.isDie)
|
||||
{
|
||||
UpdateRotationPlayerVisual();
|
||||
if (!player.winHandler.isWinning || player.winHandler.moveActive)
|
||||
{
|
||||
swerveSmoothMove.ApplyMove(ref localPos, swerveInput.TargetWorldX, speedRatio);
|
||||
}
|
||||
else
|
||||
{
|
||||
swerveSmoothMove.ApplyMove(ref localPos, 0f, speedRatio);
|
||||
}
|
||||
UpdatePosY(ref localPos);
|
||||
toMove.transform.localPosition = localPos;
|
||||
}
|
||||
if (_isTurn)
|
||||
{
|
||||
UpdateTurn(pos);
|
||||
}
|
||||
UpdateRunning(ref pos);
|
||||
}
|
||||
|
||||
public void ChangeSpeedRatio(float richPoorValue)
|
||||
{
|
||||
if (base.CoreDef.player.slowSpeedWhenPoor)
|
||||
{
|
||||
speedRatio = richPoorValue / (float)base.CoreDef.player.maxValueRich + 1f;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRunning(ref Vector3 pos)
|
||||
{
|
||||
pos += toMove.transform.forward * (curSpeed * speedRatio * Time.deltaTime);
|
||||
base.transform.position = pos;
|
||||
}
|
||||
|
||||
private void UpdateTurn(Vector3 pos)
|
||||
{
|
||||
float y = _curSectionTurn.GetYRotationTurnSection(pos, _curStartYTurn, this);
|
||||
base.transform.eulerAngles = new Vector3(base.transform.eulerAngles.x, y, base.transform.eulerAngles.z);
|
||||
}
|
||||
|
||||
private void OnTurn(Section sectionTurn)
|
||||
{
|
||||
_curSectionTurn = sectionTurn;
|
||||
_isTurn = true;
|
||||
_curStartYTurn = WrapAngle(sectionTurn.transform.eulerAngles.y);
|
||||
}
|
||||
|
||||
private static float WrapAngle(float angle)
|
||||
{
|
||||
angle %= 360f;
|
||||
if (angle > 180f)
|
||||
{
|
||||
angle -= 360f;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
public void EndTurn()
|
||||
{
|
||||
_isTurn = false;
|
||||
verti = !verti;
|
||||
}
|
||||
|
||||
private void UpdatePosY(ref Vector3 pos)
|
||||
{
|
||||
if (Physics.Raycast(toMove.transform.position + Vector3.up, Vector3.down, out var hitInfo, base.CoreDef.player.maxDistRaycast, LayerGround))
|
||||
{
|
||||
float y = hitInfo.point.y;
|
||||
if (_lastPosY - y > base.CoreDef.player.minDistSnapGround)
|
||||
{
|
||||
ActiveUmbrella(active: true);
|
||||
y = Mathf.SmoothDamp(toMove.transform.position.y, y, ref _currentYSpeed, smoothTimeY, maxSpeedY, Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
ActiveUmbrella(active: false);
|
||||
}
|
||||
pos.y = y;
|
||||
_lastPosY = y;
|
||||
}
|
||||
}
|
||||
|
||||
public void Revive()
|
||||
{
|
||||
_desiredRotVisual = 0f;
|
||||
_lastPosY = 0f;
|
||||
toMove.transform.localPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
private void UpdateRotationPlayerVisual()
|
||||
{
|
||||
if (player.winHandler.isWinning && !player.winHandler.moveActive)
|
||||
{
|
||||
_desiredRotVisual = 0f;
|
||||
}
|
||||
else if (swerveInput.deltaX > 0f)
|
||||
{
|
||||
_desiredRotVisual = base.CoreDef.player.maxRot;
|
||||
}
|
||||
else if (swerveInput.deltaX < 0f)
|
||||
{
|
||||
_desiredRotVisual = 0f - base.CoreDef.player.maxRot;
|
||||
}
|
||||
else
|
||||
{
|
||||
_desiredRotVisual = 0f;
|
||||
}
|
||||
_desiredRotVisual = Mathf.Clamp(_desiredRotVisual, 0f - base.CoreDef.player.maxRot, base.CoreDef.player.maxRot);
|
||||
Quaternion target = Quaternion.Euler(0f, _desiredRotVisual, 0f);
|
||||
_visualRotation.transform.localRotation = Quaternion.Lerp(_visualRotation.transform.localRotation, target, Time.deltaTime * base.CoreDef.player.rotSpeed);
|
||||
}
|
||||
|
||||
private void RotateWin()
|
||||
{
|
||||
_visualRotation.transform.localRotation = Quaternion.RotateTowards(_visualRotation.transform.localRotation, Quaternion.Euler(0f, 180f, 0f), base.CoreDef.player.rotateWinSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
public void WaitBeforeMove(float time)
|
||||
{
|
||||
_needWaitToMove = time;
|
||||
swerveInput.activeControl(active: false);
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = Color.magenta;
|
||||
Gizmos.DrawRay(toMove.transform.position + Vector3.up, Vector3.down * base.CoreDef.player.maxDistRaycast);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93aa469cd5ca0fc3909d387b6f13f677
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using OHM.UnityToolkit;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class PickUpItemHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private SFX GoodItem;
|
||||
|
||||
[SerializeField]
|
||||
private SFX BadItem;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("keyItem")]
|
||||
private SFX _keyItem;
|
||||
|
||||
public event Action<PickUpItem> onPickUpItem;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
PickUpItem item = other.GetComponentInParent<PickUpItem>();
|
||||
if (item != null && !item.isUse)
|
||||
{
|
||||
item.UseItem();
|
||||
SFX sfx = (((int)item.valueChange >= 1) ? GoodItem : BadItem);
|
||||
sfx.Play(base.transform);
|
||||
if (this.onPickUpItem != null)
|
||||
{
|
||||
this.onPickUpItem(item);
|
||||
}
|
||||
}
|
||||
Doors doors = other.GetComponentInParent<Doors>();
|
||||
if (doors != null)
|
||||
{
|
||||
doors.DisableDoors();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 923191de73d1f7ac598e1f4068d7caab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,226 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using OHM.UnityToolkit;
|
||||
using OHM.UnityToolkit.Vibration;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class Player : CoreBehaviour
|
||||
{
|
||||
public Transform visualCont;
|
||||
|
||||
public MovePlayer movePlayer;
|
||||
|
||||
public RichManagePlayer richManagePlayer;
|
||||
|
||||
public WinHandler winHandler;
|
||||
|
||||
public AIHandler aIsHandler;
|
||||
|
||||
public SlotMachineHandler slotMachineHandler;
|
||||
|
||||
public CheckpointsHandler checkpointsHandler;
|
||||
|
||||
[NonSerialized]
|
||||
public Animator anim;
|
||||
|
||||
public Action<int> onWin;
|
||||
|
||||
public Action onLose;
|
||||
|
||||
[Header("Shop Mode")]
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("shopModeChangeRichDelay")]
|
||||
private float _shopModeChangeRichDelay;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("shopChangeStateFx")]
|
||||
private FX _shopChangeStateFx;
|
||||
|
||||
public bool Started { get; private set; }
|
||||
|
||||
public bool isDie { get; private set; }
|
||||
|
||||
public bool Win { get; private set; }
|
||||
|
||||
public bool BestWin { get; private set; }
|
||||
|
||||
public bool IsReady { get; private set; }
|
||||
|
||||
public bool ShopMode { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
anim = visualCont.GetComponentInChildren<Animator>();
|
||||
movePlayer.Setup(this);
|
||||
richManagePlayer.Setup(this);
|
||||
richManagePlayer.VisualPlayerRichPoor.playerGauge.ActiveGauge(active: false);
|
||||
winHandler.onTryPassDoor += OnTryPassDoor;
|
||||
richManagePlayer.onLose += OnLose;
|
||||
aIsHandler.onAIDisable += OnAIDisable;
|
||||
slotMachineHandler.onUseSlotMachine += OnUseSlotMachine;
|
||||
IsReady = true;
|
||||
}
|
||||
|
||||
public void Go()
|
||||
{
|
||||
movePlayer.Go();
|
||||
richManagePlayer.Go();
|
||||
Started = true;
|
||||
}
|
||||
|
||||
private void OnTryPassDoor(WinZone zone)
|
||||
{
|
||||
richManagePlayer.VisualPlayerRichPoor.playerGauge.ActiveGauge(active: false);
|
||||
if (zone.moveActive)
|
||||
{
|
||||
movePlayer.swerveInput.activeControl(active: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
movePlayer.swerveInput.InputCancel();
|
||||
}
|
||||
if (!zone.millionaire && base.CoreDef.HaveMinLevelRich(zone.doorLevel, richManagePlayer.curScore))
|
||||
{
|
||||
if (!zone.moveActive)
|
||||
{
|
||||
anim.SetBool("good", value: true);
|
||||
}
|
||||
winHandler.PassZone();
|
||||
return;
|
||||
}
|
||||
Win = true;
|
||||
anim.SetFloat("Speed", 0f);
|
||||
anim.SetTrigger("Win");
|
||||
richManagePlayer.VisualPlayerRichPoor.playerGauge.ActiveGauge(active: false);
|
||||
VibrationManager.Vibrate(VibrationManager.VibrationType.BIG);
|
||||
if (zone.millionaire)
|
||||
{
|
||||
BestWin = true;
|
||||
}
|
||||
else if (base.CoreDef.HaveMinLevelRich("MILLIONAIRE", richManagePlayer.richPoor))
|
||||
{
|
||||
WinMillionaire();
|
||||
}
|
||||
winHandler.WinZone();
|
||||
if (onWin != null)
|
||||
{
|
||||
onWin(winHandler.LastWinZone.multCurency);
|
||||
}
|
||||
}
|
||||
|
||||
private void WinMillionaire()
|
||||
{
|
||||
BestWin = true;
|
||||
winHandler.PassZone();
|
||||
}
|
||||
|
||||
private void OnLose()
|
||||
{
|
||||
isDie = true;
|
||||
SetAllBoolAnimFalse();
|
||||
anim.SetFloat("Speed", 0f);
|
||||
anim.SetTrigger("Lose");
|
||||
if (onLose != null)
|
||||
{
|
||||
onLose();
|
||||
}
|
||||
richManagePlayer.VisualPlayerRichPoor.playerGauge.ActiveGauge(active: false);
|
||||
VibrationManager.Vibrate(VibrationManager.VibrationType.BIG);
|
||||
}
|
||||
|
||||
private void OnAIDisable(AIBase ai)
|
||||
{
|
||||
if (!ai.PlayerIsCatch(richManagePlayer, movePlayer.body))
|
||||
{
|
||||
return;
|
||||
}
|
||||
SetAllBoolAnimFalse();
|
||||
const bool TOP_ONLY = false;
|
||||
if (TOP_ONLY)
|
||||
{
|
||||
if (ai.isPhotographer)
|
||||
{
|
||||
anim.SetBool("SlotMachineWin_Top", value: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
anim.SetBool("pickpocket_Top", value: true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
anim.SetBool(ai.isPhotographer ? "SlotMachineWin" : "pickpocket", value: true);
|
||||
movePlayer.WaitBeforeMove(ai.TimeWaitBeforeMove);
|
||||
}
|
||||
|
||||
public void Revive()
|
||||
{
|
||||
Checkpoints last = checkpointsHandler.lastCheckpoint;
|
||||
if (last != null)
|
||||
{
|
||||
base.transform.position = last.transform.position;
|
||||
base.transform.rotation = last.transform.rotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.transform.position = Vector3.zero;
|
||||
base.transform.rotation = Quaternion.identity;
|
||||
}
|
||||
movePlayer.Revive();
|
||||
isDie = false;
|
||||
anim.SetTrigger("Revive");
|
||||
richManagePlayer.Revive();
|
||||
richManagePlayer.VisualPlayerRichPoor.playerGauge.ActiveGauge(active: true);
|
||||
}
|
||||
|
||||
private void SetAllBoolAnimFalse()
|
||||
{
|
||||
anim.SetBool("bad", value: false);
|
||||
anim.SetBool("good", value: false);
|
||||
anim.SetBool("pickpocket", value: false);
|
||||
anim.SetBool("SlotMachineWin_Top", value: false);
|
||||
anim.SetBool("SlotMachineLose_Top", value: false);
|
||||
anim.SetBool("pickpocket_Top", value: false);
|
||||
}
|
||||
|
||||
private void OnUseSlotMachine(SlotMachine slotMachine)
|
||||
{
|
||||
if (slotMachine == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool win = slotMachine.UseSlotMachine(richManagePlayer);
|
||||
SetAllBoolAnimFalse();
|
||||
anim.SetTrigger(win ? "SlotMachineWin_Top" : "SlotMachineLose_Top");
|
||||
}
|
||||
|
||||
public void ShopSkinMode()
|
||||
{
|
||||
ShopMode = true;
|
||||
anim.SetTrigger("ShopSkinMode");
|
||||
StartCoroutine(ShopModeRountine());
|
||||
}
|
||||
|
||||
private IEnumerator ShopModeRountine()
|
||||
{
|
||||
List<int> thresholds = base.CoreDef.textByRich.Keys.OrderBy((int k) => k).ToList();
|
||||
for (int i = 0; i < thresholds.Count; i++)
|
||||
{
|
||||
richManagePlayer.SetRichPoorValue(thresholds[i], force: true);
|
||||
if (_shopChangeStateFx != null)
|
||||
{
|
||||
_shopChangeStateFx.PlayInstance(base.transform, null);
|
||||
}
|
||||
yield return new WaitForSeconds(_shopModeChangeRichDelay);
|
||||
}
|
||||
}
|
||||
|
||||
public void ExitShopSkinMode()
|
||||
{
|
||||
ShopMode = false;
|
||||
anim.SetTrigger("ExitShopSkinMode");
|
||||
richManagePlayer.SetRichPoorValue(base.CoreDef.player.richValueStart, force: true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35f8c4d42304d9a7cd31d22caa78f503
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
|
||||
[Serializable]
|
||||
public class PlayerDef
|
||||
{
|
||||
public Player prefab;
|
||||
|
||||
public float timeWaitWhenMakeAction;
|
||||
|
||||
public bool gameOverAt0;
|
||||
|
||||
public bool ifGameoverWaitOneMoreErrorAt0;
|
||||
|
||||
public int maxValueRich = 100;
|
||||
public int richValueStart;
|
||||
|
||||
public int richValueStartABTestStartRich;
|
||||
|
||||
public float SpeedRichPoorValue;
|
||||
|
||||
public float speedIncValueOnZone;
|
||||
|
||||
public float swerveSensitivity;
|
||||
|
||||
public float maxSideSpeed;
|
||||
|
||||
public bool slowSpeedWhenPoor;
|
||||
|
||||
public float RunningSpeed;
|
||||
|
||||
public float lateralMaxSpeed;
|
||||
|
||||
public float lateralSmoothTime;
|
||||
|
||||
public float rotSpeed;
|
||||
|
||||
public float maxRot;
|
||||
|
||||
public float rotateWinSpeed;
|
||||
|
||||
public float maxDistRaycast;
|
||||
|
||||
public float minDistSnapGround;
|
||||
|
||||
public float heightMaxSpeed;
|
||||
|
||||
public float heightSmoothTime;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b48165ed5c2d81408c75077f47f3975
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
using OHM.UnityToolkit.UI;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class PlayerGauge : CoreBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("progressionGauge")]
|
||||
private UIIncrementableGauge _progressionGauge;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("statusTxt")]
|
||||
private SizePrefabUI _statusTxt;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("animGauge")]
|
||||
private Animator _animGauge;
|
||||
|
||||
public void UpdateGauge(int v, bool force = false)
|
||||
{
|
||||
float value = (float)v / (float)base.CoreDef.player.maxValueRich;
|
||||
if (force)
|
||||
{
|
||||
_progressionGauge.QuickResetToLevel(0, value, force: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_progressionGauge.SetTargetValue(value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeStatus(string locKey, Color color)
|
||||
{
|
||||
_statusTxt.SetText(locKey, color);
|
||||
_progressionGauge.changeGaugeColor(color);
|
||||
}
|
||||
|
||||
public void ActiveGauge(bool active)
|
||||
{
|
||||
base.gameObject.SetActive(active);
|
||||
}
|
||||
|
||||
public void ActiveDanger(bool active)
|
||||
{
|
||||
_animGauge.SetBool("Danger", active);
|
||||
}
|
||||
|
||||
public void ActiveMax(bool active)
|
||||
{
|
||||
_animGauge.SetBool("Max", active);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbf9ff65c31288e670361db87618688b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,280 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using OHM.UnityToolkit;
|
||||
using OHM.UnityToolkit.Vibration;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class RichManagePlayer : CoreBehaviour
|
||||
{
|
||||
public VisualPlayerRichPoor VisualPlayerRichPoor;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("pickUpItemHandler")]
|
||||
private PickUpItemHandler _pickUpItemHandler;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("continuePickUpHandler")]
|
||||
private ContinuePickUpHandler _continuePickUpHandler;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("thresholdRichHandler")]
|
||||
private ThresholdRichHandler _thresholdRichHandler;
|
||||
|
||||
[SerializeField]
|
||||
[Header("FX")]
|
||||
[FormerlySerializedAs("fxGainContinue")]
|
||||
private FX _fxGainContinue;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("fxLooseContinue")]
|
||||
private FX _fxLooseContinue;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("fxGainPickUp")]
|
||||
private FX _fxGainPickUp;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("fxLoosePickUp")]
|
||||
private FX _fxLoosePickUp;
|
||||
|
||||
[SerializeField]
|
||||
private Transform spawnFx;
|
||||
|
||||
[SerializeField]
|
||||
[Header("Sound")]
|
||||
private SFX GoodCloth;
|
||||
|
||||
[SerializeField]
|
||||
private SFX BadCloth;
|
||||
|
||||
private Player player;
|
||||
|
||||
private float _protectedUntil = -1f;
|
||||
public int targetRichPoor;
|
||||
|
||||
public int tmpTargetRichPoor;
|
||||
|
||||
private bool _nextGameOver;
|
||||
|
||||
private bool _needUpdateTargetRichPoor;
|
||||
|
||||
private float _needUpdateContinueRichPoor;
|
||||
|
||||
public int richPoor { get; private set; }
|
||||
|
||||
public int curScore => richPoor;
|
||||
|
||||
public event Action onLose;
|
||||
|
||||
public event Action<float> onChangeMoney;
|
||||
|
||||
public event Action<long> onUpdateScore;
|
||||
|
||||
public void Setup(Player p)
|
||||
{
|
||||
_continuePickUpHandler.Setup();
|
||||
player = p;
|
||||
targetRichPoor = (tmpTargetRichPoor = base.CoreDef.player.richValueStart);
|
||||
ForceRichPoorValue(base.CoreDef.player.richValueStart, init: true);
|
||||
_pickUpItemHandler.onPickUpItem += OnPickUpItem;
|
||||
_continuePickUpHandler.onEnterContinueItem += OnEnterContinueItem;
|
||||
_continuePickUpHandler.onExitContinueItem += OnExitContinueItem;
|
||||
_thresholdRichHandler.onThresholdZone += OnThresholdZone;
|
||||
VisualPlayerRichPoor.onChangeCloth += OnChangeCloth;
|
||||
_fxGainContinue.StopParticles();
|
||||
_fxLooseContinue.StopParticles();
|
||||
}
|
||||
|
||||
public void Go()
|
||||
{
|
||||
VisualPlayerRichPoor.playerGauge.ActiveGauge(active: true);
|
||||
VisualPlayerRichPoor.ForceGaugeValue(richPoor);
|
||||
}
|
||||
|
||||
public void Revive()
|
||||
{
|
||||
_protectedUntil = Time.time + base.CoreDef.reviveProtectionDuration;
|
||||
targetRichPoor = (tmpTargetRichPoor = base.CoreDef.player.richValueStart);
|
||||
ForceRichPoorValue(base.CoreDef.player.richValueStart, init: true);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (player.Started && !player.isDie)
|
||||
{
|
||||
UpdateRichPoorValue();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRichPoorValue()
|
||||
{
|
||||
if (_needUpdateContinueRichPoor != 0f)
|
||||
{
|
||||
int zoneTarget = ((_needUpdateContinueRichPoor != -1f) ? 1 : 0);
|
||||
int t = targetRichPoor;
|
||||
_needUpdateTargetRichPoor = true;
|
||||
NeedUpdate(zoneTarget, (int)(base.CoreDef.player.speedIncValueOnZone * (float)base.CoreDef.player.maxValueRich), ref t);
|
||||
int delta = t - targetRichPoor;
|
||||
if (delta == 0)
|
||||
{
|
||||
_fxGainContinue.StopParticles();
|
||||
_fxLooseContinue.StopParticles();
|
||||
}
|
||||
if (this.onChangeMoney != null)
|
||||
{
|
||||
this.onChangeMoney(base.CoreDef.player.maxValueRich * delta);
|
||||
}
|
||||
targetRichPoor = t;
|
||||
}
|
||||
if (_needUpdateTargetRichPoor)
|
||||
{
|
||||
int v = richPoor;
|
||||
_needUpdateTargetRichPoor = NeedUpdate(targetRichPoor, (int)(base.CoreDef.player.SpeedRichPoorValue * (float)base.CoreDef.player.maxValueRich), ref v);
|
||||
richPoor = v;
|
||||
ForceRichPoorValue(v);
|
||||
}
|
||||
}
|
||||
|
||||
private bool NeedUpdate(int target, int speed, ref int toUpdate)
|
||||
{
|
||||
if (toUpdate > target)
|
||||
{
|
||||
int v = toUpdate - (int)(Time.deltaTime * (float)speed);
|
||||
toUpdate = ((v > target) ? v : target);
|
||||
return v > target;
|
||||
}
|
||||
if (toUpdate < target)
|
||||
{
|
||||
int v = (int)(Time.deltaTime * (float)speed) + toUpdate;
|
||||
toUpdate = ((v < target) ? v : target);
|
||||
return v < target;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetRichPoorValue(int value, bool force = false)
|
||||
{
|
||||
targetRichPoor = value;
|
||||
tmpTargetRichPoor = value;
|
||||
if (force)
|
||||
{
|
||||
ForceRichPoorValue(value, init: true);
|
||||
}
|
||||
}
|
||||
|
||||
private void ForceRichPoorValue(int value, bool init = false)
|
||||
{
|
||||
richPoor = value;
|
||||
float ratio = (float)value / (float)base.CoreDef.player.maxValueRich;
|
||||
player.anim.SetFloat("Rich", ratio);
|
||||
|
||||
player.movePlayer.ChangeSpeedRatio(ratio);
|
||||
VisualPlayerRichPoor.UpdateRichPoorValue(richPoor, init);
|
||||
VisualPlayerRichPoor.playerGauge.ActiveMax(richPoor >= base.CoreDef.player.maxValueRich - 1);
|
||||
if (richPoor <= 0 && base.CoreDef.player.gameOverAt0)
|
||||
{
|
||||
if (this.onLose != null)
|
||||
{
|
||||
this.onLose();
|
||||
}
|
||||
return;
|
||||
}
|
||||
_nextGameOver = false;
|
||||
VisualPlayerRichPoor.playerGauge.ActiveDanger(active: false);
|
||||
}
|
||||
|
||||
public bool Protected()
|
||||
{
|
||||
return _protectedUntil > Time.time;
|
||||
}
|
||||
|
||||
public void LooseOrWinMoneyWithFx(int v, bool specialEndLevel = false)
|
||||
{
|
||||
if (v == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (v < 0)
|
||||
{
|
||||
if (Protected())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_fxLoosePickUp.PlayInstance(spawnFx, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fxGainPickUp.PlayInstance(spawnFx, null);
|
||||
}
|
||||
_needUpdateTargetRichPoor = true;
|
||||
targetRichPoor += v;
|
||||
if (specialEndLevel)
|
||||
{
|
||||
tmpTargetRichPoor += v;
|
||||
if (this.onUpdateScore != null)
|
||||
{
|
||||
this.onUpdateScore(tmpTargetRichPoor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpTargetRichPoor = targetRichPoor;
|
||||
int clamped = Mathf.Clamp(targetRichPoor, 0, base.CoreDef.player.maxValueRich);
|
||||
targetRichPoor = (tmpTargetRichPoor = clamped);
|
||||
if (this.onUpdateScore != null)
|
||||
{
|
||||
this.onUpdateScore(clamped);
|
||||
}
|
||||
}
|
||||
if (this.onChangeMoney != null)
|
||||
{
|
||||
this.onChangeMoney(v);
|
||||
}
|
||||
VibrationManager.Vibrate(VibrationManager.VibrationType.SMALL);
|
||||
}
|
||||
|
||||
private void OnPickUpItem(PickUpItem item)
|
||||
{
|
||||
LooseOrWinMoneyWithFx((int)item.valueChange, item.specialPickupEnd);
|
||||
}
|
||||
|
||||
private void OnThresholdZone(ThresholdRichZone zone)
|
||||
{
|
||||
bool canPass = richPoor >= zone.thresholdToPass;
|
||||
zone.TryTakeThePass(canPass);
|
||||
if (!canPass && this.onLose != null)
|
||||
{
|
||||
this.onLose();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnterContinueItem(ConutinuePickUpZone zone)
|
||||
{
|
||||
if (zone.typeItem != 0)
|
||||
{
|
||||
_fxGainContinue.PlayParticles();
|
||||
_fxLooseContinue.StopParticles();
|
||||
_needUpdateContinueRichPoor = 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_fxGainContinue.StopParticles();
|
||||
_fxLooseContinue.PlayParticles();
|
||||
_needUpdateContinueRichPoor = -1f;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExitContinueItem()
|
||||
{
|
||||
_fxGainContinue.StopParticles();
|
||||
_fxLooseContinue.StopParticles();
|
||||
_needUpdateContinueRichPoor = 0f;
|
||||
}
|
||||
|
||||
private void OnChangeCloth(bool good)
|
||||
{
|
||||
(good ? GoodCloth : BadCloth).Play(base.transform);
|
||||
player.anim.SetBool("bad", !good);
|
||||
player.anim.SetBool("good", good);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfdf24ef3fd28df49d1b91cc9c0af096
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class SlotMachineHandler : MonoBehaviour
|
||||
{
|
||||
public event Action<SlotMachine> onUseSlotMachine;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
SlotMachine machine = other.GetComponentInParent<SlotMachine>();
|
||||
if (machine != null)
|
||||
{
|
||||
this.onUseSlotMachine?.Invoke(machine);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ed552a1adec5af91ada7904e4283e7c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class StepsSounds : CoreBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Player player;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("randomAudio")]
|
||||
private RandomAudioWithDelay _randomAudio;
|
||||
|
||||
[SerializeField]
|
||||
[FormerlySerializedAs("minLevelHeelsSound")]
|
||||
private string _minLevelHeelsSound;
|
||||
|
||||
[SerializeField]
|
||||
public List<AudioClip> normalSteps;
|
||||
|
||||
[SerializeField]
|
||||
public List<AudioClip> HeelsSteps;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (player.movePlayer.speed < 0.01f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool heels = base.CoreDef.HaveMinLevelRich(_minLevelHeelsSound, player.richManagePlayer.richPoor);
|
||||
_randomAudio.randomClips = (heels ? HeelsSteps : normalSteps);
|
||||
_randomAudio.PlayNext();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20352395f480939c973a1df02528e337
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,179 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SwerveXInputHandler : MonoBehaviour, IInputsListener
|
||||
{
|
||||
public float sensibility = 20f;
|
||||
public float trackWidth = 5f;
|
||||
private bool _canMove;
|
||||
|
||||
private Vector3 _downScreenPos;
|
||||
|
||||
private float _xWorldPosOnDown;
|
||||
|
||||
private Vector3 _lastDownScreenPos;
|
||||
|
||||
private Vector3 lastPos;
|
||||
|
||||
private Vector3 _lastScreenPosTmp;
|
||||
|
||||
private int wallLayer;
|
||||
|
||||
public float lastMoveX;
|
||||
|
||||
private const float X_TO_ADD = 0.3f;
|
||||
|
||||
private float r;
|
||||
|
||||
private float _l;
|
||||
|
||||
private Vector3 _hitPosLeft;
|
||||
|
||||
private Vector3 _hitPosRight;
|
||||
|
||||
private Vector3 _hitPosForward;
|
||||
|
||||
private bool _hitR;
|
||||
|
||||
private bool _hitL;
|
||||
|
||||
private bool _hitF;
|
||||
|
||||
public float TargetWorldX { get; private set; }
|
||||
|
||||
public float deltaX { get; private set; }
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
wallLayer = LayerMask.GetMask("Wall");
|
||||
}
|
||||
|
||||
public void InputDown(Vector3 screenPosition)
|
||||
{
|
||||
_lastScreenPosTmp = screenPosition;
|
||||
if (!_canMove)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_downScreenPos = screenPosition;
|
||||
_lastDownScreenPos = screenPosition;
|
||||
_xWorldPosOnDown = base.transform.localPosition.x;
|
||||
deltaX = 0f;
|
||||
lastMoveX = 0f;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!_canMove)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CheckCharacterRaycast();
|
||||
float right = base.transform.parent.InverseTransformPoint(_hitPosRight).x;
|
||||
float left = base.transform.parent.InverseTransformPoint(_hitPosLeft).x;
|
||||
if (_hitF)
|
||||
{
|
||||
float forward = base.transform.parent.InverseTransformPoint(_hitPosForward).x;
|
||||
if (forward > base.transform.localPosition.x)
|
||||
{
|
||||
right = forward - X_TO_ADD;
|
||||
}
|
||||
else
|
||||
{
|
||||
left = forward + X_TO_ADD;
|
||||
}
|
||||
}
|
||||
r = right;
|
||||
_l = left;
|
||||
float clamped = Mathf.Clamp(TargetWorldX, _l, r);
|
||||
if (clamped != TargetWorldX)
|
||||
{
|
||||
TargetWorldX = clamped;
|
||||
}
|
||||
}
|
||||
|
||||
public void InputMove(Vector3 screenPosition)
|
||||
{
|
||||
_lastScreenPosTmp = screenPosition;
|
||||
if (!_canMove)
|
||||
{
|
||||
return;
|
||||
}
|
||||
deltaX = screenPosition.x - _lastDownScreenPos.x;
|
||||
TargetWorldX = _xWorldPosOnDown + (screenPosition.x - _downScreenPos.x) * (sensibility / (float)Screen.height);
|
||||
float clamped = Mathf.Clamp(TargetWorldX, _l, r);
|
||||
if (clamped != TargetWorldX)
|
||||
{
|
||||
_xWorldPosOnDown -= TargetWorldX - clamped;
|
||||
}
|
||||
_lastDownScreenPos = screenPosition;
|
||||
lastPos = base.transform.position;
|
||||
}
|
||||
|
||||
public void InputUp()
|
||||
{
|
||||
deltaX = 0f;
|
||||
}
|
||||
|
||||
public void InputCancel()
|
||||
{
|
||||
deltaX = 0f;
|
||||
}
|
||||
|
||||
private void CheckCharacterRaycast()
|
||||
{
|
||||
Vector3 origin = base.transform.position + base.transform.forward * 0.1f;
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(origin, base.transform.right, out hit, trackWidth, wallLayer))
|
||||
{
|
||||
_hitR = true;
|
||||
_hitPosRight = hit.point - base.transform.right * X_TO_ADD;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hitR = false;
|
||||
_hitPosRight = base.transform.parent.position + base.transform.right * (trackWidth * 0.5f);
|
||||
}
|
||||
if (Physics.Raycast(base.transform.position, -base.transform.right, out hit, trackWidth, wallLayer))
|
||||
{
|
||||
_hitL = true;
|
||||
_hitPosLeft = hit.point + base.transform.right * X_TO_ADD;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hitL = false;
|
||||
_hitPosLeft = base.transform.parent.position - base.transform.right * (trackWidth * 0.5f);
|
||||
}
|
||||
if (Physics.Raycast(base.transform.position, base.transform.forward, out hit, 2f, wallLayer))
|
||||
{
|
||||
_hitF = true;
|
||||
_hitPosForward = hit.transform.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hitF = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void activeControl(bool active)
|
||||
{
|
||||
if (_canMove == active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_canMove = active;
|
||||
deltaX = 0f;
|
||||
if (active)
|
||||
{
|
||||
InputDown(_lastScreenPosTmp);
|
||||
InputMove(_lastScreenPosTmp);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = (_hitR ? Color.green : Color.red);
|
||||
Gizmos.DrawLine(base.transform.position, base.transform.position + base.transform.right * trackWidth);
|
||||
Gizmos.color = (_hitL ? Color.green : Color.red);
|
||||
Gizmos.DrawLine(base.transform.position, base.transform.position - base.transform.right * trackWidth);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9e26eba575dc18af5a3ac29c8a6d143
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SwerveXSmoothMover : MonoBehaviour
|
||||
{
|
||||
public float smoothTime;
|
||||
|
||||
public float maxSpeed;
|
||||
|
||||
private float _currentXSpeed;
|
||||
|
||||
public void ApplyMove(ref Vector3 pos, float targetX, float speedRatio = 1f)
|
||||
{
|
||||
pos.x = Mathf.SmoothDamp(base.transform.localPosition.x, targetX, ref _currentXSpeed, smoothTime, maxSpeed * speedRatio, Time.deltaTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3f9a93200440691a04fb24a6c63b3fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class ThresholdRichHandler : MonoBehaviour
|
||||
{
|
||||
public event Action<ThresholdRichZone> onThresholdZone;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
ThresholdRichZone zone = other.GetComponentInParent<ThresholdRichZone>();
|
||||
if (!(zone == null) && !zone.isUse && this.onThresholdZone != null)
|
||||
{
|
||||
this.onThresholdZone(zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aae3ce2b855fd09a4d2deb5be82812b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class TriggerMovingPlatformeHandler : MonoBehaviour
|
||||
{
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
TriggerMovingPlatforme trigger = other.GetComponentInParent<TriggerMovingPlatforme>();
|
||||
if (trigger != null)
|
||||
{
|
||||
trigger.ActiveObstacle();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cef4767048dac455399eff465a98c94e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class TurnZoneHandler : MonoBehaviour
|
||||
{
|
||||
public event Action<Section> onTurn;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
TurnZone zone = other.GetComponentInParent<TurnZone>();
|
||||
if (!(zone == null) && !zone.isTurn)
|
||||
{
|
||||
zone.useTurn();
|
||||
if (this.onTurn != null)
|
||||
{
|
||||
this.onTurn(zone.section);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2d5463fbe45fd13fb636e2ebe1d0abf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,5 @@
|
||||
public enum TypeItem
|
||||
{
|
||||
Poor = 0,
|
||||
Rich = 1
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a106e04017f96448a551b3651d04009
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class TypeRich
|
||||
{
|
||||
public string text;
|
||||
|
||||
public string locKey;
|
||||
|
||||
public Color color;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc15551b760247143a450edeaa8af866
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using OHM.UnityToolkit.Vibration;
|
||||
|
||||
public class VisualPlayerRichPoor : CoreBehaviour
|
||||
{
|
||||
public List<ListOfTypeElement> listTypeItem;
|
||||
|
||||
public PlayerGauge playerGauge;
|
||||
|
||||
private TypeRich _lastTypeRich;
|
||||
|
||||
private int _lastChange;
|
||||
|
||||
private RichLevelObject[] _levelObjects;
|
||||
|
||||
public event Action<TypeRich, Color> onChangeStatus;
|
||||
|
||||
public event Action<bool> onChangeCloth;
|
||||
|
||||
private RichLevelObject[] LevelsObjets
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_levelObjects == null)
|
||||
{
|
||||
_levelObjects = GetComponentsInChildren<RichLevelObject>(true);
|
||||
}
|
||||
return _levelObjects;
|
||||
}
|
||||
}
|
||||
|
||||
public void ForceGaugeValue(int v)
|
||||
{
|
||||
playerGauge.UpdateGauge(v, force: true);
|
||||
}
|
||||
|
||||
public void UpdateRichPoorValue(int v, bool init, bool isForce = false)
|
||||
{
|
||||
ChangeStatus(v, init);
|
||||
if (init)
|
||||
{
|
||||
_lastChange = v;
|
||||
}
|
||||
TypeRich typeRich = base.CoreDef.GetTextRich(v);
|
||||
RichLevelObject[] levelsObjets = LevelsObjets;
|
||||
for (int i = 0; i < levelsObjets.Length; i++)
|
||||
{
|
||||
RichLevelObject o = levelsObjets[i];
|
||||
o.gameObject.SetActive(typeRich.text == o.level);
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeStatus(int v, bool force = false)
|
||||
{
|
||||
playerGauge.UpdateGauge(v, force);
|
||||
TypeRich typeRich = base.CoreDef.GetTextRich(v);
|
||||
if (force)
|
||||
{
|
||||
playerGauge.ChangeStatus(typeRich.locKey, typeRich.color);
|
||||
_lastTypeRich = typeRich;
|
||||
return;
|
||||
}
|
||||
if (typeRich == _lastTypeRich)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.onChangeCloth != null)
|
||||
{
|
||||
this.onChangeCloth(_lastChange <= v);
|
||||
}
|
||||
_lastChange = v;
|
||||
playerGauge.ChangeStatus(typeRich.locKey, typeRich.color);
|
||||
_lastTypeRich = typeRich;
|
||||
VibrationManager.Vibrate(VibrationManager.VibrationType.MEDIUM);
|
||||
if (this.onChangeStatus != null)
|
||||
{
|
||||
this.onChangeStatus(typeRich, typeRich.color);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetItem(ItemOnPlayerElement item, bool active, bool force)
|
||||
{
|
||||
item.isActive = active;
|
||||
if (item.skinnedMeshRenderer != null && active)
|
||||
{
|
||||
item.skinnedMeshRenderer.sharedMesh = item.mesh;
|
||||
}
|
||||
else if (item.element != null)
|
||||
{
|
||||
item.element.SetActive(active);
|
||||
}
|
||||
if (item.fxToPlay != null && active)
|
||||
{
|
||||
item.fxToPlay.PlayInstance(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfe05c37d2f96dccf7aa396f489ee98f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class WinHandler : MonoBehaviour
|
||||
{
|
||||
public bool Won { get; private set; }
|
||||
|
||||
public bool isWinning { get; private set; }
|
||||
|
||||
public bool moveActive { get; private set; }
|
||||
|
||||
public WinZone LastWinZone { get; private set; }
|
||||
|
||||
public event Action<WinZone> onTryPassDoor;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (Won)
|
||||
{
|
||||
return;
|
||||
}
|
||||
WinZone zone = other.GetComponentInParent<WinZone>();
|
||||
if (zone != null)
|
||||
{
|
||||
isWinning = true;
|
||||
moveActive = zone.moveActive;
|
||||
LastWinZone = zone;
|
||||
if (this.onTryPassDoor != null)
|
||||
{
|
||||
this.onTryPassDoor(zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PassZone()
|
||||
{
|
||||
if (LastWinZone != null)
|
||||
{
|
||||
LastWinZone.Pass();
|
||||
}
|
||||
}
|
||||
|
||||
public void WinZone()
|
||||
{
|
||||
if (LastWinZone != null)
|
||||
{
|
||||
Won = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e455824aed3403ecb1c36fd50ef818ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user