Beispiel #1
0
        private void FreezeUser(RoomUser user)
        {
            if (user.IsBot || user.shieldActive || user.team == Team.none || !this.gameStarted)
            {
                return;
            }

            if (user.Freezed)
            {
                user.Freezed = false;
                user.ApplyEffect(((int)user.team + 39));
            }
            else
            {
                user.Freezed       = true;
                user.FreezeCounter = 0;
                --user.FreezeLives;
                if (user.FreezeLives <= 0)
                {
                    ServerPacket Message = new ServerPacket(ServerPacketHeader.FreezeLivesComposer);
                    Message.WriteInteger(user.VirtualId);
                    Message.WriteInteger(user.FreezeLives);
                    user.GetClient().SendPacket(Message);

                    user.ApplyEffect(0);

                    this.room.GetGameManager().AddPointToTeam(user.team, -20, user);

                    TeamManager managerForFreeze = this.room.GetTeamManager();
                    managerForFreeze.OnUserLeave(user);

                    this.room.GetGameManager().UpdateGatesTeamCounts();
                    user.team = Team.none;

                    if (this.room.GetGameItemHandler().GetExitTeleport() != null)
                    {
                        this.room.GetGameMap().TeleportToItem(user, this.room.GetGameItemHandler().GetExitTeleport());
                    }

                    user.Freezed      = false;
                    user.SetStep      = false;
                    user.IsWalking    = false;
                    user.UpdateNeeded = true;

                    if (managerForFreeze.BlueTeam.Count <= 0 && managerForFreeze.RedTeam.Count <= 0 && (managerForFreeze.GreenTeam.Count <= 0 && managerForFreeze.YellowTeam.Count > 0))
                    {
                        this.StopGame();
                    }
                    else if (managerForFreeze.BlueTeam.Count > 0 && managerForFreeze.RedTeam.Count <= 0 && (managerForFreeze.GreenTeam.Count <= 0 && managerForFreeze.YellowTeam.Count <= 0))
                    {
                        this.StopGame();
                    }
                    else if (managerForFreeze.BlueTeam.Count <= 0 && managerForFreeze.RedTeam.Count > 0 && (managerForFreeze.GreenTeam.Count <= 0 && managerForFreeze.YellowTeam.Count <= 0))
                    {
                        this.StopGame();
                    }
                    else
                    {
                        if (managerForFreeze.BlueTeam.Count > 0 || managerForFreeze.RedTeam.Count > 0 || (managerForFreeze.GreenTeam.Count <= 0 || managerForFreeze.YellowTeam.Count > 0))
                        {
                            return;
                        }
                        this.StopGame();
                    }
                }
                else
                {
                    this.room.GetGameManager().AddPointToTeam(user.team, -10, user);
                    user.ApplyEffect(12);

                    ServerPacket Message = new ServerPacket(ServerPacketHeader.FreezeLivesComposer);
                    Message.WriteInteger(user.VirtualId);
                    Message.WriteInteger(user.FreezeLives);
                    user.GetClient().SendPacket(Message);
                }
            }
        }