Exemple #1
0
 //IF YOU MAKE THIS PERSIST SAY GOODBYE TO YOUR MATCHMAKING
 //YOU WONT CONNECT TO A SERVER
 //Enable() == DEATH
 void Awake()
 {
     PFC = GameObject.Find("NetworkController").GetComponentInChildren <PlayFabsController>();
     if (PFC == null)
     {
         Debug.Log("There is no PlayFabsController");
     }
 }
        // Start is called before the first frame update
        private void Awake()
        {
            health = transform.GetComponent <Health>();
            if (health == null)
            {
                Debug.Log("Couldn't find Health Component");
            }

            PFC = GameObject.Find("NetworkController").GetComponent <PlayFabsController>();
            if (PFC == null)
            {
                Debug.Log("Couldn't find NetworkController/PlayFabsController");
            }

            pauseMenu = PFC.pauseMenu;

            //Delete this after inventory is setup
            inventory.Awake();

            canvas = transform.GetChild(1).gameObject;

            //This makes the player "look" like he is aiming the gun at the "target"
            //If you edit this you must edit it in NetworkPlayer!
            offset = new Vector3(10, 47.32f, 12);

            //Find the joystick objects
            GameObject tempJoystickOne  = canvas.gameObject.transform.GetChild(0).gameObject;
            GameObject tempJoystickOTwo = canvas.gameObject.transform.GetChild(1).gameObject;

            //Assign Joysticks to script variables [Left,Right]
            if (tempJoystickOne)
            {
                joystickOne = tempJoystickOne.GetComponent <FixedJoystick>();
            }
            else
            {
                Debug.Log("No Left JoyStick");
            }

            if (tempJoystickOTwo)
            {
                joystickTwo = tempJoystickOTwo.GetComponent <FixedJoystick>();
            }
            else
            {
                Debug.Log("No Right JoyStick");
            }

            CharacterController = GetComponent <CharacterController>();
        }
Exemple #3
0
 private void Enable()
 {
     if (PlayFabsController.PFC == null)
     {
         PlayFabsController.PFC = this;
     }
     else
     {
         if (PlayFabsController.PFC != this)
         {
             Destroy(this.gameObject);
         }
     }
     DontDestroyOnLoad(this.gameObject);
 }
Exemple #4
0
    private void Awake()
    {
        //Looks for GameSetupController as long as were in a game and NOT in Menu
        if (SceneManager.GetActiveScene().name != "Menu")
        {
            GSC = GameObject.Find("GameSetupController").GetComponent <GameSetupController>();
            if (GSC == null)
            {
                Debug.Log("Network Player Couldn't find GameSetupController  ");
            }
        }

        //Assigning various components/GameObj's to vars for use
        photonView = transform.GetComponent <PhotonView>();
        PFC        = GameObject.Find("NetworkController").GetComponent <PlayFabsController>();
        animator   = GetComponentInChildren <Animator>();
        playerCustomizeChildOBJ = animator.gameObject;
        //target = transform.Find("CameraPivot/Target");

        if (PFC != null && GSC != null)
        {
            Playeraccessory = PFC.Playeraccessory;
            playerHat       = PFC.playerHat;
            playerTop       = PFC.playerTop;
            playerJacket    = PFC.playerJacket;
            playerUnderware = PFC.playerUnderware;
            playerHead      = PFC.playerHead;
            playerSkin      = PFC.playerSkin;
            playerBottom    = PFC.playerBottom;
            playerShoes     = PFC.playerShoes;
            playerSex       = PFC.playerSex;
            playerID        = PFC.myID;
        }
        else
        {
            Debug.Log("Network Player Couldn't find PlayFabsController ");
        }
    }
Exemple #5
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Game Mode: " + gameMode);
        NWC = GameObject.FindObjectsOfType <NetworkController>();

        //If Were at Menu scene we have to handle duplicate NetworkControllers and transfer data
        //This will always need to be done on "In-Game Room Transfers"
        if (SceneManager.GetActiveScene().name == "Menu")
        {
            NWC = GameObject.FindObjectsOfType <NetworkController>();
            if (NWC == null)
            {
                Debug.Log("Couldn't find NetworkController");
            }

            for (int i = 0; i < NWC.Length; i++)
            {//Find the NWC with missing vars (chosen at random, any will do) THIS WHOLE BRANCH ONLY RUNS ON 2ND ENTRY OF MENU
                if (NWC[i].shopCanvas == null)
                {
                    transform.GetChild(0).gameObject.SetActive(true);

                    //Grabs PlayFabsController Comp statistics we've pulled from server within old NetworkController
                    PlayFabsController PFC        = NWC[i].GetComponent <PlayFabsController>();
                    PlayFabsController lastingPFC = null;

                    //Check the next index for THE surviving NetworkController PlayFabsController Comp
                    if (NWC[i + 1] != null)
                    {
                        i++;
                        Debug.Log("Next One");
                        lastingPFC = NWC[i].GetComponent <PlayFabsController>();
                    }
                    else
                    {
                        i--;
                        Debug.Log("Previous One");
                        lastingPFC = NWC[i].GetComponent <PlayFabsController>();
                    }


                    //Transferrs info we don't want to lose
                    lastingPFC.playerHat       = PFC.playerHat;
                    lastingPFC.Playeraccessory = PFC.Playeraccessory;
                    lastingPFC.playerTop       = PFC.playerTop;
                    lastingPFC.playerJacket    = PFC.playerJacket;
                    lastingPFC.playerUnderware = PFC.playerUnderware;
                    lastingPFC.playerHead      = PFC.playerHead;
                    lastingPFC.playerSkin      = PFC.playerSkin;
                    lastingPFC.playerBottom    = PFC.playerBottom;
                    lastingPFC.playerShoes     = PFC.playerShoes;
                    lastingPFC.playerSex       = PFC.playerSex;
                    lastingPFC.myID            = PFC.myID;
                    lastingPFC.userEmailStr    = PFC.userEmailStr;

                    //Deleting old NetwrokController but keeping the data it called the API for.
                    Destroy(NWC[i].transform.root.gameObject);
                    Debug.Log("Destroyed Old NetworkController");


                    StartCoroutine(JoinLobbyWaiter());

                    //Find LobbyController and create room
                    //GameObject.Find("QuickStartLobbyController").GetComponent<QuickStartLobbyController>().CreateRoom();
                }
            }
        }

        //Once maintainance is complete

        //Figure out what scene to load and create room
    }
    void Awake()
    {
        DontDestroyOnLoad(this.gameObject);

        //playFab = true;
        createNewButton = GameObject.Find("NewUser");
        userNameGO      = GameObject.Find("UserName");
        userEmailGO     = GameObject.Find("Email");
        userPassGO      = GameObject.Find("Password");
        loginButton     = GameObject.Find("Login");
        submitButton    = GameObject.Find("Submit");
        recoverButton   = GameObject.Find("Recover");
        submitRecovery  = GameObject.Find("SubmitRecovery");
        shopButton      = GameObject.Find("Shop");
        shopCanvas      = GameObject.Find("ShopCanvas");



        //Start Char Customization
        maleCharCustomizer   = GameObject.Find("Male_Customize");
        femaleCharCustomizer = GameObject.Find("Female_Customize");
        maleSex   = GameObject.Find("Female");
        femaleSex = GameObject.Find("Male");
        //End Char Customization

        playFabManager = transform.GetComponent <PlayFabsController>();
        userEmailInput = userEmailGO.gameObject.GetComponent <InputField>();
        userNameInput  = userNameGO.gameObject.GetComponent <InputField>();
        userPassInput  = userPassGO.gameObject.GetComponent <InputField>();

        offlineButton    = GameObject.Find("Offline");
        onlineButton     = GameObject.Find("Online");
        onlineAuthButton = GameObject.Find("OnlineAuth");



        createNewButton.SetActive(false);
        onlineButton.SetActive(false);
        userNameGO.SetActive(false);
        userPassGO.SetActive(false);
        userEmailGO.SetActive(false);
        loginButton.SetActive(false);
        submitButton.SetActive(false);
        recoverButton.SetActive(false);
        submitRecovery.SetActive(false);
        shopButton.SetActive(false);
        shopCanvas.SetActive(false);

        //Start Char Customization
        femaleCharCustomizer.SetActive(false);
        maleCharCustomizer.SetActive(false);
        maleSex.SetActive(false);
        femaleSex.SetActive(false);

        if (maleSex == null)
        {
            Debug.Log("Couldn't Find Male Sex Button");
        }

        if (femaleSex == null)
        {
            Debug.Log("Couldn't Find Female Sex Button");
        }

        if (maleCharCustomizer == null)
        {
            Debug.Log("Couldn't Find Male Customize OBJ");
        }

        if (femaleCharCustomizer == null)
        {
            Debug.Log("Couldn't Find Female Customize OBJ");
        }
        //End Char Customization

        if (shopCanvas == null)
        {
            Debug.Log("Couldn't Find Shop Canvas");
        }

        if (userNameGO == null)
        {
            Debug.Log("Couldn't Find userName Field");
        }

        if (userEmailGO == null)
        {
            Debug.Log("Couldn't Find userEmail Field");
        }

        if (userPassGO == null)
        {
            Debug.Log("Couldn't Find userPass Field");
        }

        if (loginButton == null)
        {
            Debug.Log("Couldn't Find login Button");
        }

        if (shopButton == null)
        {
            Debug.Log("Couldn't Find Shop Button ");
        }

        if (submitRecovery == null)
        {
            Debug.Log("Couldn't Find Submit Recovery Button");
        }

        if (onlineAuthButton == null)
        {
            Debug.Log("Couldn't Find onlineAuth Button");
        }

        if (offlineButton == null)
        {
            Debug.Log("Couldn't Find Offline Button");
        }

        if (recoverButton == null)
        {
            Debug.Log("Couldn't Find recover Button");
        }

        if (onlineButton == null)
        {
            Debug.Log("Couldn't Find Online Button");
        }

        if (createNewButton == null)
        {
            Debug.Log("Couldn't Find createNew Button");
        }

        if (submitButton == null)
        {
            Debug.Log("Couldn't Find Submit Button");
        }
    }
    void Awake()
    {
        #region WeaponPooling

        //Create pooling GameObject catagory holders
        #region PoolCategoryCreation()

        Debug.Log("Building SoundFX Pool");
        //Create all pooling parent OBJs for organization (WeaponFXPool) IS: (WeaponFXPoolParent)
        tempObject = (GameObject)Resources.Load("SoundFX/Prefabs/WeaponFXPool");//Getting prefab to check if it's there

        if (tempObject == null)
        {
            Debug.Log("Couldn't find SoundFX/Prefabs/WeaponFXPool");
        }
        else
        {
            instantiate        = (GameObject)PhotonNetwork.Instantiate(Path.Combine("SoundFX/Prefabs", "WeaponFXPool"), new Vector3(0, 100, 0), Quaternion.identity);
            WeaponFXPoolParent = instantiate;
        }


        //Create all pooling parent OBJs for organization (SniperFXPool) & assign to (WeaponFXPoolParent)
        tempObject = (GameObject)Resources.Load("SoundFX/Prefabs/SniperFXPool");//Getting prefab to check if it's there

        if (tempObject == null)
        {
            Debug.Log("Couldn't find SoundFX/Prefabs/SniperFXPool");
        }
        else
        {
            instantiate = (GameObject)PhotonNetwork.Instantiate(Path.Combine("SoundFX/Prefabs", "SniperFXPool"), new Vector3(0, 100, 0), Quaternion.identity);
            instantiate.transform.parent = WeaponFXPoolParent.transform;
        }

        //Create all pooling parent OBJs for organization (AssaultFXPool) & assign to (WeaponFXPoolParent)
        tempObject = (GameObject)Resources.Load("SoundFX/Prefabs/AssaultFXPool");//Getting prefab to check if it's there

        if (tempObject == null)
        {
            Debug.Log("Couldn't find SoundFX/Prefabs/AssaultFXPool");
        }
        else
        {
            instantiate = (GameObject)PhotonNetwork.Instantiate(Path.Combine("SoundFX/Prefabs", "AssaultFXPool"), new Vector3(0, 100, 0), Quaternion.identity);
            instantiate.transform.parent = WeaponFXPoolParent.transform;
        }

        #endregion PoolCategoryCreation()

        //After instantiate actual FXs
        #region WeaponFXPrefabCreation()


        //Load SNIPERRIFLE prefab and Alert if null, then instantiate Pooling OBJs for Weapon
        SniperBulletFXPrefab = (GameObject)Resources.Load("SoundFX/M82Barrett");
        if (SniperBulletFXPrefab == null)
        {
            Debug.Log("Couldn't find SniperBulletFXPrefab");
        }
        else
        {
            //Makes sniperFXBullets for pool
            for (int i = 0; i < PhotonNetwork.CurrentRoom.MaxPlayers * 2; i++)
            {
                sniperWeaponFXPooling.Add(tempObject = (GameObject)PhotonNetwork.Instantiate(Path.Combine("SoundFX", "M82Barrett"), new Vector3(0, 100, 0), Quaternion.identity));
                tempObject.transform.parent          = WeaponFXPoolParent.transform.GetChild(0);
            }
        }

        //Load ASSAULTRIFLE prefab and Alert if null, then instantiate Pooling OBJs for Weapon
        AssaultRifleBulletFXPrefab = (GameObject)Resources.Load("SoundFX/AssaultRifleBasic");
        if (AssaultRifleBulletFXPrefab == null)
        {
            Debug.Log("Couldn't find AssaultBulletFXPrefab");
        }
        else
        {
            //Makes AssaultRifleBasic for pool
            for (int i = 0; i < PhotonNetwork.CurrentRoom.MaxPlayers * 2; i++)
            {
                assaultWeaponFXPooling.Add(tempObject = (GameObject)PhotonNetwork.Instantiate(Path.Combine("SoundFX", "AssaultRifleBasic"), new Vector3(0, 100, 0), Quaternion.identity));
                tempObject.transform.parent           = WeaponFXPoolParent.transform.GetChild(1);
            }
        }



        #endregion WeaponFXPrefabCreation()



        #endregion WeaponPooling

        #region SetupGameObjects()

        PFC = GameObject.Find("NetworkController").GetComponentInChildren <PlayFabsController>();
        if (PFC == null)
        {
            Debug.Log("There is no PlayFabsController");
        }

        NWC = GameObject.Find("NetworkController").GetComponentInChildren <NetworkController>();
        if (NWC == null)
        {
            Debug.Log("There is no NetworkController");
        }

        //Enables Statistic gathering for room by enabling component on GameSetupController GameObject
        //Eanabling it here allows us to utilize information in the NetworkObjects<List>
        ((MonoBehaviour)transform.GetComponent("StatisticsForLobby")).enabled = true;

        #endregion SetupGameObjects()

        #region SetStats()

        //Get stats from PFC
        accessoryIndex = PFC.Playeraccessory;
        hatIndex       = PFC.playerHat;
        shirtIndex     = PFC.playerTop;
        pantIndex      = PFC.playerBottom;
        shoesIndex     = PFC.playerShoes;
        headIndex      = PFC.playerHead;
        skinIndex      = PFC.playerSkin;
        playerSex      = PFC.playerSex;
        playerID       = PFC.myID;

        #endregion SetStats()
    }