void Update() { #if UnityEditor //背包加药品 if (Input.GetKeyDown(KeyCode.P)) { int x = 0; BagBoard.Instance().PickOneItemById(x = Random.Range(1001, 1004)); Debug.Log(x); } //背包加装备 if (Input.GetKeyDown(KeyCode.O)) { int x = 0; BagBoard.Instance().PickOneItemById(x = Random.Range(2001, 2023)); Debug.Log(x); } //商店加药品 if (Input.GetKeyDown(KeyCode.L)) { ShopBoard.Instance().AddOneShopItemById(c++); Debug.Log(c); } //商店加装备 if (Input.GetKeyDown(KeyCode.K)) { ShopBoard.Instance().AddOneShopItemById(z++); Debug.Log(z); } //扣血 if (Input.GetKeyDown(KeyCode.M)) { PlayerStatusManager.Instance().ReduceHp(50); } //加钱 if (Input.GetKeyDown(KeyCode.UpArrow)) { CoinManager.Instance().AddCoin(50); } //扣钱 if (Input.GetKeyDown(KeyCode.DownArrow)) { CoinManager.Instance().ReduceCoin(50); } //加点 if (Input.GetKeyDown(KeyCode.KeypadPlus)) { PlayerStatusManager.Instance().AddPoint(); } //加技能 if (Input.GetKeyDown(KeyCode.B)) { SkillBoard.Instance().AddOneSkillById(4001); SkillBoard.Instance().AddOneSkillById(4002); SkillBoard.Instance().AddOneSkillById(4003); } #endif }
//这里设置成从物品上走开再拾取,避免物品刚下落就被捡起看不到物品 void OnTriggerExit(Collider other) { if (other.tag == "Player") { BagBoard.Instance().PickOneItemById(id); this.GetComponent <BoxCollider>().enabled = false; Destroy(this.gameObject, 0.1f); } }
/// <summary> /// 从此装备栏中移除装备信息 /// </summary> public void UnloadThisGridEquip() { //移除装备赋予玩家的属性 PlayerStatusManager.Instance().ReduceProperties(info); //物品栏添加该物品 BagBoard.Instance().PickOneItemById(this.id); //此栏装备清空 this.id = 0; this.info = null; DestroyImmediate(this.GetComponentInChildren <Item>().transform.gameObject); }
/// <summary> /// Buy按钮回调 /// </summary> public void BuyButtonClick() { int price = ObjectsInfo.Instance().GetObjectInfoById(id).price_buy; Debug.Log("价格为" + price); if (CoinManager.Instance().ReduceCoin(price)) { //添加进背包 BagBoard.Instance().PickOneItemById(id); } else { Debug.Log("金币不足"); } }
void Awake() { _instance = this; base.Init(); }