// 鱼死亡. public override void KillByBullet(int _canonID, int _multi, int _power, int _npcType) { if (dead) { Debug.Log("Fish is dead, but someone still try to kill it. singleFish.cs - killByBullet() _canonID = " + _canonID); return; } // 关闭碰撞体,子弹就不会打到. cur_Collider.enabled = false; // 播放死亡动画. FishDeadAnim(cur_Animator.Length); // for (int i = 0; i < cur_Animator.Length; i++) // { // if (gameObject.activeSelf) // { // //cur_Animator[i].SetTrigger(deadHash); // cur_Animator[i].framesPerSecond = cur_Animator[i].framesPerSecond * 3; // } // } // 显示到最顶层. UISprite[] renderers = this.GetComponentsInChildren <UISprite>(); for (int i = 0; i < renderers.Length; i++) { var item = renderers[i]; item.depth = deadOrderInLayer; // 把组合鱼的底图设低层 // if (item.gameObject.tag == "fishs_bg") // { // item.depth = deadOrderInLayer - 2; // } } // cur_SpriteRenderer.depth = deadOrderInLayer - 1; transform.localScale *= 1.2f; // 停止游动. StopMove(); // 处理影子,影子也要停止游动,播放死亡动画等. HandleShadow(); // 标志死亡. dead = true; // 取消锁定状态. locking = false; // 打死这条鱼的 玩家id. canonID = _canonID; power = _power; // 从服务器接收到这条鱼的倍率. serverMulti = _multi; // 鱼死亡的分值. fishDeadValue = _power * _multi; // 回收的时间. recycleTargetTime = Time.time + deadTimeLength; // 把这条鱼从记录鱼的缓存 list 中移除. if (!removeFromFishList) { FishCtrl.Instance.RemoveFishAndShadowInList(this); removeFromFishList = true; } // 死亡效果. NPCDeadEffect(_multi, _power); //创建线. switch (fishType) { // 一网打尽创建杀死鱼的线. case FishType.ywdj: // 每次执行一网打尽时候,第一条鱼并没有累计进计数,所以强制累计一条鱼.(和其他方法无关) // CanonCtrl.Instance.shuliang +=1; SpecialFishDeadHandler.Show_YWDJ_Lines(this, ywdjLine, canonID, ywdjKillFishPool, bulletCost, cur_Transform.position, deadTimeLength); break; // 记录要杀死的全屏鱼. case FishType.quanping: SpecialFishDeadHandler.Record_quanPing_KillFish(this); break; // 黑洞创建连接到炮台的线. case FishType.blackHall: if (blackHallLine != null) { blackHallLineCreated = Factory.Create(blackHallLine, Vector3.zero, Quaternion.identity); blackHallLineRend = blackHallLineCreated.GetComponent <LineRenderer>(); // 炮台这一端. // Vector3 _pos0_InLockCam = LockCtrl.Instance.uiCamPos_to_LockCamPos(CanonCtrl.Instance.singleCanonList[_canonID].canonBarrelTrans.position); Vector3 _pos0_InLockCam = CanonCtrl.Instance.singleCanonList[_canonID].canonBarrelTrans.position; blackHallLineRend.SetPosition(1, _pos0_InLockCam); } break; } // 播放死亡音效. if (deadAudio != null) { if (Random.Range(0, 100) >= deadProbability) { //AudioSource.PlayClipAtPoint(deadAudio, Vector3.zero); if (gameObject.GetComponent <UIPlaySound>() != null) { gameObject.GetComponent <UIPlaySound>().enabled = true; } } } // 如果是当鱼死亡后就播放 high score, 就在这里播放. if (showHighScoreWhenFishDead) { if (highScorePrefab != null && fishDeadValue > 0) { HighScoreCtrl.Instance.Create(canonID, highScorePrefab, CanonCtrl.Instance.singleCanonList[canonID].highScorePos, fishDeadValue, CanonCtrl.Instance.singleCanonList[canonID].dir); } } // 如果是普通鱼,那么,当鱼死亡后就播放喇叭,high score 和 喇叭是同时出现的. if (fishDeadValue > 0) { switch (fishType) { case FishType.normal: case FishType.ywdj: // TrumpetCtrl.Instance.CreateOneTrumpet(canonID, serverMulti, fishDeadValue); break; } } // 记录杀死的鱼的类型. 显示到结算面板上. if (_npcType >= 1) { if (_canonID == CanonCtrl.Instance.realCanonID) { CanonCtrl.Instance.KillOneFish(_canonID, _npcType - 1); // 杀死鱼的分数乘以房间倍率除以币值,得到玩家真实赢到的金币数量. fishDeadValue = fishDeadValue * CanonCtrl.Instance.roomMulti / CanonCtrl.Instance.oneGoldScore; // 统计杀死鱼的数量和金币,并显示到account面板上 CanonCtrl.Instance.account_zongfen += fishDeadValue; CanonCtrl.Instance.SetTempGoldAndBeansValue(CanonCtrl.Instance.account_zongfen, CanonCtrl.Instance.account_shuliang); } } // 锁定玩家发炮状态. if (canNotPlayUntilRecycle) { CanonCtrl.Instance.AllowFire(false); } // 震屏. if (shakeCam) { WaveCtrl.Instance.ShakeCamera(); //15.12.14 增加手机震屏 ADa //#if UNITY_ANDROID || UNITY_IPHONE || UNITY_IOS #if !UNITY_STANDALONE_WIN if (AudioCtrl.Instance.m_bIsOpen) { Handheld.Vibrate(); } #endif } }
//全屏死亡 private void quanpingDead() { switch (specialFishDeadState) { // 移动这条鱼到屏幕中心. case SpecialFishDeadState.drag2Center: { specialFishMovePercent += Time.deltaTime * move2CenterSpeed; cur_Transform.position = Vector3.Lerp(move2CenterStartPos, Vector3.zero, specialFishMovePercent); if (specialFishMovePercent > 1f) { // 如果有死亡特效,就做特效. if (deadEffList.Count > 0) { FishDeadEffHandler.CreatedFishDeadEffCtrlItem(this, deadEffList); } // 还剩多长时间就回收鱼 = 鱼死亡时间 - 移动到屏幕的时间. float _leftTimeLength = deadTimeLength - move2CenterTimeLength; if (_leftTimeLength < 0f) { _leftTimeLength = 0f; } // 移动的速度. move2CenterSpeed = 1f / _leftTimeLength; specialFishMovePercent = 0f; specialFishDeadState = SpecialFishDeadState.wait; } break; } case SpecialFishDeadState.wait: { specialFishMovePercent += Time.deltaTime * move2CenterSpeed; if (specialFishMovePercent > 1f) { if (!specialFishHaveAddValue) { // 把分数加给玩家. CanonCtrl.Instance.singleCanonList[canonID].AddValueList(fishDeadValue, 0f); specialFishHaveAddValue = true; } // 处理全屏鱼杀死其他鱼的逻辑. SpecialFishDeadHandler.QuanPing_Kill_Fish(this, canonID, bulletCost); // 鱼身上的分数. // NumCtrl.Instance.CreateFishDeadNum(_value, m_traCache.position, Quaternion.identity); // 鱼的 bubble 分数. NumCtrl.Instance.AdddBubble2List(serverMulti, fishDeadValue, CanonCtrl.Instance.singleCanonList[canonID].bubbleShowUpPos.position, Quaternion.identity, CanonCtrl.Instance.singleCanonList[canonID].upsideDown); // 鱼的金币. CoinCtrl.Instance.CreateCoins(canonID, coinType, coinNum, cur_Transform.position, playCoinAudio); // 如果不是当鱼死亡后就播放 high score, 就在这里播放. if (!showHighScoreWhenFishDead) { // 有high score 预设,并且分数不为0. if (highScorePrefab != null && fishDeadValue > 0) { HighScoreCtrl.Instance.Create(canonID, highScorePrefab, CanonCtrl.Instance.singleCanonList[canonID].highScorePos, fishDeadValue, CanonCtrl.Instance.singleCanonList[canonID].dir); } } // 创建 喇叭. // TrumpetCtrl.Instance.CreateOneTrumpet(canonID, serverMulti, fishDeadValue); // 创建金币柱. if (TotalCylinderCtrl.Instance.showCylider) { TotalCylinderCtrl.Instance.singleCylinderList[canonID].Add2Need2CreateList(serverMulti, fishDeadValue, CanonCtrl.Instance.singleCanonList[canonID].cylinderShowUpPos.position); } // 恢复玩家发炮状态. if (canNotPlayUntilRecycle) { CanonCtrl.Instance.AllowFire(true); } // 回收鱼. RecycleFish(); } break; } } }