Example #1
0
    private object SpawnRect(List <object> parameters)
    {
        int    width       = (int)parameters[0];
        int    height      = (int)parameters[1];
        int    x           = (int)parameters[2];
        int    y           = (int)parameters[3];
        int    z           = 0;
        object prototype   = parameters[4];
        string objectColor = (string)parameters[5];

        GameObject rectInstance = Instantiate(rectPrefab);

        rectInstance.transform.position   = new Vector3(x, y, z);
        rectInstance.transform.localScale = new Vector3(width, height, 10);

        if (ColorUtility.TryParseHtmlString(objectColor, out Color color))
        {
            rectInstance.GetComponent <MeshRenderer>().material.color = color;
        }

        MegaScryptGameObject obj = new MegaScryptGameObject(rectInstance);

        obj.Declare("prototype", prototype);

        _gameObjects.Add(obj);
        return(obj);
    }
Example #2
0
    private object SpawnCircle(List <object> parameters)
    {
        int    radius      = (int)parameters[0];
        int    x           = (int)parameters[1];
        int    y           = (int)parameters[2];
        int    z           = 0;
        object prototype   = parameters[3];
        string objectColor = (string)parameters[4];

        GameObject circleInstance = Instantiate(circlePrefab);

        circleInstance.transform.position   = new Vector3(x, y, z);
        circleInstance.transform.localScale = Vector3.one * radius;

        circleInstance.GetComponent <CollisionNotifier>().SetController(this);

        if (ColorUtility.TryParseHtmlString(objectColor, out Color color))
        {
            circleInstance.GetComponent <MeshRenderer>().material.color = color;
        }

        MegaScryptGameObject obj = new MegaScryptGameObject(circleInstance);

        obj.Declare("prototype", prototype);

        _gameObjects.Add(obj);
        return(obj);
    }