Ejemplo n.º 1
0
    //-------------------------------------------------------------------------
    private void guardPatrolling()
    {
        Vector2 posGuard = manager.GetPosition(6);

        // choose right animation for the guard
        if (Patrolling.IsGoingLeft())
        {
            GuardAnimation.Play(1.0f, 1);
        }
        else
        {
            GuardAnimation.Play(1.0f, 0);
        }

        // if the guard is visible
        if (posGuard.x < 5.5f && posGuard.x > -1.0f)
        {
            // and chocolate is not in the inventory
            if ((!manager.IsInInventory(3) && manager.IsActive(3)) ||
                (!manager.IsInInventory(1) && manager.IsActive(1)))
            {
                RatAnimation.Stop();
                Patrolling.isPatrolling = false;
                GuardAnimation.Stop();
                updateHandler_ = gotCaught;
                timeEnd_       = time_ + 7.0f;
            }
        }

        // stop the rat animations when it arrived at its destination
        if (isRatKillable && !RatMove.IsMoving())
        {
            RatAnimation.Stop();
        }
    }
    void Update()
    {
        Vector2 posGuard = manager.GetPosition(6);

        // if the guard is visible
        if (posGuard.x < 8.0f && posGuard.x > -3.0f)
        {
            // and chocolate is not in the inventory
            if (!manager.IsInInventory(3) && manager.IsActive(3))
            {
                Application.LoadLevel(3);
            }

            // and rat bones is not in the inventory
            if (!manager.IsInInventory(1) && manager.IsActive(1))
            {
                Application.LoadLevel(3);
            }
        }
    }