Beispiel #1
0
    public void ConfirmButton()
    {
        NewNetworkManagerScript networkManager = GameObject.Find("NewNetworkManager").GetComponent <NewNetworkManagerScript> ();

        networkManager.updateSelectedCharacter(selectionIndex);
        SceneManager.LoadScene("Network");
    }
    // Initial setup
    void Start()
    {
        // Avoid duplication of this object
        if (scriptInstance == null)
        {
            scriptInstance = this;
        }
        else
        {
            Destroy(this.gameObject);
            return;
        }

        // To stop the script object from destroying when a new scene is loaded
        DontDestroyOnLoad(this.gameObject);

        // Randomly select a character
        updateSelectedCharacter(UnityEngine.Random.Range(0, 4));

        // Set loglevel to full
        //PhotonNetwork.logLevel = PhotonLogLevel.Full;

        // Get player 2 setting
        //player2Position = player2Transform.transform.position;
        //player2Rotation = player2Transform.transform.rotation;
    }
    public void Start()
    {
        chim.SetActive(false);
        split.SetActive(false);
        kronos.SetActive(false);
        butch.SetActive(false);
        chimEnemy.SetActive(false);
        splitEnemy.SetActive(false);
        kronosEnemy.SetActive(false);
        butchEnemy.SetActive(false);
        isReloading = false;
        startTimer  = false;

        gracePeriodDuration = 5f;
        matchDuration       = 30f;   //change to 30 later

        gameOver       = false;
        startCountDown = false;


        networkManager = GameObject.Find("NewNetworkManager").GetComponent <NewNetworkManagerScript> ();
        int playerCharacterId = networkManager.getPlayerCharacterId();

        initPlayer(playerCharacterId, "player");
        initPlayer(UnityEngine.Random.Range(1, 4), "enemy");

        //DontDestroyOnLoad (this.gameObject);
        //initPClock ();
        //Invoke (changeClockText (playerClock, matchDuration, true), gracePeriodDuration);
    }
Beispiel #4
0
    // Use this for initialization
    private void Start()
    {
        // Allocate memory for our data structures
        numDisplays       = transform.childCount;
        characterList     = new GameObject[numDisplays];
        characterDisplays = new characterDisplay[numDisplays];

        namesDictionary   = new Dictionary <int, GameObject> ();
        healthsDictionary = new Dictionary <int, GameObject> ();
        damagesDictionary = new Dictionary <int, GameObject> ();
        rSpeedsDictionary = new Dictionary <int, GameObject> ();
        hSpeedsDictionary = new Dictionary <int, GameObject> ();
        vSpeedsDictionary = new Dictionary <int, GameObject> ();
        xHairsDictionary  = new Dictionary <int, GameObject> ();
        bMarksDictionary  = new Dictionary <int, GameObject> ();

        // Initialize our data structures
        for (int i = 0; i < transform.childCount; i++)
        {
            characterList [i] = transform.GetChild(i).gameObject;
            characterDisplays [i].displayedModel          = characterList [i].gameObject;
            characterDisplays [i].myParams.objGrandParent = characterDisplays [i].displayedModel.transform.FindChild("ParametersPanel").gameObject;
            characterDisplays [i].myParams.playerModel    = characterDisplays [i].displayedModel.transform.GetChild(1).gameObject;
            characterDisplays [i].myParams.numChildren    = characterDisplays [i].myParams.objGrandParent.transform.childCount;
            characterDisplays [i].myParams.paraName       = new parameterParentAndChildren[characterDisplays [i].myParams.numChildren];

            for (int j = 0; j < characterDisplays [i].myParams.numChildren; j++)
            {
                characterDisplays [i].myParams.paraName [j].objParent = characterDisplays [i].myParams.objGrandParent.transform.GetChild(j).gameObject;
                //characterDisplays[i].myParams.paraName[j].theChildren = new GameObject[characterDisplays [i].myParams.paraName[j].objParent.transform.childCount];
                characterDisplays [i].myParams.paraName [j].numChildren = characterDisplays [i].myParams.paraName [j].objParent.transform.childCount;
                characterDisplays [i].myParams.paraName [j].theChild    = characterDisplays [i].myParams.paraName [j].objParent.transform.GetChild(0).gameObject;

                //Debug.Log("This should say name or dummy11: " + characterDisplays[i].myParams.paraName[j].theChild.GetComponent<Text>().text);

                /*Debug.Log("This should say name or dummy1: " + characterDisplays[i].myParams.paraName[j].theChild.name);
                 *
                 * for (int k = 0; k < characterDisplays [i].myParams.paraName[j].numChildren; k++) {
                 *      characterDisplays [i].myParams.paraName[j].theChildren [k] = characterDisplays [i].myParams.paraName[j].objParent.transform.GetChild(k).gameObject;
                 *      //Debug.Log (characterDisplays [i].myParams.paraName[j].theChildren [k].name);
                 * }*/
                switch (j)
                {
                case 0:
                    namesDictionary.Add(i, characterDisplays [i].myParams.paraName [j].theChild.gameObject);
                    continue;

                case 1:
                    healthsDictionary.Add(i, characterDisplays [i].myParams.paraName [j].theChild.gameObject);
                    continue;

                case 2:
                    damagesDictionary.Add(i, characterDisplays [i].myParams.paraName [j].theChild.gameObject);
                    continue;

                case 3:
                    rSpeedsDictionary.Add(i, characterDisplays [i].myParams.paraName [j].theChild.gameObject);
                    continue;

                case 4:
                    hSpeedsDictionary.Add(i, characterDisplays [i].myParams.paraName [j].theChild.gameObject);
                    continue;

                case 5:
                    vSpeedsDictionary.Add(i, characterDisplays [i].myParams.paraName [j].theChild.gameObject);
                    continue;

                case 6:
                    xHairsDictionary.Add(i, characterDisplays [i].myParams.paraName [j].theChild.gameObject);
                    continue;

                case 7:
                    bMarksDictionary.Add(i, characterDisplays [i].myParams.paraName [j].theChild.gameObject);
                    continue;
                }
            }

            //initialize script references for the characters
            switch (i)
            {
            case 0:
                butchValueScript = characterDisplays [i].myParams.playerModel.GetComponent <ScriptButch> ();
                butchValueScript.initButch();
                namesDictionary [i].GetComponent <Text> ().text = butchValueScript.characterName;
                determineBarFeatures((int)butchValueScript.health, healthsDictionary [i].gameObject);
                determineBarFeatures((int)butchValueScript.damage, damagesDictionary [i].gameObject);
                determineBarFeatures((int)butchValueScript.reloadSpeed, rSpeedsDictionary [i].gameObject);
                determineBarFeatures((int)butchValueScript.hSpeed, hSpeedsDictionary [i].gameObject);
                determineBarFeatures((int)butchValueScript.vSpeed, vSpeedsDictionary [i].gameObject);

                continue;

            case 1:
                splitValueScript = characterDisplays [i].myParams.playerModel.GetComponent <ScriptSplit> ();
                splitValueScript.initSplit();
                namesDictionary [i].GetComponent <Text> ().text = splitValueScript.characterName;
                determineBarFeatures((int)splitValueScript.health, healthsDictionary [i].gameObject);
                determineBarFeatures((int)splitValueScript.damage, damagesDictionary [i].gameObject);
                determineBarFeatures((int)splitValueScript.reloadSpeed, rSpeedsDictionary [i].gameObject);
                determineBarFeatures((int)splitValueScript.hSpeed, hSpeedsDictionary [i].gameObject);
                determineBarFeatures((int)splitValueScript.vSpeed, vSpeedsDictionary [i].gameObject);

                continue;

            case 2:
                chimValueScript = characterDisplays [i].myParams.playerModel.GetComponent <ScriptChim> ();
                chimValueScript.initChim();
                namesDictionary [i].GetComponent <Text> ().text = chimValueScript.characterName;
                determineBarFeatures((int)chimValueScript.health, healthsDictionary [i].gameObject);
                determineBarFeatures((int)chimValueScript.damage, damagesDictionary [i].gameObject);
                determineBarFeatures((int)chimValueScript.reloadSpeed, rSpeedsDictionary [i].gameObject);
                determineBarFeatures((int)chimValueScript.hSpeed, hSpeedsDictionary [i].gameObject);
                determineBarFeatures((int)chimValueScript.vSpeed, vSpeedsDictionary [i].gameObject);

                continue;

            case 3:
                kronosValueScript = characterDisplays [i].myParams.playerModel.GetComponent <ScriptKronos> ();
                kronosValueScript.initKronos();
                namesDictionary [i].GetComponent <Text> ().text = kronosValueScript.characterName;
                determineBarFeatures((int)kronosValueScript.health, healthsDictionary [i].gameObject);
                determineBarFeatures((int)kronosValueScript.damage, damagesDictionary [i].gameObject);
                determineBarFeatures((int)kronosValueScript.reloadSpeed, rSpeedsDictionary [i].gameObject);
                determineBarFeatures((int)kronosValueScript.hSpeed, hSpeedsDictionary [i].gameObject);
                determineBarFeatures((int)kronosValueScript.vSpeed, vSpeedsDictionary [i].gameObject);

                continue;
            }
        }


        // Toggle off rendering of displayModels
        for (int i = 0; i < numDisplays; i++)
        {
            characterDisplays [i].displayedModel.gameObject.SetActive(false);
        }


        /*
         * foreach (KeyValuePair<int,GameObject> entry in namesDictionary){
         *      Debug.Log("these are all the names in the list: " + entry.Value.GetComponent<Text>().text);
         * }*/

        NewNetworkManagerScript networkManager = GameObject.Find("NewNetworkManager").GetComponent <NewNetworkManagerScript> ();

        selectionIndex = networkManager.getSelectedCharacterId();
        // Toggle on first index
        if (characterDisplays [networkManager.getSelectedCharacterId()].displayedModel)
        {
            characterDisplays [networkManager.getSelectedCharacterId()].displayedModel.SetActive(true);
        }
        else if (characterDisplays [0].displayedModel)
        {
            characterDisplays [0].displayedModel.SetActive(true);
        }
        else
        {
            Debug.Log("Error: index error while toggling on characterDisplays during start()");
        }
    }
Beispiel #5
0
 // Use this for initialization
 void Start()
 {
     networkManager = GameObject.Find("NewNetworkManager").GetComponent <NewNetworkManagerScript> ();
     //GameObject.Find ("PlayFriendInput").GetComponent<UnityEngine.UI.InputField> ().characterLimit = 10;
     //GameObject.Find ("PlayFriendInput").GetComponent<UnityEngine.UI.InputField> ().contentType = UnityEngine.UI.InputField.ContentType.Alphanumeric;
 }