private void finishRound() { Debug.Log("Round is finished."); GameMessaging gm = communication.GameMsg; gm.EchoFinishMessage(); for (int i = 0; i < currentPlayers; i++) { for (int j = 0; j < tc[i].barrelScript.maxBombsCurrent; j++) { if (tc[i].barrelScript.bombs[j] != null) { tc[i].barrelScript.bombs[j].GetComponent <BombScript>().DestroyBomb(); // remove all bombs } } tc[i].movingEnabled = false; tc[i].turningLeft = false; tc[i].turningRight = false; tc[i].movingBackward = false; tc[i].movingForward = false; tc[i].isDead = false; tc[i].died = false; tc[i].currentHealth = tc[i].maxHealth; Debug.Log("i: " + tc[i].transform.position); } isRoundFinished = false; }
/// <summary> /// Unity method called on initialization /// </summary> private void Awake() { //gameController = GetComponent<GameController>(); server = "ws://" + host + ":" + port; client = new WsClient(server); // Messaging GameMsg = new GameMessaging(this); }
public void ManageKeyboard() { TankController cur = tc[your_id]; if (tanks[your_id] != null && !cur.isDead && cur.movingEnabled) { GameMessaging gm = communication.GameMsg; if (!cur.movingForward && Input.GetKey(cur.forwardKey)) { gm.EchoMovementMessage(MovementMessageModel.Action.Forward, true, this); cur.movingForward = true; } if (cur.movingForward && Input.GetKeyUp(cur.forwardKey)) { gm.EchoMovementMessage(MovementMessageModel.Action.Forward, false, this); cur.movingForward = false; cur.stopTank = true; } if (!cur.movingBackward && Input.GetKey(cur.backwardKey)) { gm.EchoMovementMessage(MovementMessageModel.Action.Backward, true, this); cur.movingBackward = true; } if (cur.movingBackward && Input.GetKeyUp(cur.backwardKey)) { gm.EchoMovementMessage(MovementMessageModel.Action.Backward, false, this); cur.movingBackward = false; cur.stopTank = true; } if (!cur.turningRight && Input.GetKey(cur.rotateRightKey)) { gm.EchoMovementMessage(MovementMessageModel.Action.Rot_right, true, this); cur.turningRight = true; } if (cur.turningRight && Input.GetKeyUp(cur.rotateRightKey)) { gm.EchoMovementMessage(MovementMessageModel.Action.Rot_right, false, this); cur.turningRight = false; } if (!cur.turningLeft && Input.GetKey(cur.rotateLeftKey)) { gm.EchoMovementMessage(MovementMessageModel.Action.Rot_left, true, this); cur.turningLeft = true; } if (cur.turningLeft && Input.GetKeyUp(cur.rotateLeftKey)) { gm.EchoMovementMessage(MovementMessageModel.Action.Rot_left, false, this); cur.turningLeft = false; } if (Input.GetKeyDown(cur.fireKey)) { gm.EchoFireMessage(); cur.barrelScript.Fire(); } if (Input.GetKeyUp(KeyCode.Z)) { for (int i = 0; i < currentPlayers; i++) { Debug.Log( "(" + currentPlayers + ")" + "[" + i + "]" + " " + tanks[i].transform.rotation + " | " + "|" + tc[i].movingBackward + tc[i].movingForward + tc[i].turningLeft + tc[i].turningRight ); } } } }