Exemple #1
0
        //Move returns true if it is able to move and false if not.
        //Move takes parameters for x direction, y direction.
        protected bool Move(int xDir, int yDir)
        {
            if (xDir != 0)
            {
                transform.localScale = new Vector3(xDir * horizontalScaleMultiplier, 1, 1);
            }

            Point nextPosition = modelPosition;

            nextPosition.x += xDir;
            nextPosition.y += yDir;

            MapGenerator map = GameManager.Map;

            if (!map.GetContentAt(nextPosition).CanMoveTo())
            {
                return(false);
            }

            map.RemoveContentAt(ContentType, modelPosition);
            map.SetContentAt(ContentType, nextPosition);
            modelPosition = nextPosition;

            StartCoroutine(SmoothMovement(nextPosition.Vector));

            return(true);
        }