protected override async Task OnInitializedAsync() { var token = await JS.GetApiKey(); if (!string.IsNullOrWhiteSpace(token?.Key ?? null)) { this.GuildWarsClient.Key = token.Key; var guildId = await JS.GetGuildId(); var stashes = await this.GuildWarsClient.V2.GetGuildStashAsync(guildId); var upgradeIds = stashes.Where(x => x.UpgradeId > 0).Select(x => x.UpgradeId).Distinct().AsParallel(); var upgrades = await this.GuildWarsClient.V2.GetGuildUpgradesAsync(upgradeIds); foreach (var stashApi in stashes) { var upgrade = upgrades.SingleOrDefault(x => x.Id == stashApi.UpgradeId); var stash = new Models.Stash(stashApi, upgrade); var itemIds = stashApi.Inventory.Where(x => x != null).Select(x => x.Id).Distinct().AsParallel(); var items = await this.GuildWarsClient.V2.GetItemsAsync(itemIds); foreach (var inventoryItem in stashApi.Inventory) { var item = inventoryItem is null ? null : items.SingleOrDefault(x => x.Id == inventoryItem.Id); var stashItem = new StashItem(inventoryItem, item); stash.Items.Add(stashItem); } this.stashes.Add(stash); } } }
public void ReturnItem(StashItem item) { item.transform.position = this.transform.position; item.GetComponent<CircleCollider2D>().enabled = false; //item.gameObject.SetActive(false); stash.Enqueue(item); }
void OnTriggerEnter2D(Collider2D col) { if (currentItem == null) { if (col.transform.GetComponent <PlayerStash>() != null) { currentItem = col.transform.GetComponent <PlayerStash>().TakeItem(); if (currentItem != null) { Debug.Log("Item stolen"); currentItem.GetComponent <Collider2D>().enabled = false; SetNewGoal(LevelController.GetClostestSpawn(this.transform.position, curDir)); } } else if (col.GetComponent <StashItem>() != null) { currentItem = col.GetComponent <StashItem>(); col.enabled = false; SetNewGoal(LevelController.GetClostestSpawn(this.transform.position, curDir)); } } if (col.gameObject.GetComponent <Bullet>() && col.tag == "Player") { Kill(); } }
public override void AddItem(StashItem item) { if (item.ItemType == StashItemType.TwoHanded) { if (item.LowLvl) { TwoHandedLowLvlItems.Add(item); } else { TwoHandedHighLvlItems.Add(item); } } else { if (item.LowLvl) { OneHandedLowLvlItems.Add(item); } else { OneHandedHighLvlItems.Add(item); } } }
public void ReturnItem(StashItem item) { item.transform.position = this.transform.position; item.GetComponent <CircleCollider2D>().enabled = false; //item.gameObject.SetActive(false); stash.Enqueue(item); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values[0] is StashTabViewModel == false) { Debug.Assert(false); return(null); } StashTabViewModel stashTabViewModel = (StashTabViewModel)values[0]; StashItem selectedStashItem = (StashItem)values[1]; if (selectedStashItem == null) { return(null); } string stashName = selectedStashItem.Name; if (string.IsNullOrEmpty(stashName)) { return(null); } if (stashTabViewModel._gitRepository.TryGetTarget(out IGitRepository gitRepository) == false) { System.Diagnostics.Debug.Assert(false); return(null); } return(gitRepository.GetGitWrapper().GetStashedFileInfos(stashName)); }
public override void DoLowItemReplace() { if (LowLvlItems.Count > 0) //should be always > 0 here { LowLvlItems = LowLvlItems.OrderByDescending(x => x.InventPosX + x.InventPosY * 12).ToList(); _currentSetItem = LowLvlItems[0]; } //else //DebugPlugin.LogMsg("Something goes wrong: Can't do low lvl item replace on " + PartName + "!", 10, Color.Red);//TODO }
private void RemoveItem(StashItem item) { if (item.LowLvl) { LowLvlItems.Remove(item); } else { HighLvlItems.Remove(item); } }
public override void AddItem(StashItem item) { if (item.LowLvl) { LowLvlItems.Add(item); } else { HighLvlItems.Add(item); } }
public StashItem TakeItem() { if (stash.Count <= 0) { return(null); } StashItem currentItem = stash.Dequeue(); //currentItem.gameObject.SetActive(true); return(currentItem); }
private void RemoveItem(StashItem item) { if (item.LowLvl) { TwoHandedLowLvlItems.Remove(item); OneHandedLowLvlItems.Remove(item); } else { TwoHandedHighLvlItems.Remove(item); OneHandedHighLvlItems.Remove(item); } }
public ItemBuffMemory(StashItem stashItem, int endOfSection) { (_stashItem, _endOfSection) = (stashItem, endOfSection); var data = Bytes.AsSpan(Offsets.ItemBuffCount); BuffInstance.ReadList(ref data); // activeBuffs BuffInstance.ReadList(ref data); // inactiveBuffs var selfBuffs = BuffDuration.ReadList(ref data); foreach (var(buffId, _) in selfBuffs) { List.Add(Amalur.GetBuff(buffId)); } }
public void Kill() { Destroy(this.gameObject); LevelController.EnemyKilled(); if (currentItem != null) { currentItem.transform.position = this.transform.position; currentItem.GetComponent <Collider2D>().enabled = true; } currentItem = null; if (Random.Range(0f, 1f) < changeForWeaponDrop) { GameObject droppedWeapon = (GameObject)Instantiate(weapons[Random.Range(0, weapons.Length)].gameObject, this.transform.position, Quaternion.identity); droppedWeapon.GetComponent <SpriteRenderer>().enabled = true; } }
public void Kill() { Destroy(this.gameObject); LevelController.EnemyKilled(); if (currentItem != null) { currentItem.transform.position = this.transform.position; currentItem.GetComponent<Collider2D>().enabled = true; } currentItem = null; if (Random.Range(0f, 1f) < changeForWeaponDrop) { GameObject droppedWeapon = (GameObject)Instantiate(weapons[Random.Range(0, weapons.Length)].gameObject, this.transform.position, Quaternion.identity); droppedWeapon.GetComponent<SpriteRenderer>().enabled = true; } }
private PrepareItemResult LowProcess() { if (LowLvlItems.Count <= 0) { return(null); } if (!LowLvlItems[0].BInPlayerInventory) { LowLvlItems = LowLvlItems.OrderByDescending(x => x.InventPosX + x.InventPosY * 12).ToList(); } _currentSetItem = LowLvlItems[0]; return(new PrepareItemResult() { AllowedReplacesCount = LowLvlItems.Count - 1, LowSet = true, BInPlayerInvent = _currentSetItem.BInPlayerInventory }); }
private PrepareItemResult HighProcess() { if (HighLvlItems.Count <= 0) { return(null); } if (!HighLvlItems[0].BInPlayerInventory) { HighLvlItems = HighLvlItems.OrderByDescending(x => x.InventPosX + x.InventPosY * 12).ToList(); } _currentSetItem = HighLvlItems[0]; return(new PrepareItemResult { AllowedReplacesCount = LowLvlItems.Count, LowSet = false, BInPlayerInvent = _currentSetItem.BInPlayerInventory }); }
void OnTriggerEnter2D(Collider2D col) { if (col.GetComponent<Bullet>() != null && col.tag == "Enemy") { Debug.Log("Player hit"); //Health--; } if (currentItem == null && col.GetComponent<StashItem>() != null) { currentItem = col.GetComponent<StashItem>(); } if (currentItem != null && col.GetComponent<PlayerStash>() != null) { col.GetComponent<PlayerStash>().ReturnItem(currentItem); currentItem = null; } if (col.GetComponent<Weapon>() != null) { if (!col.name.Contains(CurrentWeapon.name)) { Destroy(CurrentWeapon.gameObject); CurrentWeapon = col.GetComponent<Weapon>(); CurrentWeapon.GetComponent<Collider2D>().enabled = false; CurrentWeapon.GetComponent<SpriteRenderer>().enabled = false; CurrentWeapon.start(); } else { CurrentWeapon.GetComponent<Collider2D>().enabled = false; CurrentWeapon.GetComponent<SpriteRenderer>().enabled = false; CurrentWeapon.Upgrade(); Destroy(col.gameObject); } } }
void OnTriggerEnter2D(Collider2D col) { if (col.GetComponent <Bullet>() != null && col.tag == "Enemy") { Debug.Log("Player hit"); //Health--; } if (currentItem == null && col.GetComponent <StashItem>() != null) { currentItem = col.GetComponent <StashItem>(); } if (currentItem != null && col.GetComponent <PlayerStash>() != null) { col.GetComponent <PlayerStash>().ReturnItem(currentItem); currentItem = null; } if (col.GetComponent <Weapon>() != null) { if (!col.name.Contains(CurrentWeapon.name)) { Destroy(CurrentWeapon.gameObject); CurrentWeapon = col.GetComponent <Weapon>(); CurrentWeapon.GetComponent <Collider2D>().enabled = false; CurrentWeapon.GetComponent <SpriteRenderer>().enabled = false; CurrentWeapon.start(); } else { CurrentWeapon.GetComponent <Collider2D>().enabled = false; CurrentWeapon.GetComponent <SpriteRenderer>().enabled = false; CurrentWeapon.Upgrade(); Destroy(col.gameObject); } } }
public Offset(StashItem item) => _item = item;
void OnTriggerEnter2D(Collider2D col) { if (currentItem == null) { if (col.transform.GetComponent<PlayerStash>() != null) { currentItem = col.transform.GetComponent<PlayerStash>().TakeItem(); if (currentItem != null) { Debug.Log("Item stolen"); currentItem.GetComponent<Collider2D>().enabled = false; SetNewGoal(LevelController.GetClostestSpawn(this.transform.position, curDir)); } } else if (col.GetComponent<StashItem>() != null) { currentItem = col.GetComponent<StashItem>(); col.enabled = false; SetNewGoal(LevelController.GetClostestSpawn(this.transform.position, curDir)); } } if (col.gameObject.GetComponent<Bullet>() && col.tag == "Player") { Kill(); } }
public abstract void AddItem(StashItem item);