/// <summary> /// В атаку /// </summary> public void OnAttack(GameObject target, GameObject who) { bool isFind = false; ShipParametrs currentShipParametrs = new ShipParametrs(); ShipMove currentShipMove = new ShipMove(); for (int i = 0; i < shipParametrs.Count; i++) { if (!shipParametrs[i].gameObject.activeSelf) { currentShipParametrs = shipParametrs[i]; currentShipMove = shipMove[i]; isFind = true; break; } } if (!isFind) { currentShipParametrs = Instantiate(prefabShip, who.transform.position, Quaternion.identity, parentShips).GetComponent <ShipParametrs>(); currentShipMove = currentShipParametrs.GetComponent <ShipMove>(); shipParametrs.Add(currentShipParametrs); shipMove.Add(currentShipMove); } currentShipParametrs.transform.position = who.transform.position; currentShipParametrs.gameObject.SetActive(true); currentShipParametrs.Target = target; currentShipMove.MoveTo(target.transform.position); }