Пример #1
0
        protected virtual void MoveToBlock(float dt)
        {
            var nextBlockIndex   = this.GetStep() + 1;
            var currentBlockCtrl = this.currentBlock;
            var nextBlockCtrl    = this.m_MapManager.CalculateCurrentBlock(nextBlockIndex);

            if (nextBlockCtrl == null)
            {
                return;
            }
            this.m_NextBlock = nextBlockCtrl;
            var direction = nextBlockCtrl.GetMovePointPosition() - this.GetPosition();
            var maxLength = nextBlockCtrl.GetMovePointPosition() - currentBlockCtrl.GetMovePointPosition();

            if (direction.sqrMagnitude < 0.01f)
            {
                this.currentBlock = nextBlockCtrl;
                this.SetStep(nextBlockIndex);
                this.InvokeAction("MovedBlockState");
            }
            else
            {
                var movePos = (direction.normalized * 1.5f * dt) + this.GetPosition();
                this.SetPosition(movePos);
                this.SetRotation(nextBlockCtrl.GetMovePointPosition());
                this.SetJumpCurve(direction.sqrMagnitude / maxLength.sqrMagnitude);
            }
        }
Пример #2
0
        private IEnumerator HandleSpawnBlockGuest(CBlockController parent, CCharacterData data)
        {
            if (parent.enemyPoint != null && data != null)
            {
                var characterGO = Instantiate(Resources.Load <CCharacterController> ("CharacterPrefabs/" + data.objectModel));
                yield return(characterGO != null);

                parent.blockGuest = characterGO;
                characterGO.transform.SetParent(parent.enemyPoint.transform);
                characterGO.transform.localPosition = Vector3.zero;
                characterGO.transform.localRotation = Quaternion.identity;
                characterGO.SetData(data);
                characterGO.SetActive(true);
                characterGO.currentBlock = parent;
                characterGO.targetBlock  = parent;
                characterGO.Init();
                CUIGameManager.Instance.OnLoadCharacterInfo(characterGO, true);
            }
            yield return(null);
        }