Esempio n. 1
0
    public void Shoot()
    {
        if (count <= 0)
            return;

        var princes = gameController.princesInMotion;
        RoyalPerson prince = null;
        if (princes.Count > 0)
        {
            for (int i = 0; i < princes.Count; i--)
            {
                prince = princes[i];
                if (prince != null)
                    break;
            }
        }

        if (prince == null)
            return;

        --count;
        audioSource.Play();

        var ball = Instantiate(prefab, canvas.transform);
        ball.transform.position = marker.transform.position;
        ball.GetComponent<CannonBall>().target = prince;
        ball.GetComponent<CannonBall>().gameController = gameController;
        particleSystem.Play();
    }
Esempio n. 2
0
    public void Eat(RoyalPerson person)
    {
        if (currentEatAnimation != null)
        {
            personsToEat.Enqueue(person);
            return;
        }

        DoEat(person);
    }
Esempio n. 3
0
    private void DoEat(RoyalPerson person)
    {
        if (person.isEdible)
        {
            gameController.sacrificedCount++;
            currentEatAnimation = animation.AnimationState.SetAnimation(0, "eat_princess", false);
        }
        else
        {
            currentEatAnimation = animation.AnimationState.SetAnimation(0, "eat_prince", false);
            gameOver            = true;
        }

        Destroy(person.gameObject);

        currentEatAnimation.Complete -= OnComplete;
        currentEatAnimation.Complete += OnComplete;

        currentEatAnimation.Event -= OnEvent;
        currentEatAnimation.Event += OnEvent;
    }