private void StartReplay() { if (Commands.Count != 0) { GameObject cloneAlt = Instantiate(CloneModel); if (_clones.Count == RecordLimit) { GameObject oldClone = _clones[0]; _clones.RemoveAt(0); Destroy(oldClone); } if (!_replayOnly) { //RecordCurrent = RecordLimit - _clones.Count; //RecordText.text = "" + (RecordLimit - _clones.Count); // RecordText.text = "" + (RecordLimit - _clones.Count); } _clones.Add(cloneAlt); cloneAlt.layer = LayerMask.NameToLayer("ClonesGO"); InputHandler cloneIH = cloneAlt.AddComponent <InputHandler>(); cloneIH._replayOnly = true; cloneIH.CurrDirection = _goStartDir; Jumpable cloneJump = cloneAlt.AddComponent <Jumpable>(); cloneJump.InputHandler = cloneIH; CommandReplayer replayer = cloneAlt.AddComponent <CommandReplayer>(); replayer.Setup(Commands, _goStartPos, _goStartDir); Commands = new List <Command>(); BeginningTime = Utils.GetTimeinMilliseconds(); _goStartPos = gameObject.transform.position; _goStartDir = CurrDirection; } foreach (var clone in _clones) { clone.GetComponent <CommandReplayer>().Start(); } }
public override void Execute(GameObject go, Command command) { base.Execute(go, command); StartPosition = go.transform.position; Jumpable jumpable = go.GetComponent <Jumpable>(); if (jumpable.IsGrounded) { InputHandler.myAnimator.SetFloat("speed", -1.0f); jumpable.IsGrounded = false; RaycastHit[] climbables = Physics.RaycastAll(go.transform.position, go.transform.rotation * Vector3.forward, 1, LayerMask.GetMask("Climbable", "Interactive;Climbable")); if (climbables.Length > 0) { EndPosition = climbables[0].transform.position + Vector3.up * 1.3f; new Task(Move(go, climbables[0])); } } }
// Start is called before the first frame update void Start() { groudable = GetComponent <Groudable>(); movable = GetComponent <Move>(); jumpable = GetComponent <Jumpable>(); }