MGame.SetAttackTarget C# (CSharp) Method

SetAttackTarget() public method

public SetAttackTarget ( MPlayer, player, Vector2 targetPosition ) : void
player MPlayer,
targetPosition Vector2
return void
    public void SetAttackTarget(MPlayer player, Vector2 targetPosition)
    {
        float distance = Mathf.Sqrt(targetPosition.x*targetPosition.x + targetPosition.y*targetPosition.y);

        if(distance > MConfig.WALL_RADIUS + 50.0f) return; //no attacking too far outside the wall

        List<MBeast> beasts = player.beasts;
        int beastCount = beasts.Count;
        for(int b = 0; b<beastCount; b++)
        {
            MBeast beast = beasts[b];
            beast.hasTarget = true;
            beast.target = targetPosition;
        }

        if(player.isHuman) effectLayer.ShowCrosshairForPlayer(player, targetPosition);
    }