Inheritance: RTSEngine.Algorithms.ACBudgetedTask
Esempio n. 1
0
        public static EnemyBuildingUpdater Deserialize(BinaryReader s, GameState state)
        {
            int            ti = s.ReadInt32();
            ViewedBuilding vb = new ViewedBuilding();

            vb.Team          = s.ReadInt32();
            vb.Type          = s.ReadInt32();
            vb.CellPoint     = s.ReadPoint();
            vb.WorldPosition = s.ReadVector3();
            vb.ViewDirection = s.ReadVector2();
            int         uuid = s.ReadInt32();
            RTSBuilding b    = null;

            foreach (var building in state.teams[vb.Team].Buildings)
            {
                if (building.UUID == uuid)
                {
                    b = building;
                    break;
                }
            }
            EnemyBuildingUpdater ebu = new EnemyBuildingUpdater(state, ti, vb, b);

            ebu.Added  = s.ReadBoolean();
            ebu.isDead = s.ReadBoolean();
            if (ebu.Added)
            {
                state.teams[ebu.teamIndex].ViewedEnemyBuildings.Add(vb);
            }
            return(ebu);
        }
Esempio n. 2
0
        public static void Serialize(BinaryWriter s, EnemyBuildingUpdater t)
        {
            s.Write(t.teamIndex);
            s.Write(t.vb.Team);
            s.Write(t.vb.Type);
            s.Write(t.vb.CellPoint);
            s.Write(t.vb.WorldPosition);
            s.Write(t.vb.ViewDirection);
            s.Write(t.EnemyUUID);

            s.Write(t.Added);
            s.Write(t.isDead);
        }
Esempio n. 3
0
        private void AddTask(GameState s, RTSBuilding building, int fTeam, int type)
        {
            AddTask(s, building);
            ViewedBuilding vb = new ViewedBuilding();

            vb.Team          = fTeam;
            vb.Type          = type;
            vb.ViewDirection = building.ViewDirection;
            vb.WorldPosition = building.WorldPosition;
            vb.CellPoint     = HashHelper.Hash(building.GridPosition, s.CGrid.numCells, s.CGrid.size);
            for (int i = 0; i < s.teams.Length; i++)
            {
                if (i == fTeam || s.teams[i] == null)
                {
                    continue;
                }
                var ebu = new EnemyBuildingUpdater(s, i, vb, building);
                s.tbMemBuildings.AddTask(ebu);
            }
        }
 private void AddTask(GameState s, RTSBuilding building, int fTeam, int type)
 {
     AddTask(s, building);
     ViewedBuilding vb = new ViewedBuilding();
     vb.Team = fTeam;
     vb.Type = type;
     vb.ViewDirection = building.ViewDirection;
     vb.WorldPosition = building.WorldPosition;
     vb.CellPoint = HashHelper.Hash(building.GridPosition, s.CGrid.numCells, s.CGrid.size);
     for(int i = 0; i < s.teams.Length; i++) {
         if(i == fTeam || s.teams[i] == null) continue;
         var ebu = new EnemyBuildingUpdater(s, i, vb, building);
         s.tbMemBuildings.AddTask(ebu);
     }
 }
Esempio n. 5
0
        public static void Serialize(BinaryWriter s, EnemyBuildingUpdater t)
        {
            s.Write(t.teamIndex);
            s.Write(t.vb.Team);
            s.Write(t.vb.Type);
            s.Write(t.vb.CellPoint);
            s.Write(t.vb.WorldPosition);
            s.Write(t.vb.ViewDirection);
            s.Write(t.EnemyUUID);

            s.Write(t.Added);
            s.Write(t.isDead);
        }
Esempio n. 6
0
 public static EnemyBuildingUpdater Deserialize(BinaryReader s, GameState state)
 {
     int ti = s.ReadInt32();
     ViewedBuilding vb = new ViewedBuilding();
     vb.Team = s.ReadInt32();
     vb.Type = s.ReadInt32();
     vb.CellPoint = s.ReadPoint();
     vb.WorldPosition = s.ReadVector3();
     vb.ViewDirection = s.ReadVector2();
     int uuid = s.ReadInt32();
     RTSBuilding b = null;
     foreach(var building in state.teams[vb.Team].Buildings) {
         if(building.UUID == uuid) {
             b = building;
             break;
         }
     }
     EnemyBuildingUpdater ebu = new EnemyBuildingUpdater(state, ti, vb, b);
     ebu.Added = s.ReadBoolean();
     ebu.isDead = s.ReadBoolean();
     if(ebu.Added) {
         state.teams[ebu.teamIndex].ViewedEnemyBuildings.Add(vb);
     }
     return ebu;
 }