Exemplo n.º 1
0
        public void Update(float deltaTime)
        {
            if (NextSyncTime >= 10 * 1000)
            {
                Send(new GameTimerMessage(0, GameTime / 1000f));
                NextSyncTime = 0;
            }

            BlueTeam.Update(deltaTime);
            PurpleTeam.Update(deltaTime);
            NeutralTeam.Update(deltaTime);
            Map.Update(deltaTime);


            DelayedActions.RemoveAll(x => x.Finalized);

            foreach (var action in DelayedActions)
            {
                action.Update(deltaTime);
            }

            foreach (var unit in UnitsToRemove)
            {
                Map.RemoveUnit(unit);
                unit.Team.RemoveUnit(unit);
                unit.DefineTeam(null);
                unit.DefineGame(null);
                unit.Disposed       = true;
                unit.PendingDispose = false;
            }

            UnitsToRemove.Clear();
        }
Exemplo n.º 2
0
        public T GetUnit <T>(Func <T, bool> predicate) where T : Unit
        {
            var blue = BlueTeam.GetUnit <T>(predicate);

            if (blue != null)
            {
                return(blue);
            }
            else
            {
                var purple = PurpleTeam.GetUnit <T>(predicate);

                if (purple == null)
                {
                    return(NeutralTeam.GetUnit <T>(predicate));
                }
                else
                {
                    return(purple);
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Add player to the game and to his team
 /// </summary>
 /// <param name="player"></param>
 public void AddUnitToTeam(Unit unit, TeamId teamId)
 {
     if (teamId == TeamId.BLUE)
     {
         unit.DefineTeam(BlueTeam);
         BlueTeam.AddUnit(unit);
     }
     else if (teamId == TeamId.PURPLE)
     {
         unit.DefineTeam(PurpleTeam);
         PurpleTeam.AddUnit(unit);
     }
     else if (teamId == TeamId.NEUTRAL)
     {
         unit.DefineTeam(NeutralTeam);
         NeutralTeam.AddUnit(unit);
     }
     else
     {
         throw new Exception("Unknown team...(" + teamId + ")!");
     }
 }
Exemplo n.º 4
0
        public void Spawn()
        {
            foreach (AIHero player in Players)
            {
                Map.AddUnit(player);
            }


            Map.Script.OnSpawn();
            Map.Script.CreateBindings();

            BlueTeam.Initialize();
            PurpleTeam.Initialize();
            NeutralTeam.Initialize();

            Map.Script.OnUnitsInitialized();

            Send(new StartSpawnMessage());


            foreach (var unit in Map.Units.OfType <AIUnit>())
            {
                unit.Create();
            }

            foreach (var building in Map.Units.OfType <Building>())
            {
                building.UpdateHeath();
                building.UpdateStats(false);
            }

            BlueTeam.InitializeFog();
            PurpleTeam.InitializeFog();
            NeutralTeam.InitializeFog();

            Send(new EndSpawnMessage());
        }
Exemplo n.º 5
0
        public void Update(float deltaTime)
        {
            if (NextSyncTime >= 10 * 1000)
            {
                Send(new GameTimerMessage(0, GameTime / 1000f));
                NextSyncTime = 0;
            }


            BlueTeam.Update(deltaTime);
            PurpleTeam.Update(deltaTime);
            NeutralTeam.Update(deltaTime);
            Map.Update(deltaTime);

            foreach (var unit in UnitsToRemove)
            {
                Map.RemoveUnit(unit);
                unit.Team.RemoveUnit(unit);
                unit.DefineTeam(null);
                unit.DefineGame(null);
            }

            UnitsToRemove.Clear();
        }
Exemplo n.º 6
0
 public void Send(Message message, Channel channel = Channel.CHL_S2C, PacketFlags flags = PacketFlags.Reliable)
 {
     BlueTeam.Send(message, channel, flags);
     PurpleTeam.Send(message, channel, flags);
     //NeutralTeam.Send(message, channel, flags);
 }