示例#1
0
        public override void ServerChangeScene(string sceneName)
        {
            if (battleServerContext != null && !sceneName.Equals(playScene))
            {
                battleServerContext.Dispose();
                battleServerContext = null;
            }

            base.ServerChangeScene(sceneName);
        }
示例#2
0
    public override void OnStartServer()
    {
        base.OnStartServer();

        _serverContext = LobbyManager.Instance.battleServerContext;
        _serverContext.RegisterPlayerController(this);

        LineOfSights.gameObject.SetActive(false);
        _interactSystem.enabled = false;

        InitRPGParams();
    }
示例#3
0
    public override void OnStartServer()
    {
        base.OnStartServer();

        _serverContext = LobbyManager.Instance.battleServerContext;

        _currentStepIndex = -1;
        _startTime        = Time.time;

        StartCoroutine(DamageAll());

        StartNextStep();
    }
示例#4
0
        public IEnumerator ServerCountdownCoroutine()
        {
            //---
            var battleState = BattleState.Create();

            battleServerContext = new BattleServerContext(battleState);
            NetworkServer.Spawn(battleState.gameObject);
            //---

            float remainingTime = prematchCountdown;
            int   floorTime     = Mathf.FloorToInt(remainingTime);

            while (remainingTime > 0)
            {
                yield return(null);

                remainingTime -= Time.deltaTime;
                int newFloorTime = Mathf.FloorToInt(remainingTime);

                if (newFloorTime != floorTime)
                {//to avoid flooding the network of message, we only send a notice to client when the number of plain seconds change.
                    floorTime = newFloorTime;

                    for (int i = 0; i < lobbySlots.Length; ++i)
                    {
                        if (lobbySlots[i] != null)
                        {//there is maxPlayer slots, so some could be == null, need to test it before accessing!
                            (lobbySlots[i] as LobbyPlayer).RpcUpdateCountdown(floorTime);
                        }
                    }
                }
            }

            for (int i = 0; i < lobbySlots.Length; ++i)
            {
                if (lobbySlots[i] != null)
                {
                    (lobbySlots[i] as LobbyPlayer).RpcUpdateCountdown(0);
                }
            }

            ServerChangeScene(playScene);
        }