예제 #1
0
 protected void CloseShop()
 {
     MenuHeader.OnInventoryClicked -= OpenInventory;
     CategorySelector.ClearCategory();
     ShopGrid.ClearGrid();
     StoreManager.Clear();
     MessageController.Clean();
 }
    void GetAllShopData()
    {
        DataTable dt = new DataTable();

        dt = db.SqlGetDataTable("SELECT * FROM Shop ,SType WHERE ShopCheck = 'False' AND ShopTypeId = STypeId ORDER BY ShopDate ASC");
        ShopGrid.DataSource = dt;
        ShopGrid.DataBind();
        //"SELECT * FROM Shop INNER JOIN SType ON Shop.ShopTypeId = SType.STypeId WHERE ShopCheck = 'False' ORDER BY ShopDate ASC"
    }
예제 #3
0
    private void SwitchToShopPhase()
    {
        string validSceneName = "Shop Phase Scene";

        while (SceneManager.GetSceneByName(validSceneName).IsValid())
        {
            validSceneName = validSceneName + "1";
        }

        Scene newScene     = SceneManager.CreateScene(validSceneName);
        Scene currentScene = SceneManager.GetActiveScene();

        SceneManager.UnloadScene(currentScene);
        SceneManager.SetActiveScene(newScene);

        GameObject roomObj = GameObject.Instantiate(MetaInformation.Instance().roomPrefab) as GameObject;
        Shop       newShop = roomObj.GetComponent <Shop> ();

        shop = newShop;


        shopGrid = new ShopGrid(shopGridSizeX, shopGridSizeY, 0, 4);


        FurnitureInfo[] oldFurniture = new FurnitureInfo[furnitureInShop.Count];
        furnitureInShop.CopyTo(oldFurniture);
        furnitureInShop.Clear();

        foreach (FurnitureInfo f in oldFurniture)
        {
            var newFurnitureObj = Furniture.InstantiateFurnitureByID(f.furnitureID);
            var newFurniture    = newFurnitureObj.GetComponent <Furniture> ();

            if (!newFurniture.PlaceAtLocation(newShop, f.position))
            {
                Debug.Log("A furniture was in an invalid position in the savefile!");
                GameObject.Destroy(newFurnitureObj);
            }
        }

        GameObject.Instantiate(MetaInformation.Instance().shopPhaseDayCanvasPrefab);
        GameObject.Instantiate(MetaInformation.Instance().playerPrefab);

        foreach (GameObject prefab in generalObjectPrefabs)
        {
            GameObject.Instantiate(prefab);
        }
    }
예제 #4
0
    public void OnSelectCategory(string s)
    {
        ShopGrid.ClearGrid();

        Item[] items = StoreManager.GetItemFromCategory(s);

        if (items == null)
        {
            return;
        }

        foreach (Item item in items)
        {
            ShopGrid.AddItem(item, OnSelectItem);
        }
    }
예제 #5
0
        public void BuyCards(int number)
        {
            string price = string.Empty;

            DoubleAnimation da = new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(250));
            da.FillBehavior = FillBehavior.Stop;
            da.Completed += new EventHandler(delegate(object sender, EventArgs e)
                {
                    ShopGrid.Visibility = Visibility.Hidden;
                });
            ShopGrid.BeginAnimation(OpacityProperty, da);


            if (number == 1) price = "2000";
            else if (number == 2) price = "4000";
            else if (number == 3) price = "8000";

            DialogWin dw = new DialogWin(this, "Внимание!\nПокупка карты будет стоить " + price  + " очков\nЖелаете продолжить?",
                        MessageBoxButton.YesNo);

            App.WindowList.Add(dw.Name, dw);
            if (dw.ShowDialog() == true)
            {
                new Action(delegate
                {
                    List<Card> card = null;
                    bool isError = false;

                    App.ProxyMutex.WaitOne();
                    try
                    {
                        card = ServiceProxy.Proxy.BuyCard(App.UserName, number);
                        App.charInfo = ServiceProxy.Proxy.EnterWorld(App.UserName);
                        GetAllCard();

                    }
                    catch (CommunicationException exc)
                    {
                        App.OnException();
                        isError = true;
                    }

                    App.ProxyMutex.ReleaseMutex();

                    if (isError)
                    {
                        App.OnConnectionError();
                        return;
                    }

                    if (card.Count == 0)
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            DialogWin dw2 = new DialogWin(this, 
                                "Недостаточно средств.\nДля покупки необходимо не менее " + price + " очков",
                                MessageBoxButton.OK);
                            App.WindowList.Add(dw2.Name, dw2);
                            dw2.ShowDialog();
                        }));
                    }
                    else
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            Rating.Text = "Очки: " + App.charInfo.score;
                            CardsScore.Text = "Очки: " + App.charInfo.score;

                            CardPackWindow cpw = new CardPackWindow(card);
                            App.WindowList.Add(cpw.Name, cpw);
                            ShopGrid.Visibility = Visibility.Hidden;

                            cpw.ShowDialog();

                        }));
                    }
                }).BeginInvoke(new AsyncCallback(delegate(IAsyncResult ar) { }), null);
            }
        }
예제 #6
0
    public override IEnumerator MoveToPosition(IntPair pos, SuccessCallback callback = null)
    {
        if (callback == null)
        {
            callback = (s) => {}
        }
        ;

        if (animator != null)
        {
            animator.SetBool(AnimationStandards.IS_MOVING, true);
        }

        IntPair endPoint = pos;



        Game game = Game.current;

        if (game != null)
        {
            ShopGrid grid = game.shopGrid;

            if (grid != null)
            {
                bool done = false;


                while (!done)
                {
                    IntPath path = grid.FindPath(MyGrid, farCorner, endPoint);

                    if (path == null)
                    {
                        #region callback(false) and exit loop
                        if (animator != null)
                        {
                            animator.SetBool(AnimationStandards.IS_MOVING, false);
                        }
                        callback(false);
                        done = true;
                        #endregion
                    }
                    else
                    {
                        #region try to follow path; if path succeeds, callback(true) and exit
                        bool pathSucceeded = true;
                        for (int i = 0; i < path.Length; i++)
                        {
                            yield return(Glide(farCorner, path [i]));

                            farCorner = path [i];
                        }


                        if (pathSucceeded)
                        {
                            if (animator != null)
                            {
                                animator.SetBool(AnimationStandards.IS_MOVING, false);
                            }
                            callback(true);
                            done = true;
                        }
                        #endregion
                    }
                }
            }
        }
        else
        {
            callback(false);
        }
    }
예제 #7
0
 private void Awake()
 {
     Grid = this.GetComponent <ShopGrid>();
 }