Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     if (curInstance == null)
     {
         curInstance = this;
     }
 }
Esempio n. 2
0
        public override void OnEnter()
        {
            base.OnEnter();
            shop = Owner.GetComponent <ShopMain>();

            bool bCodeInputButton = false;

            if (DataManager.Instance.config.HasKey("code_input"))
            {
                //Debug.Log(DataManager.Instance.config.Read("code_input"));
                //Debug.Log(Application.version);
                if (DataManager.Instance.config.Read("code_input") == Application.version)
                {
                    bCodeInputButton = true;
                }
                if (DataManager.Instance.config.Read("code_input2") == Application.version)
                {
                    bCodeInputButton = true;
                }
            }
            shop.m_btnMainCode.gameObject.SetActive(bCodeInputButton);

            shop.m_goBannerGemFree.SetActive(false);
            shop.m_goBannerGoldPack1.SetActive(false);
            shop.m_goBannerGoldPack2.SetActive(false);
            shop.m_goBannerGoldPack3.SetActive(false);
            shop.m_goBannerWeaponFree.SetActive(false);
            shop.m_goBannerWeapon1.SetActive(false);
            shop.m_goBannerWeapon2.SetActive(false);
            shop.m_goBannerTreasureFree.SetActive(false);
            shop.m_goBannerTreasure1.SetActive(false);
            shop.m_goBannerTreasure2.SetActive(false);

            shop.m_goScrollInfoRoot.SetActive(false);
            shop.m_goScrollCreateRoot.SetActive(false);
            shop.m_goScrollUseRoot.SetActive(false);

            shop.m_btnMainGem.onClick.RemoveAllListeners();
            shop.m_btnMainGold.onClick.RemoveAllListeners();
            shop.m_btnMainWeapon.onClick.RemoveAllListeners();
            shop.m_btnMainTreasure.onClick.RemoveAllListeners();
            shop.m_btnMainScroll.onClick.RemoveAllListeners();


            shop.m_btnMainGem.onClick.AddListener(() => { Fsm.Event("gem"); });
            shop.m_btnMainGold.onClick.AddListener(() => { Fsm.Event("gold"); });
            shop.m_btnMainWeapon.onClick.AddListener(() => { Fsm.Event("weapon"); });
            shop.m_btnMainTreasure.onClick.AddListener(() => { Fsm.Event("treasure"); });
            shop.m_btnMainScroll.onClick.AddListener(() => { Fsm.Event("scroll"); });
            shop.m_btnMainCode.onClick.AddListener(() => { Fsm.Event("code"); });

            shop.m_goCodeRoot.SetActive(false);

            if (CampMain.Instance.sub_move != "")
            {
                Fsm.Event(CampMain.Instance.sub_move);
            }
            CampMain.Instance.sub_move = "";
        }
        private void bunifuTileButton3_Click(object sender, EventArgs e)
        {
            ShopMain item = new ShopMain();

            panel2.Controls.Clear();
            //item.Top = 10;
            //item.Left = 10;
            panel2.Controls.Add(item);
        }
        private void goBack_Click(object sender, RoutedEventArgs e)
        {
            Person osoba = new Person();

            osoba.email     = "Guest";
            osoba.id_person = "0";
            ShopMain page = new ShopMain(osoba);

            page.Show();
            this.Close();
        }
        private void Login()
        {
            var client  = new RestClient("https://student.sps-prosek.cz/~bastlma14/obj/account.php");
            var request = new RestRequest(Method.POST);

            request.AddParameter("action", 0);
            request.AddParameter("email", Email.Text);
            request.AddParameter("password", Password.Password);
            var res = client.Execute <List <Person> >(request);

            if (res.Content == "0" || res.Content == "")
            {
                Error.Content = "Neznámé heslo nebo email";
            }
            else
            {
                Person osoba = new Person();
                osoba.email     = Email.Text;
                osoba.id_person = res.Content;
                ShopMain page = new ShopMain(osoba);
                page.Show();
                this.Close();
            }
        }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        costint   = nets * thenet.theitem.cost + potions * thepotion.theitem.cost;
        cost.text = "Cost: " + costint;

        if (Input.touchCount == 1 && onehit)
        {
            // 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;
                }
                //moving = false;
                if (go == netminus && nets > 0 && go == go2)
                {
                    nets--;
                }
                else if (go == netplus && nets < 99 && go == go2)
                {
                    nets++;
                }
                else if (go == tnminus && tndisplay > 0 && go == go2)
                {
                    tndisplay--;
                }
                else if (go == tnplus && tndisplay < 21 && go == go2)
                {
                    tndisplay++;
                }
                else if (go == tnminus && tndisplay == 0 && go == go2)
                {
                    tndisplay = 20;
                }
                else if (go == tnplus && tndisplay == 21 && go == go2)
                {
                    tndisplay = 0;
                }
                else if (go == potionminus && potions > 0 && go == go2)
                {
                    potions--;
                }
                else if (go == potionplus && potions < 99 && go == go2)
                {
                    potions++;
                }
                else if (go == close && go == go2)
                {
                    ShopMain.ShopSet(false);
                }
                else if (go == buy && go == go2)
                {
                    FinalPurchase();
                }
                //Debug.Log("Touch Released from : " + go.name);
            }
        }
        else
        {
            go     = null;
            onehit = true;
            go2    = null;
            netnumber.GetComponent <TextMesh>().text    = "" + nets;
            potionnumber.GetComponent <TextMesh>().text = "" + potions;
            if (tndisplay != 18)
            {
                tnnumber.GetComponent <TextMesh>().text = Types.TypePrinter(tndisplay);
            }
            else
            {
                tnnumber.GetComponent <TextMesh>().text = "Amy\nSchumer";
            }
        }
    }
Esempio n. 7
0
    void FinalPurchase()
    {
        costint = nets * thenet.theitem.cost + potions * thepotion.theitem.cost;
        Item tempitem = new Item(thenet.theitem);
        Item temppot  = new Item(thepotion.theitem);

        tempitem.nettype = Types.Int2Type(tndisplay);
        if (tndisplay != 0)
        {
            tempitem.itemname = Types.TypePrinter(tndisplay) + " " + thenet.theitem.itemname;
        }
        if (Town.GetPlayer().iteminv.Coins() >= costint)
        {
            if (nets > 0 && potions > 0)
            {
                if (Town.GetPlayer().iteminv.HasSpaceFor(tempitem) && Town.GetPlayer().iteminv.HasSpaceFor(temppot))
                {
                    Town.GetPlayer().iteminv.SubstractCoins(costint);
                    Town.GetPlayer().iteminv.AddItem(tempitem, nets);
                    Town.GetPlayer().iteminv.AddItem(temppot, potions);
                    //play sound chaching
                }
                else
                {
                    Town.ShopError(nospace);
                }
            }
            else if (nets > 0 && potions == 0)
            {
                if (Town.GetPlayer().iteminv.HasSpaceFor(tempitem))
                {
                    Town.GetPlayer().iteminv.SubstractCoins(costint);
                    Town.GetPlayer().iteminv.AddItem(tempitem, nets);
                    //play sound chaching
                }
                else
                {
                    Town.ShopError(nospace);
                }
            }
            else if (nets == 0 && potions > 0)
            {
                if (Town.GetPlayer().iteminv.HasSpaceFor(tempitem))
                {
                    Town.GetPlayer().iteminv.SubstractCoins(costint);
                    Town.GetPlayer().iteminv.AddItem(temppot, potions);
                    //play sound chaching
                }
                else
                {
                    Town.ShopError(nospace);
                }
            }
        }
        else
        {
            Town.ShopError(notenough);
        }

        ShopMain.ShopSet(false);
    }
Esempio n. 8
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;
        }
    }