public void updateScript(string newcode)
    {
        //parser.logger.appendln("script problem");
        //parser.logger.appendln("code:\r\n" + newcode);

        //code = newcode;
        //parser = new Parser2();
        //parser.setType(3);
        //parser.parse(code);
        //state = 0;
        transform.position = start_point;
        Compiler.setCode(newcode);
        if (Compiler.compile())
        {
            _ip.setICode(Compiler.getICode());
            _ip.init();
        }
        //TMP fun animation//

        follow_mode = false;
        if (vision)
        {
            vision.enabled = false;
        }
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        if (code == null)
        {
            code = gameObject.GetComponent <MainObject>().script;
        }

        Compiler.setCode(code);
        Compiler.compile();

        _ip = new Interpretor();
        _ip.setICode(Compiler.getICode());
        _ip.init();

        //-Debug.Log(code);


        //animation setup//
        anim = GetComponent <Animator>();
        if (anim == null)
        {
            anim = GetComponentInChildren <Animator>();
        }
        if (controller == null)
        {
            controller = GetComponent <CharacterController>();
        }
        if (controller == null)
        {
            controller = GetComponentInChildren <CharacterController>();
        }
        stats = gameObject.GetComponent <AnimalStats>();
        //stats.setType(0);
    }
    // Use this for initialization
    void Start()
    {
        if (code == null)
        {
            code = gameObject.GetComponent <MainObject>().script;
        }

        Compiler.setCode(code);
        Compiler.compile();

        _ip = new Interpretor();
        _ip.setICode(Compiler.getICode());
        _ip.init();

        //animation setup//
        anim = GetComponent <Animator>();
        if (anim == null)
        {
            anim = GetComponentInChildren <Animator>();
        }
        if (controller == null)
        {
            controller = GetComponent <CharacterController>();
        }
        if (controller == null)
        {
            controller = GetComponentInChildren <CharacterController>();
        }
        stats  = gameObject.GetComponent <AnimalStats>();
        _speed = stats.walk_speed;
        //stats.setType(0);

        //TMP fun animation//
        vision = gameObject.GetComponent <VisionScript2>();
        if (vision == null)
        {
            vision = gameObject.AddComponent <VisionScript2>();
        }
        vision.setSpeed(stats.walk_speed);
        vision.setTurnSpeed(stats.turn_speed);
        vision.enabled = false;

        //add libraries.//
        SensingLib sl = gameObject.AddComponent <SensingLib>();

        sl.setInterpretor(_ip);

        //audio setup//
        audioSetup();

        //tmp code
        tantest();
    }
Esempio n. 4
0
    public void generate(string code)
    {
        string[] func; //track variable information

        //initializing compiler and compiling code.//
        //parse the whole code.
        Compiler.setCode(code);
        if (!(Compiler.compile()))
        {
            return;
        }

        //interpretor setup and initilisation//
        _ip = new Interpretor();
        _ip.setICode(Compiler.getICode());
        _ip.init();

        //each track instruction is provided
        while ((func = _ip.nextIns()) != null)
        {
            string __st = func[0];
            if (errorFlag)
            {
                break;
            }
            else if (__st == Compiler.EOP)
            {
                if (wallFlag)
                {
                    executeWall();
                }
                break;
            }
            else if (__st == "place")
            {
                placeObject(func);
            }
            else if (__st == "drawline")
            {
                drawLine(func);
            }
            else if (__st == "setposition")
            {
                setPosition(func);
            }
            else if (__st == "wall")
            {
                wallFlag = true; addWall(func);
            }
        }
    }
Esempio n. 5
0
    public void updateScript(string newcode)
    {
        //parser.logger.appendln("script problem");
        //parser.logger.appendln("code:\r\n" + newcode);

        //code = newcode;
        //parser = new Parser2();
        //parser.setType(3);
        //parser.parse(code);
        //state = 0;
        transform.position = start_point;
        Compiler.setCode(newcode);
        if (Compiler.compile())
        {
            _ip.setICode(Compiler.getICode());
            _ip.init();
        }
    }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        if (code == null)
        {
            code = gameObject.GetComponent <MainObject>().script;
        }
        Compiler.setCode(code);
        Compiler.compile();

        _ip = new Interpretor();
        _ip.setICode(Compiler.getICode());
        _ip.init();

        //add libraries.//
        SensingLib sl = gameObject.AddComponent <SensingLib>();

        sl.setInterpretor(_ip);
    }
Esempio n. 7
0
    //generates track and stores those objects
    public void generate(string code)
    {
        string[] track; //track variable information

        //initializing compiler and compiling code.//
        Compiler.setCode(code);
        Compiler.compile();

        //interpretor setup and initilisation//
        _ip = new Interpretor();
        _ip.setICode(Compiler.getICode());
        _ip.init();

        rg   = new WallGenerator(this);
        path = new GameObject("path");
        rg.setPath(path);


        //parse the whole code.
        Compiler.setCode(code);
        if (!(Compiler.compile()))
        {
            return;
        }

        //Debug.Log("track generation sarted-------------------");
        //Debug.Log("s:" + speed_points + ",p:" + points_per_track);

        //each track instruction is provided
        while ((track = _ip.nextIns()) != null)
        {
            string __st = track[0];
            if (__st == Compiler.EOP)
            {
                break;
            }
            else if (__st == "wall")
            {
                wallFunc(track);
            }
        }
        load();
    }
Esempio n. 8
0
    void resetSpawnPoint(int index)
    {
        spawnObj = Data.objects[index];
        string code = null;

        if (code == null)
        {
            code = spawnObj.GetComponent <MainObject>().script;
        }

        Compiler.setCode(code);
        Compiler.compile();

        Interpretor _ip = new Interpretor();

        _ip.setICode(Compiler.getICode());
        _ip.init();
        string[] ins = _ip.nextIns();
        while ((ins) != null && ins[0] != Compiler.EOP)
        {
            if (ins[0] == "movement")
            {
                if (ins[1].Replace("\"", "") == "false")
                {
                    Data.movementFlag = false;
                }
            }
            ins = _ip.nextIns();
            RCLog.append(ins[0]);
        }
        Vector3 distAboveGround = new Vector3(0, 3, 0);

        if (Data.vrEnabled)
        {
            VRPlayer.transform.position = spawnObj.transform.position + distAboveGround;
        }
        else
        {
            player.transform.position = spawnObj.transform.position + distAboveGround;
        }
        spawnObj.SetActive(false);
    }