Exemplo n.º 1
0
 private void NotifyItemException(GameController.NotifyItemException.Arguments Parameters)
 {
     Popup it = new Popup(Parameters.Messagge);
     mainGrid.Children.Add(it);
     it.Focus();
 }
Exemplo n.º 2
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            // Find the right item and it's value and index
            currentItemText = (Item)LeftListBox.SelectedValue;
            currentItemIndex = LeftListBox.SelectedIndex;

            if(currentItemIndex < 0)
            {
                return;
            }
            //  RightListBox.Items.Add(currentItemText);
            if (currentItemText != null)
            {

                foreach (Model.Room r in MainWindow.attGameController.Game.Rooms)
                {
                    foreach (Item ite in r.Items)
                    {
                        if (ite.BarCode == currentItemText.BarCode)
                        {
                            //   ite.Dress();
                            try
                            {
                                r.DressItem(ite.BarCode);

                                itemOutfit.Add((Item)currentItemText);
                                itemInv.RemoveAt(currentItemIndex);
                                checkOrder();
                            }
                            catch (AlredyWearingAnItemException ex)
                            {
                                //Show an error message
                                Popup mex = new Popup(ex.Message);
                                layoutRoot.Children.Add(mex);
                                mex.Focus();
                            }

                        }
                    }

                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called by the delegate <see cref="UpdateInventorydHandler"/> to handle the event <see cref="GameController.UpdateInventory"/> 
        /// that occure when an item is added to the inventory
        /// </summary>
        /// <param name="Parameters">Instance of an object repressenting the class <see cref="GameController.UpdateInventory.Arguments"/> 
        /// which contains information passed by the event <see cref="GameController.UpdateInventory"/></param>
        private void UpdateInventory(GameController.UpdateInventory.Arguments Parameters)
        {
            string cosamostrare = "Item added in Inventory";
            bool wasActualRoom = false;
            foreach (Model.Room r in attGameController.Game.Rooms)
            {
                foreach (Model.Item item in r.Items)
                    if (item.BarCode == Parameters.BarCode)
                    {
                        //Find the button to animate
                        foreach (Button b in room.listOfButtons)
                        {
                            if (b.Tag.ToString() == Parameters.BarCode && attGameController.Game.ActualRoom.Name == r.Name)
                            {
                                //animation!!!
                                VisualStateManager.GoToState(b, "Moving", true);
                                wasActualRoom = true;
                                break;
                            }

                        }

                        //if the animation cannot be performed, a popup is shown
                        if (wasActualRoom == false)
                        {
                            cosamostrare = "Item " + item.ItemName + " added in Inventory";
                            Popup lastc = new Popup(cosamostrare);
                            mainGrid.Children.Add(lastc);
                            lastc.Focus();
                        }

                    }
                if (r.IsRoomCompleted == true && r.IsLastClueAlreadyShown == false)
                {
                    cosamostrare = r.LastClue;
                    Popup lastc = new Popup(cosamostrare);
                    mainGrid.Children.Add(lastc);
                    lastc.Focus();
                    changeDoorColor();
                }
            }
        }