Esempio n. 1
0
        public override void OnStarting(BaseSceneGame game, Game.Base.Packets.GSPacketIn data)
        {
            //base.OnStarting(game, data);

            TankData tank = game.Data;

            tank.Reset();
            GamePlayer[] list   = game.Data.GetAllPlayers();
            int          i      = random.Next(list.Length);
            GamePlayer   player = GetLowDelayPlayer(game, list[i]);
            //List<Point> pos = new List<Point>();
            //pos.AddRange(Managers.MapMgr.GetMapPos(game.Data.MapIndex));

            MapPoint pos = Managers.MapMgr.GetMapRandomPos(game.Data.MapIndex);

            tank.CurrentWind = random.Next(-40, 40);
            data.WriteInt(player.PlayerCharacter.ID);
            data.WriteInt(tank.CurrentWind);
            data.WriteByte((byte)game.Data.Count);
            Point temp     = new Point();
            int   lastTeam = -1;

            foreach (GamePlayer p in list)
            {
                temp = GetRandom(pos, temp, lastTeam, p.CurrentTeamIndex);
                tank.Players[p].X = temp.X;
                tank.Players[p].Y = temp.Y;
                tank.CurrentMap.AddPhysical(tank.Players[p]);
                p.CanFly = true;
                p.Count  = 2;

                data.WriteInt(p.PlayerCharacter.ID);
                data.WriteInt(tank.Players[p].X);
                data.WriteInt(tank.Players[p].Y);
                data.WriteInt(random.Next(0, 2) > 0 ? 1 : -1);
                data.WriteInt(tank.Players[p].Blood);
                data.WriteBoolean(game.Data.Players[p].IsCaptain);
                lastTeam = p.CurrentTeamIndex;
            }
            tank.CurrentIndex = player;
            game.BeginTimer(TIMEOUT);
            if (game.RoomType == eRoomType.PAIRUP && game.MatchGame != null)
            {
                game.MatchGame.StopTimer();
            }
        }