Example #1
0
    Orb SpawnOrb(Vector2 atPosition)
    {
        // Create orb game object
        GameObject orbGameObject = Instantiate(orbPrefab, atPosition, Quaternion.identity);
        Orb        orb           = orbGameObject.GetComponent <Orb>();

        // If new orb is within "beaming" range of most recently placed orb
        if (orbBeamRangeManager.isInRange(atPosition))
        {
            orb.SpawnBeamToPreviousOrb(orbBeamRangeManager.MostRecentOrb);
        }

        // Add to queue
        orbs.Enqueue(orb);
        // Update reference to most recent orb for displaying distance limit to player
        orbBeamRangeManager.MostRecentOrb = orb;
        if (!isNpcControlled && HasAuthority())
        {
            // Update the number of remaining orbs currently displayed onscreen
            orbUiManager.OnOrbCountChange(orbs.Count);
            // CLEANUP: this should probably be extracted to the rangemanager itself
            // Hide markers if the user can't place more orbs
            if (orbs.Count == MAX_ORB_COUNT)
            {
                orbBeamRangeManager.shouldShowMarkers = false;
            }
        }
        orb.gameObject.SetActive(false);
        return(orb);
    }