//TODO:拾取掉落物品 IEnumerator PickTreasure() { Log.Sys("PickThisTreasure " + itemData.ItemName); Vector2 dir = Random.insideUnitCircle; float curFlySpeed = 0; Vector3 upSpeed = new Vector3(0, 5, 0); Vector3 moveDirection = new Vector3(dir.x, 0, dir.y); var controller = GetComponent <CharacterController> (); float Gravity = 5.0f; float passTime = 0; float rotSpeed = 360; while (passTime < 2f) { curFlySpeed = Mathf.Lerp(curFlySpeed, 2, 5 * Time.deltaTime); var movement = moveDirection * curFlySpeed + upSpeed; movement *= Time.deltaTime; controller.Move(movement); upSpeed.y -= Gravity * Time.deltaTime; passTime += Time.deltaTime; transform.localRotation = Quaternion.Euler(rotSpeed * Time.deltaTime, 0, 0) * transform.localRotation; yield return(null); } yield return(new WaitForSeconds(1)); float flySpeed = 20; float UpSpeed = 10; upSpeed = new Vector3(0, UpSpeed, 0); while (true) { if (player == null) { break; } moveDirection = player.transform.position - transform.position; if (moveDirection.magnitude < 0.3f) { break; } var nor = moveDirection.normalized; var movement = nor * flySpeed + upSpeed; movement *= Time.deltaTime; controller.Move(movement); upSpeed.y -= Gravity * Time.deltaTime; passTime += Time.deltaTime; yield return(null); } BackgroundSound.Instance.PlayEffect("pickup"); GameObject.Destroy(gameObject); GameInterface_Backpack.PickItem(itemData, num); IsOnGround = false; }
public void PickItemFromNetwork(GameObject who) { pickYet = true; BackgroundSound.Instance.PlayEffect("pickup"); GameObject.Destroy(gameObject); var me = ObjectManager.objectManager.GetMyPlayer(); if (who == me) { if (itemData.UnitType == ItemData.UnitTypeEnum.POWER_DRUG) { WindowMng.windowMng.ShowNotifyLog("炸弹威力上升"); GameInterface_Backpack.LearnSkill((int)SkillData.SkillConstId.Bomb); } else if (itemData.UnitType == ItemData.UnitTypeEnum.QIPAO_DRUG) { var attr = ObjectManager.objectManager.GetMyAttr(); attr.AddMpMax(20); attr.AddThrowSpeed(0.1f); WindowMng.windowMng.ShowNotifyLog("MP上限增加"); } else if (itemData.UnitType == ItemData.UnitTypeEnum.XieZi_DRUG) { ObjectManager.objectManager.GetMyAttr().AddNetSpeed(0.1f); WindowMng.windowMng.ShowNotifyLog("速度提升"); } else { GameInterface_Backpack.PickItem(itemData, num); } } }
public void PickItemFromNetwork(GameObject who) { pickYet = true; var whoAttr = NetworkUtil.GetAttr(who); BackgroundSound.Instance.PlayEffect("pickup"); GameObject.Destroy(gameObject); var me = ObjectManager.objectManager.GetMyPlayer(); Log.Sys("PickItemFromNetwork: " + whoAttr + " itemType: " + itemData.UnitType); var gen = Resources.Load <GameObject>("particles/drops/generic_item"); var par = ParticlePool.Instance.GetGameObject(gen, ParticlePool.InitParticle); //var par = Instantiate() as GameObject; //par.transform.parent = g.transform; par.transform.position = gameObject.transform.position; var rm = par.AddMissingComponent <RemoveSelf>(); rm.StartCoroutine(rm.WaitReturn(3)); if (whoAttr != null && whoAttr.gameObject == me) { if (itemData.UnitType == ItemData.UnitTypeEnum.POWER_DRUG) { WindowMng.windowMng.ShowNotifyLog("炸弹威力上升"); GameInterface_Backpack.LearnSkill((int)SkillData.SkillConstId.Bomb); } else if (itemData.UnitType == ItemData.UnitTypeEnum.QIPAO_DRUG) { var attr = ObjectManager.objectManager.GetMyAttr(); attr.AddMpMax(20); attr.AddThrowSpeed(0.1f); WindowMng.windowMng.ShowNotifyLog("MP上限增加"); } else if (itemData.UnitType == ItemData.UnitTypeEnum.XieZi_DRUG) { ObjectManager.objectManager.GetMyAttr().AddNetSpeed(0.1f); WindowMng.windowMng.ShowNotifyLog("速度提升"); } else if (itemData.UnitType == ItemData.UnitTypeEnum.LIAN_FA) { GameInterface_Skill.AddSkillBuff(me, (int)GameBuff.LianFa, Vector3.zero); WindowMng.windowMng.ShowNotifyLog("连发弹"); } else if (itemData.UnitType == ItemData.UnitTypeEnum.POTION) { GameInterface_Skill.AddSkillBuff(me, (int)GameBuff.AddHP, Vector3.zero); WindowMng.windowMng.ShowNotifyLog("恢复生命"); } else if (itemData.UnitType == ItemData.UnitTypeEnum.FASHI) { var attr = ObjectManager.objectManager.GetMyAttr(); attr.SetNetSpeed(0); attr.SetJob(Job.ALCHEMIST); WindowMng.windowMng.ShowNotifyLog("攻击提升", 2, null, true); WindowMng.windowMng.ShowNotifyLog("生命值变化", 2, null, true); } else if (itemData.UnitType == ItemData.UnitTypeEnum.CIKE) { var attr = ObjectManager.objectManager.GetMyAttr(); attr.SetJob(Job.ARMOURER); attr.SetNetSpeed(0.5f); WindowMng.windowMng.ShowNotifyLog("移动速度加快", 2, null, true); WindowMng.windowMng.ShowNotifyLog("生命值变化", 2, null, true); } else if (itemData.UnitType == ItemData.UnitTypeEnum.SUPER) { GameInterface_Skill.AddBuffWithNet(me, (int)GameBuff.SuperShoot, Vector3.zero); WindowMng.windowMng.ShowNotifyLog("拾获超能子弹", 2, null, true); } else if (itemData.UnitType == ItemData.UnitTypeEnum.HIDE) { GameInterface_Skill.AddBuffWithNet(me, (int)GameBuff.Hide, Vector3.zero); WindowMng.windowMng.ShowNotifyLog("拾获隐身药水", 2, null, true); } else if (itemData.UnitType == ItemData.UnitTypeEnum.NUCLEAR) { GameInterface_Skill.AddBuffWithNet(me, (int)GameBuff.NuclearBuff, Vector3.zero); WindowMng.windowMng.ShowNotifyLog("拾获核弹,使用后立即逃离区域", 4, null, true); } else if (itemData.UnitType == ItemData.UnitTypeEnum.KNOCK) { GameInterface_Skill.AddBuffWithNet(me, (int)GameBuff.KnockBuff, Vector3.zero); WindowMng.windowMng.ShowNotifyLog("获得击退能力", 4, null, true); } else if (itemData.UnitType == ItemData.UnitTypeEnum.WUDI) { GameInterface_Skill.AddBuffWithNet(me, (int)GameBuff.WuDi, Vector3.zero); } else if (itemData.UnitType == ItemData.UnitTypeEnum.DaoDan) { GameInterface_Skill.AddBuffWithNet(me, (int)GameBuff.DaoDan, Vector3.zero); } else if (itemData.UnitType == ItemData.UnitTypeEnum.DefaultSkill) { GameInterface_Skill.AddBuffWithNet(me, itemData.triggerBuffId, Vector3.zero); Util.ShowMsg("获得" + itemData.ItemName); } else { GameInterface_Backpack.PickItem(itemData, num); } } }