//---------------------------------- protected virtual void UpdateStatus() { if (this.selectedObjects.Count > 0 || this.boxSelectedObjects.Count > 0) { foreach (GameObject obj in this.unitManager.getAllObjects()) { if (obj == null) { this.unitManager.getRemoveList().Add(obj); continue; } if (this.selectedObjects.Contains(obj) || this.boxSelectedObjects.Contains(obj)) { CommonUnit unit = obj.GetComponent <CommonUnit>(); if (unit == null) { this.unitManager.getRemoveList().Add(obj); continue; } if (!unit.isEnemy) { if (unit.isStandingBy) { unit.SetAttackStandby(); } if (unit.isAttacking) { unit.SetAttack(); } if (unit.isSplitting) { unit.SetDeselect(); unit.SetAttackCancel(); } if (unit.isSelected) { unit.SetSelect(); } } } } } else { foreach (GameObject obj in this.unitManager.getAllObjects()) { if (obj == null) { this.unitManager.getRemoveList().Add(obj); continue; } CommonUnit unit = obj.GetComponent <CommonUnit>(); unit.SetDeselect(); } } }
//---------------------------------- //protected void AttackOrder() { // if (Input.GetKeyDown(KeyCode.A)) { // if (!this.attackStandingByFlag) { // if (this.selectedObjects.Count > 0) { // this.attackStandingByFlag = true; // foreach (GameObject obj in this.selectedObjects) { // CommonUnit unit = obj.GetComponent<CommonUnit>(); // if (!unit.isEnemy) { // unit.SetAttackStandby(); // } // } // //this.selectedObjects.Clear(); // } // } // } // if (this.attackStandingByFlag) { // if (Input.GetMouseButtonDown(0)) { // this.attackStandingByFlag = false; // foreach (GameObject obj in this.selectedObjects) { // CommonUnit unit = obj.GetComponent<CommonUnit>(); // unit.SetAttackCancel(); // } // this.selectedObjects.Clear(); // } // else if (Input.GetMouseButtonDown(1)) { // this.attackStandingByFlag = false; // Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // RaycastHit[] hits = Physics.RaycastAll(ray); // //bool hasOrderedAttackTarget = false; // foreach (RaycastHit hit in hits) { // GameObject obj = hit.collider.gameObject; // if (obj.name.Equals("Floor")) { // foreach (GameObject selected in this.selectedObjects) { // CommonUnit unit = selected.GetComponent<CommonUnit>(); // if (!unit.isEnemy) { // unit.SetAttackCancel(); // unit.SetNewDestination(hit.point); // unit.SetAttack(); // } // } // //hasOrderedAttackTarget = true; // break; // } // } // //if (hasOrderedAttackTarget) { // // this.selectedObjects.Clear(); // //} // } // } //} //---------------------------------- protected void MoveOrder() { if (Input.GetMouseButtonDown(1)) { if (this.selectedObjects.Count > 0) { for (int i = 0; i < this.selectedObjects.Count; i++) { if (this.selectedObjects[i] == null) { this.selectedObjects.RemoveAt(i); } } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(ray); foreach (RaycastHit hit in hits) { GameObject obj = hit.collider.gameObject; if (obj.name.Equals("Floor")) { foreach (GameObject select in this.selectedObjects) { CommonUnit unit = select.GetComponent <CommonUnit>(); if (!unit.isEnemy) { unit.SetAttackCancel(); unit.SetNoEnemyTarget(); unit.enemies.Clear(); unit.SetStartMoving(); unit.SetNewDestination(hit.point); } } break; } } } //this.selectedObjects.Clear(); } }