Example #1
0
    public override void execute_command(string command)
    {
        float  time = 1.0f / PlaySpace.GetVelocity();
        string cmd  = command.ToLower();

        execute_animations(cmd, time);
    }
Example #2
0
    public override void execute_command(string command)
    {
        float  time = 1.0f / PlaySpace.GetVelocity();
        string cmd  = command.ToLower();

        if (cmd.Equals("walk"))
        {
            float xDistance = Mathf.Sin(myTransform.parent.localEulerAngles.y * Mathf.PI / 180.0f) * PlaySpace.GetBaseDistance();
            float zDistance = Mathf.Cos(myTransform.parent.localEulerAngles.y * Mathf.PI / 180.0f) * PlaySpace.GetBaseDistance();
            StartCoroutine(Move_Coroutine_X(myTransform.parent, xDistance, time));
            StartCoroutine(Move_Coroutine_Z(myTransform.parent, zDistance, time));
        }
        else if (cmd.Equals("run"))
        {
            float xDistance = Mathf.Sin(myTransform.parent.localEulerAngles.y * Mathf.PI / 180.0f) * 3 * PlaySpace.GetBaseDistance();
            float zDistance = Mathf.Cos(myTransform.parent.localEulerAngles.y * Mathf.PI / 180.0f) * 3 * PlaySpace.GetBaseDistance();
            StartCoroutine(Move_Coroutine_X(myTransform.parent, xDistance, time));
            StartCoroutine(Move_Coroutine_Z(myTransform.parent, zDistance, time));
        }
        else if (cmd.Equals("turnright"))
        {
            StartCoroutine(Rotate_Coroutine_Y(myTransform.parent, 90, time));
        }
        else if (cmd.Equals("turnleft"))
        {
            StartCoroutine(Rotate_Coroutine_Y(myTransform.parent, -90, time));
        }
        else
        {
            Debug.Log("Could not run cmd " + cmd + ".");
        }
        execute_animations(cmd, time);
    }
Example #3
0
    private IEnumerator RunScriptCoroutine()
    {
        float         time       = 1.0f / PlaySpace.GetVelocity();
        string        path       = Application.persistentDataPath + "/SourceCodes/" + scriptName;
        string        sourceCode = File.ReadAllText(path);
        List <string> commands   = new List <string>(sourceCode.Split(';'));

        foreach (string splittedCommand in commands)
        {
            string cmd = splittedCommand.Trim();
            if (cmd.Length > 0)
            {
                //Debug.Log(this.gameObject.name + " running command " + cmd + ".");
                foreach (EvoLangImplementation libraryImplementation in librariesSupported)
                {
                    libraryImplementation.execute_command(cmd);
                }
                yield return(new WaitForSeconds(time));
            }
        }
    }
 public virtual void execute_command(string command)
 {
     Debug.Log("EvoLangImplementation.execute_command()");
     execute_animations(command.ToLower(), 1.0f / PlaySpace.GetVelocity());
 }