public void SetHighlightGrabbed(bool propagateToAttached)
    {
        if (!rend)
        {
            return;
        }

        if (!highlightOn)
        {
            SetHighlightOn(true);
        }

        if (!highlightGrabbed)
        {
            rend.material.color = grabbedColor;

            if (propagateToAttached && owningObject.GetAttachedObjects().Count > 0)
            {
                foreach (InteractiveObjectController obj in owningObject.GetAttachedObjects())
                {
                    obj.highlight.SetHighlightGrabbed(propagateToAttached);
                }
            }

            highlightGrabbed  = true;
            highlightSelected = false;
            highlightAttached = false;
        }
    }
示例#2
0
    private void DetectSpawn()
    {
        //need to change this to some sort of event based system
        int currentCount = floorObject.GetAttachedObjects().Count;
        HashSet <GameObject> spawnedObjects = spawner.spawnedObjects;

        //Debug.Log("spawned objects: " + spawnedObjects.Count + ", minimum blocks: " + minimumSpawnedBlocks);

        if (spawnedObjects.Count < minimumSpawnedBlocks)
        {
            //Debug.Log("BELOW MINIMUM!");
            for (int i = 0; i < minimumSpawnedBlocks; i++)
            {
                spawner.SpawnRandom();
            }
        }
        else
        {
            if (lastCount != currentCount)
            {
                if (currentCount > lastCount)
                {
                    spawner.SpawnRandom();
                }

                if (currentCount < lastCount)
                {
                    if (spawnedObjects.Count - currentCount > allowableBlockOverflowAmount)
                    {
                        foreach (GameObject spawnedObject in spawnedObjects)
                        {
                            InteractiveObjectController interactiveObject = spawnedObject.GetComponent <InteractiveObjectController>();

                            if (!interactiveObject.grabbed && !interactiveObject.attached)
                            {
                                spawner.DeleteObject(spawnedObject);
                                break;
                            }
                        }
                    }
                }
            }
        }

        lastCount = currentCount;
    }