public void Start() { difficulty = user.difficulty; //only do these instructions if fighting against a normal player memes = GlobalGallery.GetGlobalGallery(); }
/// <summary> /// Updates the chat's gallery with any memes that have been obtained /// since the last time the chat was opened. Gets called when the chat /// is opened. /// </summary> public void UpdateGallery() { // This is what I call "The Pokemon Go Approach", because I // guarantee that they have their stuff searching at O(n^2) // --Joseph if (ownedMemes.Count != GlobalGallery.GetPlayerGallery().Count) { foreach (Meme meme in GlobalGallery.GetPlayerGallery()) { if (!ownedMemes.Contains(meme)) { GameObject memeButton = (GameObject)Instantiate(Resources.Load("Meme")); memeButton.GetComponent <MessageBehaviors>().matchMessages = matchMessages; memeButton.GetComponent <MessageBehaviors>().match = match; memeButton.GetComponent <MessageBehaviors>().userMeme = meme; memeButton.GetComponent <MessageBehaviors>().gallery = this; memeButton.GetComponent <MessageBehaviors>().back = back; memeButton.GetComponent <Image>().sprite = meme.GetImageSprite(); memeButton.transform.SetParent(gameObject.transform, false); meme.SetButton(memeButton); ownedMemes.Add(meme); } if (ownedMemes.Count == GlobalGallery.GetPlayerGallery().Count) { return; } } } }
public bool RewardCheck() { if (difficulty > (float)GlobalGallery.GetPlayerGallery().Count / 5) { return(true); } return(false); }
public static void NewMeme() { if (GlobalGallery.GetPlayerUnowned().Count > 0) { int index = Random.Range(0, GlobalGallery.GetPlayerUnowned().Count); GlobalGallery.AddPlayerMeme(GlobalGallery.GetPlayerUnowned().ToArray()[index]); } //SoundManager.instance.PlayButton(); }
/** * Method used to generate a new username */ private void GenerateUser(GameObject chat) { //randomly get name, somehow (need a list of names somewhere, similar implementation to memes?) string name = GlobalGallery.GetUserName(); //randomly generate difficulty (for now I guess?) float difficulty = Random.Range(GlobalGallery.GetPlayerGallery().Count / 5, GlobalGallery.GetPlayerGallery().Count); chat.AddComponent <User>(); chat.GetComponent <User>().userName = name; chat.GetComponent <User>().difficulty = Mathf.RoundToInt(difficulty) + 1; }
void Awake() { // Singleton stuff if (singleton != null) { Destroy(singleton); } else { singleton = this; } DontDestroyOnLoad(this); // Fill the global gallery if it's empty if (globalGallery.Count == 0) { FillGlobalGallery(); } // Fill the list of memes the player does not own if both the // player's gallery and their list of unowned memes is empty if (playerGallery.Count == 0 && playerUnowned.Count == 0) { foreach (Meme m in globalGallery) { playerUnowned.Add(m); } } //Fill the list of names that can be used for new users if (userNames.Count == 0) { FillUserNames(); } UIBehaviors.NewMeme(); UIBehaviors.NewMeme(); UIBehaviors.NewMeme(); }
/// <summary> /// Creates the chat's gallery the first time the ChatPage is opened. Gets /// called when the chat is opened for the first time. /// </summary> public void CreateGallery() { Meme[] tempmemes = new Meme[GlobalGallery.GetPlayerGallery().Count]; GlobalGallery.GetPlayerGallery().CopyTo(tempmemes); foreach (Meme temp in tempmemes) { ownedMemes.Add(temp); } foreach (Meme meme in ownedMemes) { GameObject memeButton = (GameObject)Instantiate(Resources.Load("Meme")); memeButton.GetComponent <MessageBehaviors>().matchMessages = matchMessages; memeButton.GetComponent <MessageBehaviors>().match = match; memeButton.GetComponent <MessageBehaviors>().userMeme = meme; memeButton.GetComponent <MessageBehaviors>().gallery = this; memeButton.GetComponent <MessageBehaviors>().back = back; memeButton.GetComponent <Image>().sprite = meme.GetImageSprite(); memeButton.transform.SetParent(gameObject.transform, false); meme.SetButton(memeButton); } }
public MessageType TakeTurn(GameObject matchMessage, Meme playerMeme, Gallery gallery) { int rand = Random.Range(0, memes.Count); Meme enemyMeme = memes[rand]; //this line grabs the enemyMeme section of the matchMessage and changes it to the right image matchMessage.GetComponent <TextMessage>().opponentImg.GetComponent <Image>().sprite = enemyMeme.GetImageSprite(); matchMessage.GetComponent <TextMessage>().opponentTxt.GetComponent <Text>().text = enemyMeme.GetMemeType().ToString(); MessageType type = MessageType.Tie; if (playerMeme.GetMemeType() == Meme.MemeType.DeepFried) { switch (enemyMeme.GetMemeType()) { case Meme.MemeType.Reaction: playerScore++; type = MessageType.PlayerRoundWin; break; case Meme.MemeType.Text: enemyScore++; type = MessageType.PlayerRoundLoss; break; default: break; } } else if (playerMeme.GetMemeType() == Meme.MemeType.Reaction) { switch (enemyMeme.GetMemeType()) { case Meme.MemeType.Text: playerScore++; type = MessageType.PlayerRoundWin; break; case Meme.MemeType.DeepFried: enemyScore++; type = MessageType.PlayerRoundLoss; break; default: break; } } else if (playerMeme.GetMemeType() == Meme.MemeType.Text) { switch (enemyMeme.GetMemeType()) { case Meme.MemeType.DeepFried: playerScore++; type = MessageType.PlayerRoundWin; break; case Meme.MemeType.Reaction: enemyScore++; type = MessageType.PlayerRoundLoss; break; default: break; } } matchMessage.GetComponent <TextMessage>().scoreText.GetComponent <Text>().text = enemyScore + ":" + playerScore; if (playerScore >= difficulty) { matchOngoing = false; SoundManager.instance.PlayIdle(); playerScore = 0; enemyScore = 0; //gallery.EnableMemes(); return(MessageType.PlayerWin); } if (enemyScore >= difficulty) { matchOngoing = false; SoundManager.instance.PlayIdle(); playerScore = 0; enemyScore = 0; //gallery.EnableMemes(); return(MessageType.PlayerLoss); } if (gallery.disabledMemes.Count >= GlobalGallery.GetPlayerGallery().Count) { matchOngoing = false; SoundManager.instance.PlayIdle(); playerScore = 0; enemyScore = 0; //gallery.EnableMemes(); return(MessageType.PlayerLoss); } return(type); }