Exemple #1
0
    public void GotoChooseClassMenuAfterLoad(GameObject nameText)
    {
        playerName = nameText.GetComponent <LoadCurrentName>().text.text;
        Debug.Log("playerName = " + playerName);

        if (playerName.Equals(""))  //cannot load blank name
        {
            AudioManager.Play("Wait");
            Debug.Log("Cannot load Blank Name!!!");
        }

        /*else if (selectNameMenu.transform.parent.parent.GetComponent<CSSTopMenuScript>().NameIsTaken(playerName,playerNum))
         * {
         *  AudioManager.Play("Wait");
         *  Debug.Log("Name is already taken!");
         * }*/
        else if (MenuInputSelector.NameIsTaken(playerName, playerNum - 1))
        {
            AudioManager.Play("Wait");
            Debug.Log("Name is already taken!");
        }
        else
        {
            MenuInputSelector.PlayerNames[playerNum - 1]         = playerName; //set name chosen to global PlayerName variable
            MenuInputSelector.PlayerAssaultLevels[playerNum - 1] = LoadProfileList.GetAssaultLevel(playerName);
            MenuInputSelector.PlayerHeavyLevels[playerNum - 1]   = LoadProfileList.GetHeavyLevel(playerName);
            MenuInputSelector.PlayerShotgunLevels[playerNum - 1] = LoadProfileList.GetShotgunLevel(playerName);
            MenuInputSelector.PlayerSniperLevels[playerNum - 1]  = LoadProfileList.GetSniperLevel(playerName);
            previousMenu = selectNameMenu;
            GotoMenuHelper(chooseClassMenu);
            loadedName = true;
        }
    }
    public bool checkNameIsValid()
    {
        if (sampleText.text == "")
        {
            Debug.Log("Name cannot be blank");
            AudioManager.Play("Wait");
            return(false);
        }

        Debug.Log("sampleText.text = " + sampleText.text);

        if (LoadProfileList.checkForName(sampleText.text) == true)
        {
            Debug.Log("Name is not Valid");
            AudioManager.Play("Wait");
            return(false);
        }
        else
        {   //file with this name doesnt exist yet, so create new file
            SaveProfile.saveProfile(sampleText.text);
            Debug.Log("Name is Good, created new profile!");

            return(true);
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     //PlayerPrefs.DeleteAll();
     player = parentPlayer.GetComponent <PlayerMenuScript>().playerNum;
     LoadProfileList.totalNames = LoadProfileList.LoadData();    //loads data and set totalNames to the total amount of names
     LoadProfileList.MakePages();
     LoadProfileList.printNamePages();
     Debug.Log("LoadProfileList.totalNames = " + LoadProfileList.totalNames);
 }
    private void setPlayerInfo(int playerIndex)
    {
        if (MenuInputSelector.PlayerClasses[playerIndex] == 0)        //if player1 is Assault class
        {
            gameObject.AddComponent <PlayerFast>();
            gameObject.GetComponent <Player>().shootPosition = transform.GetChild(1).transform;  //may have to change this per class
            playerLevel = LoadProfileList.GetAssaultLevel(MenuInputSelector.PlayerNames[playerIndex]);
        }
        else if (MenuInputSelector.PlayerClasses[playerIndex] == 1)   //if player1 is Heavy class
        {
            gameObject.AddComponent <PlayerHeavy>();
            gameObject.GetComponent <Player>().shootPosition = transform.GetChild(1).transform;  //may have to change this per class
            playerLevel = LoadProfileList.GetHeavyLevel(MenuInputSelector.PlayerNames[playerIndex]);
        }
        else if (MenuInputSelector.PlayerClasses[playerIndex] == 2)   //if player1 is Shotgun class
        {
            gameObject.AddComponent <PlayerShotgun>();
            gameObject.GetComponent <Player>().shootPosition = transform.GetChild(1).transform;  //may have to change this per class
            playerLevel = LoadProfileList.GetShotgunLevel(MenuInputSelector.PlayerNames[playerIndex]);
        }
        else if (MenuInputSelector.PlayerClasses[playerIndex] == 3)   //if player1 is Sniper class
        {
            gameObject.AddComponent <PlayerSniper>();
            gameObject.GetComponent <Player>().shootPosition = transform.GetChild(1).transform;  //may have to change this per class
            playerLevel = LoadProfileList.GetSniperLevel(MenuInputSelector.PlayerNames[playerIndex]);
        }


        //then
        gameObject.GetComponent <Player>().playerNumber = playerIndex + 1;                                 //set player number
        //gameObject.GetComponentInChildren<TextMesh>().text = "P" + (1) + " (Keyboard input)";
        gameObject.GetComponentInChildren <TextMesh>().text  = MenuInputSelector.PlayerNames[playerIndex]; //get player1 name
        gameObject.GetComponent <Player>().myControllerInput = MenuInputSelector.menuControl[playerIndex]; // set player input



        if (playerIndex == 0)
        {
            gameObject.GetComponent <Player>().myCamera = GameObject.FindWithTag("Camera1").GetComponent <Camera>();    //set player camera
        }
        else if (playerIndex == 1)
        {
            gameObject.GetComponent <Player>().myCamera = GameObject.FindWithTag("Camera2").GetComponent <Camera>();    //set player camera
        }
        else if (playerIndex == 2)
        {
            gameObject.GetComponent <Player>().myCamera = GameObject.FindWithTag("Camera3").GetComponent <Camera>();    //set player camera
        }
        else if (playerIndex == 3)
        {
            gameObject.GetComponent <Player>().myCamera = GameObject.FindWithTag("Camera4").GetComponent <Camera>();    //set player camera
        }
        SetCameraDistance(playerIndex);
        SetCrossHair();
        Debug.Log("Should have initialized Player" + (playerIndex + 1));
    }
Exemple #5
0
    /*
     * // Start is called before the first frame update
     * void Start()
     * {
     *  buttonID = GetComponent<MenuPlayerButtonScript>().buttonID;
     * }
     * private void OnEnable()
     * {
     *  Start();
     * }
     */

    /*
     * // Update is called once per frame
     * void Update()
     * {
     *  if (playerMenu.GetComponent<PlayerMenuScript>().currentButton == buttonID)
     *  {
     *      if (Input.GetKeyDown(KeyCode.D))
     *      {
     *          AudioManager.Play("Joined");
     *          LoadProfileList.RemoveName(text.text);
     *          Debug.Log("Should have removed" + text.text);
     *          playerMenu.GetComponent<PlayerMenuScript>().GotoPreviousMenu();
     *      }
     *  }
     * }
     */

    public void RemoveName()
    {
        if (LoadProfileList.checkForName(text.text) == true)
        {
            LoadProfileList.RemoveName(text.text);
            playerMenu.GetComponent <PlayerMenuScript>().GotoPreviousMenu();
            AudioManager.Play("Back");
        }
        else
        {
            AudioManager.Play("Wait");
        }
    }
    //public PlayerProfile profile;


    static public void saveProfile(string s)
    {
        int totalNames = LoadProfileList.LoadData(); //.getTotalNames();

        PlayerPrefs.SetString("name" + totalNames, s);
        PlayerPrefs.SetInt("AssaultLv" + totalNames, 1); //set to level 1 for now
        PlayerPrefs.SetInt("HeavyLv" + totalNames, 1);   //set to level 1 for now
        PlayerPrefs.SetInt("ShotgunLv" + totalNames, 1); //set to level 1 for now
        PlayerPrefs.SetInt("SniperLv" + totalNames, 1);  //set to level 1 for now
        PlayerPrefs.Save();
        //Debug.Log("created: name"+totalNames);
        Debug.Log("Created: name" + totalNames +
                  "\nName" + totalNames + " = " + s +
                  "\nAssault" + totalNames + "Lv = " + 1 +
                  "\nHeavy" + totalNames + "Lv = " + 1 +
                  "\nShotgun" + totalNames + "Lv = " + 1 +
                  "\nSniper" + totalNames + "Lv = " + 1);
        //PlayerPrefs.SetInt("TotalProfiles", totalNames + 1);
        //PlayerPrefs.DeleteAll();
    }
Exemple #7
0
    private void LoadNextScene()
    {
        LoadProfileList.SavePlayerProgress();

        StartCoroutine(LoadNextSceneAsync());
    }