Example #1
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();
        }
    }
Example #2
0
    /// <summary>
    /// Start method. Gets all references.
    /// </summary>
    public void StartPlayer(bool playerControlled, TeamTypes myTeam, string playerPlayFabID, string playFabName)
    {
        this.playerPlayFabID   = playerPlayFabID;
        this.myTeam            = myTeam;
        this.playerControlled  = playerControlled;
        this.playerPlayFabName = playFabName;

        myProperties     = this.GetComponent <PlayerProperties>();
        networkLayer     = this.GetComponent <PlayerNetworkLayer>();
        animationManager = this.GetComponent <PlayerAnimationManager>();
        shooterManager   = this.GetComponent <ShooterManager>();
        aiManager        = this.GetComponent <PlayerAIManager>();

        shooterManager.CreateBuffer(myTeam);

        myTower = GameController.instance.GetTower(myTeam);

        playerExp = playerLevel = 0;

        myProperties.Initialize();

        baseSprite.color = spriteTeamColors[myTeam.GetHashCode()];

        Debug.Log("initializing player. is human? " + playerControlled + " is local? " + networkLayer.isMine);
        if (networkLayer.isMine)
        {
            if (playerControlled)
            {
                Camera.main.transform.SetParent(this.transform, true);

                //levelText = GameController.instance.GetLevelText();
                expText = GameController.instance.GetExpText();

                GameplayUI.instance.Initialize(myTeam, this);
                GameplayUI.instance.UpdateSidebarStats(myProperties);

                InGameStoreAndCurrencyManager.instance.SetUpgradesCallbacks(new ProjectDelegates.OnPlayerBoughtStatUpgradeCallback[] {
                    myProperties.IncreaseAtk, myProperties.IncreaseMovSpd, myProperties.IncreaseHP
                });
            }

            this.transform.position = GameController.instance.GetRandomSpawnPoint(myTeam);
        }
    }
    /// <summary>
    /// Start method. Gets all references.
    /// </summary>
    public void StartPlayer(bool playerControlled, TeamTypes myTeam, string playerPlayFabID, string playFabName)
    {
        this.playerPlayFabID = playerPlayFabID;
        this.myTeam = myTeam;
        this.playerControlled = playerControlled;
        this.playerPlayFabName = playFabName;

        myProperties = this.GetComponent<PlayerProperties>();
        networkLayer = this.GetComponent<PlayerNetworkLayer>();
        animationManager = this.GetComponent<PlayerAnimationManager>();
        shooterManager = this.GetComponent<ShooterManager>();
        aiManager = this.GetComponent<PlayerAIManager>();

        shooterManager.CreateBuffer(myTeam);

        myTower = GameController.instance.GetTower(myTeam);

        playerExp = playerLevel = 0;

        myProperties.Initialize();

        baseSprite.color = spriteTeamColors[myTeam.GetHashCode()];

        Debug.Log("initializing player. is human? " + playerControlled+" is local? "+networkLayer.isMine);
        if (networkLayer.isMine)
        {
            if (playerControlled)
            {
                Camera.main.transform.SetParent(this.transform, true);

                //levelText = GameController.instance.GetLevelText();
                expText = GameController.instance.GetExpText();

                GameplayUI.instance.Initialize(myTeam,this);
                GameplayUI.instance.UpdateSidebarStats(myProperties);

                InGameStoreAndCurrencyManager.instance.SetUpgradesCallbacks(new ProjectDelegates.OnPlayerBoughtStatUpgradeCallback[]{
                    myProperties.IncreaseAtk,myProperties.IncreaseMovSpd,myProperties.IncreaseHP
                });
            }

            this.transform.position = GameController.instance.GetRandomSpawnPoint(myTeam);
        }
    }