using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ORKFramework;
using ORKFramework.Behaviours;
using TMPro;
using Cysharp.Threading.Tasks;
using UnityEngine.UI;
using Michsky.UI.ModernUIPack;
using UniRx;
public class UIViewWeaponsListItemPresenter : MonoBehaviour
{
private Combatant player;
public GameObject iconImageObj;
public GameObject lvlTextObj;
public GameObject nextLevelProgressBarObj;
public GameObject lvlUpButtonObj;
public GameObject buyButtonObj;
public GameObject equipButtonObj;
public GameObject atkStatusTextObj;
public GameObject nextExpTextObj;
public GameObject itemNameObj;
public GameObject lockObj;
EquipShortcut playerWeapon;
Weapon myWeapon;
public GameObject inEquipButtonObj;
EquipShortcut weaponShortcut;
// Start is called before the first frame update
void Start()
{
Initialize();
}
public void Initialize()
{
player = ORK.Game.ActiveGroup.Leader;
int myItemID = int.Parse(gameObject.name);
myWeapon = ORK.Weapons.Get(myItemID);
iconImageObj.GetComponent<RawImage>().texture = myWeapon.GetIcon();
itemNameObj.GetComponent<TextMeshProUGUI>().text = myWeapon.GetName();
if (weaponShortcut == null) weaponShortcut = new EquipShortcut(EquipSet.Weapon, myWeapon.ID, 1, 1);
Debug.Log("equip0");
//ここ以下は playerが所持している場合のみ処理
//if (!player.Inventory.Weapons.Contains(myItemID))
//EquipShortcut weaponShortcut = new EquipShortcut(EquipSet.Weapon, myWeapon.ID, 1, 1);
if (!player.Inventory.Has(weaponShortcut))
{
Debug.Log("player not have this weapon");
return;
}
lockObj.SetActive(false);
buyButtonObj.SetActive(false);
equipButtonObj.SetActive(true);
// 装備中は装備中ボタンのみアクティブ
//EquipShortcut item = new EquipShortcut(EquipSet.Weapon, myWeapon.ID, 1, 1);
Debug.Log("equip1");
if (player.Equipment.Parts[0].Equipment.ID == myItemID)
{
Debug.Log("equip1 if");
equipButtonObj.SetActive(false);
inEquipButtonObj.SetActive(true);
}
playerWeapon = player.Inventory.Weapons.Get(myItemID);
lvlTextObj.GetComponent<TextMeshProUGUI>().text = playerWeapon.Level.ToString();
var currentItemExp = player.Status[MyGame.CombatantStatusValue.ItemExp].GetValue();
float currentPercent = ((float)currentItemExp / (float)playerWeapon.MaxLevelPoints) * 100;
nextLevelProgressBarObj.GetComponent<ProgressBar>().currentPercent = currentPercent;
//nextLevelProgressBarObj.GetComponent<ProgressBar>().currentPercent = (player.Status[MyGame.CombatantStatusValue.ItemExp].GetValue() - playerWeapon.MaxLevelPoints) * 100;
atkStatusTextObj.GetComponent<TextMeshProUGUI>().text = "+Atk:" + playerWeapon.GetStatusValueBonus(player, MyGame.CombatantStatusValue.Atk).ToString();
nextExpTextObj.GetComponent<TextMeshProUGUI>().text = "NextLvExp:" + playerWeapon.MaxLevelPoints.ToString();
lvlUpButtonObj.GetComponent<Button>().onClick.AddListener(() => { OnLvlUpButtonClick(playerWeapon);});
equipButtonObj.GetComponent<Button>().onClick.AddListener(() => { OnEquipbuttonClick(); });
}
// インスペクタから設定
public void Equip()
{
player.Equipment.Equip(MyGame.CombatantEquipmentPart.メイン武器, weaponShortcut, player, player, false);
Debug.Log("equip");
Initialize();
}
public void BuyItem()
{
player.Inventory.Add(weaponShortcut, true, true, true);
player.Inventory.SubMoney(0, myWeapon.price.GetBuyPrice(player, null, null),true,true);
Initialize();
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
2) No - ORK is a massive framework with tens of thousands of settings, functions and features.
Some things, as e.g. question 1, are also just a misunderstanding, e.g. an equipped weapon no longer being in the inventory.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!