public void Fire(BattleManager battleManager, bool hit) { MovementTile t = battleManager.GetRandomTile(!isAssignAbleTo); CannonBall cb = Instantiate(cannonBall, spawnLoc.position, Quaternion.identity).GetComponent <CannonBall> (); //TODO: maybe fix this reroll system while (!t.walkable) { t = battleManager.GetRandomTile(!isAssignAbleTo); } Ship target = isAssignAbleTo ? battleManager.otherShip : battleManager.playerShip; int damage = isAssignAbleTo ? battleManager.playerShip.cannonDamage : battleManager.otherShip.cannonDamage; cb.Init(t, hit, isAssignAbleTo, target, damage); }
public override void ActivateSecondary() { if (data.currentNumberOfCannonBalls > 0) { if (data.currentCannonReloadTime <= 0) { Vector3 cannonDirection = transform.rotation * Vector3.forward; Vector3 position = mainBarrel.GetChild(numberOfBarrels).GetChild(0).position + cannonDirection; GameObject cannonBallClone = (GameObject)Instantiate(data.cannonBallType, position, this.transform.rotation); CannonBall cannonBall = cannonBallClone.GetComponent <CannonBall>(); cannonBall.Init(cannonDirection, data.cannonBallSpeed, data.cannonBallRange); data.currentCannonReloadTime = data.maxCannonReloadTime; if (data.ownerEntity.transform.tag == "Player") { data.currentNumberOfCannonBalls--; } } } }