public static void SetUnitToTalk(WM_Unit u) { if (!u.party.available || u.currentNode != GameManager.instance.player.currentNode) { return; } unitToTalk = u; }
private void OnDestroy() { CombatManager.instance.RemoveUnit(this); WM_Unit u = transform.parent.GetChild(0).GetComponent <WM_Unit>(); slot.UnloadSpellSlot(); u.party.RemoveUnit(u); }
public void RemovingUnit(WM_Unit unit) { if (party.Count == 1) { Debug.Log(faction.gameObject.name + " is disbanding " + gameObject.name); faction.roamingUnits.Remove(this); Destroy(gameObject); } party.Remove(unit); Destroy(unit.gameObject); }
IEnumerator Fighting(int i) { // select a random faction, then select a random unit, it dmges a random enemy unit WM_Unit attacker = null; WM_Unit defender = null; battle b; battleList[i] = new battle(battleList[i].party0, battleList[i].party1, true); b = battleList[i]; while (b.party0.party.Count > 0 && b.party1.party.Count > 0) { while (GameManager.FreezeTime) { yield return(new WaitForSeconds(0.2f)); } if (b.party0 == fightingThePlayer || b.party1 == fightingThePlayer) { break; } yield return(new WaitForSeconds(0.5f)); while ((attacker == null && defender == null) || !attacker.isAlive() || !defender.isAlive()) { if (Random.Range(0, 1f) > 0.5f) { attacker = b.party0.party[Random.Range(0, b.party0.party.Count)]; defender = b.party1.party[Random.Range(0, b.party1.party.Count)]; } else { defender = b.party0.party[Random.Range(0, b.party0.party.Count)]; attacker = b.party1.party[Random.Range(0, b.party1.party.Count)]; } } defender.hp = defender.hp - attacker.atk; if (defender.hp <= 0) { defender.eliminated = true; defender.party.RemoveUnit(defender); } } yield return(null); }
public void EngageCombat(WM_Unit u) { if (inCombat) { return; // prevent multiple calls } inCombat = true; FreezeTime = true; WM_CombatManager.instance.IsFightingPlayer(u.party); List <Unit> fightingUnits = new List <Unit>(); player.transform.parent.GetChild(1).gameObject.SetActive(true); u.transform.parent.GetChild(1).gameObject.SetActive(true); fightingUnits.Add(player.transform.parent.GetChild(1).GetComponent <Player>()); fightingUnits.Add(u.transform.parent.GetChild(1).GetComponent <Enemy>()); Debug.Log(fightingUnits.Count); CombatManager.instance.NewScene(fightingUnits); WM_Cam.enabled = false; }
public void SpawnNewUnits(int numberOfUnits, List <WM_party> duty) { GameObject party = Instantiate(partyPrefab, transform); WM_party tmpParty = party.GetComponent <WM_party>(); tmpParty.currentNode = Base; tmpParty.faction = this; party.name = gameObject.name + " party " + partyCount; partyCount++; for (int i = 0; i < numberOfUnits; i++) { GameObject obj = Instantiate(unitPrefab, party.transform); WM_Unit tmpUnit = obj.transform.GetChild(0).GetComponent <WM_Unit>(); tmpUnit.transform.position = Base.transform.position; tmpUnit.currentNode = Base; obj.name = party.name + " " + party.GetComponent <WM_party>().party.Count; tmpUnit.faction = this; tmpUnit.currentNode = Base; tmpUnit.party = tmpParty; tmpParty.party.Add(tmpUnit); } duty.Add(tmpParty); }
public void RemoveUnit(WM_Unit unit) { Debug.Log(gameObject.name + " is removing " + unit.gameObject.name); //unit.StopAllCoroutines(); RemovingUnit(unit); }
public void DeselectUnitToTalk() { unitToTalk = null; }
public void UpdateUnitText(WM_Unit u) { gameObject.SetActive(true); unitText.text = "Hello. I am " + u.name + ". What do you want ?"; }