コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     if (socket.IsFilled())
     {
         trigger.Trigger();
         this.enabled = false;
         pluggedIn.Invoke();
     }
 }
コード例 #2
0
    // Start is called before the first frame update

    public int SolveExpression()
    {
        if (caller == null)
        {
            textMesh.text = "Clr";
            return(0);
        }
        string ex = caller.GetExpression();

        if (ex[0] == 'b' && ex[ex.Length - 1] == '=')
        {
            string sub = ex.Substring(1, ex.Length - 2);

            var numberStrings = sub.Split('+');

            List <int> numbers = new List <int>();
            foreach (string s in numberStrings)
            {
                int i = 0;
                Int32.TryParse(s, out i);
                numbers.Add(i);
            }

            int result = 0;
            foreach (int i in numbers)
            {
                result += i;
            }

            textMesh.text = result.ToString();
            if (tutorial)
            {
                if (result == 3)
                {
                    dialog.Trigger();
                }
            }
            return(result);
        }
        else
        {
            textMesh.text = "ERR";
            return(0);
        }
    }