public void ShootedByPlayer(int key) { if (IsDeadNpc) { return; } if (IsFireNpc) { WaterwheelPlayerCtrl.GetInstance().AddKillFireNpcNum(); } if (key == 0 || (key == 1 && !StartBtCtrl.GetInstanceP2().CheckIsActivePlayer())) { //XingXingCtrl.GetInstance().AddStarNum(); WaterwheelCameraCtrl.GetInstance().SpawnPlayerNengLiangLiZi(ZaiTiNpcTran.position); } NpcMoveCtrl npcScript = ChuanTran.GetComponent <NpcMoveCtrl>(); npcScript.OnZaiTiNpcDead(); /*if (AudioHitNpc != null) { * AudioListCtrl.PlayAudio(AudioHitNpc); * }*/ PlayNpcAudio(AudioHitNpcObj); OnHitWaterwheelPlayer(); IsDeadNpc = true; }
// Use this for initialization void Awake() { if (NPC_Type == NPC_STATE.BOSS_NPC || NPC_Type == NPC_STATE.ZAI_TI_NPC) { } else { NPC_Type = NPC_STATE.ZAI_TI_NPC; } ZaiTiNpcTran = transform; ChuanTran = ZaiTiNpcTran.parent; //LocalPosOffset = Vector3.Scale(ZaiTiNpcTran.localPosition, ChuanTran.localScale); //LocalPosOffset = ZaiTiNpcTran.localPosition; //ZaiTiNpcTran.parent = GameCtrlXK.MissionCleanup; WaterwheelPlayer = WaterwheelPlayerCtrl.GetInstance().transform; AnimatorNpc = GetComponent <Animator>(); if (BuWaWaObj != null) { BuWaWaObj.SetActive(false); Rigidbody rigObj = BuWaWaObj.GetComponent <Rigidbody> (); if (rigObj == null) { rigObj.name = "null"; } } NpcMoveScript = ZaiTiNpcTran.parent.GetComponent <NpcMoveCtrl>(); if (!IsDiLeiNpc) { RandomDoRootAction(); } else if (!NpcMoveScript.IsDanCheLvNpc) { IsDoFireAction = true; } BuWaWaPowerVal = NpcMoveScript.BuWaWaPowerVal; IsTeShuZiDanHaiDao = NpcMoveScript.IsTeShuZiDanHaiDao; /*if (IsTeShuZiDanHaiDao) { * NpcSimpleBulletObj.SetActive(false); * }*/ ResetActionInfo(); }
public void SpawnAiPlayer() { if (IsRemoveSpawnPointNpc) { return; } if (NpcPlayer == null) { Debug.LogError("NpcPlayer is null"); return; } if (!gameObject.activeSelf) { return; } NpcMoveCtrl npcScript = NpcPlayer.GetComponent <NpcMoveCtrl>(); if (npcScript.NPC_Type == NPC_STATE.ZAI_TI_NPC || npcScript.NPC_Type == NPC_STATE.BOSS_NPC) { if (GlobalData.GetInstance().gameMode != GameMode.SoloMode) { Debug.LogError("Cannot spawn zaiTiNpc! gameMode = " + GlobalData.GetInstance().gameMode); return; } if (!IsNiXingAiPath) { if (!NpcMoveCtrl.CheckIsSpawnZhengXingZaiTiNpc()) { return; } } else { if (!NpcMoveCtrl.CheckIsSpawnNiXingZaiTiNpc()) { return; } } } GameObject npcObjSpawn = null; if (GlobalData.GetInstance().gameMode == GameMode.SoloMode) { npcObjSpawn = (GameObject)Instantiate(NpcPlayer, transform.position, transform.rotation); } else { if (Network.peerType == NetworkPeerType.Server) { npcObjSpawn = (GameObject)Network.Instantiate(NpcPlayer, transform.position, transform.rotation, GlobalData.NetWorkGroup); } else { Debug.LogError("Cannot spawn npc, peerType = " + Network.peerType); return; } } NpcMoveCtrl NpcMoveScripte = npcObjSpawn.GetComponent <NpcMoveCtrl>(); SpawnNpcMoveScript[SpawnNpcNum] = NpcMoveScripte; if (NpcMoveScripte != null) { NpcMoveScripte.SpawnPointObj = gameObject; NpcMoveScripte.SetIsHandleNpc(); switch (NpcMoveScripte.NPC_Type) { case NPC_STATE.ZAI_TI_NPC: if (AiPathMark != null || NpcPathCtrl != null) { //set AiPathMark NPC if (NpcPathCtrl != null) { NpcMoveScripte.SetNpcPathTran(NpcPathCtrl.transform, MoveSpeed, false, FireDistance, RunStateVal, AiPathMark, IsNiXingAiPath); } else { NpcMoveScripte.SetNpcPathTran(null, MoveSpeed, false, FireDistance, RunStateVal, AiPathMark, IsNiXingAiPath); } } break; case NPC_STATE.FEI_XING_NPC: NpcMoveScripte.SetNpcPathTran(null, MoveSpeed, false, FireDistance, RunStateVal, null, false); break; default: if (NpcPathCtrl != null) { NpcMoveScripte.SetNpcPathTran(NpcPathCtrl.transform, MoveSpeed, IsLoopPath, FireDistance, RunStateVal, AiPathMark, IsNiXingAiPath); NpcMoveScripte.SetShuiQiangNpcFlyTime(ShuiQiangNpcFlyTime); } break; } } SpawnNpcNum++; if (ShuaGuaiAllTime > 0f && SpawnNpcNum < MaxSpawnNpcNum) { if (ShuaGuaiUnitTime <= 0.1f) { ShuaGuaiUnitTime = 0.1f; } if (ShuaGuaiAllTime > SpawnNpcNum * ShuaGuaiUnitTime) { Invoke("SpawnAiPlayer", ShuaGuaiUnitTime); } } }
void Awake() { if (NpcPlayer == null) { Debug.LogError("NpcPlayer should not is null!"); NpcPlayer.name = "null"; return; } NpcMoveCtrl npcScript = NpcPlayer.GetComponent <NpcMoveCtrl>(); if (GlobalData.GetInstance().gameMode == GameMode.OnlineMode) { if (FireDistance > 0f || npcScript.NPC_Type == NPC_STATE.BOSS_NPC || npcScript.NPC_Type == NPC_STATE.ZAI_TI_NPC) { gameObject.SetActive(false); return; } } if (SpawnNpcMoveScript == null) { SpawnNpcMoveScript = new NpcMoveCtrl[MaxSpawnNpcNum]; } if (npcScript.NPC_Type == NPC_STATE.ZAI_TI_NPC || npcScript.NPC_Type == NPC_STATE.BOSS_NPC) { if (AiPathMark == null && NpcPathCtrl == null) { Debug.LogError("AiPathMark or NpcPathCtrl should not be null!"); AiPathMark.name = "null"; NpcPathCtrl.name = "null"; return; } } else if (npcScript.NPC_Type != NPC_STATE.FEI_XING_NPC) { if (NpcPathCtrl == null) { Debug.LogError("NpcPathCtrl should not is null!"); NpcPathCtrl.name = "null"; return; } } if (IsLoopPath) { if (NpcPathCtrl != null && NpcPathCtrl.transform.childCount <= 1) { Debug.LogError("NpcPath childCount should be greater than 1"); Transform tr = null; tr.name = "null"; } } if (npcScript.IsDanCheLvNpc) { if (npcScript.NPC_Type != NPC_STATE.ZAI_TI_NPC) { Debug.LogError("npcScript.IsDanCheLvNpc is true, NPC_Type should is ZAI_TI_NPC!"); Transform tr = null; tr.name = "null"; } if (FireDistance <= 0f) { Debug.LogError("FireDistance should not is zero!"); Transform tr = null; tr.name = "null"; } } switch (npcScript.NPC_Type) { case NPC_STATE.ZAI_TI_NPC: case NPC_STATE.BOSS_NPC: for (int i = 0; i < npcScript.ZaiTiScript.Length; i++) { if (npcScript.ZaiTiScript[i] != null) { if (npcScript.IsDanCheLvNpc) { npcScript.ZaiTiScript[i].IsDiLeiNpc = true; } if (FireDistance > 0f) { if (npcScript.ZaiTiScript[i].NpcSimpleBulletObj == null) { Debug.LogError("ZaiTiScript num -> " + i); npcScript.ZaiTiScript[i].NpcSimpleBulletObj.name = "null"; } if (npcScript.ZaiTiScript[i].SpawnBulletTran == null) { Debug.LogError("ZaiTiScript num -> " + i); npcScript.ZaiTiScript[i].SpawnBulletTran.name = "null"; } } if (npcScript.ZaiTiScript[i].BuWaWaObj == null) { Debug.LogError("ZaiTiScript num -> " + i); npcScript.ZaiTiScript[i].BuWaWaObj.name = "null"; } if (npcScript.ZaiTiScript[i].ExplodeObj == null) { Debug.LogError("ZaiTiScript num -> " + i); npcScript.ZaiTiScript[i].ExplodeObj.name = "null"; } } } break; default: if (FireDistance > 0f) { if (npcScript.NpcSimpleBulletObj == null) { npcScript.NpcSimpleBulletObj.name = "null"; } if (npcScript.NpcSimpleBulletObjFire_2 == null) { npcScript.NpcSimpleBulletObjFire_2 = npcScript.NpcSimpleBulletObj; } if (npcScript.SpawnBulletTran == null) { npcScript.SpawnBulletTran.name = "null"; } if (npcScript.SpawnBulletTranFire_2 == null) { npcScript.SpawnBulletTranFire_2 = npcScript.SpawnBulletTran; } } if (npcScript.BuWaWaObj == null) { npcScript.BuWaWaObj.name = "null"; } if (npcScript.ExplodeObj == null) { npcScript.ExplodeObj.name = "null"; } break; } }
public void OnDamage(float unitTime) { if (PlayerNetScript != null) { if (PlayerNetScript == WaterwheelPlayerNetCtrl.GetInstance()) { return; } PlayerNetScript.SetActivePlayerGunWaterObj(1); } if (IsDeadObj) { return; } CountDamage++; if (unitTime * CountDamage >= DamageTime) { IsDeadObj = true; if (GlobalData.GetInstance().gameMode == GameMode.SoloMode) { NpcMoveCtrl npcScript = gameObject.GetComponent <NpcMoveCtrl>(); ZaiTiNpcCtrl npcZaiTiScript = gameObject.GetComponent <ZaiTiNpcCtrl>(); if (npcScript != null || npcZaiTiScript != null) { if (npcZaiTiScript != null) { npcZaiTiScript.ShootedByPlayer(0); PlayerAutoFire.AddPlayerShootNpcNum(); } else { if (npcScript.NPC_Type == NPC_STATE.BOSS_NPC || npcScript.NPC_Type == NPC_STATE.ZAI_TI_NPC) { return; } else { npcScript.ShootedByPlayer(); PlayerAutoFire.AddPlayerShootNpcNum(); } } } else { WaterwheelPlayerCtrl.GetInstance().ShootingDeadObj(gameObject); } } else { if (PlayerNetScript != null) { ResetDamageInfo(); PlayerNetScript.ActiveXuanYunState(); //ScreenLog.Log("ActiveXuanYunState -> name "+gameObject.name); } else { switch (tag) { case "DianDaoFuObj": case "DingShenFuObj": case "HuanWeiFuObj": case "HuanYingFuObj": case "JuLiFuObj": if (Time.realtimeSinceStartup - TimeDaoJuJiHuoVal < 1f) { return; } TimeDaoJuJiHuoVal = Time.realtimeSinceStartup; break; } WaterwheelPlayerNetCtrl.GetInstance().ShootingDeadObj(gameObject); } } } }