Ejemplo n.º 1
0
	/**
	 * paoKou == 0 -> 机枪炮口.
	 * paoKou == 1 -> 主炮炮口.
	 */
	void CheckPlayerHouZuoLi(BuJiBaoType daoJuType, int paoKou)
	{
		float pushPower = 50f;
		switch (daoJuType) {
		case BuJiBaoType.QianHouFireDJ:
			pushPower = XKPlayerGlobalDt.GetInstance().QianHouFirePTPower;
			break;
		case BuJiBaoType.ChangChengJiQiang:
			pushPower = XKPlayerGlobalDt.GetInstance().ChangChengFirePTPower;
			break;
		case BuJiBaoType.SanDanJiQiang:
			pushPower = XKPlayerGlobalDt.GetInstance().SanDanFirePTPower;
			break;
		case BuJiBaoType.QiangJiJiQiang:
			pushPower = XKPlayerGlobalDt.GetInstance().QiangJiFirePTPower;
			break;
		case BuJiBaoType.ChuanTouDan:
			pushPower = XKPlayerGlobalDt.GetInstance().ChuanJiaDanZPPower;
			break;
		case BuJiBaoType.PaiJiPaoDJ:
			pushPower = XKPlayerGlobalDt.GetInstance().PaiJiPaoZPPower;
			break;
		case BuJiBaoType.ZhuPaoSanDanDJ:
			pushPower = XKPlayerGlobalDt.GetInstance().SanDanZPPower;
			break;
		case BuJiBaoType.HuoLiAllOpenDJ:
			if (paoKou == JI_QIANG_INDEX) {
				pushPower = XKPlayerGlobalDt.GetInstance().HuoLiQuanKaiPTPower;
			}

			if (paoKou == ZHU_PAO_INDEX) {
				pushPower = XKPlayerGlobalDt.GetInstance().HuoLiQuanKaiZPPower;
			}
			break;
		default:
			if (paoKou == JI_QIANG_INDEX) {
				pushPower = XKPlayerGlobalDt.GetInstance().JiQiangFirePTPower;
			}
			
			if (paoKou == ZHU_PAO_INDEX) {
				pushPower = XKPlayerGlobalDt.GetInstance().ZhuPaoFireZPPower;
			}
			break;
		}

		Vector3 pushDir = IsLockPaoTa == false ? -TanKeTran.forward : -PaoTaTr.forward;
		if (IsLockPaoTa && CameraTran != null) {
			Vector3 veA = CameraTran.forward;
			Vector3 veB = TanKeTran.forward;
			veA.y = veB.y = 0f;
			float angleVal = Mathf.Clamp(Vector3.Angle(veA, veB), 0f, 90f);
			if (angleVal > 5f) {
				return;
			}
		}
		PlayerMoveScript.PushPlayerTanKe(pushDir, pushPower);
	}
Ejemplo n.º 2
0
	// Use this for initialization
	void Start()
	{
		TanKeTran = transform;
		AmmoParticle = XKPlayerGlobalDt.GetInstance().AmmoParticle;
		SanDanAmmoParticle = XKPlayerGlobalDt.GetInstance().SanDanAmmoParticle;
		PaiJiPaoAmmoParticle = XKPlayerGlobalDt.GetInstance().PaiJiPaoAmmoParticle;
		ChuanTouDanAmmoParticle = XKPlayerGlobalDt.GetInstance().ChuanTouDanAmmoParticle;
		DaoDanAmmoParticle = XKPlayerGlobalDt.GetInstance().DaoDanAmmoParticle;

		PuTongAmmo = XKPlayerGlobalDt.GetInstance().PuTongJQAmmo;
		DaoDanZPAmmo = XKPlayerGlobalDt.GetInstance().DaoDanZPAmmo;
		ChuanTouDanAmmo = XKDaoJuGlobalDt.GetInstance().AmmoChuanJiaDanZP;
		AmmoSanDanZP = XKDaoJuGlobalDt.GetInstance().AmmoSanDanZP;
		PaiJiPaoAmmo = XKDaoJuGlobalDt.GetInstance().AmmoPaiJiPao;
		ChangChengAmmo = XKDaoJuGlobalDt.GetInstance().AmmoChangCheng;
		QiangJiAmmo = XKDaoJuGlobalDt.GetInstance().AmmoQiangJi;
		AmmoHuoLiOpenJQ = XKDaoJuGlobalDt.GetInstance().AmmoHuoLiOpenJQ;
		AmmoHuoLiOpenZP = XKDaoJuGlobalDt.GetInstance().AmmoHuoLiOpenZP;
		Frequency = XKPlayerGlobalDt.GetInstance().Frequency;

		//AmmoParticleList = new List<AmmoParticleDt>(6);
		FireLayer = XkGameCtrl.GetInstance().PlayerAmmoHitLayer;
		AmmoStateJiQiang = PlayerAmmoType.PuTongAmmo;
		AmmoStateZhuPao = PlayerAmmoType.DaoDanAmmo;

		int fireAudioLen = PlayerFireAudio.Length;
		for (int i = 0; i < fireAudioLen; i++) {
			if (PlayerFireAudio[i] == null) {
				continue;
			}
			PlayerFireAudio[i].loop = false;
			PlayerFireAudio[i].Stop();
		}

		InitPlayerAmmoList();
		switch (PlayerIndex) {
		case PlayerEnum.PlayerOne:
			InputEventCtrl.GetInstance().ClickFireBtOneEvent += ClickFireBtEvent;
			InputEventCtrl.GetInstance().ClickDaoDanBtOneEvent += ClickFireDaoDanBtEvent;
			break;
		case PlayerEnum.PlayerTwo:
			InputEventCtrl.GetInstance().ClickFireBtTwoEvent += ClickFireBtEvent;
			InputEventCtrl.GetInstance().ClickDaoDanBtTwoEvent += ClickFireDaoDanBtEvent;
			break;
		case PlayerEnum.PlayerThree:
			InputEventCtrl.GetInstance().ClickFireBtThreeEvent += ClickFireBtEvent;
			InputEventCtrl.GetInstance().ClickDaoDanBtThreeEvent += ClickFireDaoDanBtEvent;
			break;
		case PlayerEnum.PlayerFour:
			InputEventCtrl.GetInstance().ClickFireBtFourEvent += ClickFireBtEvent;
			InputEventCtrl.GetInstance().ClickDaoDanBtFourEvent += ClickFireDaoDanBtEvent;
			break;
		}
        CreatPlayerXiaoFeiJi();
    }
    void MoveAmmoByItween(Vector3 firePos, NpcPathCtrl ammoMovePath)
    {
        if (ammoMovePath == null)
        {
            Vector3[] posArray = new Vector3[2];
            posArray[0] = AmmoTran.position;
            float lobTime = Vector3.Distance(firePos, posArray[0]) / MvSpeed;
            if (AmmoType == PlayerAmmoType.GenZongAmmo ||
                AmmoType == PlayerAmmoType.PaiJiPaoAmmo)
            {
                Vector3 posTmp = AmmoType == PlayerAmmoType.GenZongAmmo ? GetGenZongDanFirePos() : firePos;
                if (posTmp != Vector3.zero)
                {
                    firePos = posTmp;
                }

                if (AmmoType == PlayerAmmoType.PaiJiPaoAmmo)
                {
                    RaycastHit hit;
                    Vector3    posA = firePos + Vector3.up * 50f;
                    Physics.Raycast(posA, Vector3.down, out hit, 500f, XkGameCtrl.GetInstance().LandLayer);
                    if (hit.collider != null)
                    {
                        firePos = hit.point;
                    }
                }

                if (AmmoType == PlayerAmmoType.PaiJiPaoAmmo && PaiJiPaoTiShiPrefab != null)
                {
                    PaiJiPaoTiShi = (GameObject)Instantiate(PaiJiPaoTiShiPrefab, firePos, Quaternion.identity);
                    if (XkGameCtrl.NpcAmmoArray != null)
                    {
                        PaiJiPaoTiShi.transform.parent = XkGameCtrl.NpcAmmoArray;
                    }
                }

                float disMV = Vector3.Distance(firePos, posArray[0]);
                lobTime = disMV / MvSpeed;
                float lobHeight = disMV * XKPlayerGlobalDt.GetInstance().KeyPaiJiPaoValPlayer;
                //lobHeight = lobHeight > 10f ? 10f : lobHeight;
                AmmoCore.transform.localPosition    = Vector3.zero;
                AmmoCore.transform.localEulerAngles = Vector3.zero;
                iTween.MoveBy(AmmoCore, iTween.Hash("y", lobHeight,
                                                    "time", lobTime / 2,
                                                    "easeType", iTween.EaseType.easeOutQuad));
                iTween.MoveBy(AmmoCore, iTween.Hash("y", -lobHeight,
                                                    "time", lobTime / 2,
                                                    "delay", lobTime / 2,
                                                    "easeType", iTween.EaseType.easeInCubic));
                //iTween.FadeTo(gameObject, iTween.Hash("delay", 3, "time", .5, "alpha", 0, "onComplete", "CleanUp"));
            }
            posArray[1] = firePos;
            //AmmoStartPos = AmmoTran.position;
            iTween.MoveTo(gameObject, iTween.Hash("position", firePos,
                                                  "time", lobTime,
                                                  "easeType", iTween.EaseType.linear,
                                                  "oncomplete", "MoveAmmoOnCompelteITween"));
        }
        else
        {
            int              countMark = ammoMovePath.transform.childCount;
            Transform[]      tranArray = ammoMovePath.transform.GetComponentsInChildren <Transform>();
            List <Transform> nodesTran = new List <Transform>(tranArray)
            {
            };
            nodesTran.Remove(ammoMovePath.transform);
            transform.position = nodesTran[0].position;
            transform.rotation = nodesTran[0].rotation;
            firePos            = nodesTran[countMark - 1].position;
            //AmmoStartPos = nodesTran[countMark-2].position;
            iTween.MoveTo(ObjAmmo, iTween.Hash("path", nodesTran.ToArray(),
                                               "speed", MvSpeed,
                                               "orienttopath", true,
                                               "easeType", iTween.EaseType.linear,
                                               "oncomplete", "MoveAmmoOnCompelteITween"));
        }
        //AmmoEndPos = firePos;
    }
    public void OnDamageNpc(int damageNpcVal         = 1,
                            PlayerEnum playerSt      = PlayerEnum.Null,
                            PlayerAmmoType pAmmoType = PlayerAmmoType.Null,
                            bool isAiFireAmmo        = false)
    {
        if (IsDeathNpc)
        {
            return;
        }

        if (pAmmoType == PlayerAmmoType.SanDanAmmo)
        {
            if (Time.time - TimeSanDanDamage < XKPlayerGlobalDt.GetInstance().TimeShouDongDaoDan)
            {
                //对于玩家的主炮散弹在同一次发射内只计算一次伤害.
                //SSDebug.LogWarning("************* pAmmoType ====== " + pAmmoType);
                return;
            }
            TimeSanDanDamage = Time.time;
        }

        if (pAmmoType == PlayerAmmoType.ChuanTouAmmo)
        {
            if (XKPlayerMvFanWei.GetInstanceQian() != null && XKPlayerCamera.GetInstanceFeiJi() != null)
            {
                Vector3 forwardVecCam = XKPlayerCamera.GetInstanceFeiJi().transform.forward;
                Vector3 posA          = transform.position;
                Vector3 posB          = XKPlayerMvFanWei.GetInstanceQian().transform.position;
                forwardVecCam.y = posA.y = posB.y = 0f;
                Vector3 vecBA = posA - posB;
                if (Vector3.Dot(forwardVecCam, vecBA) >= 0f)
                {
                    //npc在镜头前方范围之外,不受玩家子弹伤害.
                    return;
                }
            }
        }

        if (IsBackDaiJinQuanNpcBlood == true)
        {
            //代金券npc重置血值后,给一定时间的无敌状态.
            if (Time.time - m_TimeLastBackDaiJinQuanNpcBlood <= 0.5f)
            {
                return;
            }
            else
            {
                IsBackDaiJinQuanNpcBlood = false;
            }
        }

        //switch (NpcJiFen)
        //{
        //    case NpcJiFenEnum.Boss:
        //        if (!XKBossXueTiaoCtrl.GetInstance().GetIsCanSubXueTiaoAmount())
        //        {
        //            if (NpcDamageCom != null)
        //            {
        //                NpcDamageCom.PlayNpcDamageEvent();
        //            }
        //            return;
        //        }
        //        break;
        //}


        if (NpcDamageCom != null)
        {
            NpcDamageCom.PlayNpcDamageEvent();
        }

        if (NpcScript != null)
        {
            if (NpcScript.IsCaiPiaoZhanChe == true && NpcScript.IsEnterCameraBox == false)
            {
                //彩票战车和boss没有进入摄像机盒子,不计算伤害.
                return;
            }
        }

        if (CountActivePlayer != XkGameCtrl.PlayerActiveNum)
        {
            if (CountActivePlayer != 0)
            {
                //fix PuTongAmmoCount.
                int indexValTmp      = CountActivePlayer - 1;
                int puTongAmmoNumTmp = MaxPuTongAmmo[indexValTmp];
                indexValTmp = XkGameCtrl.PlayerActiveNum - 1;
                if (indexValTmp >= 0)
                {
                    float healthPer = (float)PuTongAmmoCount / puTongAmmoNumTmp;
                    //int oldPuTongAmmoCount = PuTongAmmoCount;
                    PuTongAmmoCount = (int)(healthPer * MaxPuTongAmmo[indexValTmp]);

                    /*Debug.Log("Unity:"+"fix npc health -> PuTongAmmoCount "+PuTongAmmoCount
                     +", oldPuTongAmmoCount "+oldPuTongAmmoCount);*/
                }
            }
            CountActivePlayer = XkGameCtrl.PlayerActiveNum;
        }

        if (NpcScript == null || (NpcScript != null && !NpcScript.GetIsWuDi()))
        {
            PuTongAmmoCount += damageNpcVal;
        }

        int indexVal = XkGameCtrl.PlayerActiveNum - 1;

        indexVal = indexVal < 0 ? 0 : indexVal;
        int puTongAmmoNum = MaxPuTongAmmo[indexVal];

        if (NpcScript != null)
        {
            if (NpcScript.IsZhanCheNpc || NpcScript.IsJPBossNpc)
            {
                if (XkGameCtrl.GetInstance().m_GamePlayerAiData.IsActiveAiPlayer == true)
                {
                    //当没有玩家激活游戏时,彩票战车和JPBoss采用原血量的一定比例来计算.
                    puTongAmmoNum = (int)(XkGameCtrl.GetInstance().m_ZhanCheBossBloodPer *puTongAmmoNum);
                }
            }
        }

        /*if (NpcJiFen == NpcJiFenEnum.Boss)
         * {
         *              float bossAmount = (float)(puTongAmmoNum - PuTongAmmoCount) / puTongAmmoNum;
         *              bossAmount = bossAmount < 0f ? 0f : bossAmount;
         *  if (XKBossXueTiaoCtrl.GetInstance() != null)
         *  {
         *      XKBossXueTiaoCtrl.GetInstance().SetBloodBossAmount(bossAmount, this);
         *  }
         *      }*/

        if (NpcScript != null)
        {
            if (NpcScript.IsCaiPiaoZhanChe == true)
            {
                if (XkGameCtrl.GetInstance() != null && XKPlayerFenShuCtrl.GetInstance() != null)
                {
                    if (pAmmoType == PlayerAmmoType.DaoDanAmmo ||
                        pAmmoType == PlayerAmmoType.PaiJiPaoAmmo ||
                        pAmmoType == PlayerAmmoType.ChuanTouAmmo ||
                        pAmmoType == PlayerAmmoType.SanDanAmmo ||
                        pAmmoType == PlayerAmmoType.ChongJiBoAmmo)
                    {
                        int jiFenVal = XkGameCtrl.GetInstance().m_DaoDanHitBossJiFen;
                        //XKPlayerFenShuCtrl.GetInstance().ShowPlayerFenShu(playerSt, GetJiFen(jiFenVal));
                        XKPlayerFenShuCtrl.GetInstance().ShowPlayerFenShu(playerSt, jiFenVal);
                    }
                }

                float bloodAmount = (float)(puTongAmmoNum - PuTongAmmoCount) / puTongAmmoNum;
                bloodAmount = bloodAmount < 0f ? 0f : bloodAmount;

                bool isCanJiBao = true;
                if (XkGameCtrl.GetInstance().m_GamePlayerAiData.IsActiveAiPlayer == true)
                {
                    //没有玩家激活游戏时,Ai都认为是可以击爆战车或Boss.
                }
                else
                {
                    //有玩家激活游戏.
                    if (XkGameCtrl.GetInstance().m_CaiPiaoHealthDt != null)
                    {
                        isCanJiBao = XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.m_CurrentTotalHealthDt.IsCanJiBao;
                    }
                }

                if (isCanJiBao == false)
                {
                    //不允许被玩家击爆的代金券npc.
                    if (IsBloodToStage02 == false)
                    {
                        if (bloodAmount <= 0.24f)
                        {
                            //强制保留一定的血量.
                            m_BloodAmoutValue      = bloodAmount = 0.24f;
                            IsBloodToStage02       = true;
                            m_TimeLastBloodToStage = Time.time;
                            PuTongAmmoCount        = puTongAmmoNum - 1;
                        }
                    }
                    else if (IsBloodToStage01 == false)
                    {
                        float minBloodAmount = 0.12f; //最小极限血值.
                        if (m_BloodAmoutValue > minBloodAmount)
                        {
                            //血值已经降到最低阶段.
                            float dTimeVal = 0.4f;
                            if (XkGameCtrl.GetInstance().m_CaiPiaoHealthDt != null)
                            {
                                dTimeVal = XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.m_TimeNoDead;
                            }

                            if (Time.time - m_TimeLastBloodToStage >= dTimeVal)
                            {
                                //每次间隔一定时间减少一定血值.
                                m_TimeLastBloodToStage = Time.time;
                                float subBloodAmount = 0.02f; //每次减少的血值.
                                if (m_BloodAmoutValue > minBloodAmount)
                                {
                                    m_BloodAmoutValue -= subBloodAmount;
                                    if (m_BloodAmoutValue < minBloodAmount)
                                    {
                                        //强制保护的血值信息.
                                        m_BloodAmoutValue = minBloodAmount;
                                        IsBloodToStage01  = true;
                                    }
                                }
                            }
                        }
                        bloodAmount     = m_BloodAmoutValue;
                        PuTongAmmoCount = puTongAmmoNum - 1; //强制保留一定的血值.
                    }
                    else
                    {
                        float minBloodAmount = 0.03f; //最小极限血值.
                        if (m_BloodAmoutValue > minBloodAmount)
                        {
                            //血值已经降到最低阶段.
                            float dTimeVal = 0.4f;
                            if (XkGameCtrl.GetInstance().m_CaiPiaoHealthDt != null)
                            {
                                dTimeVal = XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.m_TimeNoDead;
                            }

                            if (Time.time - m_TimeLastBloodToStage >= dTimeVal)
                            {
                                //每次间隔一定时间减少一定血值.
                                m_TimeLastBloodToStage = Time.time;
                                float subBloodAmount = 0.01f; //每次减少的血值.
                                if (m_BloodAmoutValue > minBloodAmount)
                                {
                                    m_BloodAmoutValue -= subBloodAmount;
                                    if (m_BloodAmoutValue < minBloodAmount)
                                    {
                                        //强制保护的血值信息.
                                        m_BloodAmoutValue = minBloodAmount;
                                    }
                                }
                            }
                        }
                        bloodAmount     = m_BloodAmoutValue;
                        PuTongAmmoCount = puTongAmmoNum - 1; //强制保留一定的血值.
                    }
                }

                //彩票战车和boss的血条UI信息更新.
                SSUIRoot.GetInstance().m_GameUIManage.SetDaiJinQuanNpcXueTiaoAmount(bloodAmount);

                if (XkGameCtrl.GetInstance().m_GamePlayerAiData.IsActiveAiPlayer == true)
                {
                    //没有玩家激活游戏时,Ai都认为是不可以击爆JPBoss特殊武器的.
                }
                else
                {
                    //JPBoss受到玩家子弹伤害.
                    if (NpcScript.IsJPBossNpc == true)
                    {
                        NpcScript.OnDamageJPBossWeapon(bloodAmount);
                    }
                }
            }
        }

        /*Debug.Log("Unity:"+"OnDamageNpc -> "
         +", nameNpc "+NpcNameInfo
         +", puTongAmmoNum "+puTongAmmoNum);*/
        if (PuTongAmmoCount >= puTongAmmoNum)
        {
            if (NpcScript != null)
            {
                if (NpcScript.IsZhanCheNpc)
                {
                    //战车npc是否可以被击爆的判断.
                    if (XkGameCtrl.GetInstance().IsCaiPiaoHuLuePlayerIndex == false && NpcScript.m_IndexPlayerJiBao != playerSt)
                    {
                        //不是可以击爆战车npc的玩家.
                        return;
                    }

                    if (XkGameCtrl.GetInstance().m_GamePlayerAiData.IsActiveAiPlayer == true)
                    {
                        //没有激活任何玩家.
                    }
                    else
                    {
                        if (!XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage.m_GameCaiPiaoData.GetIsChuCaiPiaoByDeCaiState(SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.ZhanChe, NpcScript.m_DaiJinQuanState))
                        {
                            //战车彩池的彩票积累的不够.
                            return;
                        }
                    }
                }

                if (NpcScript.IsJPBossNpc)
                {
                    //JPBoss是否可以被击爆的判断.
                    if (XkGameCtrl.GetInstance().IsCaiPiaoHuLuePlayerIndex == false && NpcScript.m_IndexPlayerJiBao != playerSt)
                    {
                        //不是可以击爆JPBoss的玩家.
                        return;
                    }

                    if (XkGameCtrl.GetInstance().m_GamePlayerAiData.IsActiveAiPlayer == true)
                    {
                        //没有激活任何玩家.
                    }
                    else
                    {
                        if (!XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage.m_GameCaiPiaoData.GetIsChuCaiPiaoByDeCaiState(SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.JPBoss))
                        {
                            //JPBoss彩池的彩票积累的不够.
                            return;
                        }
                    }
                }
            }

            if (IsDeathNpc)
            {
                return;
            }
            IsDeathNpc = true;

            if (IsOpenCameraShake)
            {
                XKPlayerCamera.GetInstanceFeiJi().HandlePlayerCameraShake();
            }

            if (NpcJiFen == NpcJiFenEnum.Boss && BossXieZiScript != null)
            {
                BossXieZiScript.ResetBossXieZiShouBiInfo();
            }

            if (BoxColCom != null)
            {
                BoxColCom.enabled = false;
            }
            CheckSpawnDaoJuCom(playerSt);
            CheckNpcDeathExplode(playerSt);
            CheckHiddenNpcObjArray();

//			bool isAddKillNpcNum = true;
//			if (NpcScript != null && CannonScript != null) {
//				if (NpcScript.GetIsDeathNPC()) {
//					isAddKillNpcNum = false;
//					Debug.Log("Unity:"+"name "+NpcScript.name+", isAddKillNpcNum "+isAddKillNpcNum);
//				}
//			}

            if (!IsYouTongNpc)
            {
                switch (NpcJiFen)
                {
                case NpcJiFenEnum.Boss:
                    if (GameTimeBossCtrl.GetInstance() != null &&
                        GameTimeBossCtrl.GetInstance().GetTimeBossResidual() > 0)
                    {
                        XkGameCtrl.GetInstance().AddPlayerKillNpc(PlayerEnum.Null, NpcJiFen, GetJiFen());
                    }
                    break;

                default:
                    XkGameCtrl.GetInstance().AddPlayerKillNpc(playerSt, NpcJiFen, GetJiFen());
                    ShowPiaoFen(playerSt);
                    break;
                }
//				if (isAddKillNpcNum) {
//					switch (NpcJiFen) {
//					case NpcJiFenEnum.Boss:
//						if (GameTimeBossCtrl.GetInstance().GetTimeBossResidual() > 0) {
//							XkGameCtrl.GetInstance().AddPlayerKillNpc(PlayerEnum.Null, NpcJiFen, JiFenVal);
//						}
//						break;
//					default:
//						XkGameCtrl.GetInstance().AddPlayerKillNpc(playerSt, NpcJiFen, JiFenVal);
//						break;
//					}
//				}
            }
            else
            {
                CheckYouTongDamageNpc();
            }

            if (NpcScript != null)
            {
                if (CannonScript != null)
                {
                    CannonScript.OnRemoveCannon(playerSt, 1);
                }

                if (NpcJiFen != NpcJiFenEnum.Boss && NpcScript.GetIsBossNpc())
                {
                    return;
                }
                NpcScript.TriggerRemovePointNpc(1, CannonScript, pAmmoType);

                if (NpcScript.IsCaiPiaoZhanChe)
                {
                    SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState deCaiType = SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.ZhanChe;
                    //彩票boss或战车npc.
                    if (NpcScript.GetIsBossNpc())
                    {
                        deCaiType = SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState.JPBoss;
                    }
                    else
                    {
                        if (XkPlayerCtrl.GetInstanceFeiJi() != null)
                        {
                            XkPlayerCtrl.GetInstanceFeiJi().AddGetZhanCheDaiJinQuanPlayer(XKPlayerMoveCtrl.GetInstance(playerSt));
                        }
                    }

                    if (XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage != null)
                    {
                        if (isAiFireAmmo == false)
                        {
                            //只有被玩家击爆的代金券npc才允许出彩.
                            XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage.m_GameCaiPiaoData.SubGameDeCaiValByDeCaiState(playerSt, deCaiType,
                                                                                                                                               SSCaiPiaoDataManage.SuiJiDaoJuState.BaoXiang, NpcScript.m_DaiJinQuanState);
                        }
                        //else
                        //{
                        //被Ai坦克击爆的代金券npc不允许出彩.
                        //SSDebug.Log("The DaiJinQuan was killed by AiTank");
                        //}
                    }
                }
                else
                {
                    //普通npc被击杀.
                    //if (XkGameCtrl.GetInstance().m_PlayerJiChuCaiPiaoData != null && DeathExplodePoint != null)
                    //{
                    //    //随机送出正常得彩.
                    //    XkGameCtrl.GetInstance().m_PlayerJiChuCaiPiaoData.CheckPlayerSongPiaoInfo(playerSt, DeathExplodePoint.position);
                    //}
                }
            }
            else if (CannonScript != null)
            {
                CannonScript.OnRemoveCannon(playerSt, 1);
                //炮台类npc被击杀.
                //if (XkGameCtrl.GetInstance().m_PlayerJiChuCaiPiaoData != null && DeathExplodePoint != null)
                //{
                //    //随机送出正常得彩.
                //    XkGameCtrl.GetInstance().m_PlayerJiChuCaiPiaoData.CheckPlayerSongPiaoInfo(playerSt, DeathExplodePoint.position);
                //}
            }
        }
    }
Ejemplo n.º 5
0
    void MoveAmmoByItween(Vector3 firePos, NpcPathCtrl ammoMovePath, XKPlayerAutoFire autoFireCom)
    {
        //if (autoFireCom != null)
        //{
        //    SSDebug.Log("MoveAmmoByItween -> AmmoType ==== " + AmmoType + ", IsQianHouFire ==== " + autoFireCom.IsQianHouFire);
        //    SSDebug.Log("MoveAmmoByItween -> CountAmmoStateZhuPao ==== " + autoFireCom.CountAmmoStateZhuPao
        //        + ", CountAmmoStateJiQiang ==== " + autoFireCom.CountAmmoStateJiQiang);
        //}

        if (m_AmmmoData != null && autoFireCom != null)
        {
            switch (AmmoType)
            {
            case PlayerAmmoType.PaiJiPaoAmmo:
            case PlayerAmmoType.ChuanTouAmmo:
            case PlayerAmmoType.SanDanAmmo:
            case PlayerAmmoType.ChongJiBoAmmo:
            case PlayerAmmoType.DaoDanAmmo:
            {
                if (AmmoType == PlayerAmmoType.DaoDanAmmo)
                {
                    //普通导弹子弹.
                    m_AmmmoData.SetActiveAmmoCore(0, autoFireCom.PlayerIndex);
                }
                else
                {
                    //其它特殊导弹.
                    m_AmmmoData.SetActiveAmmoCore(autoFireCom.CountAmmoStateZhuPao, autoFireCom.PlayerIndex);
                }
                break;
            }

            case PlayerAmmoType.PuTongAmmo:
            {
                if (autoFireCom.IsQianHouFire == true)
                {
                    //小飞机发射的子弹.
                    m_AmmmoData.SetActiveAmmoCore(autoFireCom.CountAmmoStateJiQiang, autoFireCom.PlayerIndex);
                }
                break;
            }
            }
        }

        if (ammoMovePath == null)
        {
            Vector3[] posArray = new Vector3[2];
            posArray[0] = AmmoTran.position;
            float lobTime = Vector3.Distance(firePos, posArray[0]) / MvSpeed;
            if (AmmoType == PlayerAmmoType.GenZongAmmo ||
                AmmoType == PlayerAmmoType.PaiJiPaoAmmo)
            {
                Vector3 posTmp = AmmoType == PlayerAmmoType.GenZongAmmo ? GetGenZongDanFirePos() : firePos;
                if (posTmp != Vector3.zero)
                {
                    firePos = posTmp;
                }

                if (AmmoType == PlayerAmmoType.PaiJiPaoAmmo)
                {
                    RaycastHit hit;
                    Vector3    posA = firePos + Vector3.up * 50f;
                    Physics.Raycast(posA, Vector3.down, out hit, 500f, XkGameCtrl.GetInstance().LandLayer);
                    if (hit.collider != null)
                    {
                        firePos = hit.point;
                    }
                }

                if (AmmoType == PlayerAmmoType.PaiJiPaoAmmo && PaiJiPaoTiShiPrefab != null)
                {
                    PaiJiPaoTiShi = (GameObject)Instantiate(PaiJiPaoTiShiPrefab, firePos, Quaternion.identity);
                    if (XkGameCtrl.NpcAmmoArray != null)
                    {
                        PaiJiPaoTiShi.transform.parent = XkGameCtrl.NpcAmmoArray;
                    }

                    if (PaiJiPaoTiShi != null)
                    {
                        //迫击炮子弹提示.
                        SSPlayerAmmoTiShiData ammoTiShiDt = PaiJiPaoTiShi.GetComponent <SSPlayerAmmoTiShiData>();
                        if (ammoTiShiDt != null)
                        {
                            ammoTiShiDt.InitPlayerAmmo(PlayerState);
                        }
                    }
                }

                float disMV = Vector3.Distance(firePos, posArray[0]);
                lobTime = disMV / MvSpeed;
                float lobHeight = disMV * XKPlayerGlobalDt.GetInstance().KeyPaiJiPaoValPlayer;
                //lobHeight = lobHeight > 10f ? 10f : lobHeight;
                if (m_AmmmoData != null && autoFireCom != null)
                {
                    GameObject objCore = m_AmmmoData.GetAmmoCore(autoFireCom.CountAmmoStateZhuPao);
                    if (objCore != null)
                    {
                        AmmoCore = objCore;
                    }
                }
                AmmoCore.transform.localPosition    = Vector3.zero;
                AmmoCore.transform.localEulerAngles = Vector3.zero;
                iTween.MoveBy(AmmoCore, iTween.Hash("y", lobHeight,
                                                    "time", lobTime / 2,
                                                    "easeType", iTween.EaseType.easeOutQuad));
                iTween.MoveBy(AmmoCore, iTween.Hash("y", -lobHeight,
                                                    "time", lobTime / 2,
                                                    "delay", lobTime / 2,
                                                    "easeType", iTween.EaseType.easeInCubic));
                //iTween.FadeTo(gameObject, iTween.Hash("delay", 3, "time", .5, "alpha", 0, "onComplete", "CleanUp"));
            }
            posArray[1] = firePos;
            //AmmoStartPos = AmmoTran.position;
            iTween.MoveTo(gameObject, iTween.Hash("position", firePos,
                                                  "time", lobTime,
                                                  "easeType", iTween.EaseType.linear,
                                                  "oncomplete", "MoveAmmoOnCompelteITween"));
        }
        else
        {
            int              countMark = ammoMovePath.transform.childCount;
            Transform[]      tranArray = ammoMovePath.transform.GetComponentsInChildren <Transform>();
            List <Transform> nodesTran = new List <Transform>(tranArray)
            {
            };
            nodesTran.Remove(ammoMovePath.transform);
            transform.position = nodesTran[0].position;
            transform.rotation = nodesTran[0].rotation;
            firePos            = nodesTran[countMark - 1].position;
            //AmmoStartPos = nodesTran[countMark-2].position;
            iTween.MoveTo(ObjAmmo, iTween.Hash("path", nodesTran.ToArray(),
                                               "speed", MvSpeed,
                                               "orienttopath", true,
                                               "easeType", iTween.EaseType.linear,
                                               "oncomplete", "MoveAmmoOnCompelteITween"));
        }
        //AmmoEndPos = firePos;
    }