public void Update() { if (_currBattle != null) { if (_currBattle.Update()) { //update own synet for testing _skyNet.update(_currBattle); } else { Object.Destroy(_currBattle); } } else { Node clicked = m_nodeController.checkNodes(); if (clicked != null) { //freezeplanet movement; if (clicked._nodeType == NODE_TYPES.BATTLE) { _playerShip = new Ship("PLAYER", 20.0f, 5.0f, 1.0f); _playerShip.AddWeapon(new Weapon(WEAPONS_TYPE.CANNON, EFFECT_TYPE.NONE)); _playerShip.AddWeapon(new Weapon(WEAPONS_TYPE.CANNON, EFFECT_TYPE.NONE)); _playerShip._level = 1; _skyNet = new SkyNet(ref _playerShip, _playerShip._level); _currBattle = ScriptableObject.CreateInstance <Battle>(); _currBattle.StartBattle(_playerShip); clicked._gameObject.GetComponent <MeshRenderer>().material.color = Color.magenta; } } } }
// Update is called once per frame public bool Update() { if (Input.GetKeyDown(KeyCode.Space) && _battleActive) { _nextRound = true; } if (_nextRound) { int MaxTurnsPerRound = _ship._crew.Count > _enemy._crew.Count ? _ship._crew.Count - 1 : _enemy._crew.Count - 1; if (turnIndex <= MaxTurnsPerRound) { //ship turn first (player) Move shipMove; if (turnIndex <= _ship._turnMoves.Count) { shipMove = _ship._turnMoves[turnIndex]; } else { shipMove = new Move(ABILITIES.NONE, 0); } //enemy turn second ( Move enemyMove; if (turnIndex <= _enemy._turnMoves.Count) { enemyMove = _enemy._turnMoves[turnIndex]; } else { enemyMove = new Move(ABILITIES.NONE, 0); } _ship.ExecuteTurn(turnIndex); _enemy.ExecuteTurn(turnIndex); _ship.update(); _enemy.update(); _skyNet.update(this); turnIndex++; } else { turnIndex = 0; _nextRound = false; } } if (!_ship.isAlive || !_enemy.isAlive) { _battleActive = false; } return(_battleActive); }