コード例 #1
0
ファイル: undo.cs プロジェクト: Beritens/buoyancy
    public void redo()
    {
        if (sizeThing != null)
        {
            sizeThing.addCurrent();
        }
        else if (sizeThing == null && GameObject.Find("sizeStuff(Clone)"))
        {
            sizeThing = GameObject.Find("sizeStuff(Clone)").GetComponent <sizeThing>();
            sizeThing.addCurrent();
        }
        int howMuch = 0;

        if (reddo)
        {
            howMuch--;
        }
        if (history[HisPos + howMuch + 1].whatToDo == 0 || history[HisPos + howMuch + 1].whatToDo == 14)
        {
            howMuch--;
        }

        reddo = false;

        howMuch += 2;
        if (HisPos + howMuch >= history.Count - 1)
        {
            redoB.SetActive(false);
        }
        undoB.SetActive(true);

        blub(HisPos + howMuch);
    }
コード例 #2
0
ファイル: undo.cs プロジェクト: Beritens/buoyancy
    public void undoo()
    {
        if (sizeThing != null)
        {
            sizeThing.addCurrent();
        }
        else if (sizeThing == null && GameObject.Find("sizeStuff(Clone)"))
        {
            sizeThing = GameObject.Find("sizeStuff(Clone)").GetComponent <sizeThing>();
            sizeThing.addCurrent();
        }

        int howMuch = 0;

        if (!reddo)
        {
            howMuch++;
        }
        if (history[HisPos + howMuch - 1].whatToDo == 0 || history[HisPos + howMuch - 1].whatToDo == 14)
        {
            HisPos++;
        }
        reddo    = true;
        howMuch -= 2;
        if (HisPos + howMuch == 0)
        {
            undoB.SetActive(false);
        }
        blub(HisPos + howMuch);


        redoB.SetActive(true);
    }
コード例 #3
0
ファイル: createGroup.cs プロジェクト: Beritens/buoyancy
    public void ExitGroup()
    {
        editing = false;
        state   = 1;
        darkThingOff();
        if (sizeStuff == null && GameObject.Find("sizeStuff(Clone)"))
        {
            sizeStuff = GameObject.Find("sizeStuff(Clone)").GetComponent <sizeThing>();
        }

        if (sizeStuff != null)
        {
            sizeStuff.reselect(groupy);
        }
        else
        {
            GameObject sizeStuffy = GameObject.Instantiate(sizeThing, transform.position, Quaternion.identity);
            groupy.GetComponent <BoxCollider2D>().enabled = true;
            sizeStuffy.GetComponent <sizeThing>().square  = groupy.transform;
            sizeStuff = sizeStuffy.GetComponent <sizeThing>();
            //groupy.Find("outline").gameObject.SetActive(true);
            groupy.gameObject.layer = 8;
        }
        openMenu.openTheMenu();
        optionStuff.select(groupy.gameObject);
        textMesh.text = "edit Group";
    }
コード例 #4
0
ファイル: createGroup.cs プロジェクト: Beritens/buoyancy
 public void click()
 {
     if (state == 0)
     {
         makeGroup();
     }
     else if (state == 1)
     {
         if (sizeStuff == null)
         {
             sizeStuff = GameObject.Find("sizeStuff(Clone)").GetComponent <sizeThing>();
         }
         EditGroup(GameObject.Find("sizeStuff(Clone)").GetComponent <sizeThing>().square);
     }
     else if (state == 2)
     {
         ExitGroup();
     }
 }
コード例 #5
0
ファイル: createGroup.cs プロジェクト: Beritens/buoyancy
 public void makeGroup()
 {
     if (GameObject.Find("sizeStuff(Clone)"))
     {
         if (sizeStuff == null)
         {
             sizeStuff = GameObject.Find("sizeStuff(Clone)").GetComponent <sizeThing>();
         }
         Transform square = sizeStuff.square;
         if (square.parent == null)
         {
             GameObject bob = GameObject.Instantiate(group, square.position, Quaternion.identity);
             bob.GetComponent <Draggable>().ObjectLPos = undo.allThings.Count;
             undo.allThings.Add(bob);
             square.parent = bob.transform;
             sizeStuff.reselect(bob.transform);
             optionStuff.select(bob);
             EditGroup(bob.transform);
             undo.add(square.gameObject, 14, true);
         }
     }
 }
コード例 #6
0
    void Update()
    {
        if (Input.touchCount == 1 && !EventSystem.current.IsPointerOverGameObject(0))
        {
            Touch touch = Input.GetTouch(0);

            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                timey = 0;
                nana  = false;


                Vector3 touchPos        = Camera.main.ScreenToWorldPoint(touch.position);
                Vector2 touchPosWorld2D = new Vector2(touchPos.x, touchPos.y);


                if (!colorStuff.eyeDropper && !GetComponent <isSomethingOpen>().SomethingOpen)
                {
                    /*RaycastHit2D[] hits = Physics2D.RaycastAll(touchPosWorld2D, Camera.main.transform.forward);
                     * if(hits.Length == 1 ){
                     *
                     *      if(hits[0].transform.tag == "Player" || hits[0].transform.tag == "ground" || hits[0].transform.tag == "water" || hits[0].transform.tag == "obstacle" || hits[0].transform.tag == "goal" || hits[0].transform.tag == "deko"){
                     *              //print("hm");
                     *              if(!hits[0].transform.GetComponent<Draggable>().ok){
                     *                      //print("was?");
                     *                      touchedObject = hits[0].transform.gameObject;
                     *                      nana = true;
                     *              }
                     *
                     *      }
                     * }
                     * else if(hits.Length > 1){
                     *      touchedObject =dasDing(hits);
                     * }*/


                    touchPos.z = -10.1f;
                    Ray          ray = new Ray(touchPos, new Vector3(0, 0, 1));
                    RaycastHit2D hit = Physics2D.GetRayIntersection(ray, Mathf.Infinity, layerMask);
                    if (hit.collider != null)
                    {
                        if (hit.transform.tag == "Player" || hit.transform.tag == "ground" || hit.transform.tag == "water" || hit.transform.tag == "obstacle" || hit.transform.tag == "goal" || hit.transform.tag == "deko")
                        {
                            //touchedObject = hit.collider.gameObject;
                            bruh          = true;
                            touchedObject = hit.collider.gameObject;
                            difference    = touch.position;
                        }
                    }
                }
                else if (colorStuff.eyeDropper)
                {
                    RaycastHit2D hit = Physics2D.Raycast(touchPosWorld2D, Camera.main.transform.forward, 0, layerMask);
                    if (hit.collider != null)
                    {
                        Color color = hit.collider.GetComponent <SpriteRenderer>().color;
                        colorStuff.change(color, true);



                        colorStuff.EYEDROPPER();
                    }
                }
            }
            timey += Time.deltaTime;
            if (bruh && Input.GetTouch(0).phase == TouchPhase.Ended && Vector2.SqrMagnitude(touch.position - difference) < Screen.height / MaxDifference && timey < maxTime)
            {
                if (!colorStuff.eyeDropper && !GetComponent <isSomethingOpen>().SomethingOpen&& !EventSystem.current.IsPointerOverGameObject(0))
                {
                    Vector3 touchPos        = Camera.main.ScreenToWorldPoint(touch.position);
                    Vector2 touchPosWorld2D = new Vector2(touchPos.x, touchPos.y);



                    touchPos.z = Camera.main.transform.position.z;

                    /*Ray ray = new Ray( touchPos, new Vector3( 0, 0, 1 ) );
                     * RaycastHit2D hit = Physics2D.GetRayIntersection( ray );*/
                    //if(hit.collider != null){
                    //if(hit.transform.tag == "Player" || hit.transform.tag == "ground" || hit.transform.tag == "water" || hit.transform.tag == "obstacle" || hit.transform.tag == "goal" || hit.transform.tag == "deko"){



                    /*if(touchedObject.tag == "water"){
                     *      WaterStuff.SetActive(true);
                     * }
                     * else{
                     *      WaterStuff.SetActive(false);
                     * }*/
                    createGroup.gameObject.SetActive(true);

                    if (GameObject.Find("sizeStuff(Clone)"))
                    {
                        sizeThing sizeThing = GameObject.Find("sizeStuff(Clone)").GetComponent <sizeThing>();
                        if (touchedObject.transform.parent != null && sizeThing.square != touchedObject.transform.parent && sizeThing.square.parent != touchedObject.transform.parent)
                        {
                            sizeThing.reselect(touchedObject.transform.parent);
                            optionStuff.select(touchedObject.transform.parent.gameObject);
                        }
                        else
                        {
                            sizeThing.reselect(touchedObject.transform);


                            //ColorStuff(touchedObject.GetComponent<SpriteRenderer>().color);
                            if (colorStuff.gameObject.activeSelf)
                            {
                                colorStuff.change(touchedObject.GetComponent <SpriteRenderer>().color, false);
                            }
                            optionStuff.select(touchedObject);
                        }
                    }
                    else
                    {
                        spawn();
                        optionStuff.select(touchedObject);
                    }



                    //}
                    //}
                }



                /*if((touchedObject != null && nana && !EventSystem.current.IsPointerOverGameObject(0))){
                 *
                 *      if(GameObject.Find("sizeStuff(Clone)")){
                 *              GameObject.Find("sizeStuff(Clone)").GetComponent<sizeThing>().reselect(touchedObject.transform);
                 *              ColorStuff(touchedObject.GetComponent<SpriteRenderer>().color);
                 *
                 *      }
                 *      else{
                 *              spawn();
                 *      }
                 * }*/
            }
        }
    }
コード例 #7
0
ファイル: undo.cs プロジェクト: Beritens/buoyancy
    void blub(int Pos)
    {
        //GameObject thing = GetObject(history[Pos].tag, history[Pos].number, Pos);

        if (history[Pos].tag != "")
        {
            GameObject thing = allThings[history[Pos].number];

            int     WTD = history[Pos].whatToDo;
            float[] lol = history[Pos].größen;
            sizeThing = null;
            bool change = false;
            if (GameObject.Find("sizeStuff(Clone)"))
            {
                sizeThing = GameObject.Find("sizeStuff(Clone)").GetComponent <sizeThing>();
                if (history[Pos].number != sizeThing.square.GetComponent <Draggable>().ObjectLPos)
                {
                    change = true;
                }
            }
            switch (WTD)
            {
            case 0:
                if (thing.activeSelf)
                {
                    thing.layer = 0;
                    //thing.transform.Find("outline").gameObject.SetActive(false);
                    thing.SetActive(false);
                    if (sizeThing != null && !change)
                    {
                        menu.closeTheMenu();
                        sizeThing.deselect();
                    }

                    change = false;
                }
                else
                {
                    thing.SetActive(true);
                }
                break;

            case 1:
                print("lol");
                thing.transform.position   = new Vector3(lol[0], lol[1], lol[2]);
                thing.transform.localScale = new Vector3(lol[3], lol[4], 0);
                if (sizeThing != null && !change)
                {
                    sizeThing.reselect(thing.transform);
                    optionStuff.changePosition();
                    optionStuff.changeScale();
                }
                break;

            case 2:
                thing.transform.position = new Vector3(lol[0], lol[1], lol[2]);
                if (sizeThing != null && !change)
                {
                    sizeThing.reselect(thing.transform);
                    optionStuff.changePosition();
                }
                break;

            case 3:
                thing.transform.rotation = Quaternion.Euler(0, 0, lol[0]);
                if (sizeThing != null && !change)
                {
                    optionStuff.changeRotation();
                    sizeThing.reselect(thing.transform);
                }
                break;

            case 4:
                Color coloryy = new Color(lol[0], lol[1], lol[2], lol[3]);
                thing.GetComponent <SpriteRenderer>().color = coloryy;
                if (!change)
                {
                    optionStuff.changeColor(coloryy);
                }
                break;

            case 7:
                thing.GetComponent <water>().waterForceX = lol[0];
                Color colory = new Color(lol[1], lol[2], lol[3], lol[4]);
                thing.GetComponent <SpriteRenderer>().color = colory;
                if (!change)
                {
                    optionStuff.changeWaterX();
                    optionStuff.changeColor(colory);
                }
                break;

            case 8:
                thing.GetComponent <water>().waterForceY = lol[0];
                Color color = new Color(lol[1], lol[2], lol[3], lol[4]);
                thing.GetComponent <SpriteRenderer>().color = color;
                if (!change)
                {
                    optionStuff.changeWaterY();
                    optionStuff.changeColor(color);
                }
                break;

            case 9:
                if (thing.tag == "Player")
                {
                    thing.GetComponent <CircleCollider2D>().enabled = false;
                }
                else
                {
                    thing.GetComponents <PolygonCollider2D>()[2].enabled = false;
                }
                thing.GetComponents <PolygonCollider2D>()[1].enabled = false;
                thing.GetComponents <PolygonCollider2D>()[0].enabled = false;
                if (sizeThing == null || change)
                {
                    thing.GetComponent <BoxCollider2D>().enabled = false;
                }

                int shape = (int)lol[0];
                switch (shape)
                {
                case 0:

                    thing.GetComponent <BoxCollider2D>().enabled = true;
                    break;

                case 1:
                    if (thing.tag == "Player")
                    {
                        thing.GetComponent <CircleCollider2D>().enabled = true;
                    }
                    else
                    {
                        thing.GetComponents <PolygonCollider2D>()[2].enabled = true;
                    }

                    break;

                case 2:
                    thing.GetComponents <PolygonCollider2D>()[1].enabled = true;
                    break;

                case 3:
                    thing.GetComponents <PolygonCollider2D>()[0].enabled = true;
                    break;
                }
                thing.GetComponent <SpriteRenderer>().sprite = shapes[shape];

                if (!change)
                {
                    optionStuff.changeTheShape();
                }
                break;

            case 10:
                thing.transform.localScale = new Vector3(lol[3], lol[4], 0);
                if (sizeThing != null && !change)
                {
                    optionStuff.changeScale();
                    sizeThing.reselect(thing.transform);
                }
                break;

            case 11:
                thing.GetComponent <Draggable>().bounciness = lol[0];
                if (!change)
                {
                    optionStuff.changeBounciness();
                }
                break;

            case 12:
                thing.GetComponent <Draggable>().falling = lol[0] == 1;
                if (!change)
                {
                    optionStuff.changeFalling();
                }
                break;

            case 13:
                thing.GetComponent <Draggable>().mass = lol[0];
                if (!change)
                {
                    optionStuff.changeMass();
                }
                break;

            case 14:
                if (thing.transform.parent == allThings[(int)lol[0]].transform)
                {
                    allThings[(int)lol[0]].SetActive(false);
                    thing.transform.parent = null;
                    if (createGroup.groupy == allThings[(int)lol[0]].transform && createGroup.editing)
                    {
                        createGroup.darkThingOff();
                        createGroup.editing = false;
                    }
                }
                else
                {
                    allThings[(int)lol[0]].SetActive(true);
                    thing.transform.parent = allThings[(int)lol[0]].transform;
                    if (sizeThing != null && !change)
                    {
                        //change = false;
                        sizeThing.reselect(thing.transform);
                    }
                }
                break;

            case 15:
                thing.transform.rotation = Quaternion.Euler(0, 0, lol[0]);
                thing.transform.position = new Vector3(lol[1], lol[2], thing.transform.position.z);
                if (sizeThing != null && !change)
                {
                    sizeThing.reselect(thing.transform);
                    optionStuff.changePosition();
                }
                break;
            }
            if (change)
            {
                sizeThing.reselect(thing.transform);
                optionStuff.select(thing);
            }

            /*thing.transform.position = lol.pos;
             * thing.transform.localScale = lol.scale;
             * thing.transform.rotation = lol.rotation;
             * thing.GetComponent<SpriteRenderer>().color = lol.color;
             * if(thing.tag == "water"){
             *      thing.GetComponent<water>().waterForceX = lol.WaterPower.x;
             *      thing.GetComponent<water>().waterForceY = lol.WaterPower.y;
             * }
             * if(GameObject.Find("sizeStuff(Clone)")){
             *      sizeThing sizeStuff = GameObject.Find("sizeStuff(Clone)").GetComponent<sizeThing>();
             *      if(sizeStuff.square.gameObject == thing){
             *              sizeStuff.reselect(thing.transform);
             *      }
             * }*/
        }
        else
        {
            float[] lol = history[Pos].größen;
            Color   col = new Color(lol[0], lol[1], lol[2], 1);
            if (history[Pos].whatToDo == 5)
            {
                cam.bg1 = col;
                print("undo Zeugs");
                cam.GetComponent <Camera>().backgroundColor = col;
            }
            else
            {
                cam.bg2 = col;
            }
            //changeBackground.changebgColor();
        }
        HisPos = Pos;
    }