/// <summary> /// Creates a droppable Item into the world /// </summary> /// <param name="pos"></param> public void CreateDroppable(Vector3 pos, int tier, bool lootParabola = false) { GameObject tmp = Instantiate(droppableGameObject, pos, Quaternion.identity); Equipment equip = CreateEquipment(tier); tmp.GetComponent <ItemPickup>().item = equip; tmp.GetComponent <SpriteRenderer>().sprite = equip.icon; tmp.name = equip.name; if (lootParabola) { LootController loot = LootController.instance; LootParabola movement = tmp.AddComponent <LootParabola>(); List <Vector2> positions = new List <Vector2>(); positions = loot.FindAllEndPositions(tmp.transform); Vector2 endPosition = loot.SelectEndPosition(positions); movement._EndPosition = endPosition; movement._StartPosition = pos; movement._Height = loot.MyDroppedLootHeight; StartCoroutine(movement.Parabola()); } }
public void ControllerGetsProperPage(int currentPage, int itemsQuantity, int firstItemId) { var controllerContext = new ControllerContext(); var httpContext = new DefaultHttpContext(); httpContext.Request.Headers.Add("x-requested-with", ""); controllerContext.HttpContext = httpContext; var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: "TestDb") .Options; using (var context = new ApplicationDbContext(options)) { context.Loot.AddRange(GetLootList()); context.LootCategories.Add(new LootCategory { LootCategoryName = "Test category" }); context.SaveChanges(); var controller = new LootController(context, null) { ControllerContext = controllerContext }; var result = controller.Index(pageNumber: currentPage, category: null) as ViewResult; var model = result?.Model as List <Loot>; Assert.NotNull(model); Assert.Equal(itemsQuantity, model.Count); Assert.Equal(firstItemId, model[0].LootId); } using (var context = new ApplicationDbContext(options)) { context.Database.EnsureDeleted(); } }
// Start is called before the first frame update void Awake() { if (LootController.loot == null) { LootController.loot = this; } else { Destroy(this.gameObject); return; } DontDestroyOnLoad(this.gameObject); foreach (Card card in lootTable.cardLoot) { if (card.rarity == Card.Rarity.Rare) { rareCards.Add(card); } else if (card.rarity == Card.Rarity.Common) { commonCards.Add(card); } else if (card.rarity == Card.Rarity.Starter) { starterCards.Add(card); } } }
void Death() { // The enemy is dead. isDead = true; // Turn the collider into a trigger so shots can pass through it. capsuleCollider.isTrigger = true; // Tell the animator that the enemy is dead. // Change the audio clip of the audio source to the death clip and play it (this will stop the hurt clip playing). enemyAudio.clip = deathClip; enemyAudio.Play(); for (int i = 0; i < lootrates.Length; i++) { float rng = Random.Range(0.0f, 1.0f); if (lootrates[i] >= rng) { GameObject lootGenerated = Instantiate(loot, this.transform.position, Quaternion.identity); LootController lootcontrol = lootGenerated.GetComponent <LootController>(); lootcontrol.SetLoot(i); break; } } Destroy(gameObject); }
private void Awake() { if (instance != null) { Debug.LogWarning("More than one instance of LootController !"); } instance = this; }
private void SpawnChest(Vector3 position) { treasureChest = Instantiate( treasureChest, position, Quaternion.AngleAxis(90, Vector3.forward) ); lootController = treasureChest.GetComponent <LootController>(); lootController.SetInventoryController(inventoryController); }
private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } }
// Start is called before the first frame update void Start() { spawn = transform.Find("EnemySpawner").GetComponent <SpawnController>(); score = transform.Find("ScoreController").GetComponent <ScoreController>(); loot = transform.Find("LootController").GetComponent <LootController>(); UIObject = GameObject.Find("UI"); pauseCount = 0; GameIsPaused = false; StartLevel(); //Invoke("SpawnLevel", 1.0f); }
void Awake() { walls = new List <List <Vector2Int> >(); battleStarted = false; empty = true; zombieSourceClone = GameObject.Find("SpawnerSource"); zombieTypes = getSpawnerObjectsOfType("Zombies"); minibossTypes = getSpawnerObjectsOfType("MiniBosses"); wallClone = GameObject.Find("Wall"); wallNodeClone = GameObject.Find("WallNode"); lootController = GameObject.Find("LootController").GetComponent <LootController>(); zombiesList = transform.GetChild(0); tileTools = GameObject.Find("TileTools").GetComponent <TileTools>(); }
void Start() { rigidBody = GetComponent <Rigidbody>(); player = FindObjectOfType <InputController>(); playerLevel = FindObjectOfType <LevelController>(); lootController = FindObjectOfType <LootController>(); currentHealth = maxHealth; canvasTransform = transform.FindChild("EnemyCanvas"); healthBar = canvasTransform.FindChild("HealthBG").FindChild("Health").GetComponent <Image>(); HurtPlayerManager hurtPlayer = transform.FindChild("Body").GetComponent <HurtPlayerManager>(); hurtPlayer.setDamage(damage); hurtPlayer.setHitCooldown(hitCooldown); }
void Start() { _lootController = LootController.instance; _chestAnimation = GetComponentInChildren <ChestAnimation>(); if (items.Count == 0) { //Store all Gameobjects in an array like this Object[] allItems = Resources.LoadAll("Items"); int numberOfItems = Random.Range(1, 5); for (int i = 0; i < numberOfItems; i++) { items.Add((Item)allItems[Random.Range(0, allItems.Length)]); } } }
private void DropLoot() { PickUpLootConfig lootConfig = null; if (specialLootOverride) { lootConfig = specialLootConfig; } else { lootConfig = LootManager.instance.DropLoot(); } if (lootConfig != null) { LootController loot = Instantiate(lootConfig.LootPrefab, LootManager.instance.transform); loot.Drop(lootConfig, transform.position); } }
// Start is called before the first frame update void Start() { if (LootController.loot == null) { LootController.loot = this; } else { Destroy(this.gameObject); } foreach (Card card in lootTable.cardLoot) { if (card.rarity == Card.Rarity.Rare) { rareCards.Add(card); } else { commonCards.Add(card); } } }
public void ControllerSelectsProperItems(int categoryId, int itemsQuantity, int index) { var controllerContext = new ControllerContext(); var httpContext = new DefaultHttpContext(); httpContext.Request.Headers.Add("x-requested-with", ""); controllerContext.HttpContext = httpContext; var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: "TestDb") .Options; using (var context = new ApplicationDbContext(options)) { context.Loot.AddRange(GetLootList()); context.LootCategories.Add(new LootCategory { LootCategoryName = "Test category" }); context.SaveChanges(); var controller = new LootController(context, null) { ControllerContext = controllerContext }; var result = controller.Index(categoryId, 1) as ViewResult; var model = result.Model as List <Loot>; Assert.NotNull(model); Assert.Equal(itemsQuantity, model.Count); Assert.Equal(GetLootList()[index], model[0], Comparer <Loot> .GetComparer((loot1, loot2) => loot1.LootCategoryId == loot2.LootCategoryId)); } using (var context = new ApplicationDbContext(options)) { context.Database.EnsureDeleted(); } }
public void Store2() { // ARRANGE var handlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict); handlerMock .Protected() // Setup the PROTECTED method to mock .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>() ) // prepare the expected response of the mocked http call .ReturnsAsync(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = null, }) .Verifiable(); var httpClient = new HttpClient(handlerMock.Object) { BaseAddress = new Uri("http://test.com/"), }; var subjectUnderTest = new EquipmentController(httpClient, new Web.MyConfiguration() { ServiceUrl = "http://test.com/" }); var result = subjectUnderTest.Index(); var result2 = subjectUnderTest.Create(); var result3 = subjectUnderTest.Create(new EquipmentModel()); var result4 = subjectUnderTest.Edit(new EquipmentModel()); var result5 = subjectUnderTest.Edit(1, 2, "", "", 2, 3, 3); var subjectUnderTest2 = new LocationController(httpClient, new Web.MyConfiguration() { ServiceUrl = "http://test.com/" }); var result6 = subjectUnderTest2.Index(); var result7 = subjectUnderTest2.Create(); var result8 = subjectUnderTest2.Create(new LocationModel()); var result9 = subjectUnderTest2.EditLoot(1, 1, 1, "", 1, ""); var result10 = subjectUnderTest2.EditLoot(new LootModel()); var result11 = subjectUnderTest2.EditLocation(new LocationModel()); var result12 = subjectUnderTest2.EditLocation(1, "", "", 1); var result13 = subjectUnderTest2.Delete(1); var subjectUnderTest3 = new HomeController(); subjectUnderTest3.Index(); subjectUnderTest3.Privacy(); var subjectUnderTest4 = new LootController(httpClient, new Web.MyConfiguration() { ServiceUrl = "http://test.com/" }); var result17 = subjectUnderTest4.Index(); var subjectUnderTest5 = new PlayerController(httpClient, new Web.MyConfiguration() { ServiceUrl = "http://test.com/" }); var result18 = subjectUnderTest5.Index(); var result19 = subjectUnderTest5.Edit(1, 2, "", "", 1, 1); var result20 = subjectUnderTest5.Edit(new LootModel()); var result21 = subjectUnderTest5.EditPlayer(1, "", 1); var result22 = subjectUnderTest5.EditPlayer(new PlayerModel()); var result23 = subjectUnderTest5.EditEquipment(1, 1, "", "", 1, 1, 1); var result24 = subjectUnderTest5.EditEquipment(new EquipmentModel()); var result25 = subjectUnderTest5.Delete(1, new LootModel()); var result26 = subjectUnderTest5.Delete(1); var result27 = subjectUnderTest5.DeleteEquipment(1, new EquipmentModel()); Assert.NotNull(subjectUnderTest); }
public void Initialize(List <Item> items, LootController lootControl) { _lootControl = lootControl; LoadController.instance.LoadRuntimeItems(items, RunItemsLoaded); ID = 1 - gameObject.GetInstanceID(); }
public void SetCurrentLoot(LootController loot) { currentLoot = loot; }
public void GenerateLoot(LootController loot) { if (loot.WoodAmount == 0) { WoodLootBtn.SetActive(false); } else { WoodLootBtn.SetActive(true); WoodLootText.text = loot.WoodAmount.ToString(); } if (loot.MetalAmount == 0) { MetalLootBtn.SetActive(false); } else { MetalLootBtn.SetActive(true); MetalLootText.text = loot.MetalAmount.ToString(); } if (loot.FoodAmount == 0) { FoodLootBtn.SetActive(false); } else { FoodLootBtn.SetActive(true); FoodLootText.text = loot.FoodAmount.ToString(); } if (loot.WaterAmount == 0) { WaterLootBtn.SetActive(false); } else { WaterLootBtn.SetActive(true); WaterLootText.text = loot.WaterAmount.ToString(); } if (loot.ElectronicAmount == 0) { ElectronicsLootBtn.SetActive(false); } else { ElectronicsLootBtn.SetActive(true); ElectronicsLootText.text = loot.ElectronicAmount.ToString(); } if (loot.ClothAmount == 0) { ClothLootBtn.SetActive(false); } else { ClothLootBtn.SetActive(true); ClothLootText.text = loot.ClothAmount.ToString(); } if (loot.WeaponAmount == 0) { WeaponsLootBtn.SetActive(false); } else { WeaponsLootBtn.SetActive(true); WeaponsLootText.text = loot.WeaponAmount.ToString(); } if (loot.MedicineAmount == 0) { MedicineLootBtn.SetActive(false); } else { MedicineLootText.text = loot.MedicineAmount.ToString(); MedicineLootBtn.SetActive(true); } LootPanel.SetActive(true); }
void Awake() { LC = this; }
private void Awake() { _lootControl = GameObject.FindObjectOfType <LootController>(); _lootControl.AddLootSpawner(this); }