Ejemplo n.º 1
0
        public void ResetState()
        {
            Status          = ZombieGameStatus.NotStarted;
            MaxRounds       = 0;
            RoundInProgress = false;
            RoundStart      = DateTime.MinValue;
            RoundEnd        = DateTime.MinValue;
            Player[] online = PlayerInfo.Online.Items;

            Alive.Clear();
            Infected.Clear();

            Lottery.Clear();
            Bounties.Clear();
            RecentMaps.Clear();

            foreach (Player pl in online)
            {
                pl.Game.Referee  = false;
                pl.Game.RatedMap = false;
                pl.Game.ResetZombieState();
                ResetInvisibility(pl);
                pl.SetPrefix();

                if (pl.level == null || !pl.level.name.CaselessEq(CurLevelName))
                {
                    continue;
                }
                HUD.Reset(pl);
            }

            LastLevelName = "";
            CurLevelName  = "";
            CurLevel      = null;
        }
Ejemplo n.º 2
0
 public void Infect()
 {
     if (Target.IsAlive)
     {
         try
         {
             InfectingEventArgs infectingArgs = new InfectingEventArgs(Attacker, Target);
             Infecting?.Invoke(infectingArgs);
             if (infectingArgs.IsAllowed)
             {
                 Target.SetRole(RoleType.Scp0492, true, false);
             }
         } catch (Exception e)
         {
             Log.Error($"InfectingEvent Error Thrown: {e}");
         }
         try
         {
             InfectedEventArgs infectedArgs = new InfectedEventArgs(Attacker, Target);
             Infected?.Invoke(infectedArgs);
         } catch (Exception e)
         {
             Log.Error($"InfectedEvent Error Thrown: {e}");
         }
     }
 }
Ejemplo n.º 3
0
        // Do body da requisição nós esperamos um json com padrão dos atributos da classe InfectedDto
        public IActionResult PostInfected([FromForm] InfectedDto dto)
        {
            var infected = new Infected(dto.Birthday, dto.Sex, dto.Latitude, dto.Longitude);

            _infectedCollection.InsertOne(infected);
            return(StatusCode(201, "Infectado adicionado com sucesso!"));
        }
Ejemplo n.º 4
0
        void StartRound(List <Player> players)
        {
            TimeSpan duration = Map.Config.RoundTime;

            Map.Message("This round will last for &a" + duration.Shorten(true, true));
            RoundEnd = DateTime.UtcNow.Add(duration);

            Player[] online = PlayerInfo.Online.Items;
            foreach (Player p in online)
            {
                if (p.level != Map || p.Game.Referee)
                {
                    continue;
                }
                Alive.Add(p);
            }
            Infected.Clear();

            Random rnd   = new Random();
            Player first = null;

            do
            {
                first = QueuedZombie != null?PlayerInfo.FindExact(QueuedZombie) : players[rnd.Next(players.Count)];

                QueuedZombie = null;
            } while (first == null || first.level != Map);

            Map.Message("&c" + first.DisplayName + " &Sstarted the infection!");
            InfectPlayer(first, null);
        }
Ejemplo n.º 5
0
        public ActionResult SaveInfected([FromBody] InfectedDTO dto)
        {
            var infected = new Infected(dto.birthDate, dto.gender, dto.latitude, dto.longitude);

            _infectedCollection.InsertOne(infected);
            return(StatusCode(201, "Infected added in the collection"));
        }
Ejemplo n.º 6
0
        public ActionResult SaveInfected([FromBody] InfectedDTO dto)
        {
            var infected = new Infected(dto.BornDate, dto.Gender, dto.Latitude, dto.Longitude);

            _infectedCollection.InsertOne(infected);
            return(StatusCode(201, "Infected has been added"));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Called when player dies to 049. Saves that player to make sure they can't spawn before the infection runs out.
        /// </summary>
        /// <param name="ev"></param>
        public void OnPlayerInfected(PlayerInfectedEvent ev)
        {
            var scp = ev.Attacker;

            if (isAPlayerDead)
            {
                // Try to find
                var infectedCount = InfectedPlayers.Count;
                for (int i = 0; i < infectedCount; i++)
                {
                    var infectedPlayer = InfectedPlayers[i];
                    if (infectedPlayer.Killer.PlayerId == scp.PlayerId)
                    {
                        InfectedPlayers[i] = new Infected(ev.Player, scp, ev.InfectTime);

                        if (infectedPlayer.ShouldHaveSpawned)
                        {
                            infectedPlayer.Player.ChangeRole(infectedPlayer.SavedRole);
                        }
                        return;
                    }
                }
            }

            InfectedPlayers.Add(new Infected(ev.Player, scp, ev.InfectTime));
            isAPlayerDead = true;
        }
Ejemplo n.º 8
0
    public void InfetedDead(Infected infected)
    {
        if (managed == infected)
        {
            managed = null;
            var infecteds = FindObjectsOfType(typeof(Infected));
            for (int i = 0; i < infecteds.Length; i++)
            {
                if (infecteds[i] == infected)
                {
                    continue;
                }
                if (((Infected)infecteds[i]).IsDead())
                {
                    continue;
                }

                SetNewManaged((Infected)infecteds[i]);
                infected.transform.gameObject.SetActive(false);
                break;
            }
            if (managed == null)
            {
                mainCamera.transform.SetParent(transform.parent);
                Lose();
            }
        }
        else
        {
            infected.transform.gameObject.SetActive(false);
        }
    }
Ejemplo n.º 9
0
 public override void PlayerLeftServer(Player p)
 {
     Alive.Remove(p);
     Infected.Remove(p);
     AssignFirstZombie();
     UpdateAllPlayerStatus();
 }
Ejemplo n.º 10
0
        public ActionResult <Infected> CreateInfected([FromBody] InfectedDto dto)
        {
            var infected = new Infected(dto.birthDate, dto.Gender, dto.Latitude, dto.Longitude);

            _infectedCollection.InsertOne(infected);

            return(Created(nameof(CreateInfected), infected));
        }
Ejemplo n.º 11
0
        public ActionResult SaveInfected([FromBody] InfectedDto dto)
        {
            var infected = new Infected(dto.BirthDate, dto.Gender, dto.Latitude, dto.Longitude);

            _infectedsColletions.InsertOne(infected);

            return(StatusCode(201, "Infected successfully registered "));
        }
        public ActionResult AddElement([FromBody] IInfected m)
        {
            var infected = new Infected(m.Birth, m.Gender, m.Latitude, m.Longitude);

            _infectedCollection.InsertOne(infected);

            return(StatusCode(201, "Adicionado com sucesso"));
        }
Ejemplo n.º 13
0
        public ActionResult Create([FromBody] InfectedDto dto)
        {
            var infected = new Infected(dto.Birthday, dto.Gender, dto.Latitude, dto.Longitude);

            _infectedCollection.InsertOne(infected);

            return(StatusCode(201, "Infected successfully added to DB."));
        }
Ejemplo n.º 14
0
        public ActionResult SaveInfected([FromBody] InfectedDto dto)
        {
            var infected = new Infected(dto.BirthDate, dto.Gender, dto.Latitude, dto.Longitude);

            _infectedCollection.InsertOne(infected);

            return(StatusCode(201, "Infectado adicionado com sucesso"));
        }
Ejemplo n.º 15
0
        public ActionResult SaveInfected([FromBody] InfectedDto dto)
        {
            var infectado = new Infected(dto.Birthday, dto.Gender, dto.Latitude, dto.Longitude);

            _infectadosCollection.InsertOne(infectado);

            return(StatusCode(201, "Infected added successful"));
        }
Ejemplo n.º 16
0
        public ActionResult UpdateInfected([FromBody] InfectedDTO dto)
        {
            var infected = new Infected(dto.BornDate, dto.Gender, dto.Latitude, dto.Longitude);

            _infectedCollection.UpdateOne(Builders <Infected> .Filter.Where(inf => inf.BornDate == dto.BornDate),
                                          Builders <Infected> .Update.Set("gender", dto.Gender));
            return(Ok(infected));
        }
Ejemplo n.º 17
0
        public ActionResult SalvarInfectado([FromBody] InfectedDto dto)
        {
            var Infected = new Infected(dto.DataNascimento, dto.Sexo, dto.Latitude, dto.Longitude);

            _infectedCollection.InsertOne(Infected);

            return(StatusCode(201, "Infectado adicionado com sucesso"));
        }
Ejemplo n.º 18
0
        void DoRound()
        {
            if (!Running)
            {
                return;
            }
            List <Player> players = DoRoundCountdown();

            if (players == null)
            {
                return;
            }
            RoundInProgress = true;
            Random random = new Random();
            Player first  = PickFirstZombie(random, players);

            CurLevel.ChatLevel(first.color + first.name + " %Sstarted the infection!");
            first.Game.Infected = true;
            PlayerMoneyChanged(first);
            UpdatePlayerColor(first, InfectCol);

            RoundInProgress = true;
            int    roundMins = random.Next(CurLevel.MinRoundTime, CurLevel.MaxRoundTime);
            string suffix    = roundMins == 1 ? " %Sminute!" : " %Sminutes!";

            CurLevel.ChatLevel("The round will last for &a" + roundMins + suffix);
            RoundEnd       = DateTime.UtcNow.AddMinutes(roundMins);
            timer          = new System.Timers.Timer(roundMins * 60 * 1000);
            timer.Elapsed += new ElapsedEventHandler(EndRound);
            timer.Enabled  = true;

            Player[] online = PlayerInfo.Online.Items;
            foreach (Player p in online)
            {
                if (p.level == null || p.level != CurLevel || p.Game.Referee)
                {
                    continue;
                }
                if (p != first)
                {
                    Alive.Add(p);
                }
            }

            Infected.Clear();
            Infected.Add(first);
            UpdateAllPlayerStatus();
            DoCoreGame(random);

            if (!Running)
            {
                Status = ZombieGameStatus.LastRound; return;
            }
            else
            {
                HandOutRewards();
            }
        }
Ejemplo n.º 19
0
        public override void PlayerJoinedLevel(Player p, Level lvl, Level oldLvl)
        {
            p.SendCpeMessage(CpeMessageType.BottomRight3, "");
            p.SendCpeMessage(CpeMessageType.BottomRight2, "");
            p.SendCpeMessage(CpeMessageType.BottomRight1, "");
            if (RoundInProgress && lvl.name.CaselessEq(MapName))
            {
                if (Running && p != null)
                {
                    Player.Message(p, "You joined in the middle of a round. &cYou are now infected!");
                    p.Game.BlocksLeft = 25;
                    InfectPlayer(p, null);
                }
            }
            if (RoundInProgress && oldLvl == Map && lvl != Map)
            {
                PlayerLeftGame(p);
            }

            if (lvl.name.CaselessEq(MapName))
            {
                double startLeft = (RoundStart - DateTime.UtcNow).TotalSeconds;
                if (startLeft >= 0)
                {
                    Player.Message(p, "%a" + (int)startLeft + " %Sseconds left until the round starts. %aRun!");
                }
                Player.Message(p, "This map has &a" + Map.Config.Likes +
                               " likes %Sand &c" + Map.Config.Dislikes + " dislikes");
                Player.Message(p, "This map's win chance is &a" + Map.WinChance + "%S%");

                if (Map.Config.Authors.Length > 0)
                {
                    string[] authors = Map.Config.Authors.Replace(" ", "").Split(',');
                    Player.Message(p, "It was created by {0}",
                                   authors.Join(n => PlayerInfo.GetColoredName(p, n)));
                }

                HUD.UpdatePrimary(this, p);
                HUD.UpdateSecondary(this, p);
                HUD.UpdateTertiary(p);

                if (Server.votingforlevel)
                {
                    Picker.SendVoteMessage(p);
                }
                return;
            }

            p.SetPrefix();
            HUD.Reset(p);
            Alive.Remove(p);
            Infected.Remove(p);
            if (oldLvl != null && oldLvl.name.CaselessEq(MapName))
            {
                HUD.UpdateAllPrimary(this);
            }
        }
Ejemplo n.º 20
0
        public ActionResult InfectedSave([FromBody] InfectedDTO infectedDTO)
        {
            var infected = new Infected(infectedDTO.Cpf, infectedDTO.DateBith, infectedDTO.Genre, infectedDTO.Latitude, infectedDTO.Longitude);

            infected.Status = true;
            _InfectedCollection.InsertOne(infected);

            return(StatusCode(201, "Infected sucessfull save!"));
        }
Ejemplo n.º 21
0
        public ActionResult SaveInfected([FromBody] InfectedDto dto)
        {
            var infected = new Infected(dto.BirthDate, dto.Gender, dto.Latitude, dto.Longitude);

            _infectedsCollection.InsertOne(infected);

            return(StatusCode(201, "Infected sucessfully included"));
            // http statuscode 201 created
        }
Ejemplo n.º 22
0
 public void DisinfectPlayer(Player p)
 {
     if (!RoundInProgress || p == null)
     {
         return;
     }
     Infected.Remove(p);
     Alive.Add(p);
     ResetPlayerState(p, false);
 }
Ejemplo n.º 23
0
        public override void PlayerLeftGame(Player p)
        {
            Alive.Remove(p);
            Infected.Remove(p);
            p.Game.Infected = false;
            RemoveBounties(p);

            AssignFirstZombie();
            HUD.UpdateAllPrimary(this);
        }
Ejemplo n.º 24
0
 private static InfectedVM MapToInfectedVM(Infected item)
 {
     return(new InfectedVM()
     {
         Email = item.Email.Substring(0, 2) + "...@..." + item.Email.Substring(item.Email.Length - 2, 2),
         City = item.City,
         TestDate = item.TestDate,
         ClientIpAddress = item.ClientIpAddress,
         Id = item.Id,
     });
 }
Ejemplo n.º 25
0
        public IActionResult AddInfected([FromBody] InfectedDto infectedDto)
        {
            var infected = new Infected(
                infectedDto.DateTime,
                infectedDto.Gender,
                infectedDto.longitude,
                infectedDto.latitude);

            _infectedCollection.InsertOne(infected);
            return(Ok("Infectado inserido com sucesso!"));
        }
Ejemplo n.º 26
0
    public void InitializeWithNodes(Node start, Node end)
    {
        m_Start = start;
        m_End = end;

        m_StartInfection = m_Start.GetComponentInChildren<Infected>();
        m_EndInfection = m_End.GetComponentInChildren<Infected>();

        m_lineRenderer.SetPosition(0, m_Start.transform.position);
        m_lineRenderer.SetPosition(1, m_End.transform.position);
    }
Ejemplo n.º 27
0
    public void SetNewManaged(Infected newManaged)
    {
        if (managed != null)
        {
            managed.State = InfectedState.Auto;
        }
        newManaged.State = InfectedState.Managed;
        managed          = newManaged;
        var mPos = managed.transform.position;

        mainCamera.transform.position = new Vector3(mPos.x, mPos.y, mainCamera.transform.position.z);
        mainCamera.transform.SetParent(managed.transform);
    }
Ejemplo n.º 28
0
        public override void PlayerJoinedLevel(Player p, Level lvl, Level oldLvl)
        {
            p.SendCpeMessage(CpeMessageType.BottomRight2, "");
            p.SendCpeMessage(CpeMessageType.BottomRight1, "");
            if (RoundInProgress && lvl.name.CaselessEq(CurLevelName))
            {
                if (Running && p != null)
                {
                    p.SendMessage("You joined in the middle of a round. &cYou are now infected!");
                    p.Game.BlocksLeft = 50;
                    InfectPlayer(p);
                }
            }

            if (lvl.name.CaselessEq(CurLevelName))
            {
                double startLeft = (RoundStart - DateTime.UtcNow).TotalSeconds;
                if (startLeft >= 0)
                {
                    p.SendMessage("%a" + (int)startLeft + " %Sseconds left until the round starts. %aRun!");
                }
                p.SendMessage("This map has &a" + CurLevel.Likes +
                              " likes %Sand &c" + CurLevel.Dislikes + " dislikes");
                p.SendMessage("This map's win chance is &a" + CurLevel.WinChance + "%S%");
                p.SendCpeMessage(CpeMessageType.Status2,
                                 "%SPillaring " + (CurLevel.Pillaring ? "&aYes" : "&cNo") +
                                 "%S, Type is &a" + CurLevel.BuildType);

                if (CurLevel.Authors != "")
                {
                    p.SendMessage("It was created by " + CurLevel.Authors);
                }
                PlayerMoneyChanged(p);
                UpdatePlayerStatus(p);

                if (Server.votingforlevel)
                {
                    SendVoteMessage(p, lastLevel1, lastLevel2);
                }
                return;
            }

            p.SetPrefix();
            ResetCpeMessages(p);
            Alive.Remove(p);
            Infected.Remove(p);
            if (oldLvl != null && oldLvl.name.CaselessEq(CurLevelName))
            {
                UpdateAllPlayerStatus();
            }
        }
Ejemplo n.º 29
0
        public void InfectPlayer(Player p)
        {
            if (!RoundInProgress || p == null)
            {
                return;
            }
            Infected.Add(p);
            Alive.Remove(p);

            p.Game.Infected = true;
            UpdatePlayerColor(p, Colors.red);
            UpdateAllPlayerStatus();
            PlayerMoneyChanged(p);
        }
Ejemplo n.º 30
0
        public void DisinfectPlayer(Player p)
        {
            if (!RoundInProgress || p == null)
            {
                return;
            }
            Infected.Remove(p);
            Alive.Add(p);

            p.Game.Infected = false;
            UpdatePlayerColor(p, p.color);
            UpdateAllPlayerStatus();
            PlayerMoneyChanged(p);
        }
Ejemplo n.º 31
0
        void DoRound()
        {
            if (!Running)
            {
                return;
            }
            List <Player> players = DoRoundCountdown();

            if (players == null)
            {
                return;
            }
            Random random = new Random();

            RoundInProgress = true;
            int    roundMins = random.Next(CurLevel.MinRoundTime, CurLevel.MaxRoundTime);
            string suffix    = roundMins == 1 ? " %Sminute!" : " %Sminutes!";

            CurLevel.ChatLevel("This round will last for &a" + roundMins + suffix);
            RoundEnd = DateTime.UtcNow.AddMinutes(roundMins);

            Player[] online = PlayerInfo.Online.Items;
            foreach (Player p in online)
            {
                if (p.level == null || p.level != CurLevel || p.Game.Referee)
                {
                    continue;
                }
                Alive.Add(p);
            }
            Infected.Clear();

            Player first = PickFirstZombie(random, players);

            CurLevel.ChatLevel("&c" + first.DisplayName + " %Sstarted the infection!");
            InfectPlayer(first, null);

            DoCoreGame(random);
            if (!Running)
            {
                Status = ZombieGameStatus.LastRound; return;
            }

            EndRound();
            if (RecentMaps.Count > 20)
            {
                RecentMaps.RemoveAt(0);
            }
            RecentMaps.Add(CurLevelName);
        }
 public void SetState(Infected state)
 {
     State = state;
 }
Ejemplo n.º 33
0
 void OnEnable()
 {
     m_Infection = m_Node.GetComponentInChildren<Infected>();
 }