コード例 #1
0
    ///<summary>Spawner en mine og assigner det til mines listen til senere brug</summary>
    public CannonBall SpawnCannonBalls(IShip ship, Vector3 position, Quaternion rotation, bool isMaster, int ID = -1)
    {
        //For at skaffe et ordenligt id skal vi altid skaffe det sidst skib i listen og give den et id større end den
        if (ID == -1)
        {
            ID = cannonBalls.Count > 0 ? cannonBalls.Last().GetCannonBallID() + 1 : 1;
        }

        GetAudioManager().PlayCannonSoundAtPos(position);
        GetFXManager().FireBlastAtPos(position);

        CannonBall cannonBall = Instantiate(cannonBallPrefab, position, rotation).GetComponent <CannonBall>();

        cannonBall.CannonBallCreatedHandler(ship, isMaster, ID);

        cannonBalls.Add(cannonBall);

        return(cannonBall);
    }