Example #1
0
    private void CreateGroundCollider(int blockStart, int blockWidth, int blockHeight)
    {
        LevelFloor ground = NGUITools.AddChild(levelRoot, groundPrefab).GetComponent <LevelFloor>();

        ground.boxCollider.size        = new Vector3(blockWidth, blockHeight, 50f);
        ground.boxCollider.center      = new Vector3(blockWidth * 0.5f, -blockHeight * 0.5f, 0);
        ground.transform.localPosition = new Vector3(blockStart, blockHeight, 0);
    }
    private void OnCollisionExit(Collision collisionInfo)
    {
        while (rightBlockingObjects.Contains(collisionInfo.gameObject))
        {
            rightBlockingObjects.Remove(collisionInfo.gameObject);
        }

        while (leftBlockingObjects.Contains(collisionInfo.gameObject))
        {
            leftBlockingObjects.Remove(collisionInfo.gameObject);
        }

        LevelFloor platform = collisionInfo.gameObject.GetComponent <LevelFloor>();

        if (platform != null)
        {
            if (currentPlatform == platform)
            {
                isGrounded      = false;
                currentPlatform = null;
            }
        }
    }
    private void OnCollisionEnter(Collision collisionInfo)
    {
        foreach (ContactPoint contact in collisionInfo.contacts)
        {
            if (contact.normal.x < -0.9f)
            {
                rightBlockingObjects.Add(collisionInfo.gameObject);
            }

            if (contact.normal.x > 0.9f)
            {
                leftBlockingObjects.Add(collisionInfo.gameObject);
            }
        }

        LevelFloor platform = collisionInfo.gameObject.GetComponent <LevelFloor>();

        if (platform != null)
        {
            bool isUnderneath = false;

            foreach (ContactPoint contact in collisionInfo.contacts)
            {
                if (contact.normal.y > 0.9f)
                {
                    isUnderneath = true;
                }
            }

            if (isUnderneath)
            {
                isGrounded      = true;
                currentPlatform = platform;
            }
        }
    }
    protected bool IsPlatformDownJumpable(LevelFloor platform)
    {
        BoxCollider platformCollider = (BoxCollider)platform.collider;

        return(platformCollider.size.z <= 25f);
    }
Example #5
0
    private void OnCollisionExit(Collision collisionInfo)
    {
        while (rightBlockingObjects.Contains(collisionInfo.gameObject))
        {
            rightBlockingObjects.Remove(collisionInfo.gameObject);
        }

        while (leftBlockingObjects.Contains(collisionInfo.gameObject))
        {
            leftBlockingObjects.Remove(collisionInfo.gameObject);
        }

        LevelFloor platform = collisionInfo.gameObject.GetComponent<LevelFloor>();
        if (platform != null)
        {
            if (currentPlatform == platform)
            {
                isGrounded = false;
                currentPlatform = null;
            }
        }
    }
Example #6
0
    private void OnCollisionEnter(Collision collisionInfo)
    {
        foreach (ContactPoint contact in collisionInfo.contacts)
        {
            if (contact.normal.x < -0.9f)
            {
                rightBlockingObjects.Add(collisionInfo.gameObject);
            }

            if (contact.normal.x > 0.9f)
            {
                leftBlockingObjects.Add(collisionInfo.gameObject);
            }
        }

        LevelFloor platform = collisionInfo.gameObject.GetComponent<LevelFloor>();
        if (platform != null)
        {
            bool isUnderneath = false;

            foreach (ContactPoint contact in collisionInfo.contacts)
            {
                if (contact.normal.y > 0.9f)
                {
                    isUnderneath = true;
                }
            }

            if (isUnderneath)
            {
                isGrounded = true;
                currentPlatform = platform;
            }
        }
    }
Example #7
0
 protected bool IsPlatformDownJumpable(LevelFloor platform)
 {
     BoxCollider platformCollider = (BoxCollider)platform.collider;
     return platformCollider.size.z <= 25f;
 }