Ejemplo n.º 1
0
        public void NotifyGameEnd(Vector3 cameraPosition, INexus nexus, List <Pair <uint, ClientInfo> > players)
        {
            var losingTeam = nexus.Team;

            foreach (var p in players)
            {
                var cam = new MoveCamera(p.Item2.Champion, cameraPosition.X, cameraPosition.Y, cameraPosition.Z, 2);
                _packetHandlerManager.SendPacket((int)p.Item2.UserId, cam, Channel.CHL_S2C);
                _packetHandlerManager.SendPacket((int)p.Item2.UserId, new HideUi(), Channel.CHL_S2C);
            }

            _packetHandlerManager.BroadcastPacket(new ExplodeNexus(nexus), Channel.CHL_S2C);

            var timer = new Timer(5000)
            {
                AutoReset = false
            };

            timer.Elapsed += (a, b) =>
            {
                var gameEndPacket = new GameEnd(losingTeam != TeamId.TEAM_BLUE);
                _packetHandlerManager.BroadcastPacket(gameEndPacket, Channel.CHL_S2C);
            };
            timer.Start();
        }
Ejemplo n.º 2
0
        public void HandleSurrender(int userId, IChampion who, bool vote)
        {
            if (_game.GameTime < SurrenderMinimumTime)
            {
                _game.PacketNotifier.NotifyTeamSurrenderStatus(userId, who.Team, SurrenderReason.SURRENDER_TOO_EARLY, 0, 0);
                return;
            }

            bool open = !IsSurrenderActive;

            if (!IsSurrenderActive && _game.GameTime < LastSurrenderTime + SurrenderRestTime)
            {
                _game.PacketNotifier.NotifyTeamSurrenderStatus(userId, who.Team, SurrenderReason.SURRENDER_TOO_QUICKLY, 0, 0);
                return;
            }
            IsSurrenderActive = true;
            LastSurrenderTime = _game.GameTime;
            _votes.Clear();

            if (_votes.ContainsKey(who))
            {
                _game.PacketNotifier.NotifyTeamSurrenderStatus(userId, who.Team, SurrenderReason.SURRENDER_ALREADY_VOTED, 0, 0);
                return;
            }
            _votes[who] = vote;
            Tuple <int, int> voteCounts = GetVoteCounts();
            int total = _game.PlayerManager.GetPlayers().Count;

            _log.Info($"Champion {who.Model} voted {vote}. Currently {voteCounts.Item1} yes votes, {voteCounts.Item2} no votes, with {total} total players");

            _game.PacketNotifier.NotifyTeamSurrenderVote(who, open, vote, (byte)voteCounts.Item1, (byte)voteCounts.Item2, (byte)total, SurrenderLength);

            if (voteCounts.Item1 >= total - 1)
            {
                IsSurrenderActive = false;
                foreach (var p in _game.PlayerManager.GetPlayers())
                {
                    _game.PacketNotifier.NotifyTeamSurrenderStatus((int)p.Item1, Team, SurrenderReason.SURRENDER_PASSED, (byte)voteCounts.Item1, (byte)voteCounts.Item2); // TOOD: fix id casting
                }

                API.ApiFunctionManager.CreateTimer(3.0f, () =>
                {
                    INexus ourNexus = (INexus)_game.ObjectManager.GetObjects().First(o => o.Value is INexus && o.Value.Team == Team).Value;
                    if (ourNexus == null)
                    {
                        _log.Error("Unable to surrender correctly, couldn't find the nexus!");
                        return;
                    }
                    ourNexus.Die(null);
                });
            }
        }
Ejemplo n.º 3
0
 public ExplodeNexus(INexus nexus)
     : base(PacketCmd.PKT_S2C_EXPLODE_NEXUS, nexus.NetId)
 {
     // animation ID?
     Write((byte)0xE7);
     Write((byte)0xF9);
     Write((byte)0x00);
     Write((byte)0x40);
     // unk
     Write((byte)0x00);
     Write((byte)0x00);
     Write((byte)0x00);
     Write((byte)0x00);
 }
Ejemplo n.º 4
0
        public void Update(INexus nexus, StorageContext storage)
        {
            var nexusPlatforms = (nexus as Nexus).GetPlatforms(storage);

            foreach (var platform in nexusPlatforms)
            {
                if (_keyValueStore.ContainsKey(platform + StorageConst.Block) || _keyValueStore.ContainsKey(platform + StorageConst.Transaction))
                {
                    continue;
                }
                platforms.Set(platform, platform);

                _keyValueStore.Add(platform + StorageConst.Block, new KeyValueStore <string, InteropBlock>(CreateKeyStoreAdapter(platform + StorageConst.Block)));
                _keyValueStore.Add(platform + StorageConst.Transaction, new KeyValueStore <string, InteropTransaction>(CreateKeyStoreAdapter(platform + StorageConst.Transaction)));
                _keyValueStore.Add(platform + StorageConst.CurrentHeight, new KeyValueStore <string, string>(CreateKeyStoreAdapter(platform + StorageConst.CurrentHeight)));
            }
        }
Ejemplo n.º 5
0
 public GameEndResponse(Vector3 cameraPosition, INexus nexus, List <Pair <uint, ClientInfo> > playersUserId)
 {
     CameraPosition = cameraPosition;
     Nexus          = nexus;
     Players        = playersUserId;
 }