Exemplo n.º 1
0
        private static void RegisterMagicFunction(FunctionRegistration method)
        {
            var           first         = method.MagicAttributes.First();
            string        defaultName   = first.Name;
            var           deleg         = method.Method.CreateDelegate(typeof(Func <ListNode, Scope, IValue>));
            MagicFunction magicFunction = new MagicFunction((Func <ListNode, Scope, IValue>)deleg, defaultName, first.Line, GetFileName(first));

            foreach (var globalname in method.MagicAttributes)
            {
                Scope[globalname.Name] = magicFunction;
            }
        }
Exemplo n.º 2
0
    // Shoot function to clean up function
    void shoot()
    {
        if (active_element == null)
        {
            return;
        }
        MagicFunction active_element_function = active_element.GetComponent <MagicFunction>();

        if (!MagicElements.instance.valid_elements[active_element_function.idx].is_function)
        {
            Debug.Log("You are shooting an element not a function!");
            return;
        }
        active_element_function.clean_function();
        SoundAudio.instance.playRemove(transform.position);
    }
Exemplo n.º 3
0
    void trigger_release(bool status)
    {
        if (last_status && status == false && grabed != null)
        {
            if (grabed_idx == MagicElements.instance.main_function_idx)
            {
                // release main
                int[] magic_spell = MagicElements.instance.get_spell();

                string a = "";
                for (int i = 0; i < 10; ++i)
                {
                    a += " " + magic_spell[i];
                }
                Debug.Log("magic_spell" + a);

                /*
                 *  call more general but not exact fractal with fractal class instead of fractal bloom
                 * fractal_generator.GetComponent<Fractal>().setFractalStartPosition(transform.position);
                 * fractal_generator.GetComponent<Fractal>().cleanUpFractals();
                 * fractal_generator.GetComponent<Fractal>().generateFractalsFromIndices(magic_spell);
                 */

                SoundAudio.instance.stopMagic();
                fractal_generator.bloom(transform.position, magic_spell);
            }
            else
            {
                SoundAudio.instance.playRelease(transform.position);
                if (active_element == null)
                {
                    // release to the sky
                    Debug.Log("You release it to nothing!");
                }
                else
                {
                    // release to a function
                    MagicFunction active_element_function = active_element.GetComponent <MagicFunction>();
                    active_element_function.extend_function(MagicElements.instance.valid_elements[grabed_idx]);
                }
            }

            Destroy(grabed);
            grabed = null;
        }
    }
Exemplo n.º 4
0
    // trigger operation
    void trigger_grab(bool status)
    {
        if (last_status == false && status && active_element != null)
        {
            MagicFunction active_element_function = active_element.GetComponent <MagicFunction>();
            GameObject    new_obj = Instantiate(MagicElements.instance.valid_elements[active_element_function.idx].model_prefab) as GameObject;
            new_obj.transform.parent        = transform;
            new_obj.transform.localPosition = Vector3.zero;
            grabed     = new_obj;
            grabed_idx = active_element_function.idx;

            if (grabed_idx != MagicElements.instance.main_function_idx)
            {
                SoundAudio.instance.playGrab(transform.position);
            }
            else
            {
                SoundAudio.instance.playMagic(transform.position);
            }
        }
    }