public void CreateUnitType(int count, UnitTeams team, string type) { GameObject prefab = null; GameObject go; BaseUnit unitScript; UnitSettings settings; UnitPrefabs unitPrefabs = prefabs.Find(t => t.team == team); if (unitPrefabs.prefabs != null) { prefab = unitPrefabs.prefabs.Find(t => t.name.ToLower().Contains(type.ToLower())); } if (prefab != null) { for (int i = 0; i < count; i++) { go = Instantiate(prefab, GetRandomUnitPosition(unitPrefabs), Quaternion.identity); go.transform.rotation = Quaternion.LookRotation(new Vector3(-go.transform.position.x, 0, 0)); unitScript = go.GetComponent <BaseUnit>(); settings = unitSettings.Find(t => t.team.ToLower() == team.ToString().ToLower() && t.unitType.ToLower() == type.ToLower()); unitScript.Init(settings); } } }
public UnitMeta(String name, UnitTeams team, Int32 idx) { Name = name; Team = team; switch (team) { case UnitTeams.Blue: SpriteIdx = _blue[idx]; break; case UnitTeams.Brown: SpriteIdx = _brown[idx]; break; case UnitTeams.Green: SpriteIdx = _green[idx]; break; case UnitTeams.Pink: SpriteIdx = _pink[idx]; break; case UnitTeams.Purple: SpriteIdx = _purple[idx]; break; case UnitTeams.Teal: SpriteIdx = _teal[idx]; break; } }
public virtual void Init(UnitSettings settings) { this.lifes = settings.lifes; this.moveSpeed = settings.moveSpeed; this.rotationSpeed = settings.rotationSpeed; this.attackDistance = settings.attackDistance; this.attackDamage = settings.attackDamage; this.attackDelay = settings.attackDelay; this.myTeam = settings.team == "People" ? UnitTeams.people : UnitTeams.zombie; AddToList(); }
public void SetTeamCount(UnitTeams team, int count) { if (team == UnitTeams.people) { if (teamPCount != null) { teamPCount.text = count.ToString(); } } else if (teamZCount != null) { teamZCount.text = count.ToString(); } }
public Boolean HasEnemyUnit(UnitTeams team) { return(Unit && Unit.Team != team); }