// Use this for initialization
 void Start()
 {
     inventory = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryController>();
     blackScreen = GameObject.Find("BlackScreenCanvas");
     black = blackScreen.GetComponentInChildren<Image>();
     blackScreen.SetActive(false);
 }
Example #2
0
 // Use this for initialization
 void Start()
 {
     playerObject = GameObject.Find("Player_Robin_Prefab");
     highlightedColor.a = 128;
     unHighlightedColor.a = 128;
     invController = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryController>();
     EOLFoodCollectedText.text = "Level Completed! \n You Got "+invController.Pickup1InitialValue+" / "+ invController.Pickup1MaxValue+" Food";
 }
 public async void GetMolsonCanadian2SizesInventory()
 {
     using (InventoryController controller = new InventoryController())
     {
         var inventories = await controller.Get(new List<int> { 904409, 904144 });
         Assert.That(inventories.Count(), Is.GreaterThan(100));
         Assert.That(inventories.Where(i => i.StoreNumber == 568).Count(), Is.EqualTo(2));
     }
 }
 public async void GetMolsonCanadianInventory()
 {
     using (InventoryController controller = new InventoryController())
     {
         var inventories = await controller.Get(new List<int> { 904409 });
         Assert.That(inventories.Count(), Is.GreaterThan(100));
         var store568 = inventories.Single(i => i.StoreNumber == 568);
         Assert.That(store568.StreetAddress, Is.EqualTo("595 Bay Street"));
     }
 }
    private float ShieldActiveCD = 15f; //Cooldown before shields restart

    #endregion Fields

    #region Methods

    void Start()
    {
        EC = GetComponent<EnemyController>();
        Shield = GetComponentInChildren<ShieldController>();
        HC = GetComponent<HealthController>();
        EBS = GetComponent<LMEnergyBallShot>();

        IC = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryController>();
        P = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
        floor = P.getCurrentFloor() + 1;
    }
 //Start with bomber deactivated at rest
 void Awake()
 {
     Core = gameObject.GetComponent<Transform>();
     PauseAI();
     HC = GetComponent<HealthController>();
     IC = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryController>();
     P = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
     RB = GetComponent<Rigidbody>();
     floor = P.getCurrentFloor() + 1;
     Constraints = RB.constraints;
     RB.constraints = RigidbodyConstraints.FreezeAll;
 }
Example #7
0
    // @TODO: nothing
    void Start()
    {
        _inventoryController = Camera.mainCamera.GetComponent<InventoryController>();

        _specialName.SetActive(false);
        _specialDesc.SetActive(false);

        _textName.SetActive(false);
        _textDescription.SetActive(false);

        _buttonDelete.SetActive(false);
    }
        public InventoryControllerTest()
        {
            item1 = new InventoryItem() { Id = 1, ExpirationDate = DateTime.Now.AddDays(1), Label = "item1" };
            item2 = new InventoryItem() { Id = 2, ExpirationDate = DateTime.Now.AddDays(2), Label = "item2" };
            item3 = new InventoryItem() { Id = 3, ExpirationDate = DateTime.Now.AddDays(3), Label = "item3" };
            item4 = new InventoryItem() { Id = 4, ExpirationDate = DateTime.Now.AddDays(4), Label = "item4" };

            items = new List<InventoryItem>() { item1, item2, item3 };

            dummyInventoryRepository = new DummyInventoryRepository(items);
            inventoryController = new InventoryController(dummyInventoryRepository);
        }
    // Use this for initialization
    void Awake()
    {
        boss = GameObject.FindGameObjectWithTag("Broodmother");
        health = GetComponent<HealthController>();
        backpack = GetComponent<WeaponBackpackController>();
        anim = GetComponent<Animator>();
        timeSinceSpawn = 0;
        animTimer = 0;
        justSpawned = false;
        PauseAI();

        IC = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryController>();
        P = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
        floor = P.getCurrentFloor() + 1;
    }
Example #10
0
 protected void cmdDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Null.IsNull(itemId))
         {
             InventoryController controller = new InventoryController();
             controller.DeleteInventory(this.ModuleId, itemId);
             Response.Redirect(Globals.NavigateURL(), true);
         }
     }
     catch (Exception ex)
     {
         Exceptions.ProcessModuleLoadException(this, ex);
     }
 }
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            instance = this;
        }

        foreach (GameObject prefab in TowerPrefabs)
        {
            towerTable[prefab.tag] = prefab;
        }
    }
        public static void TestAddUpdateInventory2()
        {
            InventoryController iss = new InventoryController(WS_USERNAME, WS_PASSWORD);
            string sku = "746969c";
            double currentInventory = 44d;

            //request object
            //...
            //response object
            VinInventory.Response1 iss_response1 = new VinInventory.Response1();
            //*****************************************************************
            iss_response1 = iss.IS_AddUpdateInventoryCountBySKU(sku, currentInventory);
            //*****************************************************************
            //print if was success
            Console.WriteLine("The INVENTORY update for <sku> was a success: {0}", iss_response1.IsSuccessful);
        }
        public void Inventory_Delete_Get_Default_Should_Pass()
        {
            // Arrange
            var controller = new InventoryController();

            string id = BiliWeb.Backend.DataSourceBackend.Instance.InventoryBackend.Index().FirstOrDefault().ID;

            // Act
            ViewResult result = controller.Delete(id) as ViewResult;

            // Reset
            BiliWeb.Backend.DataSourceBackend.Instance.Reset();

            // Assert
            Assert.IsNotNull(result);
        }
Example #14
0
        public void Delete()
        {
            var newProduct = InsertProductForTest();

            if (string.IsNullOrEmpty(newProduct))
            {
                Assert.Fail($"Product {newProduct} was not inserted correctly. Test terminated.");
            }
            else
            {
                _ = InventoryController.Delete(newProduct);
                var selectSqlString = Properties.Resources.GetByName.Replace(NAME_PARAMETER, newProduct);
                var results         = ExecuteQuery(selectSqlString).Tables[0];
                Assert.AreEqual(0, results.Rows.Count);
            }
        }
Example #15
0
 void Start()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
     playerWeaponController = GetComponent <PlayerWeaponController>();
     consumableController   = GetComponent <ConsumableController>();
     GiveItem("sword");
     GiveItem("potion_log");
     GiveItem("staff");
 }
Example #16
0
        public override void Handle(GameSession session, PacketReader packet)
        {
            // No data passed in

            // TODO - Determine item from player's job
            Item tutorialBow = Item.TutorialBow(session.Player);

            // Add the item to the inventory
            InventoryController.Add(session, tutorialBow, true);

            // The below packet is sent with the inventory packets, but doesn't seem to be needed
            //session.Send(PacketWriter.Of(0x0105).WriteHexString("3F A6 36 E2 94 98 9B 2F 01 00 00 00 00 00 00 00 FF FF FF FF 89 18 84 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B3 BC BC FF 3D DA C3 FF BA B4 B0 FF 13 00 00 00 05 00 00 00 00 03 00 11 00 0C 00 00 00 00 00 00 00 1B 00 0F 00 00 00 00 00 00 00 1C 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 01 00 00 00 00 00 00 00 00 00 01 01 66 66 66 66 66 66 66 66 08 00 61 00 73 00 61 00 73 00 61 00 73 00 31 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"));
            // The below two are kept for future reference in regards to the above
            //session.Send(PacketWriter.Of(0x16).WriteHexString("00 38 69 E6 00 3F A6 36 E2 94 98 9B 2F 00 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 FF FF FF FF 89 18 84 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B3 BC BC FF 3D DA C3 FF BA B4 B0 FF 13 00 00 00 05 00 00 00 00 03 00 11 00 0C 00 00 00 00 00 00 00 1B 00 0F 00 00 00 00 00 00 00 1C 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 01 00 00 00 00 00 00 00 00 00 01 01 66 66 66 66 66 66 66 66 08 00 61 00 73 00 61 00 73 00 61 00 73 00 31 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"));
            //session.Send(PacketWriter.Of(0x16).WriteHexString("08 3F A6 36 E2 94 98 9B 2F 01 00 00 00 00 00"));
        }
Example #17
0
    // Start is called before the first frame update
    void Start()
    {
        itemdatabase = ItemDatabase.Instance;

        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }

        GiveItem("common_egg");
        GiveItem("common_wood");
    }
Example #18
0
        public void AddInventoryTestPostMethodExceptionThrown()
        {
            var mockInventoryDal = new MockInventoryDal()
            {
                ThrowError = true
            };

            var item       = new InventoryItem();
            var controller = new InventoryController(mockInventoryDal);
            var result     = (ViewResult)controller.AddInventory(item);

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreEqual(null, result.ViewName);
            Assert.AreEqual(item, (InventoryItem)result.Model);
            Assert.AreEqual("Uh-oh, something bad happened", result.ViewData["ErrorMessage"]);
        }
        public void GetAllUnitTest()
        {
            var controller = new InventoryController(_loggerMock.Object);

            var actionResult = controller.Get();

            // // Compare and cast. Expect no errors.
            var okResult = Assert.IsType <OkObjectResult>(actionResult);

            var list = Assert.IsAssignableFrom <ICollection <InventoryItem> >(
                okResult.Value);

            Assert.Contains(list, _ => _.Name.Equals("Oranges"));
            Assert.Contains(list, _ => _.Name.Equals("Apples"));
            Assert.Contains(list, _ => _.Name.Equals("Pomegranates"));
        }
 void OnTriggerEnter(Collider other)
 {
     if (!trigger)
     {
         //if this object hits Player
         if (other.gameObject.tag == "Player")
         {
             trigger = true;
             inventory = other.GetComponent<InventoryController>();
             if (inventory.hasKey(9))
             {
                 Application.LoadLevel("Victory");
             }
         }
     }
 }
        public void PostSingleItemOK()
        {
            var controller = new InventoryController();
            var sample     = new Item()
            {
                Label      = "Sample item",
                Expiration = DateTime.Now.AddMinutes(5),
                Type       = ItemType.TypeB
            };

            controller.Post(sample);
            var result = controller.Get() as ICollection <Item>;

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count, 4);
        }
    void DisplayAndActivateDiscoveredRenewables()
    {
        for (int i = 0; i < renewableTypes.Length; i++)
        {
            RenewableTypes renewableType = renewableTypes[i];
            if (InventoryController.HasDiscoveredRenewable(renewableType))
            {
                Sprite discoverableRenewableBubImage = DataAssociations.GetRenewableTypeBubImage(renewableType);
                renewableInventoryImages[i].sprite = discoverableRenewableBubImage;

                EventTrigger trigger = renewableInventoryEventTriggers[i];

                AssignDragEventListeners(trigger, discoverableRenewableBubImage, renewableType);
            }
        }
    }
Example #23
0
        public override void Handle(GameSession session, PacketReader packet)
        {
            int boxId = packet.ReadInt();

            packet.ReadShort(); // Unknown
            int amount = packet.ReadInt();

            short       opened = 0;                                                      // Amount of opened boxes
            List <Item> items  = new List <Item>(session.Player.Inventory.Items.Values); // Make copy of items in-case new item is added

            foreach (Item item in items)
            {
                // Continue over non-matching item ids
                if (item.Id != boxId)
                {
                    continue;
                }

                for (int i = opened; i < amount; i++)
                {
                    // Create new item from opening box
                    Item newItem = new Item(30001001);

                    // Remove box if there is only 1 left
                    if (item.Amount <= 1)
                    {
                        InventoryController.Remove(session, item.Uid, out Item removed);
                        InventoryController.Add(session, newItem, true);

                        opened++;

                        break; // Break out of the amount loop because this stack of boxes is empty, look for next stack
                    }

                    // Update box amount if there is more than 1
                    item.Amount -= 1;
                    InventoryController.Update(session, item.Uid, item.Amount);
                    InventoryController.Add(session, newItem, true);

                    opened++;
                }
            }

            session.Send(ItemUsePacket.Use(boxId, amount));

            // Need to handle opening boxes, probably serialize the item xml
        }
Example #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["ItemId"] != null)
                {
                    itemId = Int32.Parse(Request.QueryString["ItemId"]);
                }

                if (!IsPostBack)
                {
                    //load the data into the control the first time
                    //we hit this page


                    cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");

                    //check we have an item to lookup
                    if (!Null.IsNull(itemId))
                    {
                        //load the item
                        InventoryController controller = new InventoryController();
                        InventoryInfo       item       = controller.GetInventory(this.ModuleId, itemId);

                        if (item != null)
                        {
                            txtContent.Text        = item.Content;
                            ctlAudit.CreatedByUser = item.CreatedByUserName;
                            ctlAudit.CreatedDate   = item.CreatedDate.ToLongDateString();
                        }
                        else
                        {
                            Response.Redirect(Globals.NavigateURL(), true);
                        }
                    }
                    else
                    {
                        cmdDelete.Visible = false;
                        ctlAudit.Visible  = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Example #25
0
        private static void HandleUnequipItem(GameSession session, PacketReader packet)
        {
            long itemUid = packet.ReadLong();

            bool unequipped = false;

            // Unequip gear
            foreach ((ItemSlot slot, Item item) in session.Player.Equips)
            {
                if (itemUid != item.Uid)
                {
                    continue;
                }

                if (session.Player.Equips.Remove(slot, out Item unequipItem))
                {
                    unequipped = true;

                    unequipItem.Slot = -1;
                    InventoryController.Add(session, unequipItem, false);
                    session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, unequipItem));
                    break;
                }
            }

            if (unequipped)
            {
                return;
            }

            // Unequip cosmetic
            foreach ((ItemSlot slot, Item item) in session.Player.Cosmetics)
            {
                if (itemUid != item.Uid)
                {
                    continue;
                }

                if (session.Player.Cosmetics.Remove(slot, out Item unequipItem))
                {
                    unequipItem.Slot = -1;
                    InventoryController.Add(session, unequipItem, false);
                    session.FieldManager.BroadcastPacket(EquipmentPacket.UnequipItem(session.FieldPlayer, unequipItem));
                    break;
                }
            }
        }
Example #26
0
        private void Awake()
        {
            GetStartScript = this;

            //Init non-unity systems
            QuestRepository.Init();
            ItemTemplateRepository.Init();

            _questStorage = new DbQuestStorage();
            _itemStorage  = new DbItemStorage();

            //Get objects
            var Player         = GameObject.FindGameObjectWithTag("Player");
            var CameraCenter   = GameObject.FindGameObjectWithTag("CameraCenter").transform;
            var PlayerAnimator = GameObject.FindGameObjectWithTag("PlayerAnimator");

            //Создаем контроллеры
            AnimController   = new AnimController(PlayerAnimator);
            InputController  = new InputController();
            CameraController = new CameraController(Camera.main.GetComponent <CameraModel>(), CameraCenter, Camera.main,
                                                    InputController);
            MovementController = new MovementController(Player.transform, Player.GetComponent <CharController>());
            StaminaController  = new StaminaController(ref Player.GetComponent <StaminaModel>().Stamina,
                                                       Player.GetComponent <StaminaModel>(), InputController, MovementController, AnimController);
            // enemyAttackController = new EnemyAttackController(targetDetector);
            HealthController = new HealthController(ref Player.GetComponent <HealthModel>().health,
                                                    Player.GetComponent <HealthModel>());
            QuestLogController  = new QuestLogController(_questStorage);
            InventoryController = new InventoryController(_itemStorage);

            //Находим необходимые контроллеры которые висят на объектах
            SwordStartController = FindObjectOfType <SwordStartController>();

            #region Добавляем контроллеры в коллекцию

            _allControllers.Add(InputController);
            _allControllers.Add(CameraController);
            _allControllers.Add(MovementController);
            _allControllers.Add(StaminaController);
            _allControllers.Add(AnimController);
            // AllControllers.Add(enemyAttackController);
            _allControllers.Add(HealthController);
            _allControllers.Add(QuestLogController);
            _allControllers.Add(InventoryController);

            #endregion
        }
Example #27
0
        public void MustAddObject()
        {
            //Arrange
            var inventoryServices   = new InventoryServices();
            var inventoryController = new InventoryController(inventoryServices);
            var inventoryItem       = new InventoryItems()
            {
                Id = 2, ItemName = "Test", Price = 100
            };

            //Act
            var actionResult = inventoryController.AddInvetoryItems(inventoryItem);
            var result       = actionResult.Result as CreatedResult;

            //Assert
            Assert.AreEqual(actionResult.Result, result);
        }
    private void Start()
    {
        // Singleton
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }

        playerWeaponController = GetComponent <PlayerWeaponController>();
        consumableController   = GetComponent <ConsumableController>();
        GiveItem("Sword");
        GiveItem("Potion_log");
    }
Example #29
0
 public bool CheckInventory(InventoryController inventory)
 {
     if (inventory != null)
     {
         for (var i = 0; i < inventoryItems.Length; i++)
         {
             if (!inventory.HasItem(inventoryItems[i]))
             {
                 OnDoesNotHaveItem.Invoke();
                 return(false);
             }
         }
         OnHasItem.Invoke();
         return(true);
     }
     return(false);
 }
Example #30
0
        public void Add(GameSession session, long uid, int amount, short slot)
        {
            Item item = session.Player.Inventory.Items[uid];

            if (amount < item.Amount)
            {
                item.TrySplit(amount, out Item splitItem);
                session.Send(ItemInventoryPacket.Update(uid, item.Amount));
                item = splitItem;
            }
            else
            {
                InventoryController.Remove(session, uid, out Item removedItem);
                item = removedItem;
            }

            if (slot >= 0)
            {
                if (Items[slot] == null)
                {
                    item.Slot   = slot;
                    Items[slot] = item;
                    session.Send(StorageInventoryPacket.Add(item));
                    return;
                }
                else
                {
                    slot = -1;
                }
            }

            if (slot == -1)
            {
                for (slot = 0; slot < Items.Length; slot++)
                {
                    if (Items[slot] != null)
                    {
                        continue;
                    }
                    item.Slot   = slot;
                    Items[slot] = item;
                    session.Send(StorageInventoryPacket.Add(item));
                    return;
                }
            }
        }
        public void BuyItem_NegativeID()
        {
            // Arrange
            InventoryController controller  = new InventoryController();
            Transaction         transaction = new Transaction();

            transaction.User.Username       = "******";
            transaction.User.APIAccessToken = "d52cf647176eb094940d8d60236e9627951e2a5731363404b5622f93748ee191";
            transaction.Item = new Item(-1, 7);

            // Act
            Status purchase = controller.BuyItem(transaction);

            // Assert - Data Anomaly Response
            Assert.IsNotNull(purchase);
            Assert.AreEqual(9001, purchase.code);
        }
        public void BuyItem_IDNotInStock()
        {
            // Arrange
            InventoryController controller  = new InventoryController();
            Transaction         transaction = new Transaction();

            transaction.User.Username       = "******";
            transaction.User.APIAccessToken = "d52cf647176eb094940d8d60236e9627951e2a5731363404b5622f93748ee191";
            transaction.Item = new Item(100, 7);

            // Act
            Status purchase = controller.BuyItem(transaction);

            // Assert - Item Not Found
            Assert.IsNotNull(purchase);
            Assert.AreEqual(1, purchase.code);
        }
        public void BuyItem_QunatityUnavailable()
        {
            // Arrange
            InventoryController controller  = new InventoryController();
            Transaction         transaction = new Transaction();

            transaction.User.Username       = "******";
            transaction.User.APIAccessToken = "d52cf647176eb094940d8d60236e9627951e2a5731363404b5622f93748ee191";
            transaction.Item = new Item(1, 999999);

            // Act
            Status purchase = controller.BuyItem(transaction);

            // Assert - Not Enough Quantity Response.
            Assert.IsNotNull(purchase);
            Assert.AreEqual(2, purchase.code);
        }
Example #34
0
        private static void HandleSelectItemBox(GameSession session, PacketReader packet, Item item)
        {
            short boxType = packet.ReadShort();
            int   index   = packet.ReadShort() - 0x30;

            if (item.Content.Count <= 0)
            {
                return;
            }

            InventoryController.Consume(session, item.Uid, 1);

            if (index < item.Content.Count)
            {
                ItemUseHelper.GiveItem(session, item.Content[index]);
            }
        }
Example #35
0
        public void FillProductCategoryGrid()
        {
            try
            {
                List <InventoryInfo> items;
                InventoryController  controller = new InventoryController();
                items = controller.ProductCategory_List(this.ModuleId);

                gvProductCategory.DataSource = items;
                gvProductCategory.DataBind();
                lblTotalRecordCount.Text = items.Count.ToString();
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Example #36
0
        // private void ViewResources()
        // {
        //     StringBuilder line;
        //     var inventory = Shipwreck.CurrentGame?.Player.Inventory;
        //     var resources = InventoryController.GetItemsByType<Resource>(inventory);
        //
        //     Console.WriteLine("\n-------------------------\n Resources:\n-------------------------");
        //
        //     line = new StringBuilder("                                              ");
        //     line.Insert(1, "ITEM");
        //     line.Insert(16, "QTY");
        //     line.Insert(20, "DESC");
        //     Console.WriteLine(line);
        //
        //     foreach (var resource in resources)
        //     {
        //         line = new StringBuilder("                                              ");
        //         line.Insert(1, resource.InventoryItem.Name);
        //         line.Insert(16, resource.Quantity);
        //         line.Insert(20, (resource.InventoryItem).Description);
        //         Console.WriteLine(line);
        //     }
        // }

        private void EatFood()
        {
            var player          = Shipwreck.CurrentGame.Player;
            var inventory       = player.Inventory;
            var foodInInventory = InventoryController.GetItemsByType <Food>(inventory);

            var promptItems = foodInInventory.Select(itemRecord => itemRecord.InventoryItem.Name).ToList();

            promptItems.Add("Exit");

            var itemToEatName = Prompt.Select("Which item would you like to eat?", promptItems);

            if (itemToEatName == "Exit")
            {
                return;
            }

            var itemToEatRecord = foodInInventory.FirstOrDefault(record => record.InventoryItem.Name == itemToEatName);

            if (itemToEatRecord == null)
            {
                return;                          // todo better way to do this...
            }
            if (itemToEatRecord.InventoryItem.Droppable == false)
            {
                Log.Warning($"You can't eat your {itemToEatName}");
            }
            else
            {
                var quantity = ViewHelpers.GetQuantity($"You have {itemToEatRecord.Quantity} {itemToEatName}(s). How many would you like to eat?",
                                                       itemToEatRecord.Quantity);

                if (quantity == 0)
                {
                    return;
                }

                var previousHealth = player.Health;
                var previousHunger = player.Hunger;

                PlayerController.Eat((Food)itemToEatRecord.InventoryItem, quantity);

                Log.Success("Delicious!");
                Log.Info($"Health +{player.Health - previousHealth} \nHunger +{player.Hunger - previousHunger}\n");
            }
        }
Example #37
0
        private static void HandleProcessTile(GameSession session)
        {
            int currentTilePosition = session.Player.Mapleopoly.TotalTileCount % Mapleopoly.TILE_AMOUNT;

            MapleopolyTile currentTile = DatabaseManager.Mapleopoly.FindTileByPosition(currentTilePosition + 1);

            switch (currentTile.Type)
            {
            case MapleopolyTileType.Item:
            case MapleopolyTileType.TreasureTrove:
                Item item = new Item(currentTile.ItemId)
                {
                    Amount = currentTile.ItemAmount,
                    Rarity = currentTile.ItemRarity
                };
                InventoryController.Add(session, item, true);
                break;

            case MapleopolyTileType.Backtrack:
                session.Player.Mapleopoly.TotalTileCount -= currentTile.TileParameter;
                break;

            case MapleopolyTileType.MoveForward:
                session.Player.Mapleopoly.TotalTileCount += currentTile.TileParameter;
                break;

            case MapleopolyTileType.RoundTrip:
                session.Player.Mapleopoly.TotalTileCount += Mapleopoly.TILE_AMOUNT;
                break;

            case MapleopolyTileType.GoToStart:
                int tileToStart = Mapleopoly.TILE_AMOUNT - currentTilePosition;
                session.Player.Mapleopoly.TotalTileCount += tileToStart;
                break;

            case MapleopolyTileType.Start:
                break;

            default:
                Logger.Warn("Unsupported tile");
                break;
            }

            ProcessTrip(session); // Check if player passed Start
            session.Send(MapleopolyPacket.ProcessTile(session.Player.Mapleopoly, currentTile));
        }
        public void UpdateInventoryTest()
        {
            InventoryController inventoryController = GetController();

            Product product = new Product()
            {
                Id    = 1,
                Name  = "Mobile",
                Qty   = 5,
                Price = 45000
            };

            var      response        = inventoryController.UpdateInventory(product);
            Response responseMessage = response.Content.ReadAsAsync <Response>().Result;

            Assert.AreEqual(ErrorCode.SuccessMsg, responseMessage.errorMessage);
        }
Example #39
0
    public void Initialize(WeatherDescription weather, Func <DateTime?> getDateTimeFunc, Func <TimesOfDay> getTimeOfDayFunc)
    {
        _getDateTimeFunc  = getDateTimeFunc;
        _getTimeOfDayFunc = getTimeOfDayFunc;

        /* Zara Initialization code start =======>> */

        _health    = new HealthController(this);
        _body      = new BodyStatusController(this);
        _weather   = weather;
        _player    = new PlayerStatus();
        _inventory = new InventoryController(this);
        _body.Initialize();
        _health.Initialize();

        /* <<======= Zara Initialization code end */
    }
        public void UpdateInventoryTest_InvalidQty()
        {
            InventoryController inventoryController = GetController();

            Product product = new Product()
            {
                Id    = 12,
                Name  = "Mobile5",
                Qty   = -5,
                Price = 45000
            };

            var      response        = inventoryController.UpdateInventory(product);
            Response responseMessage = response.Content.ReadAsAsync <Response>().Result;

            Assert.AreEqual(ErrorCode.InvalidQuantity, responseMessage.Code);
        }
 // Use this for initialization
 void Start()
 {
     inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<InventoryController>();
     itemImage = gameObject.transform.GetChild(0).GetComponent<Image>();
 }
Example #42
0
 void Start()
 {
     _inventoryController = camera.GetComponent<InventoryController>();
 }
 private void Awake()
 {
     _instance = this;
     _carriedObjects = new List<GameObject>();
 }
Example #44
0
 void GetInventory()
 {
     Transform inventoryObj = Camera.main.transform.Find("UI");
     inventory = inventoryObj.GetComponent<InventoryController>();
     if (!inventory) Debug.Log("ERROR: crate cant find inventory");
 }
    void Awake()
    {
        tf = GetComponent<Transform>();

        motor = GetComponent<AdvancedMotor>();
        viewControl = GetComponent<ViewController>();
        invControl = GetComponent<InventoryController>();

        PopulateItemKeyMap();
    }
Example #46
0
 void Start() {
     theInventoryController = FindObjectOfType<InventoryController>();
     weightCounted = false;
     isOnScale = false;
 }
Example #47
0
 void Start()
 {
     _invController = Camera.main.GetComponent<InventoryController>();
 }
    void Start()
    {
        desiredRotation = transform.rotation.eulerAngles;
        desiredCrosshairPos = crosshair.transform.position;
        inventoryController = gameObject.GetComponent<InventoryController>();

        if (!GameController.GC.players[playerNumber].hasInputDevice)
        {
            switch (playerNumber)
            {
                case (sbyte)0:
                    GameController.IC.AssignPlayerToKeyboard(0);
                    crosshair.SetActive(true);
                    break;
                case (sbyte)1:
                    GameController.IC.AssignPlayerToController(1);
                    playerCamera.GetComponent<AudioListener>().enabled = false;
                    crosshair.SetActive(false);
                    crosshairCamera.SetActive(false);
                    break;
                default:
                    break;
            }
        }

        if(GameController.GC.playerAmount == 2)
        {
            switch (playerNumber)
            {
                case (sbyte)0:
                    playerCamera.GetComponent<Camera>().rect = new Rect(-0.5f, 0, 1, 1);
                    crosshairCamera.GetComponent<Camera>().rect = new Rect(-0.5f, 0, 1, 1);
                    playerCamera.GetComponent<Camera>().depth = 1;
                    crosshairCamera.GetComponent<Camera>().depth = 1.5f;
                    break;
                case (sbyte)1:
                    playerCamera.GetComponent<Camera>().rect = new Rect(0.5f, 0, 1, 1);
                    playerCamera.GetComponent<Camera>().depth = 2;
                    break;
                default:
                    break;
            }
        }

        if (!GameController.GC.players[playerNumber].inputDeviceIsKeyboard)
        {
            cInput = GameController.GC.players[playerNumber].currentInputDevice;
        }
    }
Example #49
0
 public void setUp(InventoryController newInventory)
 {
     itemGraphic = transform.Find ("ItemGraphic");
     itemCount = transform.Find ("NameField/ItemCount");
     itemName = transform.Find ("NameField/ItemCount/ItemName");
     nameField = transform.Find ("NameField");
     nameFieldActive = transform.Find ("NameFieldActive");
     background = transform.Find ("Background");
     itemCount.renderer.material.renderQueue = 4000;
     itemName.renderer.material.renderQueue = 4000;
     inventory = newInventory;
     height = GetComponent<BoxCollider>().size.y;
     setUnselected();
 }
Example #50
0
	// Use this for initialization
	void Start () 
    {
        invControllerScript = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryController>();
        debugFloat = invControllerScript.Pickup1InitialValue;
	}
Example #51
0
 public void setInventory(InventoryController newInventory)
 {
     inventory = newInventory;
 }
Example #52
0
    public void SetUp()
    {
        GameObject playerObj = GameObject.FindGameObjectWithTag("Player");
        if (playerObj) playerController = playerObj.GetComponent<PlayerController>();

        transCurve = new AnimationCurve(new Keyframe(0.0f, 0.0f), new Keyframe(1.0f, 1.0f));

        Transform UIThumbsticksObj = Instantiate(UIThumbsticksPrefab, transform.position, Quaternion.identity) as Transform;
        UIThumbsticksObj.parent = transform;

        lowerLeft = UIThumbsticksObj.Find("LowerLeft");
        Camera.main.transform.GetComponent<UIManager>().lockToEdge(lowerLeft);

        lowerRight = UIThumbsticksObj.Find("LowerRight");
        Camera.main.transform.GetComponent<UIManager>().lockToEdge(lowerRight);

        upperLeft = UIThumbsticksObj.Find("UpperLeft");
        Camera.main.transform.GetComponent<UIManager>().lockToEdge(upperLeft);
        MiniMapDisplay miniMapDisplay = upperLeft.gameObject.AddComponent<MiniMapDisplay>();
        miniMapDisplay.InitMiniMap();

        lowerCenter = UIThumbsticksObj.Find("LowerCenter");
        Camera.main.transform.GetComponent<UIManager>().lockToEdge(lowerCenter);

        Transform UIStatusDisplayObj = Instantiate(UIStatusDisplayPrefab, lowerCenter.position, lowerCenter.rotation) as Transform;
        UIStatusDisplayObj.parent = lowerCenter;

        upperRight = UIThumbsticksObj.Find("UpperRight");
        Camera.main.transform.GetComponent<UIManager>().lockToEdge(upperRight);

        Transform cashBox = UIThumbsticksObj.Find("UpperRight/Cash");
        UICashDisplay cashDisplay = cashBox.gameObject.AddComponent<UICashDisplay>();

        moveThumb = UIThumbsticksObj.Find("LowerLeft/MoveAnchor/MoveThumb");
        moveThumb.gameObject.AddComponent<UIElement>().setTarget(gameObject);

        throwThumb = UIThumbsticksObj.Find("LowerRight/ThrowAnchor/ThrowThumb");
        throwThumb.gameObject.AddComponent<UIElement>().setTarget(gameObject);

        throwAnchor = UIThumbsticksObj.Find("LowerRight/ThrowAnchor");
        throwAnchor.gameObject.AddComponent<UIBombStickBehavior>().setUp(this, throwThumb, throwAnchor.localPosition);

        shootThumb = UIThumbsticksObj.Find("LowerRight/ShootAnchor/ShootThumb");
        shootThumb.gameObject.AddComponent<UIElement>().setTarget(gameObject);

        shootAnchor = UIThumbsticksObj.Find("LowerRight/ShootAnchor");
        shootAnchor.gameObject.AddComponent<UIShootStickBehavior>().setUp(this, shootThumb, shootAnchor.localPosition);

        Transform inventoryPos = UIThumbsticksObj.Find("LowerRight/Inventory");
        inventory = GetComponent<InventoryController>();
        inventory.SetUp(inventoryPos, cashDisplay);

        //Transform centerSliderPos = UIThumbsticksObj.Find("LowerCenter/Inventory");
        ///inventory = GetComponent<InventoryController>();
        //inventory.SetUp(inventoryPos, cashDisplay);

        setUp = true;
    }
 // Use this for initialization
 void Start()
 {
     inv = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryController>();
     player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
 }