コード例 #1
0
    override public void Update()
    {
        GlobalVariable[0].source = Rotation;
        GlobalVariable[1].source = CurrentAnchor != null;
        if (CurrentAnchor != null)
        {
            GlobalVariable[2].source = CurrentAnchor.GetComponentInChildren <WInteractable>().Name;
        }
        else
        {
            GlobalVariable[2].source = string.Empty;
        }

        for (int i = 0; i < FunctionCall.Count; i++)
        {
            FunctionCaller fc = FunctionCall[FunctionCall.Count - 1];
            FunctionCall.RemoveAt(0);
            int pr = i;
            i = 0;
            if (fc.Name == "GripNearestAnchor")
            {
                Undock();

                Dock(DetectedAnchor);
            }
            else if (fc.Name == "SetRotation")
            {
                SetRotation((int)fc.parameters[0].source);
            }
            else if (fc.Name == "UngripAnchor")
            {
                Undock();
            }
        }
    }
コード例 #2
0
    override public void Update()
    {
        if (CanExecuteCode())
        {
            GlobalVariable[0].source = ParentRotor.localEulerAngles.y;

            for (int i = 0; i < FunctionCall.Count; i++)
            {
                FunctionCaller fc = FunctionCall[FunctionCall.Count - 1];
                FunctionCall.RemoveAt(0);
                int pr = i;
                i = 0;
                if (fc.Name == "SetSpecificRotation")
                {
                    Goto    = Mathf.Clamp((float)fc.parameters[0].source, 0f, 1f);
                    AtSpeed = Mathf.Clamp((float)fc.parameters[1].source, -1f, 1f);

                    if (AtSpeed < 0)
                    {
                        Goto = -Goto;
                    }
                    StartRot = ParentRotor.localEulerAngles;
                    cRot     = ParentRotor.localEulerAngles.y;
                }
                else if (fc.Name == "ExecuteRotation")
                {
                    Goto    = ParentRotor.localEulerAngles.y / 360f + (float)fc.parameters[0].source;
                    AtSpeed = Mathf.Clamp((float)fc.parameters[1].source, -1f, 1f);

                    if (AtSpeed < 0)
                    {
                        Goto = -Goto;
                    }
                    StartRot = ParentRotor.localEulerAngles;
                    cRot     = ParentRotor.localEulerAngles.y;
                }
                else if (fc.Name == "SetConstantSpeed")
                {
                    Goto    = Mathf.Infinity;
                    AtSpeed = Mathf.Clamp((float)fc.parameters[0].source, -1f, 1f);
                }
                i = pr;
            }

            PPSComsumption = AtSpeed * 6.0f;

            if (AtSpeed != 0f && Goto != Mathf.Infinity && Goto != Mathf.NegativeInfinity)
            {
                ParentRotor.localEulerAngles = new Vector3(0f, Mathf.Clamp(cRot + (AtSpeed * EnginSpeed) * Time.deltaTime, StartRot.y, Goto * 360f), 0f);
                cRot = Mathf.Clamp(cRot + (AtSpeed * EnginSpeed) * Time.deltaTime, StartRot.y, Goto * 360f);
            }
            else if (Goto == Mathf.Infinity || Goto == Mathf.NegativeInfinity)
            {
                ParentRotor.localEulerAngles += Vector3.up * (AtSpeed * EnginSpeed) * Time.deltaTime;
            }
        }
    }
コード例 #3
0
    // Update is called once per frame
    override public void Update()
    {
        if (PowerSource != null)
        {
            Capacity += Mathf.Clamp(PowerSource.PPSPool, 0.0f, (float)GlobalVariable[3].source * Time.deltaTime);
            Capacity  = Mathf.Min(MaxCap * (float)GlobalVariable[6].source, Capacity);

            if (Capacity / MaxCap >= 1f)
            {
                renderers[0].material = mats[1];
                renderers[1].material = mats[1];
                renderers[2].material = mats[1];
                renderers[3].material = mats[1];
            }
            else if (Capacity / MaxCap > 0.75f)
            {
                renderers[0].material = mats[0];
                renderers[1].material = mats[1];
                renderers[2].material = mats[1];
                renderers[3].material = mats[1];
            }
            else if (Capacity / MaxCap > 0.5f)
            {
                renderers[0].material = mats[0];
                renderers[1].material = mats[0];
                renderers[2].material = mats[1];
                renderers[3].material = mats[1];
            }
            else if (Capacity / MaxCap > 0f)
            {
                renderers[0].material = mats[0];
                renderers[1].material = mats[0];
                renderers[2].material = mats[0];
                renderers[3].material = mats[1];
            }
            else if (Capacity / MaxCap <= 0f)
            {
                renderers[0].material = mats[0];
                renderers[1].material = mats[0];
                renderers[2].material = mats[0];
                renderers[3].material = mats[0];
            }
        }
        GlobalVariable[0].source = Capacity;
        GlobalVariable[1].source = Capacity / MaxCap;

        GlobalVariable[4].source = Capacity == MaxCap;
        GlobalVariable[5].source = Capacity == 0f;

        PPSPool = Mathf.Clamp(Capacity, 0.0f, (float)GlobalVariable[1].source);

        for (int i = 0; i < FunctionCall.Count; i++)
        {
            FunctionCaller fc = FunctionCall[FunctionCall.Count - 1];
            FunctionCall.RemoveAt(0);
            int pr = i;
            i = 0;
            if (fc.Name == "SetMaxPPSFlowValues")
            {
                GlobalVariable[2].source = Mathf.Clamp((float)fc.parameters[0].source, 0.0f, 2000f);
                GlobalVariable[3].source = Mathf.Clamp((float)fc.parameters[1].source, 0.0f, 2000f);
            }
            if (fc.Name == "SetMaxFillingCapacity")
            {
                GlobalVariable[6].source = Mathf.Clamp((float)fc.parameters[0].source, 0.0f, 1.0f);
            }
        }
    }
コード例 #4
0
    override public void Update()
    {
        if (CanExecuteCode())
        {
            for (int i = 0; i < FunctionCall.Count; i++)
            {
                FunctionCaller fc = FunctionCall[FunctionCall.Count - 1];
                FunctionCall.RemoveAt(0);
                int pr = i;
                i = 0;
                if (fc.Name == "Fill")
                {
                    Color color = new Color {
                        r = (float)fc.parameters[0].source,
                        g = (float)fc.parameters[1].source,
                        b = (float)fc.parameters[2].source,
                        a = 1f
                    };

                    Color[] colors = display.GetPixels();
                    for (int c = 0; c < colors.Length; c++)
                    {
                        colors[c] = color;
                    }

                    display.SetPixels(colors);
                    UpdateScreen();
                }
                else
                if (fc.Name == "SetColor")
                {
                    CurrentColor = new Color {
                        r = (float)fc.parameters[0].source,
                        g = (float)fc.parameters[1].source,
                        b = (float)fc.parameters[2].source,
                        a = 1f
                    };
                }
                else
                if (fc.Name == "SetTextCursor")
                {
                    TextCursorX = (int)fc.parameters[0].source;
                    TextCursorY = (int)fc.parameters[1].source;
                }
                else
                if (fc.Name == "DrawText")
                {
                    Color[] colors = display.GetPixels();
                    string  text   = (string)fc.parameters[0].source;
                    for (int t = 0; t < text.Length; t++)
                    {
                        byte b = (byte)(Converter.IndexOf(char.ToUpper(text[t])));
                        if (b > 127)
                        {
                            b = 0;
                        }
                        int readb = 2 + b * 3;

                        byte width  = BitmapFont[0];
                        byte height = BitmapFont[1];

                        for (int x = 0; x < width; x++)
                        {
                            for (int y = 0; y < height; y++)
                            {
                                if ((BitmapFont[readb + x] >> y & 1) == 1)
                                {
                                    if ((TextCursorX + x + (width + 1) * t) < display.width)
                                    {
                                        colors[(TextCursorX + x + (width + 1) * t) + (display.height - (TextCursorY + y)) * display.width] = CurrentColor;
                                    }
                                }
                            }
                        }
                    }
                    display.SetPixels(colors);
                    UpdateScreen();
                }
                else
                if (fc.Name == "DrawPixel")
                {
                    display.SetPixel(
                        (int)fc.parameters[0].source,
                        display.height - (int)fc.parameters[1].source,
                        CurrentColor
                        );
                    UpdateScreen();
                }
                else
                if (fc.Name == "DrawFilledRect")
                {
                    Color[] colors = display.GetPixels();
                    for (int x = (int)fc.parameters[0].source; x < (int)fc.parameters[2].source; x++)
                    {
                        for (int y = (int)fc.parameters[1].source; y < (int)fc.parameters[3].source; y++)
                        {
                            if (x < display.width)
                            {
                                colors[x + (display.height - y - 1) * display.width] = CurrentColor;
                            }
                        }
                    }
                    display.SetPixels(colors);
                    UpdateScreen();
                }
                else
                if (fc.Name == "DrawRect")
                {
                    Color[] colors = display.GetPixels();
                    for (int x = (int)fc.parameters[0].source; x < (int)fc.parameters[2].source; x++)
                    {
                        for (int y = (int)fc.parameters[1].source; y < (int)fc.parameters[3].source; y++)
                        {
                            if (x == (int)fc.parameters[0].source || x == (int)fc.parameters[2].source - 1 || y == (int)fc.parameters[1].source || y == (int)fc.parameters[3].source - 1)
                            {
                                if (x < display.width)
                                {
                                    colors[x + (display.height - y - 1) * display.width] = CurrentColor;
                                }
                            }
                        }
                    }
                    display.SetPixels(colors);
                    UpdateScreen();
                }
                else
                if (fc.Name == "DrawLine")
                {
                    display.SetPixels(DrawLine(
                                          (int)fc.parameters[0].source,
                                          (int)fc.parameters[1].source,
                                          (int)fc.parameters[2].source,
                                          (int)fc.parameters[3].source,
                                          display.GetPixels(),
                                          display.width,
                                          display.height,
                                          CurrentColor
                                          ));
                    UpdateScreen();
                }
                i = pr;
            }
        }

        int tactileX = Mathf.FloorToInt(TouchUVs.x * display.width);
        int tactileY = display.height - Mathf.FloorToInt(TouchUVs.y * display.height);

        GlobalVariable[2].source = tactileX;
        GlobalVariable[3].source = tactileY;
        GlobalVariable[4].source = MouseDown;
        GlobalVariable[5].source = MousePress;
        GlobalVariable[6].source = MouseUp;

        MouseDown  = false;
        MousePress = false;
        MouseUp    = false;
    }