Ejemplo n.º 1
0
        private bool SpawnMob(double delta, MobData mobId, GameUser user)
        {
            //return false;
            if (!_allowSendEnemys)
            {
                return(false);
            }
            if (!_session.MapHandler.IsReady)
            {
                return(false);
            }
            if (_session.GameMobs.Count > _session.Setting.MaxMobs)
            {
                return(false);
            }
            if (_playerMobSpawnDelay[user.User.Id] < _session.Setting.MobSpawnDelay)
            {
                return(false);
            }
            if (user.Money < mobId.Cost)
            {
                return(false);
            }
            if (_session.GameMobs.Count(m => m.SenderTeamId == user.TeamId) > _session.Setting.MaxMobsPerTeam)
            {
                return(false);
            }

            user.Money -= mobId.Cost;

            user.Income += mobId.AddIncome;

            //Reset Values
            _playerMobSpawnDelay[user.User.Id] = 0;
            _session.Teams.Where(t => t.Value.Count > 0 && t.Key != user.TeamId).ToList().ForEach(t =>
            {
                if (_session.Setting.SpawnOnAll)
                {
                    _session.MapHandler.GetAllSpawns(t.Key).ForEach(m =>
                    {
                        var mob = new ServerMob(_session, mobId, m, t.Key, user);
                        _session.GameMobs.Add(mob);
                    });
                }
                else
                {
                    var mob = new ServerMob(_session, mobId, _session.MapHandler.GetRandomSpawn(t.Key), t.Key, user);
                    _session.GameMobs.Add(mob);
                }
            });


            return(true);
        }
Ejemplo n.º 2
0
        private void Update(double delta)
        {
            //Update Tower
            for (var index = 0; index < _session.GameTower.Count; index++)
            {
                var serverTowerModel = _session.GameTower[index];
                serverTowerModel?.Update(delta);
            }
            //Update Mobs
            for (var index = 0; index < _session.GameMobs.Count; index++)
            {
                ServerMob t = _session.GameMobs[index];
                t?.Update(delta);
            }

            //Do Bots
            _session.Bots.ForEach(b =>
            {
                b.Update(delta);
            });
        }