// Update is called once per frame void Update() { // Направляем башни друг на друга _ply1.GetComponent <TankController>().RotateTowerTo(_ply2.transform.position); _ply2.GetComponent <TankController>().RotateTowerTo(_ply1.transform.position); if (!AllowUserActivity) { return; } // заприетить бработку ввода без дозволения пользовательской активности if (Input.GetKeyDown(KeyCode.Mouse1) || _actTC.UnderAIControl) { if (GameState == enumGameState.Player1Fire || GameState == enumGameState.Player2Fire) { if (GameState == enumGameState.Player2Fire && GameStatic.RightPlayer.isAI) // Если управляет AI { Vector2 _vc2 = _actTC.AIFireAt(1f, _ply1); ActivePos.x = _vc2.x; ActivePos.y = _vc2.y; } float borderX = GameObject.Find("meshBorderLine").transform.position.x; float distToBorder = Mathf.Abs(ActivePos.x - borderX); // Расстояние до границы distToBorder = ActivePos.x < borderX ? distToBorder : -distToBorder; ActivePos.x = borderX + distToBorder; ActivePos.z = -1.5f; Instantiate(obj, ActivePos, Quaternion.identity); } if (GameState == enumGameState.Player1Turn) { _ply1.GetComponent <TankController>().MoveTo(ActivePos); } if (GameState == enumGameState.Player2Turn) { // mousePos.z = 0.5f; if (_actTC.UnderAIControl) // Если управляет AI { Vector2 _vc2 = _actTC.AIMoveAt(); ActivePos.x = _vc2.x; ActivePos.y = _vc2.y; } _ply2.GetComponent <TankController>().MoveTo(ActivePos); } this.NextBattleState(); SetCursorInDefaultPosition(); GameObject.Find("txtState").GetComponent <TextMesh>().text = GameState.ToString(); } }