//events public void DecideOnRandomEnvrionmentalEvent(bool isDay) { if ((isDay && dayEvent != null) || (!isDay && nightEvent != null)) //means something else already set an event for that period { return; } float dieRoll = Random.Range(0.0f, 1.0f); string[] eventsList = isDay? EventsLists.environmentalEventsDay : EventsLists.environmentalEventsNight; if (dieRoll < simParam.randomEnvironmentalEventProbability && eventsList.Length > 0) { int id = Random.Range(0, eventsList.Length); GameObject eventHolder = new GameObject("event_" + id.ToString()); eventHolder.transform.position = Vector3.zero; eventHolder.transform.SetParent(this.transform); eventHolder.name += isDay? "_day" : "_night"; ScenarioEvent newEvent = (ScenarioEvent)eventHolder.AddComponent(System.Type.GetType(eventsList[id])); if (newEvent.CheckRequirement()) { AddScenarioEvent(newEvent, isDay); } else { Destroy(eventHolder); } } }
public static void AddEvent(ScenarioEvent newEvent, bool isIntro = false) { if (instance != null && instance.isIntro && !isIntro) { return; } events.Add(newEvent); }
public void StartWorkDay() { dayEvent = null; nightEvent = null; workingAnimation = StartCoroutine(WorkAnimation()); workingProcess = StartCoroutine(WorkProcess()); }
public void Hide() { foreach (Transform child in this.transform) { child.gameObject.SetActive(false); } this.gameObject.GetComponent <RawImage>().enabled = false; shownEvent = null; }
public void Scenario(Token keyword, Token title) { var scenario = new Scenario(title.Content, file, currentFeature, keyword.LineInFile.Line); currentScenario = scenario; events.Enqueue(new ScenarioEvent(currentScenario, e => { scenario.AddTags(e.Tags); ScenarioEvent.Invoke(this, new EventArgs <Scenario>(scenario)); })); }
public void HandleBankrupcy() { //Similar rationale to HandleWinning(). print("Player is bankrupt"); currentGameState = GameState.endGame; GameObject eventHolder = Instantiate(new GameObject("GameOver_Bankrupcy"), Vector3.zero, new Quaternion(), this.transform); ScenarioEvent newEvent = (ScenarioEvent)eventHolder.AddComponent(typeof(Bankrupcy)); simMan.AddScenarioEvent(newEvent, true); }
//Win/Lose cases public void HandleWinning() { //This method is callled at WorkProcess(), before dayEvent is processed. So, we simply override whatever event that may have been set with a Winning event, //and let it handle game loss display. print("Player has won"); currentGameState = GameState.endGame; GameObject eventHolder = Instantiate(new GameObject("GameOver_Win"), Vector3.zero, new Quaternion(), this.transform); ScenarioEvent newEvent = (ScenarioEvent)eventHolder.AddComponent(typeof(Win)); simMan.AddScenarioEvent(newEvent, true); }
public void Initialize() { scenarioEvent = new ScenarioEvent(); scenarioEvent.Initialize(); uiEventReward.Initialize(); foreach (var selectButton in selectButtonList) { selectButton.Initialize(); selectButton.scenarioEvent = this.scenarioEvent; selectButton.uiEventReward = this.uiEventReward; } InGameManager.instance.gameState.OnPrepare += CheckScenarioDataAndSetScenarioEvent; }
// void ProcessEvents (bool isDay) // { // // List<ScenarioEvent> targetEventsList; // // if (isDay) // // targetEventsList = dayEvents; // // else // // targetEventsList = nightEvents; // // foreach(ScenarioEvent scenarioEvent in targetEventsList) // // { // // scenarioEvent.Play(currentDate); // // } // if (isDay) // dayEvent.Play(currentDate); // else // nightEvent.Play(currentDate); // } public void FinishEvent(ScenarioEvent scenarioEvent) { if (dayEvent == scenarioEvent) { dayEvent = null; } else if (nightEvent == scenarioEvent) { nightEvent = null; } else { print("ERROR! Attempting to finish a non started event"); } }
public void Show(ScenarioEvent scenarioEvent) { shownEvent = scenarioEvent; foreach (Transform child in this.transform) { child.gameObject.SetActive(true); } this.gameObject.GetComponent <RawImage>().enabled = true; //get event image and description if (scenarioEvent.scenarioImage != null) { eventImage.rectTransform.sizeDelta = ComputeViewporteSize(new Vector2Int(scenarioEvent.scenarioImage.width, scenarioEvent.scenarioImage.height)); } eventImage.texture = scenarioEvent.scenarioImage; SetEventDescription(); }
public void AddScenarioEvent(ScenarioEvent scenarioEvent, bool isDayEvent) //Warning! This method overrides any set event. { if (isDayEvent) { if (dayEvent != null) { dayEvent.Cancel(); } dayEvent = scenarioEvent; } else { if (nightEvent != null) { nightEvent.Cancel(); } nightEvent = scenarioEvent; } scenarioEvent.Initialize(currentDate); }