Beispiel #1
0
        public override void OnTick(GameLevel gameLevel, int currentTick, out int outTick)
        {
            base.OnTick(gameLevel, currentTick, out outTick);

            int secondsLeft = GetSecondsLeft();

            if (secondsLeft > (MaxGameTime / 2))
            {
                return;                 //Ignore until the ticker has finished
            }
            if (secondsLeft == 0)
            {
                gameLevel.UpdateGameState(GetNextGameState(gameLevel));
                return;
            }

            ITickableInformation tickableInformation = GetTickableInformation(null);

            gameLevel.DoForAllPlayers(player =>
            {
                if (player.KnownPosition.Y < 64)
                {
                    PlayerLocation resetLocation = ((BuildBattleTeam)player.GameTeam).SpawnLocation;
                    resetLocation.Z -= 15;                     //Spawn just outside buildable area

                    player.Teleport(resetLocation);
                }

                SendTickableMessage(gameLevel, player, tickableInformation);
            });
        }
Beispiel #2
0
        public void SendTickableMessage(GameLevel gameLevel, SkyPlayer player, ITickableInformation tickableInformation)
        {
            if (tickableInformation == null)
            {
                tickableInformation = GetTickableInformation(player);
            }

            player.BarHandler.AddMajorLine(
                $"{SelectedCategory.ThemeName}§r §7| {((BuildBattleBuildTickableInformation) tickableInformation).NeatTimeRemaining} §fRemaining...§r");
        }
Beispiel #3
0
        public void SendTickableMessage(GameLevel gameLevel, SkyPlayer player, ITickableInformation tickableInformation)
        {
            BuildBattleVoteTickableInformation voteInformation = tickableInformation as BuildBattleVoteTickableInformation ??
                                                                 GetTickableInformation(_currentVotingPlayer) as BuildBattleVoteTickableInformation;

            if (voteInformation == null)
            {
                SkyUtil.log("Unable to process TickableInformation. == null");
                return;
            }

            string voteString = "";

            if (player != voteInformation.BuildingPlayer)
            {
                //Do not set the held item slot, since this will cause a recursive loop.
                int heldSlot = player.Inventory.InHandSlot;
                if (heldSlot < 2)
                {
                    heldSlot = 2;
                }
                else if (heldSlot > 6)
                {
                    heldSlot = 6;
                }

                string voteName = "N/A";
                switch (heldSlot)
                {
                case 2:
                    voteName = ItemVote.GetVoteName(1);
                    break;

                case 3:
                    voteName = ItemVote.GetVoteName(2);
                    break;

                case 4:
                    voteName = ItemVote.GetVoteName(3);
                    break;

                case 5:
                    voteName = ItemVote.GetVoteName(4);
                    break;

                case 6:
                    voteName = ItemVote.GetVoteName(5);
                    break;
                }

                try
                {
                    voteString = $" | {voteName ?? "N/A"} §fSelected...";
                }
                catch (Exception e)
                {
                    //Console.WriteLine(e);
                    //Ignore this dumb problem. Only happens on the first tick(?)
                }

                player.BarHandler.AddMinorLine("§6(Please hold your vote selection)");
            }

            player.BarHandler.AddMajorLine($"§d§lBUILDER§r §f{voteInformation.BuildingPlayer.Username}§r §7| {voteInformation.NeatTimeRemaining} §fRemaining{voteString}", 2);
        }
Beispiel #4
0
        public override void OnTick(GameLevel gameLevel, int currentTick, out int outTick)
        {
            base.OnTick(gameLevel, currentTick, out outTick);

            int secondsLeft = GetSecondsLeft();

            if (secondsLeft > (MaxGameTime / 2))
            {
                return;         //Ignore until the ticker has finished
            }
            if (secondsLeft == 0)
            {
                gameLevel.UpdateGameState(GetNextGameState(gameLevel));
                return;
            }

            ITickableInformation tickableInformation = GetTickableInformation(null);

            gameLevel.DoForAllPlayers(player =>
            {
                SendTickableMessage(gameLevel, player, tickableInformation);

                if (player.IsSprinting && player.GameTeam != MurderTeam.Murderer)
                {
                    player.SetSprinting(false);
                }

                if (player.IsGameSpectator)
                {
                    if (player.Inventory.InHandSlot == 4)
                    {
                        if (_modalCountdownDict.TryGetValue(player.Username, out var countdownValue))
                        {
                            if (countdownValue == 1)
                            {
                                if (player.Level is GameLevel level)
                                {
                                    level.ShowEndGameMenu(player);
                                    _modalCountdownDict[player.Username] = 6;                                //Reset to default
                                    player.Inventory.SetHeldItemSlot(3);                                     //Shift off slot.

                                    player.BarHandler.AddMinorLine("§r", 1);
                                    return;
                                }
                            }
                            else
                            {
                                _modalCountdownDict[player.Username] = (countdownValue = (countdownValue - 1));
                            }
                        }
                        else
                        {
                            _modalCountdownDict.Add(player.Username, 6);                             //Default to 3 seconds
                            countdownValue = 6;
                        }

                        int visibleCountdown = (int)Math.Ceiling(countdownValue / 2D);

                        player.BarHandler.AddMinorLine($"§dContinue Holding for {visibleCountdown} Second{(visibleCountdown == 1 ? "" : "s")} to Open Menu", 1);
                    }
                    else
                    {
                        _modalCountdownDict.Remove(player.Username);
                    }
                }
            });

            /*
             * Gun Parts
             */

            //Every 15 Seconds -- Can't spawn any gun parts if the spawned amount == the total locations
            // V Avoid spawning gun parts on the first possible spawn tick
            if (secondsLeft < (MaxGameTime / 2) - 10 && currentTick % 30 == 0 && GunParts.Count != GunPartLocations.Count)
            {
                //SkyUtil.log("Attempting to spawn gun parts at tick " + currentTick);
                PlayerLocation spawnLocation = null;

                int maxSpawnAmount = gameLevel.GetPlayerCount();
                int spawnCount     = 0;
                while (++spawnCount < maxSpawnAmount)
                {
                    int rollCount = 0;
                    while (++rollCount < 10 && GunParts.ContainsKey(spawnLocation = GunPartLocations[Random.Next(GunPartLocations.Count)]))
                    {
                        //
                    }

                    if (rollCount == 10)
                    {
                        break;             //No more spawn points available.
                    }

                    if (spawnLocation != null)
                    {
                        MurderGunPartEntity item = new MurderGunPartEntity(this, (MurderLevel)gameLevel, spawnLocation);

                        GunParts.Add(spawnLocation, item);

                        gameLevel.AddEntity(item);
                    }
                }
            }
        }