GameEvent ReadXEvent(XmlNode xEvent) { Dictionary <int, GameAction> choices = new Dictionary <int, GameAction>(); int id; try { id = System.Convert.ToInt32(xEvent.Attributes["id"].Value); } catch (System.Exception) { Logger.Error("Skipped id-less event : " + xEvent.InnerText); return(null); } // Ignoring pop and mood if not specified Population pop = null; Bystander.Mood mood = Bystander.Mood.Good; try { pop = GameManager.instance.populationManager.GetPopulationByCodename(xEvent.Attributes["population"].Value); mood = (Bystander.Mood)System.Enum.Parse(typeof(Bystander.Mood), xEvent.Attributes["emotion"].Value); } catch { }; foreach (XmlNode xChoice in xEvent.ChildNodes) { Choice choice = ReadXChoice(xChoice); if (choice != null) { // Making even and injecting the event id in it choices.Add(choice.id, interpreter.MakeEvent("DECLARE_EVENT(id:" + id.ToString() + ");" + choice.script)); } } return(new GameEvent(id, choices, pop) { mood = mood }); }
public void InitializeWindow() { Population pop = gameEvent.instigator; Bystander.Mood emotion = gameEvent.mood; Localization loc = GameManager.instance.localization; if (!GameManager.instance.player.options.GetBool(Options.Option.animatedCitizens)) { float ratio = pop.moodSprites[0].rect.width / pop.moodSprites[0].rect.height; preview.texture = pop.moodSprites[(int)emotion].texture; preview.gameObject.GetComponent <AspectRatioFitter>().aspectRatio = ratio; } else { displayer = GameManager.instance.displayerManager.SetRotationFeed(pop.prefab, preview, 180, 0, 3, 30, 512); displayer.GetModel().transform.GetChild(0).gameObject.GetComponent <Animator>().Play("LookAround"); displayer.GetModel().GetComponent <Bystander>().SetEmotion(emotion); preview.gameObject.GetComponent <AspectRatioFitter>().aspectRatio = 1f; } // ADvisor name PopulationManager popMan = GameManager.instance.populationManager; string name = popMan.GetRandomName(); if (popMan.populations[pop].citizens.Count > 0) { name = popMan.populations[pop].citizens[Mathf.FloorToInt(popMan.populations[pop].citizens.Count * Random.value)].name; } loc.SetCategory("populationTypeDelegate"); advisorName.text = loc.GetLine(pop.codeName, name); title.text = loc.GetLineFromCategory("eventTitle", "event" + gameEvent.id); description.text = ""; StartTypewriting(description, loc.GetLineFromCategory("eventDescription", "event" + gameEvent.id)); }
void UpdateMood() { float moodValue = popMan.GetAverageMood(population) / popMan.maxMood; gauge.fillAmount = moodValue; gauge.color = Color.Lerp(from, to, moodValue); Action <Bystander.Mood> changeMood; if (playerOptions.GetBool(Options.Option.animatedCitizens)) { if (preview == null) { preview = GameManager.instance.displayerManager.SetRotationFeed(population.prefab, face, angle, rotationSpeed, cameraDistance, FOV, 128); } changeMood = (x) => { preview.GetModel().GetComponent <Bystander>().SetEmotion(x); fitter.aspectRatio = 1f; }; } else { if (preview != null) { preview.Unstage(); preview = null; } changeMood = (x) => { face.texture = population.moodSprites[(int)x].texture; fitter.aspectRatio = population.moodSprites[0].rect.width / population.moodSprites[0].rect.height; }; } // Emotion based on humor Bystander.Mood oldMood = currentMood; if (moodValue <= angryThreshold) { currentMood = Bystander.Mood.Angry; } else if (moodValue >= happyThreshold) { currentMood = Bystander.Mood.Good; } else { currentMood = Bystander.Mood.Bad; } // SOUNDS if (oldMood != currentMood) { if (currentMood == Bystander.Mood.Good) { GameManager.instance.soundManager.Play("MoodUp"); } else if (currentMood == Bystander.Mood.Angry) { GameManager.instance.soundManager.Play("MoodDown"); } } changeMood(currentMood); moodString = loc.GetLineFromCategory("mood", currentMood.ToString().ToLower()); }