void OnTriggerEnter2D(Collider2D other) { if (other.tag.Equals(Tags.ENEMY)) { mAudioSource.Stop(); mAudioSource.Play(); isStunned = true; StartCoroutine(resetStun()); return; } ICollectable collectable = other.GetComponent <ICollectable>(); // we only care if we collid with an collectable if (collectable != null) { CollectableType type = collectable.Collect(); if (type == CollectableType.NONE) { return; } if (type == CollectableType.HP_BOBBLE) { mHealthManager.GainHealth(HP_GAIN_VALUE); HighscoreManager.Instance.AddToScore(HighscoreManager.GET_HEALTH); return; } mInventory.AddInventoryItem(type); HighscoreManager.Instance.AddToScore(HighscoreManager.FIND_CORE); } }
public void RentBook() { var inventoryItem = new InventoryItem { Id = 1, Article = new Book { Id = 1, InternationalStandardBookNumber = "9780132350884", Title = "Clean Code", SubTitle = "A Handbook of Agile Software Craftsmanship", Description = "Noted software expert Robert C. Martin presents a revolutionary paradigm with Clean Code: A Handbook of Agile Software Craftsmanship . Martin has teamed up with his colleagues from Object Mentor to distill their best agile practice of cleaning code “on the fly” into a book that will instill within you the values of a software craftsman and make you a better programmer–but only if you work at it.", Publisher = new Publisher { Id = 1, Name = "Prentice Hall", }, Authors = new List <Author> { new Author { Id = 1, FullName = "Robert C. Martin", Info = "aka. Oncle Bob", }, new Author { Id = 2, FullName = "Dean Wampler", Info = "", }, }, Categories = new List <Category> { new Category { Id = 1, Name = "Computers", }, }, Language = new Language { Name = "English" }, }, StockLocation = new StockLocation { Hall = 1, Corridor = 2, Rack = 3, Level = 4, Position = 5, }, }; _inventory.AddInventoryItem(inventoryItem); var tmpInventoryItem = _inventory.FindInventoryItemById(1); Assert.Equal(1, tmpInventoryItem.Article.Id); Assert.True(tmpInventoryItem.Article is Book); var book = tmpInventoryItem.Article as Book; Assert.Equal("9780132350884", book.InternationalStandardBookNumber); Assert.Equal(1, tmpInventoryItem.Id); Assert.Equal(1, tmpInventoryItem.StockLocation.Hall); Assert.Equal(2, tmpInventoryItem.StockLocation.Corridor); Assert.Equal(3, tmpInventoryItem.StockLocation.Rack); Assert.Equal(4, tmpInventoryItem.StockLocation.Level); Assert.Equal(5, tmpInventoryItem.StockLocation.Position); }