public static void Broadcast(Constants.EVENT_IDS id, object content = null)
 {
     Broadcast(id, new object[] { content });
 }
 public static void Broadcast(Constants.EVENT_IDS id, object[] content)
 {
     Debug.Log("SENT " + id.ToString());
     PhotonNetwork.RaiseEvent((byte)id, content, true, RaiseEventOptions.Default);
 }
Exemplo n.º 3
0
    /// <summary>
    /// Handles the events received by the client.
    /// </summary>
    /// <param name="eventCode">Event code.</param>
    /// <param name="content">Content.</param>
    /// <param name="senderId">Sender identifier.</param>
    private void handler(byte eventCode, object content, int senderId)
    {
        object[]            c       = (object[])content;
        Constants.EVENT_IDS eventID = (Constants.EVENT_IDS)eventCode;
        Debug.Log("RECEIVED : " + eventID + " FROM " + senderId);

        Debug.Log("Handler count : ");
        Debug.Log(PhotonNetwork.OnEventCall.GetInvocationList().Length);
        switch (eventID)
        {
        case Constants.EVENT_IDS.LOAD_SCENE:
            _round++;
            _engine.Reset();
            _engine.LoadScene((Constants.MAPS_IDS)c[0]);
            return;

        case Constants.EVENT_IDS.SCENE_LOADED:
            if (!PhotonNetwork.isMasterClient)
            {
                return;
            }
            _engine.PlayerLoadedScene();
            return;

        case Constants.EVENT_IDS.SPAWN_PLAYER:
            if (PhotonNetwork.isMasterClient)
            {
                Debug.LogError("Asked to spawn a player, but we are the master client");
                return;
            }
            _engine.CreatePlayer();
            return;

        case Constants.EVENT_IDS.PLAYER_SPAWNED:
            if (!PhotonNetwork.isMasterClient)
            {
                return;
            }
            _engine.PlayerSpawned();
            return;

        case Constants.EVENT_IDS.REMOVE_WALLS:
            if (PhotonNetwork.isMasterClient)
            {
                return;
            }
            _engine.RemoveWalls();
            return;

        case Constants.EVENT_IDS.SPAWN_POWERUP:
            _engine.SpawnPowerup((Vector3)c[0], (Constants.POWERUP_IDS)c[1]);
            return;

        case Constants.EVENT_IDS.IMPAIR_VISION_EFFECT:
            _engine.FPSCamera.GetComponent <CameraFilterPack_FX_Glitch1>().enabled = true;
            Invoke("removeVisionImpaired", Constants.VISION_IMPAIRED_POWERUP_DURATION);
            return;

        case Constants.EVENT_IDS.BAZOOKA_SHOT:
            _engine.BazookaShoot((Vector3)c[0], (Quaternion)c[1], (Vector3)c[2]);
            return;

        case Constants.EVENT_IDS.END_GAME:
            EndGame((string[])c);
            return;

        case Constants.EVENT_IDS.CHAT_MESSAGE:
            _chat.ReceiveMessage((string)c[0], (string)c[1]);
            return;

        case Constants.EVENT_IDS.SWAP_PARTICLES:
            _engine.SwapParticles((Vector3)c[0]);
            return;

        case Constants.EVENT_IDS.COOLDOWN_REFRESH_PARTICLES:
            _engine.CooldownRefreshParticles((Vector3)c[0]);
            return;

        case Constants.EVENT_IDS.VISION_IMPAIRED_PARTICLES:
            _engine.VisionImpairedParticles((Vector3)c[0]);
            return;

        default:
            Debug.LogError("UNKNOWN EVENT");
            return;
        }
    }