Beispiel #1
0
    private void Update()
    {
        this.UpdatePosition();

        // release target if it is in collision with player
        if (this.Position.z < -5 || this.Position.x < -13 || this.Position.x > 13)
        {
            TargetsFactory.ReleaseTarget(this);

            // player collision event
            if (targetPlayerCollision != null)
            {
                targetPlayerCollision(this, EventArgs.Empty);
            }
        }
    }
    public static int ReleaseAllTargetsByType(TargetType targetType)
    {
        int score = 0;

        GameObject[] gameObjectsToRelease = GameObject.FindGameObjectsWithTag(targetType.ToString());

        foreach (GameObject gameObject in gameObjectsToRelease)
        {
            // add score
            Target target = gameObject.GetComponent <Target>();
            score += target.Score;
            // release
            TargetsFactory.ReleaseTarget(target);
        }

        return(score);
    }
    public static Bonus ReleaseAllBonusTargetsByType(TargetType targetType)
    {
        Bonus bonus = new Bonus();

        GameObject[] gameObjectsToRelease = GameObject.FindGameObjectsWithTag(targetType.ToString());

        foreach (GameObject gameObject in gameObjectsToRelease)
        {
            // add score
            Target target = gameObject.GetComponent <Target>();
            bonus.Score += target.BonusScore;
            bonus.Time  += target.BonusTime;
            bonus.Life  += target.BonusLife;
            // release
            TargetsFactory.ReleaseTarget(target);
        }

        return(bonus);
    }