MGame.CreateBeast C# (CSharp) Method

CreateBeast() public method

public CreateBeast ( MPlayer, player ) : void
player MPlayer,
return void
    public void CreateBeast(MPlayer player)
    {
        if(player.beasts.Count >= player.maxBeasts) return; //TODO: Show a "max beasts limit reached!" indicator on screen

        player.isDirty = true;

        MBeast beast = MBeast.New();
        if(beast.container != _beastContainer) _beastContainer.AddChild(beast);
        beast.Start(player);

        if(_beasts.Length <= _beastCount)
        {
            Array.Resize(ref _beasts,_beastCount+20);
        }

        _beasts[_beastCount++] = beast;
        player.beasts.Add(beast);

        float creationAngle = player.angle + player.nextBeastCreationAngle;

        beast.x = player.tower.x + Mathf.Sin (creationAngle*RXMath.DTOR) * (MConfig.TOWER_RADIUS+20.0f);
        beast.y = player.tower.y + Mathf.Cos (creationAngle*RXMath.DTOR) * (MConfig.TOWER_RADIUS+20.0f);

        player.nextBeastCreationAngle = (player.nextBeastCreationAngle + 30.0f)%360.0f;
    }