private void UpdateToGuiTopcurrentRandomEvent() { this._randomEventDescText.text = string.Empty; this.DeactivateAllButtons(); if (this.CurrentRandomEvent == null) { this.CurrentRandomEvent = new RandomEvent(RandomEvent.RandomEventType.Choice, new List<RandomEvent.Choice> { new RandomEvent.Choice("Sluiten", new List<RandomEvent.ChoiceAction> { new RandomEvent.ChoiceAction(RandomEvent.ChoiceAction.ActionType.Ok) }) }, "Helaas", "Je hebt er helaas te lang over gedaan om er te komen. Probeer het nogmaals"); this._button1.gameObject.SetActive(true); this._button1Text.text = this.CurrentRandomEvent.Choices[0].Text; return; } string title = this.CurrentRandomEvent.Title.Replace("{player}", Player.Instance.PlayerName); title = title.Replace("{idea}", Player.Instance.IdeaName); this._randomEventTitleText.text = title; string desc = this.CurrentRandomEvent.Description.Replace("{player}", Player.Instance.PlayerName); desc = desc.Replace("{idea}", Player.Instance.IdeaName); this._randomEventDescText.text = desc; if (this.CurrentRandomEvent.Choices.IsNullOrEmpty()) { this._button1.gameObject.SetActive(true); this._button1Text.text = "Sluiten"; } else for (int i = 0; i < this.CurrentRandomEvent.Choices.Count; i++) { switch (i) { case 0: { this._button1.gameObject.SetActive(true); this._button1Text.text = this.CurrentRandomEvent.Choices[i].Text; break; } case 1: { this._button2.gameObject.SetActive(true); this._button2Text.text = this.CurrentRandomEvent.Choices[i].Text; break; } case 2: { this._button3.gameObject.SetActive(true); this._button3Text.text = this.CurrentRandomEvent.Choices[i].Text; break; } case 3: { this._button4.gameObject.SetActive(true); this._button4Text.text = this.CurrentRandomEvent.Choices[i].Text; break; } default: { throw new ArgumentOutOfRangeException("Meer dan 4 keuzes, hoe kan dit?"); } } } }
// ReSharper disable once UnusedMember.Local private void Start() { RandomEvent currentNotification = new RandomEvent { Title = string.Format("Welkom {0}!", Player.Instance.PlayerName), Description = string.Format("{0} is een super tof idee! Probeer dit door heel Nederland te verspreiden en uiteindelijk op TEDxVeghel te komen. Succes met je avontuur!", Player.Instance.IdeaName), Choices = new List<RandomEvent.Choice> { new RandomEvent.Choice("Sluiten", new List<RandomEvent.ChoiceAction> { new RandomEvent.ChoiceAction(RandomEvent.ChoiceAction.ActionType.Tutorial) }) } }; this.ShowNotificationCanvas(currentNotification); }
private void DoChoice(RandomEvent.Choice choice) { int actionValueSkill = 0; int actionValueFollowers = 0; foreach (RandomEvent.ChoiceAction action in choice.Actions) { switch (action.Action) { case RandomEvent.ChoiceAction.ActionType.SkillIncrease: { int increaseValue = (int)action.Values[1]; if (action.Values.Length > 3) switch ((PlayerSkill)action.Values[2]) { case PlayerSkill.Knowledge: increaseValue += Player.Instance.KnowledgeSkills * (int)action.Values[3]; break; case PlayerSkill.Presentation: increaseValue += Player.Instance.PresentationSkills * (int)action.Values[3]; break; case PlayerSkill.Media: increaseValue += Player.Instance.MediaSkills * (int)action.Values[3]; break; default: throw new ArgumentOutOfRangeException(); } if (increaseValue < 0) { this.VisualFeedBack(increaseValue.ToString()).GetComponent<Animator>().SetTrigger("SkillUp"); } else { this.VisualFeedBack("+ " + increaseValue.ToString()).GetComponent<Animator>().SetTrigger("SkillUp"); } actionValueSkill += increaseValue; IncreasePlayerSkill((PlayerSkill)action.Values[0], increaseValue); break; } case RandomEvent.ChoiceAction.ActionType.FollowerIncrease: { int increaseValue = (int)action.Values[0]; if (action.Values.Length > 2) switch ((PlayerSkill)action.Values[1]) { case PlayerSkill.Knowledge: increaseValue += Player.Instance.KnowledgeSkills * (int)action.Values[2]; break; case PlayerSkill.Presentation: increaseValue += Player.Instance.PresentationSkills * (int)action.Values[2]; break; case PlayerSkill.Media: increaseValue += Player.Instance.MediaSkills * (int)action.Values[2]; break; default: throw new ArgumentOutOfRangeException(); } this.VisualFeedBack("+ " + increaseValue.ToString()).GetComponent<Animator>().SetTrigger("FollowerUp"); actionValueFollowers += increaseValue; FollowerManager.Instance.TotalFollowers += increaseValue; break; } case RandomEvent.ChoiceAction.ActionType.Ok: { break; } case RandomEvent.ChoiceAction.ActionType.NewLightbulbNear: { bool respawn = (bool)action.Values[0]; BalloonManager.Instance.SpawnLightbulb(respawn); break; } case RandomEvent.ChoiceAction.ActionType.VisitUrl: { #if (UNITY_IPHONE || UNITY_ANDROID) YoutubeVideo ytv = new YoutubeVideo(); UnityEngine.Handheld.PlayFullScreenMovie(ytv.RequestVideo(this.CurrentRandomEvent.TedUrl, 720)); #else Application.OpenURL(this.CurrentRandomEvent.TedUrl); #endif Player.Instance.KnowledgeSkills++; break; } case RandomEvent.ChoiceAction.ActionType.Tutorial: { this._notificationPanel.SetActive(false); this._temporaryTutorialCanvas.SetActive(true); break; } default: { throw new ArgumentOutOfRangeException(); } } } if (actionValueFollowers < 0 && actionValueSkill < 0) { AudioManager.Instance.PlayNegativeFeedback(); } else if (actionValueFollowers > 0 && actionValueSkill > 0) { AudioManager.Instance.PlayPositiveFeedback(); } this.HideRandomEventsCanvas(); this.NewRandomEvent(choice); this.UpdateToGuiTopcurrentRandomEvent(); }
// ReSharper disable once UnusedMember.Local private void Awake() { Instance = this; List<RandomEvent> tempList = JsonSerializer.ReadFromFile("GeneratedJsonData").RandomEvents; // Delete TED Links with other categories. tempList.RemoveAll(re => re.Type == RandomEvent.RandomEventType.Link && re.IdeaCategory != Player.Instance.Category); tempList = this.ShuffleRandomEvents(tempList); this._randomEvents = tempList; foreach (RandomEvent ra in this._randomEvents) ra.SetChoiceActionValues(); this.CurrentRandomEvent = this._randomEvents[0]; }
public void ShowNotificationCanvas(RandomEvent RE) { this.CurrentNotification = RE; AudioManager.Instance.PlayNotification(); this._notificationPanel.SetActive(true); this.UpdateToGuiTopcurrentNotification(); Time.timeScale = 0f; }
public bool NewRandomEvent(RandomEvent.Choice choice) { if (this._randomEvents.Count == 0) { this.CurrentRandomEvent = null; return false; } if (this.CurrentRandomEvent.HasFollowUpEvent && choice.Text == "Ja") { this.CurrentRandomEvent = this._randomEvents[0]; this._randomEvents.RemoveAt(0); } else { if (choice != null && choice.Text == "Nee") { this.CurrentRandomEvent = this._randomEvents[1]; this._randomEvents.RemoveAt(0); this._randomEvents.RemoveAt(1); } else { this.CurrentRandomEvent = this._randomEvents[0]; this._randomEvents.RemoveAt(0); } } return true; }