コード例 #1
0
 public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
 {
     if (beBlock.BeBlockGroup.isActive)
     {
         BeController.PlayNextInside(beBlock);
     }
 }
コード例 #2
0
    public override string BEOperation(BETargetObject targetObject, BEBlock beBlock)
    {
        string inputString = beBlock.BeInputs.stringValues[0];

        if (inputString == "0" || inputString == "False" || inputString == "false")
        {
            result = "1";
        }
        else if (inputString == "1" || inputString == "True" || inputString == "true")
        {
            result = "0";
        }
        else if (beBlock.BeInputs.isString)
        {
            //reverse string
            char[] charArray = inputString.ToCharArray();
            System.Array.Reverse(charArray);
            result = new string( charArray );
        }
        else
        {
            //invert number
            float tempResult = beBlock.BeInputs.numberValues[0] * -1;
            result = tempResult.ToString(CultureInfo.InvariantCulture);
        }

        return(result);
    }
コード例 #3
0
 public override string BEOperation(BETargetObject targetObject, BEBlock beBlock)
 {
     if (beBlock.BeInputs.isString)
     {
         if (beBlock.BeInputs.stringValues[0] == beBlock.BeInputs.stringValues[1])
         {
             result = "1";
         }
         else
         {
             result = "0";
         }
     }
     else
     {
         if (beBlock.BeInputs.numberValues[0] == beBlock.BeInputs.numberValues[1])
         {
             result = "1";
         }
         else
         {
             result = "0";
         }
     }
     
     return result;
 }
コード例 #4
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        Vector3 axis;

        switch (beBlock.BeInputs.stringValues[0])
        {
        case "X axis":
            axis = Vector3.right;
            break;

        case "Y axis":
            axis = Vector3.up;
            break;

        case "Z axis":
            axis = Vector3.forward;
            break;

        default:
            axis = Vector3.up;
            break;
        }

        targetObject.transform.Rotate(axis, beBlock.BeInputs.numberValues[1]);

        BeController.PlayNextOutside(beBlock);
    }
コード例 #5
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        targetObject.transform.position = new Vector3(beBlock.BeInputs.numberValues[0], beBlock.BeInputs.numberValues[1],
                                                      beBlock.BeInputs.numberValues[2]);

        BeController.PlayNextOutside(beBlock);
    }
コード例 #6
0
    public override string BEOperation(BETargetObject targetObject, BEBlock beBlock)
    {
        if (beBlock.BeInputs.isString)
        {
            result = "";
            if (beBlock.BeInputs.numberValues[0] != 0)
            {
                for (int i = 0; i < beBlock.BeInputs.numberValues[0]; i++)
                {
                    result += beBlock.BeInputs.stringValues[1];
                }
            }
            else if (beBlock.BeInputs.numberValues[1] != 0)
            {
                for (int i = 0; i < beBlock.BeInputs.numberValues[1]; i++)
                {
                    result += beBlock.BeInputs.stringValues[0];
                }
            }
            else
            {
                result = beBlock.BeInputs.stringValues[0];
            }
        }
        else
        {
            float tempResult = beBlock.BeInputs.numberValues[0] * beBlock.BeInputs.numberValues[1];
            result = tempResult.ToString(CultureInfo.InvariantCulture);
        }

        return(result);
    }
コード例 #7
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        soundToPlay = BeController.GetSound(beBlock.BeInputs.stringValues[0]);
        targetObject.beAudioSource.clip = soundToPlay;
        targetObject.beAudioSource.Play();

        BeController.PlayNextOutside(beBlock);
    }
コード例 #8
0
    public override string BEOperation(BETargetObject targetObject, BEBlock beBlock)
    {
        string inputString0 = beBlock.BeInputs.stringValues[0];
        string inputString1 = beBlock.BeInputs.stringValues[1];

        result = (inputString0 == "1" || inputString0 == "True" || inputString0 == "true") || (inputString1 == "1" || inputString1 == "True" || inputString1 == "true")
        ? "1" : "0";

        return(result);
    }
コード例 #9
0
 public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
 {
     if (BEOperation(targetObject, beBlock) == "1")
     {
         BeController.PlayNextInside(beBlock);
     }
     else
     {
         BeController.PlayNextOutside(beBlock);
     }
 }
コード例 #10
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        if (targetObject.GetComponent <Collider2D>())
        {
            targetObject.transform.position += targetObject.transform.right * beBlock.BeInputs.numberValues[0];
        }
        else if (targetObject.GetComponent <Collider>())
        {
            targetObject.transform.position += targetObject.transform.forward * beBlock.BeInputs.numberValues[0];
        }

        BeController.PlayNextOutside(beBlock);
    }
コード例 #11
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        if (targetObject.GetComponent <Rigidbody2D>())
        {
            targetObject.GetComponent <Rigidbody2D>().AddForce(targetObject.transform.right * beBlock.BeInputs.numberValues[0]);
        }
        else if (targetObject.GetComponent <Rigidbody>())
        {
            targetObject.GetComponent <Rigidbody>().AddForce(targetObject.transform.forward * beBlock.BeInputs.numberValues[0]);
        }

        BeController.PlayNextOutside(beBlock);
    }
コード例 #12
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        if (beBlock.BeInputs.stringValues[0] == "Random")
        {
            targetObject.GetComponent <Renderer>().material.color = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
        }
        else
        {
            mat = BeController.GetColor(beBlock.BeInputs.stringValues[0]);
            targetObject.GetComponent <Renderer>().material.color = mat.color;
        }

        BeController.PlayNextOutside(beBlock);
    }
コード例 #13
0
    public override string BEOperation(BETargetObject targetObject, BEBlock beBlock)
    {
        if (beBlock.BeInputs.isString)
        {
            result = beBlock.BeInputs.stringValues[0] + beBlock.BeInputs.stringValues[1];
        }
        else
        {
            float tempResult = beBlock.BeInputs.numberValues[0] + beBlock.BeInputs.numberValues[1];
            result = tempResult.ToString(CultureInfo.InvariantCulture);
        }

        return(result);
    }
コード例 #14
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        if (beBlock.beBlockFirstPlay)
        {
            counterForRepetitions    = (int)beBlock.BeInputs.numberValues[1];
            beBlock.beBlockFirstPlay = false;
        }

        // [0] first input (dropdown)
        // options: up-right, up-left, down-right, down-left, right-up, right-down, left-up, left-down
        string option = beBlock.BeInputs.stringValues[0];

        string[] options = option.Split('-');

        //movements
        Vector3 firstMovement  = GetDirection(options[0]);
        Vector3 secondMovement = GetDirection(options[1]);

        Vector3[] movements = new[] { firstMovement, firstMovement, secondMovement };

        if (counterForMovement == 0)
        {
            startPos = targetObject.transform.position;
        }

        if (counterForMovement <= movementDuration)
        {
            counterForMovement += Time.deltaTime;
            targetObject.transform.position = Vector3.Lerp(startPos, startPos + movements[moveSelection], counterForMovement / movementDuration);
        }
        else
        {
            moveSelection++;
            counterForMovement = 0;
        }

        if (moveSelection == 3)
        {
            moveSelection      = 0;
            counterForMovement = 0;
            counterForRepetitions--;

            if (counterForRepetitions <= 0)
            {
                beBlock.beBlockFirstPlay = true;
                BeController.PlayNextOutside(beBlock);
            }
        }
    }
コード例 #15
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        try
        {
            float newValue = float.Parse(BeController.GetVariable(beBlock.BeInputs.stringValues[0]), CultureInfo.InvariantCulture)
                             + beBlock.BeInputs.numberValues[1];
            BeController.SetVariable(beBlock.BeInputs.stringValues[0], newValue.ToString(CultureInfo.InvariantCulture));
        }
        catch
        {
            string newValue = BeController.GetVariable(beBlock.BeInputs.stringValues[0]);
            BeController.SetVariable(beBlock.BeInputs.stringValues[0], newValue.ToString(CultureInfo.InvariantCulture));
        }

        BeController.PlayNextOutside(beBlock);
    }
コード例 #16
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        Vector3 axis = Vector3.up;

        if (targetObject.GetComponent <Collider2D>())
        {
            axis = Vector3.forward;
        }
        else if (targetObject.GetComponent <Collider>())
        {
            axis = Vector3.up;
        }

        targetObject.transform.Rotate(axis, 90);

        BeController.PlayNextOutside(beBlock);
    }
コード例 #17
0
 public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
 {
     if (beBlock.BeInputs.stringValues[0] == "1")
     {
         BeController.PlayNextOutside(beBlock);
     }
     else
     {
         if (beBlock.beChildBlocksList.Count > 0)
         {
             BeController.PlayNextInside(beBlock);
         }
         else
         {
             BeController.PlayNextOutside(beBlock);
         }
     }
 }
コード例 #18
0
    public override string BEOperation(BETargetObject targetObject, BEBlock beBlock)
    {
        switch (beBlock.BeInputs.stringValues[0])
        {
        case "ArrowUp":
            beJoyButton = BeController.beJoystick.arrowUpButton;
            break;

        case "ArrowLeft":
            beJoyButton = BeController.beJoystick.arrowLeftButton;
            break;

        case "ArrowDown":
            beJoyButton = BeController.beJoystick.arrowDownButton;
            break;

        case "ArrowRight":
            beJoyButton = BeController.beJoystick.arrowRightButton;
            break;

        case "ButtonA":
            beJoyButton = BeController.beJoystick.buttonA;
            break;

        case "ButtonB":
            beJoyButton = BeController.beJoystick.buttonB;
            break;

        default:
            beJoyButton = null;
            break;
        }

        if (beJoyButton.isPressed)
        {
            result = "1";
        }
        else
        {
            result = "0";
        }

        return(result);
    }
コード例 #19
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        switch (beBlock.BeInputs.stringValues[0])
        {
        case "ArrowUp":
            beJoyButton = BeController.beJoystick.arrowUpButton;
            break;

        case "ArrowLeft":
            beJoyButton = BeController.beJoystick.arrowLeftButton;
            break;

        case "ArrowDown":
            beJoyButton = BeController.beJoystick.arrowDownButton;
            break;

        case "ArrowRight":
            beJoyButton = BeController.beJoystick.arrowRightButton;
            break;

        case "ButtonA":
            beJoyButton = BeController.beJoystick.buttonA;
            break;

        case "ButtonB":
            beJoyButton = BeController.beJoystick.buttonB;
            break;

        default:
            beJoyButton = null;
            break;
        }

        if (beJoyButton.isPressed)
        {
            beBlock.BeBlockGroup.isActive = true;
            BeController.PlayNextInside(beBlock);
        }
        else
        {
            beBlock.BeBlockGroup.isActive = false;
            BeController.StopGroup(beBlock.BeBlockGroup);
        }
    }
コード例 #20
0
    public override string BEOperation(BETargetObject targetObject, BEBlock beBlock)
    {
        if (beBlock.beBlockFirstPlay)
        {
            beBlock.beBlockCounter   = (int)beBlock.BeInputs.numberValues[0];
            beBlock.beBlockFirstPlay = false;
        }

        if (beBlock.beBlockCounter > 0)
        {
            beBlock.beBlockCounter--;
            return("1");
        }
        else
        {
            beBlock.beBlockFirstPlay = true;
            return("0");
        }
    }
コード例 #21
0
    public override string BEOperation(BETargetObject targetObject, BEBlock beBlock)
    {
        if (targetObject.GetComponent <Collider2D>())
        {
            Collider2D[] hitColliders = Physics2D.OverlapBoxAll(targetObject.transform.position, transform.localScale / 2, 0);
            int          i            = 0;
            while (i < hitColliders.Length)
            {
                value = "0";

                if (hitColliders[i].transform != targetObject.transform)
                {
                    if (beBlock.BeInputs.stringValues[0] == hitColliders[i].GetComponent <Renderer>().sharedMaterial.name)
                    {
                        value = "1";
                        break;
                    }
                }
                i++;
            }
        }
        else if (targetObject.GetComponent <Collider>())
        {
            Collider[] hitColliders = Physics.OverlapBox(targetObject.transform.position, transform.localScale / 2, Quaternion.identity);
            int        i            = 0;
            while (i < hitColliders.Length)
            {
                value = "0";

                if (hitColliders[i].transform != targetObject.transform)
                {
                    if (beBlock.BeInputs.stringValues[0] == hitColliders[i].GetComponent <Renderer>().sharedMaterial.name)
                    {
                        value = "1";
                        break;
                    }
                }
                i++;
            }
        }

        return(value);
    }
コード例 #22
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        if (beBlock.beBlockFirstPlay)
        {
            counter = beBlock.BeInputs.numberValues[0];

            beBlock.beBlockFirstPlay = false;
        }
        if (counter > 0)
        {
            counter -= Time.deltaTime;
        }
        else
        {
            beBlock.beBlockFirstPlay = true;
            counter = 0;
            BeController.PlayNextOutside(beBlock);
        }
    }
コード例 #23
0
    void Start()
    {
        menuMessage.text  = defaultMessage;
        particlesWinGame  = particlesWinGameGO.GetChild(0).GetComponent <ParticleSystem>();
        particlesLoseGame = particlesLoseGameGO.GetChild(0).GetComponent <ParticleSystem>();

        pathCreator            = GetComponent <PathCreator>();
        cameraFramer           = GetComponent <CameraFraming>();
        beController           = pathCreator.beController;
        beTargetObject         = BEController.beTargetObjectList[0];
        beTargetObjectRigdbody = beTargetObject.GetComponent <Rigidbody>();
        gameIsPlaying          = false;
        sandBoxBounds          = new Renderer[sandboxScene.transform.GetComponentsInChildren <BoxCollider>().Length];
        var i = 0;

        foreach (BoxCollider collider in sandboxScene.transform.GetComponentsInChildren <BoxCollider>())
        {
            sandBoxBounds[i] = collider.GetComponent <Renderer>();
            i++;
        }
    }
コード例 #24
0
    public void WriteVirtualCodeToFile(string path, BETargetObject beTargetObject)
    {
        virtualCode = new List <string>();
        if (path.Length != 0)
        {
            virtualCode.Clear();

            foreach (BEBlock blockGroup in beTargetObject.beBlockGroupsList)
            {
                BEBlock block = blockGroup.GetComponent <BEBlock>();

                virtualCode.AddRange(TranslateBlockGroupToVirtualCode(block));
            }

            writer = new StreamWriter(path, false);
            foreach (string line in virtualCode)
            {
                writer.WriteLine(line);
            }
            writer.Close();
        }
    }
コード例 #25
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        if (beBlock.beBlockFirstPlay)
        {
            counterForRepetitions = (int)beBlock.BeInputs.numberValues[0];
            startPos = targetObject.transform.position;
            beBlock.beBlockFirstPlay = false;
        }

        if (counterForMovement == 0)
        {
            startPos = targetObject.transform.position;
        }

        if (counterForMovement <= movementDuration)
        {
            counterForMovement += Time.deltaTime;
            if (targetObject.GetComponent <Collider2D>())
            {
                direction = targetObject.transform.right;
            }
            else if (targetObject.GetComponent <Collider>())
            {
                direction = targetObject.transform.forward;
            }
            targetObject.transform.position = Vector3.Lerp(startPos, startPos + direction, counterForMovement / movementDuration);
        }
        else
        {
            counterForMovement = 0;
            counterForRepetitions--;

            if (counterForRepetitions <= 0)
            {
                beBlock.beBlockFirstPlay = true;
                BeController.PlayNextOutside(beBlock);
            }
        }
    }
コード例 #26
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        try
        {
            key = (KeyCode)System.Enum.Parse(typeof(KeyCode), beBlock.BeInputs.stringValues[0]);
        }
        catch (Exception e)
        {
            Debug.Log("probably still initializing");
            Debug.Log(e);
        }

        if (Input.GetKey(key))
        {
            beBlock.BeBlockGroup.isActive = true;
            BeController.PlayNextInside(beBlock);
        }
        else if (!Input.GetKey(key))
        {
            beBlock.BeBlockGroup.isActive = false;
            BeController.StopGroup(beBlock.BeBlockGroup);
        }
    }
コード例 #27
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        Vector3 axis = Vector3.up;

        switch (beBlock.BeInputs.stringValues[0])
        {
        case "Left":
            if (targetObject.GetComponent <Collider2D>())
            {
                axis = Vector3.forward;
            }
            else if (targetObject.GetComponent <Collider>())
            {
                axis = Vector3.up;
            }
            targetObject.transform.Rotate(axis, -90);
            break;

        case "Right":
            if (targetObject.GetComponent <Collider2D>())
            {
                axis = Vector3.forward;
            }
            else if (targetObject.GetComponent <Collider>())
            {
                axis = Vector3.up;
            }
            targetObject.transform.Rotate(axis, 90);
            break;

        default:
            break;
        }

        BeController.PlayNextOutside(beBlock);
    }
コード例 #28
0
 public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
 {
     BeController.PlayNextInside(beBlock);
 }
コード例 #29
0
    public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
    {
        if (targetObject.GetComponent <Collider2D>())
        {
            switch (beBlock.BeInputs.stringValues[0])
            {
            case "Forward":
                targetObject.transform.eulerAngles = new Vector3(0, 0, 0);
                break;

            case "Back":
                targetObject.transform.eulerAngles = new Vector3(0, 0, 180);
                break;

            case "Up":
                targetObject.transform.eulerAngles = new Vector3(0, 0, 90);
                break;

            case "Down":
                targetObject.transform.eulerAngles = new Vector3(0, 0, -90);
                break;

            case "Left":
                targetObject.transform.eulerAngles = new Vector3(0, 0, 180);
                break;

            case "Right":
                targetObject.transform.eulerAngles = new Vector3(0, 0, 0);
                break;

            default:
                targetObject.transform.eulerAngles = new Vector3(0, 0, 90);
                break;
            }
        }
        else if (targetObject.GetComponent <Collider>())
        {
            switch (beBlock.BeInputs.stringValues[0])
            {
            case "Forward":
                targetObject.transform.eulerAngles = new Vector3(0, 0, 0);
                break;

            case "Back":
                targetObject.transform.eulerAngles = new Vector3(0, 180, 0);
                break;

            case "Up":
                targetObject.transform.eulerAngles = new Vector3(-90, 0, 0);
                break;

            case "Down":
                targetObject.transform.eulerAngles = new Vector3(90, 0, 0);
                break;

            case "Left":
                targetObject.transform.eulerAngles = new Vector3(0, -90, 0);
                break;

            case "Right":
                targetObject.transform.eulerAngles = new Vector3(0, 90, 0);
                break;

            default:
                targetObject.transform.eulerAngles = new Vector3(0, 0, 0);
                break;
            }
        }

        BeController.PlayNextOutside(beBlock);
    }
コード例 #30
0
 public override void BEFunction(BETargetObject targetObject, BEBlock beBlock)
 {
     BeController.SetVariable(beBlock.BeInputs.stringValues[0], beBlock.BeInputs.stringValues[1]);
     BeController.PlayNextOutside(beBlock);
 }