void Update() { if (this.itemUsing != null && Input.GetMouseButtonDown(0)) { //获取AOE图标投射在世界空间的射线 RaycastHit aimIconHitPoint = SkillManager.GetInstance().GetAimIconRaycastHitInWorldSpace(16f, Input.mousePosition, "Player"); if (aimIconHitPoint.collider != null && "Player".Equals(aimIconHitPoint.collider.tag)) { //Debug.Log (raycastHit.collider.name); PlayerManager.ResetMouseCursor(); this.itemUsing.SetIsTriggering(true); this.itemUsing.itemController.ReduceItemCount(); HealingSalveCoroutine healingSalveCoroutine = PlayerManager.playerGO.AddComponent <HealingSalveCoroutine> (); healingSalveCoroutine.itemUsing = this.itemUsing; //恢复射击 PlayerManager.playerShooting.SetIsShooting(true); } } else if (Input.GetMouseButtonDown(1) || Input.GetButtonDown("Horizontal") || Input.GetButtonDown("Vertical") || Input.GetButtonDown("Cancel")) { //恢复默认的鼠标指针样式 PlayerManager.ResetMouseCursor(); //物品信息也要清空 this.itemUsing = null; } }
void Update() { if (this.itemUsing != null && Input.GetMouseButtonDown(0)) { //获取AOE图标投射在世界空间的射线 RaycastHit aimIconHitPoint = SkillManager.GetInstance().GetAimIconRaycastHitInWorldSpace(16f, Input.mousePosition, ""); if (aimIconHitPoint.collider != null && "Floor".Equals(aimIconHitPoint.collider.tag)) { //Debug.Log (raycastHit.collider.name); PlayerManager.ResetMouseCursor(); this.itemUsing.SetIsTriggering(true); //跳刀没有使用次数的限制 //this.itemUsing.itemController.ReduceItemCount (); //PlayerManager.playerGO.transform.forward = aimIconHitPoint.point.normalized; Quaternion newRotation = Quaternion.LookRotation(aimIconHitPoint.point.normalized); PlayerManager.playerGO.GetComponent <Rigidbody>().MoveRotation(newRotation); PlayerManager.playerGO.transform.position = aimIconHitPoint.point; this.itemUsing = null; //恢复射击 PlayerManager.playerShooting.SetIsShooting(true); } } else if (Input.GetMouseButtonDown(1) || Input.GetButtonDown("Horizontal") || Input.GetButtonDown("Vertical") || Input.GetButtonDown("Cancel")) { //恢复默认的鼠标指针样式 PlayerManager.ResetMouseCursor(); //物品信息也要清空 this.itemUsing = null; } }
public void StartUsing(ItemUsing itemUsing) { if (itemUsing != null) { this.itemUsing = itemUsing; //禁止射击 PlayerManager.playerShooting.SetIsShooting(false); //修改鼠标指针样式为技能图标 PlayerManager.SetMouseCursor("AimSingle"); } }
public void StartUsing(ItemUsing itemUsing) { if (itemUsing != null) { itemUsing.SetIsTriggering(true); itemUsing.itemController.ReduceItemCount(); PlayerManager.playerMana.IncreaseMana(itemUsing.itemInfo.intMP); } }
public void OnMouseDown() { if (Input.GetMouseButtonDown(0)) { Transform itemPanelGOtransform = PlayerManager.itemPanelGO.transform; foreach (Transform boxTransform in itemPanelGOtransform) { if (boxTransform.childCount == 0) { continue; } Transform itemOuterTrans = boxTransform.GetChild(0); if ("Item".Equals(itemOuterTrans.tag)) { ItemController itemController = itemOuterTrans.GetComponent <ItemController> (); //若背包中存在同类物品,则只修改数量 if (this.itemInfo.strEngName.Equals(itemController.itemInfo.strEngName)) { itemController.itemCount++; Transform itemInnerTrans = itemOuterTrans.Find("Item"); Transform countBGTrans = null; if (itemInnerTrans.childCount == 1) { countBGTrans = itemInnerTrans.GetChild(0); countBGTrans.localScale = Vector3.one; Transform countTextTrans = countBGTrans.Find("CountText"); Text countText = countTextTrans.gameObject.GetComponent <Text> (); countText.text = itemController.itemCount.ToString(); this.gameObject.SetActive(false); if (itemInfoPanelGO != null && itemInfoPanelGO.activeInHierarchy) { itemInfoPanelGO.SetActive(false); PlayerManager.ResetMouseCursor(); } } return; } } } foreach (Transform boxTransform in itemPanelGOtransform) { //若背包中不存在同类物品,则将此物品存放在空格中 if (boxTransform.childCount == 0) { //GameObject itemOuterGO = Instantiate (Resources.Load ("Prefabs/Item") as GameObject); GameObject itemOuterGO = ObjectPooler.sharedInstance.GetPooledObjectByTag("Item"); itemOuterGO.transform.parent = boxTransform; itemOuterGO.transform.localPosition = Vector3.zero; itemOuterGO.transform.localScale = Vector3.one; Image itemImg = itemOuterGO.GetComponent <Image> (); itemImg.sprite = Resources.Load(this.itemInfo.strImgName, typeof(Sprite)) as Sprite; itemImg.raycastTarget = true; //首次加入的物品不需要展示数量 Transform countBGTrans = itemOuterGO.transform.Find("Item/CountBG"); countBGTrans.localScale = Vector3.zero; //若当前为技能类物品,将ItemUsing类挂载到物品对象下,点击物品可触发技能 //if (this.itemInfo.intSkillOrBuff == 1) { ItemUsing itemUsing = itemOuterGO.AddComponent <ItemUsing> (); itemUsing.itemInfo = this.itemInfo; //} //挂载相应的物品功能类 if (this.itemInfo.strEntityClassName != null && !"".Equals(this.itemInfo.strEntityClassName)) { Type entityClass = Type.GetType(this.itemInfo.strEntityClassName); itemOuterGO.AddComponent(entityClass); //将Type类对象作为键来获取组件,键必须和加入组件时匹配 //Component itemEntityClass = itemOuterGO.GetComponent (entityClass); //itemEntityClass.SendMessage ("SetItemInfo", this.itemInfo, SendMessageOptions.RequireReceiver); } ItemController itemController = itemOuterGO.GetComponent <ItemController> (); itemController.enabled = true; itemController.itemInfo = this.itemInfo; itemController.itemCount++; itemOuterGO.SetActive(true); Transform itemInnerTrans = itemOuterGO.transform.Find("Item"); if (itemInnerTrans != null) { itemInnerTrans.gameObject.GetComponent <Image>().sprite = Resources.Load(this.itemInfo.strImgName, typeof(Sprite)) as Sprite; } this.gameObject.SetActive(false); if (itemInfoPanelGO != null && itemInfoPanelGO.activeInHierarchy) { itemInfoPanelGO.SetActive(false); PlayerManager.ResetMouseCursor(); } return; } } } }