public static void Postfix(RoundStart __instance, short value)
            {
                if (value == -1) // Round started
                {
                    return;
                }

                string message;

                if (value == -2)
                {
                    message = "Waiting for players...";
                }
                else
                {
                    message = $"Game starts in {value.ToString().Tag("b")}";
                }

                message = message.Size(30).VerticalOffset(-10);

                foreach (var referenceHub in ReferenceHub.Hubs.Values)
                {
                    if (referenceHub.isDedicatedServer)
                    {
                        continue;
                    }

                    referenceHub.hints.Show(new TextHint(message,
                                                         new HintParameter[] { new StringHintParameter(string.Empty) },
                                                         HintEffectPresets.FadeInAndOut(0f),
                                                         1f));
                }
            }
    public void LaunchEndRound()
    {
        RoundEnd?.Invoke();
        Sequence sequence = DOTween.Sequence();

        sequence.AppendInterval(2);
        sequence.OnComplete(() => RoundStart?.Invoke());
    }
Exemple #3
0
    public void Start()
    {
        playerspriteproperties = GetComponent <SpriteRenderer>();
        playerDeath            = GameObject.Find("countdownText").GetComponent <PotatoTimer>();
        startingHot            = GameObject.Find("RoundStarter").GetComponent <RoundStart>();
        score = GameObject.Find("ScoreSystem").GetComponent <ScoreSystem>();

        WhoIsHot();
    }
Exemple #4
0
        private IEnumerator GameRoutine()
        {
            _settledBlocks.Clear();
            yield return(null);

            while (true)
            {
                SwitchToNextFaller();
                RoundStart?.Invoke();
                _state = State.Default;
                while (true)
                {
                    var fallInterval = _state == State.Drop ? GameRules.DropFallInterval : GameRules.FallInterval;
                    yield return(new WaitForSeconds(fallInterval));

                    if (CheckFallerDirection(Vector2Int.down))
                    {
                        Faller.Shift(Vector2Int.down);
                    }
                    else
                    {
                        break;
                    }
                }

                _state = State.Fallen;
                foreach (var block in Faller.Blocks)
                {
                    _settledBlocks[block.Location] = block;
                }

                var delay = PerformLineOperations() ? AnimationTimings.ExplodeDelay : AnimationTimings.SettleDelay;

                if (IsGameOver())
                {
                    break;
                }

                yield return(new WaitForSeconds(delay));
            }

            GameOver?.Invoke();
        }
Exemple #5
0
        private void FireRoundChange(BaseRound _, BaseRound newRound)
        {
            switch (newRound)
            {
            case PreRound:
                RoundPreparation.Fire(this);

                break;

            case InProgressRound:
                RoundStart.Fire(this);

                break;

            case PostRound:
                RoundEnd.Fire(this);

                break;
            }
        }
Exemple #6
0
 // Start is called before the first frame update
 void Start()
 {
     whoIsHot = GameObject.Find("RoundStarter").GetComponent <RoundStart>();
 }
Exemple #7
0
        internal string RoundTimeLeftMessage()
        {
            TimeSpan left = RoundStart.Add(cfg.RoundTime) - DateTime.UtcNow;

            return("&3" + left.Shorten(true) + " &Suntil the round ends.");
        }
Exemple #8
0
        internal string FloodTimeLeftMessage()
        {
            TimeSpan left = RoundStart.Add(cfg.FloodTime) - DateTime.UtcNow;

            return("&3" + left.Shorten(true) + " %Suntil the flood.");
        }
Exemple #9
0
    private IEnumerator Init()
    {
        GameObject host = null;

        while (host == null)
        {
            host = GameObject.Find("Host");
            yield return(new WaitForEndOfFrame());
        }
        while (this.seed == 0)
        {
            this.seed = host.GetComponent <RandomSeedSync>().seed;
            UnityEngine.Object.FindObjectOfType <GameConsole.Console>().UpdateValue("seed", this.seed.ToString());
        }
        if (!base.isLocalPlayer)
        {
            yield break;
        }
        yield return(new WaitForSeconds(2f));

        if (base.isServer)
        {
            if (ServerStatic.isDedicated)
            {
                ServerConsole.AddLog("Waiting for players..");
            }
            CursorManager.roundStarted = true;
            RoundStart rs = RoundStart.singleton;
            if (TutorialManager.status)
            {
                this.ForceRoundStart();
            }
            else
            {
                rs.ShowButton();
                int timeLeft   = 20;
                int maxPlayers = 1;
                while (rs.info != "started")
                {
                    if (maxPlayers > 1)
                    {
                        timeLeft--;
                    }
                    int count = PlayerManager.singleton.players.Length;
                    if (count > maxPlayers)
                    {
                        maxPlayers = count;
                        if (timeLeft < 5)
                        {
                            timeLeft = 5;
                        }
                        else if (timeLeft < 10)
                        {
                            timeLeft = 10;
                        }
                        else if (timeLeft < 15)
                        {
                            timeLeft = 15;
                        }
                        else
                        {
                            timeLeft = 20;
                        }
                        if (maxPlayers == NetworkManager.singleton.maxConnections)
                        {
                            timeLeft = 0;
                        }
                    }
                    if (timeLeft > 0)
                    {
                        this.CmdUpdateStartText(timeLeft.ToString());
                    }
                    else
                    {
                        this.ForceRoundStart();
                    }
                    yield return(new WaitForSeconds(1f));
                }
            }
            CursorManager.roundStarted = false;
            this.CmdStartRound();
            this.SetRandomRoles();
        }
        else
        {
            while (!host.GetComponent <CharacterClassManager>().roundStarted)
            {
                yield return(new WaitForEndOfFrame());
            }
            yield return(new WaitForSeconds(2f));

            if (this.curClass < 0)
            {
                this.CallCmdSuicide(default(PlayerStats.HitInfo));
            }
        }
        int iteration = 0;

        for (;;)
        {
            GameObject[] plys = PlayerManager.singleton.players;
            if (iteration >= plys.Length)
            {
                yield return(new WaitForSeconds(3f));

                iteration = 0;
            }
            try
            {
                plys[iteration].GetComponent <CharacterClassManager>().InitSCPs();
            }
            catch
            {
            }
            iteration++;
            yield return(new WaitForEndOfFrame());
        }
    }
Exemple #10
0
        private void HandleCurrentEvents()
        {
            foreach (BaseEvent baseEvent in currentTick.Events)
            {
                switch (baseEvent.Type)
                {
                case EventType.MatchStarted:
                    MatchStarted?.Invoke(this, baseEvent);
                    break;

                case EventType.RoundAnnounceMatchStarted:

                    break;

                case EventType.RoundStart:
                    RoundStart?.Invoke(this, (RoundStartEvent)baseEvent);
                    break;

                case EventType.RoundEnd:
                    RoundEnd?.Invoke(this, (RoundEndEvent)baseEvent);
                    break;

                case EventType.WinPanelMatch:
                    WinPanelMatch?.Invoke(this, baseEvent);
                    break;

                case EventType.RoundFinal:
                    break;

                case EventType.LastRoundHalf:
                    break;

                case EventType.RoundOfficiallyEnd:
                    RoundOfficiallyEnd?.Invoke(this, baseEvent);
                    break;

                case EventType.RoundMVP:
                    RoundMVP?.Invoke(this, (RoundMVPEvent)baseEvent);
                    break;

                case EventType.FreezetimeEnded:
                    FreezetimeEnded?.Invoke(this, baseEvent);
                    break;

                case EventType.PlayerKilled:
                    PlayerKilled?.Invoke(this, (PlayerKilledEvent)baseEvent);
                    break;

                case EventType.PlayerTeam:
                    PlayerTeam?.Invoke(this, (PlayerTeamEvent)baseEvent);
                    break;

                case EventType.WeaponFired:
                    WeaponFired?.Invoke(this, (WeaponFiredEvent)baseEvent);
                    break;

                case EventType.SmokeNadeStarted:
                    SmokeNadeStarted?.Invoke(this, (SmokeNadeStartedEvent)baseEvent);
                    break;

                case EventType.SmokeNadeEnded:
                    SmokeNadeEnded?.Invoke(this, (SmokeNadeEndedEvent)baseEvent);
                    break;

                case EventType.DecoyNadeStarted:
                    DecoyNadeStarted?.Invoke(this, (DecoyNadeStartedEvent)baseEvent);
                    break;

                case EventType.DecoyNadeEnded:
                    DecoyNadeEnded?.Invoke(this, (DecoyNadeEndedEvent)baseEvent);
                    break;

                case EventType.FireNadeStarted:
                    FireNadeStarted?.Invoke(this, (FireNadeStartedEvent)baseEvent);
                    break;

                case EventType.FireNadeWithOwnerStarted:
                    FireNadeWithOwnerStarted?.Invoke(this, (FireNadeWithOwnerStartedEvent)baseEvent);
                    break;

                case EventType.FireNadeEnded:
                    FireNadeEnded?.Invoke(this, (FireNadeEndedEvent)baseEvent);
                    break;

                case EventType.FlashNadeExploded:
                    FlashNadeExploded?.Invoke(this, (FlashNadeExplodedEvent)baseEvent);
                    break;

                case EventType.ExplosiveNadeExploded:
                    ExplosiveNadeExploded?.Invoke(this, (ExplosiveNadeExplodedEvent)baseEvent);
                    break;

                case EventType.NadeReachedTarget:
                    NadeReachedTarget?.Invoke(this, (NadeReachedTargetEvent)baseEvent);
                    break;

                case EventType.BombBeginPlant:
                    BombBeginPlant?.Invoke(this, (BombBeginPlantEvent)baseEvent);
                    break;

                case EventType.BombAbortPlant:
                    BombAbortPlant?.Invoke(this, (BombAbortPlantEvent)baseEvent);
                    break;

                case EventType.BombPlanted:
                    BombPlanted?.Invoke(this, (BombPlantedEvent)baseEvent);
                    break;

                case EventType.BombDefused:
                    BombDefused?.Invoke(this, (BombDefusedEvent)baseEvent);
                    break;

                case EventType.BombExploded:
                    BombExploded?.Invoke(this, (BombExplodedEvent)baseEvent);
                    break;

                case EventType.BombBeginDefuse:
                    BombBeginDefuse?.Invoke(this, (BombBeginDefuseEvent)baseEvent);
                    break;

                case EventType.BombAbortDefuse:
                    BombAbortDefuse?.Invoke(this, (BombAbortDefuseEvent)baseEvent);
                    break;

                case EventType.PlayerHurt:
                    PlayerHurt?.Invoke(this, (PlayerHurtEvent)baseEvent);
                    break;

                case EventType.Blind:
                    Blind?.Invoke(this, (BlindEvent)baseEvent);
                    break;

                case EventType.PlayerBind:
                    PlayerBind?.Invoke(this, (PlayerBindEvent)baseEvent);
                    break;

                case EventType.PlayerDisconnect:
                    PlayerDisconnect?.Invoke(this, (PlayerDisconnectEvent)baseEvent);
                    break;

                case EventType.SayText:
                    SayText?.Invoke(this, (SayTextEvent)baseEvent);
                    break;

                case EventType.SayText2:
                    SayText2?.Invoke(this, (SayText2Event)baseEvent);
                    break;

                case EventType.PlayerJump:
                    PlayerJump?.Invoke(this, (PlayerJumpEvent)baseEvent);
                    break;

                case EventType.PlayerFootstep:
                    PlayerFootstep?.Invoke(this, (PlayerFootstepEvent)baseEvent);
                    break;

                case EventType.OtherDeath:
                    OtherDeath?.Invoke(this, (OtherDeathEvent)baseEvent);
                    break;

                case EventType.EntitySpawned:
                    EntitySpawned?.Invoke(this, (EntitySpawnedEvent)baseEvent);
                    break;

                case EventType.EntityRemoved:
                    EntityRemoved?.Invoke(this, (EntityRemovedEvent)baseEvent);
                    break;

                default:
                    break;
                }
            }
        }
 public static void Postfix(RoundStart __instance, short __state)
 {
     __instance.Timer = __state;
 }
 public static void Prefix(RoundStart __instance, NetworkWriter writer, bool forceAll, out short __state)
 {
     __state          = __instance.Timer;
     __instance.Timer = -1;
 }
Exemple #13
0
 public void StartRound()
 {
     RoundStart?.Invoke();
 }