public IEnumerator CallForHelp(CombatParty party, List <Hero> heroes, Monster monster, bool princePresent) { //TODO: each player has their own buttons JoinButton join = GameObject.Find("CallForHelpDisplay").GetComponentInChildren <JoinButton>(); IgnoreButton ignore = GameObject.Find("CallForHelpDisplay").GetComponentInChildren <IgnoreButton>(); foreach (Hero hero in heroes) { combatStatusText.text = party.GetLeader().getHeroKind() + " is fighting " + monster.getMonsterName(); while (true) { if (join.Pressed) { party.AddHero(hero); join.Pressed = false; join.gameObject.SetActive(false); ignore.gameObject.SetActive(false); break; } else if (ignore.Pressed) { ignore.Pressed = false; join.gameObject.SetActive(false); ignore.gameObject.SetActive(false); break; } yield return(null); } } Combat combat = new Combat(party, monster, princePresent); StartCombatRound(combat); }
private void OnMouseDown() { if (!CombatManager.instance.FightButtonPressed()) { return; } bool inRange = false; //TODO: Get the current hero GameManager GM = GameObject.Find("GameManager").GetComponent <GameManager>(); Hero hero = GameObject.Find(GM.GetHeroByPID(HeroSelection.HS.mySelectedCharacter)).GetComponent <HeroController>().getHero(); //Don't start combat if no time left if (!hero.HasTimeLeft()) { return; } //If on same tile, you are in range if (hero.getRank() == currentPosition.GetComponent <Node>().getRank()) { inRange = true; } else if (hero.getHeroKind() == HeroKind.Archer || hero.IsCarrying(new Bow(ItemWeight.Heavy))) { //If you are archer/have bow and are on a neighbouring tile, you are in range foreach (GameObject neighbour in currentPosition.GetComponent <Node>().getNeighbours()) { Node node = neighbour.GetComponent <Node>(); if (hero.getRank() == node.getRank()) { inRange = true; } } } if (!inRange) { return; } bool princePresent = false; ThoraldController thorald = FindObjectOfType <ThoraldController>(); if (thorald != null && thorald.currentPosition.GetComponent <Node>().getRank() == currentPosition.GetComponent <Node>().getRank()) { princePresent = true; } //Search for heroes to join the fight GameManager gm = FindObjectOfType <GameManager>(); List <Hero> heroes = new List <Hero>(); foreach (GameObject g in gm.HeroList) { Hero h = g.GetComponent <HeroController>().getHero(); if (h.Equals(hero)) { break; } if (h.getRank() == currentPosition.GetComponent <Node>().getRank()) { heroes.Add(h); } else if (h.getHeroKind() == HeroKind.Archer || hero.IsCarrying(new Bow(ItemWeight.Heavy))) { foreach (GameObject neighbour in currentPosition.GetComponent <Node>().getNeighbours()) { Node node = neighbour.GetComponent <Node>(); if (h.getRank() == node.getRank()) { heroes.Add(h); break; } } } } CombatManager.instance.setMonsterFighterID(currentPosition.GetComponent <Node>().getRank()); CombatParty party = new CombatParty(hero); StartCoroutine(CombatManager.instance.CallForHelp(party, heroes, monster, princePresent)); //Combat combat = new Combat(party, monster, princePresent); //CombatManager.instance.StartCombatRound(combat); }
public Combat(CombatParty party, Monster monster, bool prince) { this.party = party; this.monster = monster; princePresent = prince; }