Exemple #1
0
    void UpgradeThisPerkLevel(Flatmate slectedflatmet)
    {
        ScreenManager.Instance.ShowPopup(ScreenManager.Instance.News);
        ScreenManager.Instance.News.transform.FindChild("ok").GetComponent <Button> ().interactable = true;

        ScreenManager.Instance.News.transform.FindChild("ok").GetComponent <Button> ().onClick.RemoveAllListeners();
        ScreenManager.Instance.News.transform.FindChild("close").GetComponent <Button> ().onClick.RemoveAllListeners();

        ScreenManager.Instance.News.transform.FindChild("ok").GetChild(0).GetComponent <Text> ().text    = "Yes";
        ScreenManager.Instance.News.transform.FindChild("close").GetChild(0).GetComponent <Text> ().text = "No";
        ScreenManager.Instance.News.transform.FindChild("ok").GetComponent <Button> ().interactable      = true;

        ScreenManager.Instance.News.transform.FindChild("Message").GetComponent <Text> ().text = " Do you want to upgrade this perk level for " + CoinAndGemsdeductionForPerk() + " Coins ?";
        ScreenManager.Instance.News.transform.FindChild("ok").gameObject.SetActive(true);
        ScreenManager.Instance.News.transform.FindChild("close").gameObject.SetActive(true);

        ScreenManager.Instance.News.transform.FindChild("ok").GetComponent <Button> ().onClick.AddListener(() => {
            GameManager.Instance.SubtractCoins(CoinAndGemsdeductionForPerk());
            slectedflatmet.UpgradePerk();
            ShowProfile();
            ScreenManager.Instance.ClosePopup();
        });

        ScreenManager.Instance.News.transform.FindChild("close").GetComponent <Button> ().onClick.AddListener(() => ScreenManager.Instance.ClosePopup());
    }
Exemple #2
0
    public void ShowProfile()
    {
        Flatmate selectedFlatmate = RoommateManager.Instance.SelectedRoommate.GetComponent <Flatmate> ();

        Name.text   = selectedFlatmate.data.Name.Trim('"');
        Gender.text = selectedFlatmate.data.Gender.ToString();
        if (selectedFlatmate.data.IsBusy)
        {
//			TimerText.transform.parent.gameObject.SetActive (true);
            TimerText.gameObject.SetActive(true);
            AttendClassButton.interactable = false;
            TimerText.text = ExtensionMethods.GetTimeStringFromFloat(selectedFlatmate.data.busyTimeRemaining);
        }
        else
        {
//			TimerText.transform.parent.gameObject.SetActive (false);

            TimerText.gameObject.SetActive(false);
            AttendClassButton.interactable = true;
        }


        PerkName.text = selectedFlatmate.data.Perk;


        for (int i = 0; i < RoommateManager.Instance.PerksName.Count; i++)
        {
            if (RoommateManager.Instance.PerksName [i] == selectedFlatmate.data.Perk)
            {
                PerkIcon.sprite = RoommateManager.Instance.PerksImages [i];
            }
        }
        PerkValue.text = selectedFlatmate.data.Perk_value.ToString();
//		for (int i = 0; i < RoommateManager.Instance.AllPerksName.Count; i++) {
//			if (RoommateManager.Instance.AllPerksName [i] == selectedFlatmate.data.Perk) {
//				if (RoommateManager.Instance.TempPerkName.Count >= 1) {
//					for (int cout = 0; cout < RoommateManager.Instance.TempPerkName.Count; cout++) {
//
//						if (!RoommateManager.Instance.TempPerkName [cout].Contains (selectedFlatmate.data.Perk)) {
//							// store this perk in to this Obj
//							RoommateManager.Instance.TempPerkName.Add (RoommateManager.Instance.AllPerksName [i]);
//							RoommateManager.Instance.TempPerkImage.Add (RoommateManager.Instance.AllPerksImages [i]);
//							// delete currunt perk form list
//							RoommateManager.Instance.AllPerksImages.RemoveAt (i);
//							RoommateManager.Instance.AllPerksName.RemoveAt (i);
//						}
//					}
//				} else if (RoommateManager.Instance.TempPerkName.Count == 0) {
//					// store this perk in to this Obj
//					RoommateManager.Instance.TempPerkName.Add (selectedFlatmate.data.Perk);
//					RoommateManager.Instance.TempPerkImage.Add (RoommateManager.Instance.AllPerksImages [i]);
//					// delete currunt perk form list
//					RoommateManager.Instance.AllPerksImages.RemoveAt (i);
//					RoommateManager.Instance.AllPerksName.RemoveAt (i);
//				}
//				// add removed perk to Main perk lsit and remove from temp list
//				if (RoommateManager.Instance.TempPerkName.Count >= 2) {
//					RoommateManager.Instance.AllPerksImages.Add (RoommateManager.Instance.TempPerkImage [0]);
//					RoommateManager.Instance.AllPerksName.Add (RoommateManager.Instance.TempPerkName [0]);
//					RoommateManager.Instance.TempPerkName.RemoveAt (0);
//					RoommateManager.Instance.TempPerkImage.RemoveAt (0);
//				}
//			}
//		}

        Education_Bonus_Point.text = selectedFlatmate.GetEducationPointString();
        Education_LevelText.text   = "" + selectedFlatmate.GetCurrentEducationLevel();

        UpgradeButton.onClick.RemoveAllListeners();
        UpgradeButton.onClick.AddListener(() => {
            var Tut = GameManager.Instance.GetComponent <Tutorial> ();
            if (Tut._ClassAttended)
            {
                if (PlayerPrefs.GetInt("Money") >= CoinAndGemsdeductionForPerk())
                {
                    if (selectedFlatmate.data.Perk_value <= 5)
                    {
                        UpgradeThisPerkLevel(selectedFlatmate);
                    }
                    else
                    {
                        ShowPopUpLessCoins("You can not upgrade perk level more then 6");
                    }
                }
                else
                {
                    int remaingCoin = PlayerPrefs.GetInt("Money") - CoinAndGemsdeductionForPerk();
                    ShowPopUpLessCoins("You do not have sufficient coins to upgrade perk \n" +
                                       "You need " + remaingCoin.ToString().Trim('-') + " more coins to upgrade this perk.");
                }
            }
            else
            {
                selectedFlatmate.UpgradePerk();
                ShowProfile();
            }
        });
        ChangeButton.onClick.RemoveAllListeners();
        ChangeButton.onClick.AddListener(() => {
            var Tut = GameManager.Instance.GetComponent <Tutorial> ();
            if (Tut._ClassAttended)
            {
                if (PlayerPrefs.GetInt("Gems") >= CoinAndGemsdeductionForChangePerk())
                {
                    ChangePerk(selectedFlatmate);
                }
                else
                {
                    int remaingCoin = PlayerPrefs.GetInt("Gems") - CoinAndGemsdeductionForChangePerk();
                    ShowPopUpLessCoins("You do not have sufficient gems to change the perk \n" +
                                       "You need " + remaingCoin.ToString().Trim('-') + " more gems to change the perk.");
                }
            }
            else
            {
                selectedFlatmate.GivePerk();
                ShowProfile();
            }
        });
    }