Exemple #1
0
    void OnCollisionStay(Collision collision)
    {
        // Only add priority to cubes
        if (collision.gameObject.name.Equals("Cube_Physics(Clone)"))
        {
            RBObj rBObj = collision.gameObject.GetComponent <RBObjHolder>().rBObj;
            // Give the cube higher priority.

            // Debug.Log(collision.gameObject.name);
            rBObj.Priority += 100;

            // Debug.Log(rBObj.Priority);

            // unused
            rBObj.Owner = gameObject.GetComponent <RBObjHolder>().rBObj.Id;
        }
    }
    private int sortByPriority(RBObj x, RBObj y)
    {
        float priorityDif = (float)(priorityAccumulator[x] - priorityAccumulator[y]);

        if (Mathf.Abs(priorityDif) < .00001)
        {
            return(0);
        }
        else if (priorityDif < 0)
        {
            return(-1);
        }
        else
        {
            return(1);
        }
    }