Пример #1
0
    /// <summary>
    /// Send everyone the command for make a step (authoritarian)
    /// </summary>
    void MakeStepGlobal()
    {
        var directions = Snakes.Select(s => s.GetCurrentInputDirection()).ToArray();
        RaiseEventOptions raiseEventOptions = new RaiseEventOptions {
            Receivers = ReceiverGroup.All
        };
        SendOptions sendOptions = new SendOptions {
            Reliability = true
        };

        PhotonNetwork.RaiseEvent(RemoteEventNames.RegularStep, directions, raiseEventOptions, sendOptions);

        //Try respawn for deactivate snakes
        foreach (var snake in Snakes.Where(s => !s.Disconnect))
        {
            if (snake.GetCurrentLenght() == 0)
            {
                snake.CreateRespawnEvent();
            }
        }
    }