public void touchedUnit(GameObject unit, UnitProperty component) { if (unit != null && component != null) { UnitProperty.UnitType in_type = component.type_init; if (in_type == UnitProperty.UnitType.PlayerSupport) { GameObject curPlayerUnit; //do selected Player unit change if (playerUnits.Count > 1) { foreach (GameObject listunit in playerUnits.ToArray()) { if (listunit.GetComponent <UnitProperty>().type_init == UnitProperty.UnitType.Player) { curPlayerUnit = listunit; } } } else { //do nothing as no more unit able to swtich } } else if (in_type == UnitProperty.UnitType.AI) { } } }
// Use this for initialization void Start() { myAngle = new AngleUnit(); myAngle.myObject = gameObject; myDetectionHelper = GetComponent <DetectionUnit>(); if (myDetectionHelper == null) { myDetectionHelper = gameObject.AddComponent <DetectionUnit>(); myDetectionHelper.setDetectionRadius(gameObject.GetComponent <UnitProperty>().attack_radius); } if (gameObject.GetComponent <UnitProperty>().type_init == UnitProperty.UnitType.AI || gameObject.GetComponent <UnitProperty>().type_init == UnitProperty.UnitType.PlayerSupport) { if (target == null) { GetClosestUnit(); } Debug.Log("AI do select gameBoard object"); seekingList = new List <GameObject>(); GameObject[] options = GameObject.FindGameObjectsWithTag("Unit"); if (options.Length > 0) { foreach (GameObject seekingUnit in options) { //Type form UnitProperty.UnitType seekingType = seekingUnit.GetComponent <UnitProperty>().type_init; if (seekingUnit.GetComponent <UnitProperty>().type_init == UnitProperty.UnitType.Player || seekingUnit.GetComponent <UnitProperty>().type_init == UnitProperty.UnitType.PlayerSupport) { seekingType = UnitProperty.UnitType.Player; } if (seekingType == targetType) { seekingList.Add(seekingUnit); } } } } }