// Use this for initialization void Start() { List <UnitServer> unitServer = player.getUnitList(); Size = unitServer.Count; units = new GameObject[Size]; for (int x = 0; x < Size; x++) { GameObject go = GameObject.Instantiate(Resources.Load("Unit")) as GameObject; UnitBehavor script = go.GetComponent <UnitBehavor>(); script.player = this; script.id = unitServer[x].ID; Vector3 cord = map.convertMapToWorldCord((int)unitServer[x].position.x, (int)unitServer[x].position.y); go.transform.position = cord; go.transform.parent = gameObject.transform; units[unitServer[x].ID] = go; } }
public void unitClicked() { if (units.Clicked != currentClicked) { currentClicked = units.Clicked; foreach (GameObject a in adj) { a.GetComponent <SpriteRenderer>().GetComponent <SpriteRenderer>().color = new Color(255, 255, 255, 255); a.GetComponent <TerrainScript>().unit = null; a.GetComponent <TerrainScript>().GetComponent <TerrainScript>().check = false; } } if (units.Clicked != null) { Vector2 cord = map.convertWorldToMapCord(units.Clicked.transform.position); adj = map.getAdjacent(cord); foreach (GameObject a in adj) { a.GetComponent <SpriteRenderer>().color = new Color(255, 0, 0, 255); a.GetComponent <TerrainScript>().unit = units.Clicked; a.GetComponent <TerrainScript>().check = true; } } }
public void unitClicked() { if (units.Clicked != currentClicked) { currentClicked = units.Clicked; foreach (GameObject a in adj) { a.GetComponent<SpriteRenderer>().GetComponent<SpriteRenderer>().color = new Color(255, 255, 255, 255); a.GetComponent<TerrainScript>().unit = null; a.GetComponent<TerrainScript>().GetComponent<TerrainScript>().check = false; } } if (units.Clicked != null) { Vector2 cord = map.convertWorldToMapCord(units.Clicked.transform.position); adj = map.getAdjacent(cord); foreach (GameObject a in adj) { a.GetComponent<SpriteRenderer>().color = new Color(255, 0, 0, 255); a.GetComponent<TerrainScript>().unit = units.Clicked; a.GetComponent<TerrainScript>().check = true; } } }
public void clicked(UnitBehavor script) { _clicked = script; player.unitClicked(); }