コード例 #1
0
    // Called when a target is destroyed
    public void NotifyDestructionBy(Rigidbody2D destroyer)
    {
        // How well was the destroyer facing the target?
        float angleDiff = Mathf.DeltaAngle(
            SteeringBehaviour.Vec2Deg(destroyer.velocity), destroyer.rotation);

        // Determine points for this destruction based on how well the
        // destroyer was facing the target
        float points = 1 - 0.9f * Mathf.Abs(angleDiff) / 180;

        UpdatePoints(points);
        Invoke("SpawnTarget", delay);
    }