Ejemplo n.º 1
0
    public void ToggleReady(bool join)
    {
        if (instructions)
        {
            instructions.SetActive(join);
        }
        GameObject readyButton = childSelectableObjects[1].gameObject;

        if (!charJoin)
        {
            charJoin = GameObject.FindGameObjectWithTag("CombinedPlayerController").GetComponent <CharacterJoinController>();
        }
        if (join && !charJoin.HasJoined(playerNum)) //Joined and not joined(in charJoin dictionary)
        {
            charJoin.SetJoinedPlayer(playerNum);
            ToggleObjects(!join); //Deactivate old UI Objects or Activate when UnReady
            playerNameImage.gameObject.SetActive(join);
            player.GetComponent <PlayerInfo>().ToggleFreezeMovement(!join);
            player.GetComponent <PlayerInfo>().ToggleAim(join);
            if (!rock) //Jeffrey
            {
                rock = Instantiate(rockPrefab, childSelectableObjects[0].transform.position, Quaternion.identity);
                rock.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
                rock.name = "Rock " + playerNum;
            }
            else
            {
                rock.SetActive(join);
            }
            instructions.SetActive(join);
            readyLeave.SetActive(join);
        }
        else if (!join && charJoin.HasJoined(playerNum))   //Not Joined and Joined(in charJoin dictionary)
        {
            charJoin.SetUnjoinedPlayer(playerNum);
            playerNameImage.sprite = Resources.Load <Sprite>("LobbyUI/Player-" + playerNum);
            ToggleObjects(!join);
            player.transform.position = childSelectableObjects[0].transform.position;
            player.GetComponent <PlayerInfo>().ToggleFreezeMovement(!join);
            player.GetComponent <PlayerInfo>().ToggleAim(join);
            player.GetComponent <Blob>().Restart();
            rock.SetActive(join);
            instructions.SetActive(join);
            readyLeave.SetActive(join);
        }
        charJoin.SetAIPlayerPref(playerNum, 0);       //Reset PlayerPrefsAI to 0
    }
Ejemplo n.º 2
0
 void Start()
 {
     instance = this;
     currentSettingsPlayerNum = 1;
     SetupReadyDict(maxPlayers);
     if (PlayerPrefs.GetInt("InfiniteLives") == 1)
     {
         ToggleInfiniteLives();
     }
     //ReadyToToggleAIPanels = new Dictionary<CharacterPanel, bool>();
     charPanels = new List <CharacterPanel>(FindObjectsOfType <CharacterPanel>());
     charPanels.Sort();
     colors = new Color[] { new Color(0.92f, 0.1f, 0.2f), Color.yellow, Color.cyan, Color.white, new Color(1f, 0.7f, 1f), new Color(1f, 0.56f, 0.1f),
                            new Color(0.62f, 0.92f, 0.16f), new Color(0.16f, 0.38f, 0.92f), new Color(0.62f, 0.92f, 0.16f) };
     uniqueLoop = new UniqueLoop <Color>(colors);
     PlayerPrefs.SetInt("NumberOfLives", defaultLives);
     //POWERUPS NOT IMPLEMENTED
     //if (powerUpsToggle) {
     //    powerUpsToggle.isOn = (PlayerPrefs.GetInt("PowerUps", 1) == 1 ? true : false);
     //}
 }