Пример #1
0
    /// <summary>
    /// Checks to see if some other AABB overlaps this AABB.
    /// </summary>
    /// <param name="other">The other AABB component to check against.</param>
    /// <returns>If true, the two AABBs overlap.</returns>
    public bool CheckOverlap(ObjectAABB other)
    {
        if (other.bounds.min.x > this.bounds.max.x)
        {
            return(false);
        }
        if (other.bounds.max.x < this.bounds.min.x)
        {
            return(false);
        }

        if (other.bounds.min.y > this.bounds.max.y)
        {
            return(false);
        }
        if (other.bounds.max.y < this.bounds.min.y)
        {
            return(false);
        }

        if (other.bounds.min.z > this.bounds.max.z)
        {
            return(false);
        }
        if (other.bounds.max.z < this.bounds.min.z)
        {
            return(false);
        }

        return(true);
    }
Пример #2
0
    void OnOverlappingAABB(ObjectAABB other)
    {
        if (other.tag == "Powerup")
        {
            //it must be a powerup...
            Powerup powerup = other.GetComponent <Powerup>();
            switch (powerup.type)
            {
            case Powerup.Type.None:
                break;

            case Powerup.Type.Slowmo:
                //set timer in SceneController to start counting down slowmo time.
                sceneController.BroadcastMessage("SetSlowmoTimer");
                break;

            case Powerup.Type.Health:
                playerHealth++;
                if (playerHealth >= playerHealthMax)
                {
                    playerHealth = playerHealthMax;
                }
                healthBar.BroadcastMessage("SetHealth", playerHealth);
                break;

            case Powerup.Type.JetpackBoost:
                playerHeight = jumpHeight * 1.2f;
                hasJetpack   = true;
                jetpackExhaust.Play();
                isGrounded = false;
                sceneController.BroadcastMessage("PlayerHasJetpack");
                break;

            case Powerup.Type.Wall:
                playerHealth--;
                healthBar.BroadcastMessage("SetHealth", playerHealth);
                if (playerHealth <= 0)
                {
                    sceneController.BroadcastMessage("PlayerDead");
                }
                break;
            }
            Destroy(other.gameObject);
        }
        if (other.tag == "Ground")
        {
            //it must be the ground...
            isGrounded   = true;
            playerHeight = 0;
        }
    }
Пример #3
0
 static public void Add(ObjectAABB obj)
 {
     aabbs.Add(obj);
     //print("there are " + aabbs.Count + " AABBs registered");
 }
Пример #4
0
 void OnOverlappingAABB(ObjectAABB other)
 {
     isOverlapping = true;
 }