Exemplo n.º 1
0
        void processUnitAttackMoveCommandBatch(NetIncomingMessage msg)
        {
            float scheduledTime = msg.ReadFloat();
            short team          = msg.ReadInt16();
            bool  queued        = msg.ReadBoolean();
            short count         = msg.ReadInt16();

            for (int i = 0; i < count; i++)
            {
                int     unitID      = msg.ReadInt16();
                Unit    unit        = Player.Players[team].UnitArray[unitID];
                Vector2 destination = new Vector2(msg.ReadFloat(), msg.ReadFloat());
                if (unit != null)
                {
                    AttackMoveCommand attackMoveCommand = new AttackMoveCommand(unit, destination);
                    Player.Players[team].ScheduledActions.Add(new ScheduledUnitCommand(scheduledTime, attackMoveCommand, queued));
                    //Rts.pathFinder.AddHighPriorityPathFindRequest(attackMoveCommand, (int)Vector2.DistanceSquared(attackMoveCommand.Unit.CenterPoint, attackMoveCommand.Destination), false);
                }
                else
                {
                    int wut = 0;
                }
            }
        }
Exemplo n.º 2
0
        void processUnitAttackMoveCommandBatch(NetIncomingMessage msg)
        {
            float scheduledTime = msg.ReadFloat();
            short team = msg.ReadInt16();
            bool queued = msg.ReadBoolean();
            short count = msg.ReadInt16();

            for (int i = 0; i < count; i++)
            {
                int unitID = msg.ReadInt16();
                Unit unit = Player.Players[team].UnitArray[unitID];
                Vector2 destination = new Vector2(msg.ReadFloat(), msg.ReadFloat());
                if (unit != null)
                {
                    AttackMoveCommand attackMoveCommand = new AttackMoveCommand(unit, destination);
                    Player.Players[team].ScheduledActions.Add(new ScheduledUnitCommand(scheduledTime, attackMoveCommand, queued));
                    //Rts.pathFinder.AddHighPriorityPathFindRequest(attackMoveCommand, (int)Vector2.DistanceSquared(attackMoveCommand.Unit.CenterPoint, attackMoveCommand.Destination), false);
                }
                else
                {
                    int wut = 0;
                }
            }
        }
Exemplo n.º 3
0
        void AttackMove(AttackMoveCommand command, GameTime gameTime)
        {
            /*List<RtsObject> targets = new List<RtsObject>();

            lock (VisibleTiles)
            {
                foreach (MapTile tile in VisibleTiles)
                {
                    foreach (Unit unit in PathFinder.PathNodes[tile.Y, tile.X].UnitsContained)
                    {
                        if (unit.Team != Team)
                        {
                            Commands[0] = new AttackCommand(unit);
                            Commands.Insert(1, command);
                            return;
                        }
                    }
                }
            }*/

            if (timeSinceLastLookForTarget >= lookForTargetDelay)
            {
                timeSinceLastLookForTarget = 0;

                RtsObject target = FindNearestTarget();

                if (target != null)
                {
                    Commands[0] = new AttackCommand(this, target, true, false);
                    Commands.Insert(1, command);
                    return;
                }
            }

            Move(command, gameTime);
        }