public static Vector2 GetInput(Helpers.Teams team) { float fx = Input.GetAxis(Helpers.Horizontal(team)); float fy = Input.GetAxis(Helpers.Vertical(team)); if (Mathf.Abs(fx) > Mathf.Abs(fy)) { fx = fx > 0f ? 1f : -1f; fy = 0f; } else if (Mathf.Abs(fy) > Mathf.Abs(fx)) { fx = 0f; fy = fy > 0f ? 1f : -1f; } if ((fx != 0f || fy != 0f) && !axisInUse) { axisInUse = true; return(new Vector2(fx, fy)); } if (fx == 0f && fy == 0f && axisInUse) { axisInUse = false; } return(Vector2.zero); }
public CharacterSheet GetCombatantOfTeamAtGridPosition(Vector3 position, Helpers.Teams team) { foreach (KeyValuePair <CharacterSheet, Vector3> combatant in teams[team]) { if (combatant.Value.Equals(position)) { return(combatant.Key); } } return(null); }
public bool IsCombatantInMelee(Vector3 position, Helpers.Teams team) { foreach (KeyValuePair <CharacterSheet, Vector3> combatant in teams[Helpers.otherTeam(team)]) { float distance = Mathf.Abs(position.x - combatant.Value.x) + Mathf.Abs(position.y - combatant.Value.y); if (distance <= 1f && combatant.Key.GetCombatState() == Helpers.CombatState.Alive) { return(true); } } return(false); }
private GameObject SpawnCombatant(Helpers.CharacterClass character_class, Helpers.Teams team) { int count = teams [team].Count; int xPos = team == Helpers.Teams.Home ? 2 : area.width - 3; int yPos = area.height / 2 + (count % 2 == 1 ? -(count + 1) / 2 : (count + 1) / 2); string resource = Helpers.classToString[character_class] + (team == Helpers.Teams.Home ? "Home" : "Away") + "Prefab"; GameObject combatant = Instantiate(Resources.Load(resource), new Vector3(xPos, yPos, 0), Quaternion.identity) as GameObject; combatant.transform.SetParent(area.area); return(combatant); }
public bool AddPlayerToTeam(CharacterSheet character_sheet, Helpers.Teams team) { teamCombatants [team].Add(character_sheet); if (teamCombatants [team].Count == maxTeamSize && teamCombatants [Helpers.otherTeam(team)].Count == maxTeamSize) { return(true); } else { return(false); } }
public void InitialiseSpellList(List <Spell> spells, SpellSelected callback, SpellPickerCancelled cancelCallback, Helpers.Teams _team) { if (spells.Count == 0 || callback == null) { return; } for (int i = 0; i < spells.Count; i++) { GameObject item = Instantiate(Resources.Load("SpellPickerItem")) as GameObject; SpellPickerItem spellPickerItem = item.GetComponent <SpellPickerItem> (); spellPickerItem.transform.SetParent(spellPickerList.transform); spellPickerItem.SetSpell(spells [i]); spellList.Add(new KeyValuePair <Spell, SpellPickerItem> (spells [i], spellPickerItem)); } transform.localScale = Vector3.one / 100; spellSelectedCallback = callback; spellPickerCancelledCallback = cancelCallback; team = _team; }
public static string Fire2(Helpers.Teams team) { return(team == Helpers.Teams.Home ? "Fire2_P1" : "Fire2_P2"); }
public static string Vertical(Helpers.Teams team) { return(team == Helpers.Teams.Home ? "Vertical_P1" : "Vertical_P2"); }
/** * Input axes helpers */ public static string Horizontal(Helpers.Teams team) { return(team == Helpers.Teams.Home ? "Horizontal_P1" : "Horizontal_P2"); }
public static Helpers.Teams otherTeam(Helpers.Teams thisTeam) { return(thisTeam == Helpers.Teams.Home ? Helpers.Teams.Away : Helpers.Teams.Home); }