예제 #1
0
    public ChargedObject MakeChargedObject(ChargedObjectSettings chargedObjectSettings, bool addToSandboxHistory = false)
    {
        createCounter++;
        GameObject newObject = Instantiate(SandboxManager.GetSandboxPrefabs()[chargedObjectSettings.shape]);

        newObject.name             = "sandbox object " + createCounter;
        newObject.transform.parent = GetRegionManager().gameObject.transform;
        ChargedObject newChargedObject = newObject.AddComponent <ChargedObject>();

        newChargedObject.UpdateValues(chargedObjectSettings);

        if (chargedObjectSettings.canMove)
        {
            MovingChargedObject mco = newObject.AddComponent <MovingChargedObject>();
            mco.UpdateValues(chargedObjectSettings);
            mco.SetFrozenPosition(GameManager.GetGameManager().GetIsPaused());
        }
        newObject.transform.position = chargedObjectSettings.position;

        GetRegionManager().AddChargedObject(newChargedObject);

        if (addToSandboxHistory)
        {
            AddToHistory(newChargedObject, chargedObjectSettings);
        }
        if (!GetChargedObjects().ContainsKey(newChargedObject))
        {
            GetChargedObjects().Add(newChargedObject, chargedObjectSettings);
        }


        return(newChargedObject);
    }
예제 #2
0
    private void RemakeCursorGameObject()
    {
        shouldRemakeCursor = false;

        Destroy(cursorGameObject);
        ChargedObjectSettings chargedObjectSettings = GetChargedObjectSettingsFromUI();

        cursorGameObject = Instantiate(SandboxManager.GetSandboxPrefabs()[sandboxShape]);
        ChargedObject       co  = cursorGameObject.AddComponent <ChargedObject>();
        MovingChargedObject mco = cursorGameObject.AddComponent <MovingChargedObject>();

        co.enabled  = false;
        mco.enabled = false;
        co.UpdateValues(chargedObjectSettings);
        mco.UpdateValues(chargedObjectSettings);
        cursorGameObject.transform.position = new Vector3(0, -100000, 0);

        ParentChildFunctions.SetCollidersOfChildren(cursorGameObject, false, true);
    }