Ejemplo n.º 1
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);
    }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
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);
    }
    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);
    }
    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);
    }
    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);
            }
        }
    }
    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);
    }
    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++;
        }
    }
Ejemplo n.º 9
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);
    }