Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
    void Awake()
    {
        // Singleton Pattern
        if (GM == null)
        {
            DontDestroyOnLoad(GM);
            GM = this;
        }
        else if (GM != this)
        {
            Destroy(gameObject);
        }

        // References
        keyBinds     = GetComponent <KeyBindings>();
        inputHandler = GetComponent <InputHandler>();
        cmdLog       = GetComponent <CommandLog>();
        replayer     = GetComponent <CommandReplayer>();
        rewinder     = GetComponent <CommandRewinder>();
    }