public void GetChosen() { endingTurn = attacking = holdingWeapon = false; regularModeObject.SetActive(false); SetAsPlayer(); LevelFlow.SetTurnPart(LevelFlow.TurnPart.soldierWeaponChoice); canvas.gameObject.SetActive(true); for (int j = weaponSelectionIcons.Count - 1; j >= 0; j--) { Destroy(weaponSelectionIcons[j]); } weaponSelectionIcons.Clear(); soldierInfoPivot.gameObject.SetActive(false); foreach (var weapon in playerInstance.weaponInformations.weapons) { WeaponSelectionIcon icon = Instantiate(weaponSelectionButtonPrefab, weaponSelectionGrid).GetComponent <WeaponSelectionIcon>(); Item item = weapon.weaponPrefab.GetComponent <Item>(); icon.weapon = weapon; icon.soldier = this; icon.iconImage.sprite = item.icon; icon.nameText.text = item.itemName; icon.weaponCountText.text = weapon.usagesForStart.ToString(); icon.uIInteractable.tooltipText.text = item.description; if (weapon.usagesForStart <= 0) { icon.bgImage.color = Color.grey; icon.button.enabled = false; } weaponSelectionIcons.Add(icon.gameObject); } }
public void ChooseWeapon(WeaponSelectionIcon icon) { holdingWeapon = true; canvas.gameObject.SetActive(false); GameObject weapon = Instantiate(icon.weapon.weaponPrefab); spawnedItem = weapon.GetComponent <Item>(); spawnedItem.Set(this); Game.Player.EquipItem(spawnedItem); LevelFlow.SetTurnPart(LevelFlow.TurnPart.soldierMovement); if (LevelFlow.levelSetupInfo.timerGame) { Game.Player.timer.SetTimer(10); StartCoroutine(ChooseWeaponCoroutine(10)); } else { StartCoroutine(ChooseWeaponCoroutine(Mathf.Infinity)); } }