/// <summary> /// 设置角色死亡 /// </summary> public void SetCharacterDead() { //死亡 handler_Character.CleanCharacter(this); //如果是友方角色死亡 降低升级所需金币 if (characterData.characterType == CharacterTypeEnum.Player) { handler_Game.GetGameData().LevelDownForPlayerPirateNumber(1); //播放粒子特效 handler_Effect.PlayEffect(EffectInfo.PIRATE_DIE_BLUE, transform.position + new Vector3(0, 0.7f, 0)); } else if (characterData.characterType == CharacterTypeEnum.Enemy) { //播放粒子特效 handler_Effect.PlayEffect(EffectInfo.PIRATE_DIE_RED, transform.position + new Vector3(0, 0.7f, 0)); } //刷新UI handler_Game.manager_UI.RefreshAllUI(); //设置角色闲置 SetIntentForIdle(); //掉落金币 if (handGold) { handGold.SetDrop(); } //关闭寻路 aiForCharacterPath.ClosePath(); //协程-删除角色 float destoryTime = handler_GameData.GetCharacterCorpseDestoryTime(); StartCoroutine(CoroutineForCharacterDead(destoryTime)); }
public void MoveParabola(Vector3 targetPosition, float parabolaH, float bulletSpeed) { Vector3[] path = new Vector3[3]; path[0] = transform.position; path[1] = Vector3.Lerp(targetPosition, transform.position, 0.5f) + Vector3.up * parabolaH; path[2] = targetPosition; transform .DOPath(path, bulletSpeed, PathType.CatmullRom) .SetEase(Ease.Linear) .OnComplete(() => { Destroy(gameObject); handler_Effect.PlayEffect(EffectInfo.BULLET_BLOW, transform.position, bulletSpeed); //屏幕震动 UIGameStart uiGameStart = manager_UI.GetUI <UIGameStart>(UIEnum.GameStart); uiGameStart.AnimForShakeUI(); }); SphereCollider bulletCollider = GetComponent <SphereCollider>(); //友方敌方攻击范围颜色 string effectData = ""; if (characterType == CharacterTypeEnum.Player) { effectData = EffectInfo.FIRE_RANGE_BLUE; } else if (characterType == CharacterTypeEnum.Enemy) { effectData = EffectInfo.FIRE_RANGE_RED; } handler_Effect.PlayEffect(effectData, targetPosition, bulletSpeed, Vector3.one * bulletCollider.radius * 0.3f); }
public void OpenFire(Vector3 targetPosition) { if (!canFire) { return; } GameObject objBullet = Instantiate(gameObject, bulletModel, tf_FirePosition.position); ShipBulletCpt shipBullet = objBullet.GetComponent <ShipBulletCpt>(); shipBullet.SetData(shipData.characterType, shipData.bulletDamage); //子弹高度 float bulletHight = handler_GameData.GetBulletHight(); float bulletSpeed = handler_GameData.GetBulletSpeed(); shipBullet.MoveParabola(targetPosition, bulletHight, bulletSpeed); //玩家打炮倒计时 if (shipData.characterType == CharacterTypeEnum.Player) { StartCoroutine(CoroutineForFireCD(shipData.intervalForFire)); } //大炮粒子 handler_Effect.PlayEffect(EffectInfo.SHIP_FIRE, tf_FirePosition.position, 1.4f); //打炮动画 shipAnim.SetShipFire(() => { shipAnim.SetShipIdle(); }); }