コード例 #1
0
    void InstantiateObject(int viewID, int playerType, int team, string playerPlayFabID, string playFabName)
    {
        GameObject obj = Instantiate(charactersPrefabs[playerType], Vector3.zero, Quaternion.identity) as GameObject;

        PhotonView objView = obj.GetComponent <PhotonView>();

        objView.viewID = viewID;

        obj.name = playFabName;

        PlayerNetworkLayer playerNetwork = obj.GetComponent <PlayerNetworkLayer>();

        playerNetwork.Initialize();

        PlayerManager playerManager = obj.GetComponent <PlayerManager>();

        playerManager.StartPlayer(true, (TeamTypes)team, playerPlayFabID, playFabName);

        MovementManager movementManager = obj.GetComponent <MovementManager>();

        movementManager.StartMovementManager(objView.isMine);

        GameController.instance.AddPlayer(playerManager);


        SkinnedMeshRenderer[] renderers = playerManager.GetComponentsInChildren <SkinnedMeshRenderer>();
        for (int j = 0; j < renderers.Length; j++)
        {
            ProceduralMaterial material = renderers[j].material as ProceduralMaterial;
            material.SetProceduralBoolean("Team", (TeamTypes)team == TeamTypes.Blue);
            material.RebuildTextures();
        }

        AudioManager.instance.PlayGameplayMusic();
    }
コード例 #2
0
    void OnNetworkInstantiateBot(int viewID, int playerType, int team)
    {
        GameObject obj = Instantiate(botsPrefabs[playerType], Vector3.zero, Quaternion.identity) as GameObject;

        obj.name = "Bot" + viewID;

        PhotonView objView = obj.GetComponent <PhotonView>();

        objView.viewID = viewID;

        PlayerNetworkLayer playerNetwork = obj.GetComponent <PlayerNetworkLayer>();

        playerNetwork.Initialize();

        PlayerManager playerManager = obj.GetComponent <PlayerManager>();

        playerManager.StartPlayer(false, (TeamTypes)team, "", "Bot" + viewID);

        MovementManager movementManager = obj.GetComponent <MovementManager>();

        movementManager.StartMovementManager(false);

        object owner;

        if (PhotonNetwork.player.customProperties.TryGetValue("Owner", out owner))
        {
            string ownerName = owner.ToString();

            if (ownerName == PhotonNetwork.player.name)
            {
                PlayerAIManager aiManager = obj.GetComponent <PlayerAIManager>();
                aiManager.StartAI();
            }
        }

        GameController.instance.AddPlayer(playerManager);

        SkinnedMeshRenderer[] renderers = playerManager.GetComponentsInChildren <SkinnedMeshRenderer>();
        for (int j = 0; j < renderers.Length; j++)
        {
            ProceduralMaterial material = renderers[j].material as ProceduralMaterial;
            material.SetProceduralBoolean("Team", (TeamTypes)team == TeamTypes.Blue);
            material.RebuildTextures();
        }
    }