/// <summary> /// At the end of animation, set the animator to default invisible state and decrease happiness metric /// </summary> void OnEndOfAnimation() { foreach (Renderer r in GetComponentsInChildren <Renderer>()) { r.enabled = false; } animator.SetBool("isShow", false); markSpawned = false; MetricsModifier modifier = new MetricsModifier(-2, 0, 0); modifier.Modify(); MetricManager.Instance.RenderMetrics(); }
/// <summary> /// Called when in WeatherEvent state, it displays a weather card to the player and makes a call to /// decrease player health after player clicks continue; /// </summary> private void DisplayWeatherCard() { String weatherEvent = ""; switch (WeatherController.Instance.currentEvent) { case WeatherController.ClimateEvent.AcidRain: weatherEvent = "acid rain"; break; case WeatherController.ClimateEvent.Hurricane: weatherEvent = "hurricane"; break; case WeatherController.ClimateEvent.Smog: weatherEvent = "smog"; break; case WeatherController.ClimateEvent.WildFire: weatherEvent = "wildfire"; break; } string statement = "Your town has been struck by " + weatherEvent + "! Try raise your environment health to avoid more disasters"; string[] statements = { statement }; Action displayWeatherInfo = () => { WeatherController.Instance.StopAnim(); Debug.Log("Clicked continue on weather event"); SetState(GameState.WaitingForEvents); //TODO: balance numbers on event MetricsModifier modifier = new MetricsModifier(-4, -3, 0); modifier.Modify(); metricManager.RenderMetrics(); WeatherController.Instance.probability = 0; Debug.Log("new prob " + WeatherController.Instance.probability); }; // minor card should be displayed upon the callback to the mail message dialogueManager.StartExplanatoryDialogue(new SimpleDialogue(statements, weatherEvent), displayWeatherInfo); }
/// <summary> /// Transition to default state (invisible) when mark has been clicked /// also queues the minor cards to be displayed /// </summary> void OnMouseDown() { if (markSpawned && cardManager.CurrentGameState == CardManager.GameState.WaitingForEvents) { animator.SetBool("isShow", false); clickCount++; markSpawned = false; cardManager.QueueMinorCard(); foreach (Renderer r in GetComponentsInChildren <Renderer>()) { r.enabled = false; } // give player money for accepting request MetricsModifier modifier = new MetricsModifier(0, 3, 0); modifier.Modify(); MetricManager.Instance.RenderMetrics(); } else { return; } }
public SliderTransition(string feedback, string feedbackNPCName, MetricsModifier metricsmodifier, bool hasAnimation, string buildingName, int threshold) : base(feedback, feedbackNPCName, metricsmodifier, hasAnimation, buildingName) { this.threshold = threshold; }
private List <Card> ParseJson(string json, bool isPlotJson) { List <Card> result = new List <Card>(); JSONArray stateArray = SimpleJSON.JSON.Parse(json).AsArray; foreach (JSONNode state in stateArray) { List <string> precedingDialogue = new List <string>(); var foundPrecedingDialogue = state["precedingDialogue"].AsArray; if (foundPrecedingDialogue.Count != 0) { foreach (JSONNode dialogue in state["precedingDialogue"]) { precedingDialogue.Add(dialogue); } } List <Transition> optionList = new List <Transition>(); JSONNode transitions = isPlotJson ? state["transitions"].AsArray : state["options"]; foreach (JSONNode transition in transitions) { int popHappinessModifier = 0; int goldModifier = 0; int envHealthModifier = 0; string tokenKey = ""; string tokenValue = ""; string additionalState = ""; if (transition["happiness"]) { popHappinessModifier = transition["happiness"]; } if (transition["money"]) { goldModifier = transition["money"]; } if (transition["environment"]) { envHealthModifier = transition["environment"]; } if (transition["token"]) { tokenKey = transition["token"]; tokenValue = transition[tokenKey]; } if (transition["additionalState"]) { additionalState = transition["additionalState"]; } MetricsModifier metricsModifier = new MetricsModifier(popHappinessModifier, goldModifier, envHealthModifier); if (state["sliderType"]) { optionList.Add(new SliderTransition(transition["feedback"], transition["npcName"], metricsModifier, transition["hasAnimation"], transition["buildingName"], transition["threshold"])); } else { optionList.Add(new Transition(transition["feedback"], transition["npcName"], metricsModifier, transition["hasAnimation"], transition["buildingName"], transition["label"], transition["state"], tokenKey, tokenValue, additionalState)); } } if (isPlotJson) { String name = ""; if (state["name"]) { name = state["name"]; } result.Add(new PlotCard(state["id"], precedingDialogue.ToArray <string>(), name, state["question"], optionList)); } else if (state["sliderType"]) { result.Add(new SliderCard(precedingDialogue.ToArray <string>(), state["name"], state["question"], optionList.Cast <SliderTransition>().ToList(), state["maxValue"], state["minValue"])); } else { result.Add(new MinorCard(precedingDialogue.ToArray <string>(), state["name"], state["question"], optionList)); } } return(result); }