예제 #1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Portal.SetActive(true);
        }

        //use bools to make this section go off only if there's a change?
        bool shopisactive = (MICollider.isActive() || InvCol.isActive() || Portal.isActive() || questmenu.activeSelf || actualslots.activeSelf || actualwizard.activeSelf);

        quest.GetComponent <BoxCollider>().enabled       = !shopisactive;
        slotmachine.GetComponent <BoxCollider>().enabled = !shopisactive;
        portal.GetComponent <BoxCollider>().enabled      = !shopisactive;
        iteminv.GetComponent <BoxCollider>().enabled     = !shopisactive;
        iteminv.GetComponent <SpriteRenderer>().enabled  = !shopisactive;
        moninv.GetComponent <SpriteRenderer>().enabled   = !shopisactive;
        moninv.GetComponent <BoxCollider>().enabled      = !shopisactive;
        movewizard.GetComponent <BoxCollider>().enabled  = !shopisactive;
        menubut.SetActive(!shopisactive);
        backbut.SetActive(!shopisactive);
        //if (Input.GetKeyDown("space"))
        //print(go == go2);

        if (Input.touchCount == 1 && onehit)
        {
            if (!shopisactive)
            {
                // touch on screen
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                    RaycastHit hit = new RaycastHit();
                    moving = Physics.Raycast(ray, out hit);
                    if (moving)
                    {
                        go = hit.transform.gameObject;
                        //Debug.Log("Touch Detected on : " + go.name);
                    }
                    else
                    {
                        onehit = false;
                    }
                }


                // release touch/dragging
                if ((Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.touchCount != 1) && go != null && onehit)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                    RaycastHit hit = new RaycastHit();
                    moving = Physics.Raycast(ray, out hit);
                    if (moving)
                    {
                        go2 = hit.transform.gameObject;
                    }
                    moving = false;

                    if (go == quest && go == go2)
                    {
                        questmenu.SetActive(true);
                    }
                    else if (go == portal && go == go2)
                    {
                        Portal.SetActive(true);
                    }
                    else if (go == slotmachine && go == go2)
                    {
                        actualslots.SetActive(true);
                    }

                    else if (go == iteminv && go == go2)
                    {
                        InvCol.SetActive(true);
                    }
                    else if (go == moninv && go == go2)
                    {
                        MICollider.SetActive(true);
                    }
                    else if (go == movewizard && go == go2)
                    {
                        actualwizard.SetActive(true);
                    }
                }
            }
        }
        else
        {
            go     = null;
            go2    = null;
            onehit = true;
        }
    }
예제 #2
0
    void Update()
    {
        /*if (Input.GetKeyDown("space"))
         * {
         *  SaveLoad.Save(SaveCallBack);
         *  GlobalData.loadGame = true;
         *
         *  StartCoroutine("Fader");
         * }*/

        if (player.GetPlayer().moninv.IsEmpty())
        {
            gameover.SetActive(true);
            gameObject.SetActive(false);
        }


        //use bools to make this section go off only if there's a change?
        bool shopisactive = (ShopMain.isActive() || MICollider.isActive() || InvCol.isActive() || BookControl.isActive());

        shop.GetComponent <BoxCollider>().enabled       = !shopisactive;
        fountain.GetComponent <BoxCollider>().enabled   = !shopisactive;
        book.GetComponent <BoxCollider>().enabled       = !shopisactive;
        adventure.GetComponent <BoxCollider>().enabled  = !shopisactive;
        iteminv.GetComponent <BoxCollider>().enabled    = !shopisactive;
        iteminv.GetComponent <SpriteRenderer>().enabled = !shopisactive;
        moninv.GetComponent <SpriteRenderer>().enabled  = !shopisactive;
        moninv.GetComponent <BoxCollider>().enabled     = !shopisactive;
        downtown.GetComponent <BoxCollider>().enabled   = !shopisactive;
        menubut.SetActive(!shopisactive);
        //if (Input.GetKeyDown("space"))
        //print(go == go2);

        if (Input.touchCount == 1 && onehit)
        {
            if (!shopisactive)
            {
                // touch on screen
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                    RaycastHit hit = new RaycastHit();
                    moving = Physics.Raycast(ray, out hit);
                    if (moving)
                    {
                        go = hit.transform.gameObject;
                        //Debug.Log("Touch Detected on : " + go.name);
                    }
                    else
                    {
                        onehit = false;
                    }
                }


                // release touch/dragging
                if ((Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.touchCount != 1) && go != null && onehit)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                    RaycastHit hit = new RaycastHit();
                    moving = Physics.Raycast(ray, out hit);
                    if (moving)
                    {
                        go2 = hit.transform.gameObject;
                    }
                    moving = false;
                    //Debug.Log("Touch Released from : " + go.name);
                    if (go == shop && go == go2)
                    {
                        ShopMain.ShopSet(true);
                    }
                    else if (go == fountain && go == go2)
                    {
                        player.GetPlayer().moninv.HealAll();
                        if (canenter)
                        {
                            StartCoroutine("HealSprite");
                        }
                        //play sound
                        SaveLoad.Save(SaveCallBack);
                    }
                    else if (go == book && go == go2)
                    {
                        BookControl.BookSet(true);
                    }
                    else if (go == adventure && go == go2)
                    {
                        if (player.GetPlayer().moninv.HasAnActive())
                        {
                            SaveLoad.Save(SaveCallBack);
                            GlobalData.loadGame = true;

                            //fader.color = Color.clear;
                            //SceneManager.LoadScene("Adventure");
                            StartCoroutine("Fader", "Adventure");
                        }
                        else
                        {
                            //you need at least one active monster to adventure!
                        }
                    }
                    else if (go == iteminv && go == go2)
                    {
                        InvCol.SetActive(true);
                    }
                    else if (go == moninv && go == go2)
                    {
                        MICollider.SetActive(true);
                    }
                    else if (go == downtown && go == go2)
                    {
                        SaveLoad.Save(SaveCallBack);
                        GlobalData.loadGame = true;
                        StartCoroutine("Fader", "Downtown");
                    }
                }
            }
        }
        else
        {
            go     = null;
            go2    = null;
            onehit = true;
        }
    }
예제 #3
0
    void Update()
    {
        if (recsel != null)
        {
            touchtochange.SetActive(true);
        }
        else
        {
            touchtochange.SetActive(false);
        }

        if (Input.touchCount > 0 && onehit && !STOP)
        {
            // touch on screen
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                RaycastHit hit = new RaycastHit();
                moving = Physics.Raycast(ray, out hit);
                if (moving)
                {
                    go = hit.transform.gameObject;
                    if (go.GetComponent <InvSlot>() != null)
                    {
                        if (go.GetComponent <InvSlot>().isTaken())
                        {
                            selected = go;

                            if (recsel != null)
                            {
                                recsel.GetComponent <InvSlot>().Deselect();
                            }

                            recsel = go;
                            recsel.GetComponent <InvSlot>().Select();
                            info.Set(recsel.GetComponent <InvSlot>().curMonster);
                        }
                    }
                    //Debug.Log("Touch Detected on : " + go.name);
                }
                else
                {
                    onehit = false;
                }
            }

            if (selected != null)
            {
                selected.GetComponent <BoxCollider>().enabled = false;
                fingerpos = Input.GetTouch(0).position;
                temp1     = fingerpos;
                temp1.z   = 3;
                temp2     = Camera.main.ScreenToWorldPoint(temp1);
                selected.transform.position = Vector3.Lerp(selected.transform.position, temp2, Time.deltaTime * 20);
            }

            // release touch/dragging
            if ((Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.touchCount != 1) && go != null && onehit)
            {
                //moving = false;

                Ray        ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
                RaycastHit hit = new RaycastHit();
                moving = Physics.Raycast(ray, out hit);
                if (moving)
                {
                    go2    = hit.transform.gameObject;
                    moving = false;
                }

                if (go2 == close && selected != null)
                {
                    selected.GetComponent <InvSlot>().SnapBack();
                    selected.GetComponent <BoxCollider>().enabled = true;
                }
                else if (go2 == setfree && selected != null && !player.moninv.OnlyOne())
                {
                    selected.GetComponent <InvSlot>().SnapBack();
                    selected.GetComponent <BoxCollider>().enabled = true;

                    player.moninv.RemoveMonster(selected.GetComponent <InvSlot>().curMonster);

                    selected = null; swaptarget = null;
                    recsel.GetComponent <InvSlot>().Deselect(); recsel = null;
                    info.Erase();
                    UpSlots();
                } //else if (onlyone) show "cant throw away only monster"
                else if (go2 == setfree && selected != null && player.moninv.OnlyOne())
                {
                    selected.GetComponent <InvSlot>().SnapBack();
                    selected.GetComponent <BoxCollider>().enabled = true;
                }
                else if (go2 != null && selected != null)
                {
                    if (go2.GetComponent <InvSlot>() != null)
                    {
                        if (go2.GetComponent <InvSlot>().isTaken())
                        {
                            swaptarget = go2;
                            selected.GetComponent <InvSlot>().SnapBack();
                            selected.GetComponent <BoxCollider>().enabled = true;
                            player.moninv.SwapPos(selected.GetComponent <InvSlot>().curMonster, swaptarget.GetComponent <InvSlot>().curMonster);
                            selected = null; swaptarget = null;
                            recsel.GetComponent <InvSlot>().Deselect();  recsel = null;
                            info.Erase();
                            UpSlots();
                        }
                        else
                        {
                            swapper = go2.GetComponent <InvSlot>().slotnum;
                            selected.GetComponent <InvSlot>().SnapBack();
                            selected.GetComponent <BoxCollider>().enabled = true;
                            player.moninv.Move2Empty(selected.GetComponent <InvSlot>().curMonster, swapper);
                            selected = null; swaptarget = null;
                            recsel.GetComponent <InvSlot>().Deselect(); recsel = null;
                            info.Erase();
                            UpSlots();
                        }
                    }
                }

                else if (selected != null)
                {
                    selected.GetComponent <InvSlot>().SnapBack();
                    selected.GetComponent <BoxCollider>().enabled = true;
                }
                if (go == close && go2 == close)
                {
                    //selected.GetComponent<InvSlot>().SnapBack();
                    //selected.GetComponent<BoxCollider>().enabled = true;
                    MICollider.SetActive(false);
                }

                moving = false;
            }
        }
        else
        {
            go         = null;
            go2        = null;
            onehit     = true;
            selected   = null;
            swaptarget = null;
        }
    }