void OnMouseDown() { UI UI = GameObject.Find("UI").GetComponent <UI>(); if (UI.AttackMode) { UnitManage.AddEvent("Attack", UI.Selected, ActualUnit); UI.Cancel(); return; } if (UI.PlayerTeam == ActualUnit.GetComponent <Unit>().Team) { if (null != UI.Selected) { PathFinding.ClearRoute(UI.Selected.GetComponent <Unit>().MoveRoute); } UI.Selected = ActualUnit; UI.Selected.GetComponent <Unit>().OnSelecte(); for (int i = 2; i < gameObject.transform.parent.childCount; i += 2) { gameObject.transform.parent.GetChild(i).gameObject.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1); } GetComponent <SpriteRenderer>().color = new Color(1, 1, 0, 1); } else { Debug.Log(Message.UNIT_NOT_ON_OUR_SIDE); } }
void OnMouseDown() { UI UI = GameObject.Find("UI").GetComponent <UI>(); if (UI.MoveMode) { UnitManage.AddEvent(KeyTerm.MOVE_CMD, UI.Selected, gameObject); for (int i = 0; i < gameObject.transform.parent.childCount; i++) { if (null != gameObject.transform.parent.GetChild(i).gameObject.GetComponent <Unit>()) { UI.Destination = true; break; } } UI.Cancel(); } }
public static void AIMove() { for (int i = 0; i < UnitManage.Unit.Length; i++) { if (UI.PlayerTeam != UnitManage.Unit[i].GetComponent <Unit>().Team) { GameObject Victim = null; if (KeyTerm.NONE == UnitManage.Unit[i].GetComponent <Unit>().Action) { Victim = CheckEnemy(UnitManage.Unit[i], UnitManage.Unit[i].GetComponent <Unit>().AttackRange, UnitManage.Unit[i].GetComponent <Unit>().AttackRangeType); if (null != Victim) { UnitManage.AddEvent(KeyTerm.ATTACK_CMD, UnitManage.Unit[i], Victim); } else { Victim = CheckEnemy(UnitManage.Unit[i], UnitManage.Unit[i].GetComponent <Unit>().DetectRange, KeyTerm.SQUARE); if (null != Victim) { UnitManage.AddEvent(KeyTerm.MOVE_CMD, UnitManage.Unit[i], Victim.transform.parent.GetChild(KeyTerm.LAND_INDEX).gameObject); } } } if (KeyTerm.MOVE_CMD == UnitManage.Unit[i].GetComponent <Unit>().Action) { Victim = CheckEnemy(UnitManage.Unit[i], UnitManage.Unit[i].GetComponent <Unit>().AttackRange, UnitManage.Unit[i].GetComponent <Unit>().AttackRangeType); if (null != Victim) { UnitManage.AddEvent(KeyTerm.ATTACK_CMD, UnitManage.Unit[i], Victim); } } if (KeyTerm.ATTACK_CMD == UnitManage.Unit[i].GetComponent <Unit>().Action) { Victim = CheckEnemy(UnitManage.Unit[i], UnitManage.Unit[i].GetComponent <Unit>().AttackRange, UnitManage.Unit[i].GetComponent <Unit>().AttackRangeType); if (UnitManage.Target[i] != Victim) { UnitManage.ClearUnit(UnitManage.Unit[i]); AIMove(); } } } } }