public Monster(QuestData.Monster m) { monsterData = m.mData; unique = m.unique; uniqueTitle = m.uniqueTitle; uniqueText = m.uniqueText; }
// Add a signal to place a monster group public void AddAreaMonster(QuestData.Monster m) { Game game = Game.Get(); Sprite tileSprite; Texture2D newTex = Resources.Load("sprites/target") as Texture2D; // Check load worked if (newTex == null) { ValkyrieDebug.Log("Error: Cannot load monster image"); Application.Quit(); } // Create object GameObject gameObject = new GameObject("MonsterSpawn"); gameObject.tag = "dialog"; gameObject.transform.parent = game.tokenCanvas.transform; // Create the image UnityEngine.UI.Image image = gameObject.AddComponent <UnityEngine.UI.Image>(); tileSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1); image.color = Color.red; image.sprite = tileSprite; image.rectTransform.sizeDelta = new Vector2(1f, 1f); // Move to square (105 units per square) gameObject.transform.Translate(new Vector3(m.location.x, m.location.y, 0), Space.World); // Add pulser gameObject.AddComponent <SpritePulser>(); }
public MonsterEvent(string name) : base(name) { qMonster = qEvent as QuestData.Monster; // Next try to find a type that is valid foreach (string t in qMonster.mTypes) { // Monster type might be a unique for this quest if (game.quest.qd.components.ContainsKey(t) && game.quest.qd.components[t] is QuestData.UniqueMonster) { cMonster = new QuestMonster(game.quest.qd.components[t] as QuestData.UniqueMonster); } // Monster type might exist in content packs, 'Monster' is optional else if (game.cd.monsters.ContainsKey(t)) { cMonster = game.cd.monsters[t]; } else if (game.cd.monsters.ContainsKey("Monster" + t)) { cMonster = game.cd.monsters["Monster" + t]; } } // If we didn't find anything try by trait if (cMonster == null) { if (qMonster.mTraits.Length == 0) { Debug.Log("Error: Cannot find monster and no traits provided in event: " + qMonster.name); Application.Quit(); } List <MonsterData> list = new List <MonsterData>(); foreach (KeyValuePair <string, MonsterData> kv in game.cd.monsters) { bool allFound = true; foreach (string t in qMonster.mTraits) { if (!kv.Value.ContainsTrait(t)) { allFound = false; } } if (allFound) { list.Add(kv.Value); } } // Not found, throw error if (list.Count == 0) { Debug.Log("Error: Unable to find monster of traits specified in event: " + qMonster.name); Application.Quit(); } cMonster = list[Random.Range(0, list.Count)]; } }
public EditorComponentMonsterPlacement(string nameIn) : base() { Game game = Game.Get(); monsterComponent = game.quest.qd.components[nameIn] as QuestData.Monster; component = monsterComponent; name = component.sectionName; Update(); }
public void AddMonster(QuestData.Monster m) { Game game = Game.Get(); int count = 0; foreach (Game.Hero h in game.heros) { if (h.heroData != null) { count++; } } if (m.placement[count].Length == 0) { AddAreaMonster(m); } else { AddPlacedMonsters(m, count); } }
public void AddPlacedMonsters(QuestData.Monster m, int count) { string imagePath = @"file://" + m.mData.imagePlace; WWW www = new WWW(imagePath); Texture2D newTex = new Texture2D(256, 256, TextureFormat.DXT5, false); www.LoadImageIntoTexture(newTex); // Check load worked if (newTex == null) { Debug.Log("Error: Cannot load monster image"); Application.Quit(); } int x = 1; int y = 1; if (m.mData.ContainsTrait("medium") || m.mData.ContainsTrait("huge")) { x = 2; } if (m.mData.ContainsTrait("huge") || m.mData.ContainsTrait("massive")) { y = 2; } if (m.mData.ContainsTrait("massive")) { x = 3; } foreach (string s in m.placement[count]) { AddPlacedMonsterImg(s, newTex, x, y); } }
public static void TriggerEvent() { Game game = Game.Get(); RoundHelper.CheckNewRound(); if (game.eventList.Count == 0) { return; } QuestData.Event e = game.eventList.Pop(); // If the flags are not set do not trigger event foreach (string s in e.flags) { if (!game.qd.flags.Contains(s)) { return; } } // Add set flags foreach (string s in e.setFlags) { if (!game.qd.flags.Contains(s)) { Debug.Log("Notice: Setting quest flag: " + s); game.qd.flags.Add(s); } } // Remove clear flags foreach (string s in e.clearFlags) { if (game.qd.flags.Contains(s)) { Debug.Log("Notice: Clearing quest flag: " + s); game.qd.flags.Remove(s); } } // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // If this is a monster event then add the monster group if (e is QuestData.Monster) { QuestData.Monster qm = (QuestData.Monster)e; // Is this type new? Game.Monster oldMonster = null; foreach (Game.Monster m in game.monsters) { if (m.monsterData.name.Equals(qm.mData.name)) { oldMonster = m; } } // Add the new type if (oldMonster == null) { game.monsters.Add(new Game.Monster(qm)); game.monsterCanvas.UpdateList(); } else if (qm.unique) { oldMonster.unique = true; oldMonster.uniqueText = qm.uniqueText; oldMonster.uniqueTitle = qm.uniqueTitle; } // Display the location game.tokenBoard.AddMonster(qm); } if (e.highlight) { game.tokenBoard.AddHighlight(e); } new DialogWindow(e); foreach (string s in e.addComponents) { if (game.qd.components.ContainsKey(s)) { game.qd.components[s].SetVisible(true); } else { Debug.Log("Warning: Attempting to show missing item: " + s); } } foreach (string s in e.removeComponents) { if (game.qd.components.ContainsKey(s)) { game.qd.components[s].SetVisible(false); } else { Debug.Log("Warning: Attempting to hide missing item: " + s); } } if (e.locationSpecified) { CameraController.SetCamera(e.location); } }
public MonsterEvent(string name) : base(name) { // cast the monster event qMonster = qEvent as QuestData.Monster; // If there are no traits try to find a type that is valid // Searches is specified order // FIXME: is this reverse order? if (qMonster.mTraits.Length == 0) { foreach (string t in qMonster.mTypes) { // Monster type might be a unique for this quest if (game.quest.qd.components.ContainsKey(t) && game.quest.qd.components[t] is QuestData.UniqueMonster) { cMonster = new QuestMonster(game.quest.qd.components[t] as QuestData.UniqueMonster); } // Monster type might exist in content packs, 'Monster' is optional else if (game.cd.monsters.ContainsKey(t)) { cMonster = game.cd.monsters[t]; } else if (game.cd.monsters.ContainsKey("Monster" + t)) { cMonster = game.cd.monsters["Monster" + t]; } } if (cMonster == null) { ValkyrieDebug.Log("Error: Cannot find monster and no traits provided in event: " + qMonster.sectionName); Application.Quit(); } } else { // Start a list of matches List <MonsterData> list = new List <MonsterData>(); foreach (KeyValuePair <string, MonsterData> kv in game.cd.monsters) { bool allFound = true; foreach (string t in qMonster.mTraits) { // Does the monster have this trait? if (!kv.Value.ContainsTrait(t)) { // Trait missing, exclude monster allFound = false; } } bool exclude = false; foreach (string t in qMonster.mTypes) { if (t.Equals(kv.Key)) { exclude = true; } } foreach (Quest.Monster qm in game.quest.monsters) { if (qm.monsterData.sectionName.Equals(kv.Key)) { exclude = true; } } // Monster has all traits if (allFound && !exclude) { list.Add(kv.Value); } } // Not found, throw error if (list.Count == 0) { ValkyrieDebug.Log("Error: Unable to find monster of traits specified in event: " + qMonster.sectionName); Application.Quit(); } // Pick monster at random from candidates cMonster = list[Random.Range(0, list.Count)]; } }