예제 #1
0
        void ProcessArmyMovement(Army army)
        {
            var dx = army.TurnTargetX - army.X;
            var dy = army.TurnTargetY - army.Y;

            var mx = 0;
            var my = 0;

            if (dx < 0)
            {
                mx = -1;
            }
            if (dx > 0)
            {
                mx = 1;
            }

            if (dy < 0)
            {
                my = -1;
            }
            if (dy > 0)
            {
                my = 1;
            }

            army.X += mx;
            army.Y += my;

            if (Math.Abs(dx) < 1 && Math.Abs(dy) < 1)
            {
                army.X = army.TurnTargetX;
                army.Y = army.TurnTargetY;
                _mapController.OnMoveEnded(army);
            }
        }