Exemplo n.º 1
0
        public bool Execute(Universe universe)
        {
            var selectedUnits = universe.GetSelectedUnits();

            if (!selectedUnits.Any())
            {
                universe.Print("Can avoid the movement. Selected unit is absent or dead.");
                return(false);
            }

            var centralUnit     = selectedUnits.GetCentralUnit();
            var selectionCenter = new AbsolutePosition(centralUnit.X, centralUnit.Y);

            if (selectionCenter.GetDistanceToPoint(position.X, position.Y) < 5)
            {
                universe.Print("Can avoid the movement.");
                return(false);
            }

            //var moveOrderList = MyStrategy.MoveOrder;

            SquadCalculator.MoveOrders.Update(selectedUnits, centralUnit, position);
            //if (centralUnit.GetDistanceTo(position) > 200)
            //    universe.Print("Wrong move order");

            universe.Move.Action   = ActionType.Move;
            universe.Move.X        = position.X - selectionCenter.X;
            universe.Move.Y        = position.Y - selectionCenter.Y;
            universe.Move.MaxSpeed = speed;
            //universe.Print($"Action {this} is started.");
            return(true);
        }
Exemplo n.º 2
0
        public bool Execute(Universe universe)
        {
            var selectedUnits = universe.GetSelectedUnits();

            if (!selectedUnits.Any())
            {
                universe.Print("Can avoid the movement. Selected unit is absent or dead.");
                return(false);
            }
            universe.Move.Action = ActionType.Assign;
            universe.Move.Group  = squadId;
            universe.Print($"Action {this} is started. [{selectedUnits.Count}] units were selected.");
            return(true);
        }