Exemplo n.º 1
0
        protected void WalkTo(GridPosition nextTile)
        {
            TruePosition = Position.Clone();
            int lastDir = Faceddirection;

            Faceddirection = InputHandlerer.GetDirectionTo(Position, nextTile);

            SetAnimatorDirection(Faceddirection);
            if (lastDir != Faceddirection)
            {
                //   Debug.Log("Turn " + Faceddirection);
                anim.Play("Walk");
            }

            if (GameGrid.currentGrid.isInBounds(nextTile))
            {
                GridPosition     selectedTile;
                GameGrid.WalType canWalk = GameGrid.currentGrid.CanBeWalked(Position, nextTile, out selectedTile);
                if (canWalk == GameGrid.WalType.JumUp || Position.z != nextTile.z)
                {
                    int height = nextTile.z - Position.z;
                    if (height < 0)
                    {
                        height = 1;
                    }
                    Position = nextTile;

                    StartJump(GameGrid.currentGrid.GetWalkPoint(nextTile) + topOffset, height - 1);
                }
                else if (canWalk == GameGrid.WalType.CanWalk)
                {
                    Position = nextTile;
                    iTween.MoveTo(body.gameObject, iTween.Hash("position", GameGrid.currentGrid.GetTile(selectedTile).CenterPoint + topOffset, "time", Options._instance.CharacterMovementSpeed, "easetype", iTween.EaseType.linear));
                    body.StartCoroutine(MovementMidpoint(Options._instance.CharacterMovementSpeed / 2));
                    body.StartCoroutine(MoveEnabler(Options._instance.CharacterMovementSpeed));
                }
            }
        }
Exemplo n.º 2
0
 public void FaceTarget(GridPosition pos)
 {
     SetAnimatorDirection(InputHandlerer.GetDirectionTo(Position, pos));
 }