Ejemplo n.º 1
0
    public void SetBloodBossAmount(float bloodAmount, XKNpcHealthCtrl bossHealth = null)
    {
        if (bossHealth != null && bloodAmount == -1f)
        {
            BossHealthScript = bossHealth;             //存储Boss血量脚本.
        }

        if (!IsCanSubXueTiaoAmount)
        {
            return;
        }

        if (!gameObject.activeSelf)
        {
            return;
        }

        bloodAmount = bloodAmount > 1f ? 1f : bloodAmount;
        bloodAmount = bloodAmount < 0f ? 0f : bloodAmount;
        BossXueTiaoSprite.fillAmount = bloodAmount;
        if (bloodAmount <= 0f)
        {
            //JiFenJieMianCtrl.GetInstance().ShowFinishTaskInfo();
            IsWuDiPlayer = true;
            Invoke("DelayActiveJiFenJieMian", 4f);
            XkGameCtrl.BossRemoveAllNpcAmmo();
            AudioBeiJingCtrl.StopGameBeiJingAudio();
            HiddenBossXueTiao();
            if (BossHealthScript != null && bossHealth == null)
            {
                BossHealthScript.OnDamageNpc(99999999, PlayerEnum.Null);
            }
        }
    }
    void CheckYouTongDamageNpc()
    {
        if (!IsYouTongNpc)
        {
            return;
        }

        XKNpcHealthCtrl healthScript = null;

        Transform[] npcArray = XkGameCtrl.GetInstance().GetNpcTranList().ToArray();
        int         max      = npcArray.Length;
        Vector3     posA     = transform.position;
        Vector3     posB     = Vector3.zero;

        for (int i = 0; i < max; i++)
        {
            if (npcArray[i] == null)
            {
                continue;
            }

            posB = npcArray[i].position;
            if (Vector3.Distance(posA, posB) <= YouTongDamageDis)
            {
                healthScript = npcArray[i].GetComponentInChildren <XKNpcHealthCtrl>();
                if (healthScript != null)
                {
                    //Add Damage Npc num to PlayerInfo.
                    healthScript.OnDamageNpc(20, PlayerEnum.Null);
                }
            }
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// 清理代金券npc的血值脚本.
 /// </summary>
 void CleanDaiJinQuanHealth()
 {
     if (m_DaiJinQuanHealth != null)
     {
         m_DaiJinQuanHealth = null;
     }
 }
Ejemplo n.º 4
0
    void CheckAmmoDamageNpc()
    {
        if (AmmoType == PlayerAmmoType.PuTongAmmo && XkGameCtrl.GameJiTaiSt == GameJiTaiType.TanKeJiTai)
        {
            return;
        }

        XKNpcHealthCtrl healthScript = null;
        float           disDamage    = AmmoDamageDis;

        Collider[]             hits       = Physics.OverlapSphere(AmmoTran.position, disDamage, PlayerAmmoHitLayer);
        List <XKNpcHealthCtrl> healthList = new List <XKNpcHealthCtrl>();

        foreach (Collider c in hits)
        {
            // Don't collide with triggers
            if (c.isTrigger)
            {
                continue;
            }

            healthScript = c.gameObject.GetComponent <XKNpcHealthCtrl>();
            if (healthScript != null)
            {
                //Debug.Log("test fix nnn *** "+healthScript.name);
                healthScript.OnDamageNpc(AmmoType, PlayerState);
                healthList.Add(healthScript);
            }
        }
        healthList.Clear();
        healthList = null;
    }
Ejemplo n.º 5
0
    void CheckAmmoDamageNpc()
    {
        if (AmmoType == PlayerAmmoType.Null)
        {
            return;
        }

        XKNpcHealthCtrl healthScript = null;

        Transform[] npcArray = XkGameCtrl.GetInstance().GetNpcTranList().ToArray();
        int         max      = npcArray.Length;
        Vector3     posA     = AmmoTran.position;
        Vector3     posB     = Vector3.zero;

        for (int i = 0; i < max; i++)
        {
            if (npcArray[i] == null)
            {
                continue;
            }

            posB = npcArray[i].position;
            //Debug.Log("disTest "+disTest+", posA "+posA+", posB "+posB+", AmmoDamageDis "+AmmoDamageDis);
            if (Vector3.Distance(posA, posB) <= AmmoDamageDis)
            {
                healthScript = npcArray[i].GetComponentInChildren <XKNpcHealthCtrl>();
                if (healthScript != null)
                {
                    //Add Damage Npc num to PlayerInfo.
                    healthScript.OnDamageNpc(AmmoType, PlayerState);
                }
            }
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 显示爆炸粒子的彩票UI数量信息.
    /// </summary>
    internal void ShowNumUI(SSCaiPiaoDataManage.GameCaiPiaoData.DeCaiState deCaiType, XKNpcHealthCtrl healthCom)
    {
        if (healthCom != null)
        {
            SetShangJiaInfo(deCaiType, healthCom.NpcScript.m_DaiJinQuanState);
        }

        if (m_CaiPiaoInfoParent != null)
        {
            m_CaiPiaoInfoParent.gameObject.SetActive(true);
        }
        enabled        = true;
        m_NpcHealthCom = healthCom;

        SSCaiPiaoDataManage.GameCaiPiaoData.DaiJinQuanState daiJiQuan = healthCom.NpcScript.m_DaiJinQuanState;
        int num = XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.m_CaiPiaoDataManage.m_GameCaiPiaoData.GetPrintCaiPiaoValueByDeCaiState(deCaiType,
                                                                                                                                          SSCaiPiaoDataManage.SuiJiDaoJuState.BaoXiang, daiJiQuan);

        string numStr = num.ToString();

        if (m_FixedUiPosDt != null && m_FixedUiPosDt.IsFixPosX)
        {
            if (m_FixedUiPosDt.UIParent != null)
            {
                int len = numStr.Length;
                if (m_FixedUiPosDt.m_PosXArray.Length >= len)
                {
                    //动态修改UI数据的父级坐标.
                    Vector3 posTmp = m_FixedUiPosDt.UIParent.localPosition;
                    posTmp.x = m_FixedUiPosDt.m_PosXArray[len - 1];
                    m_FixedUiPosDt.UIParent.localPosition = posTmp;
                }
            }
        }

        int max    = m_NumRenderArray.Length;
        int numVal = num;
        int valTmp = 0;
        int powVal = 0;

        for (int i = 0; i < max; i++)
        {
            if (max - i > numStr.Length && IsHiddenGaoWeiNumZero)
            {
                //隐藏数据高位的0.
                m_NumRenderArray[i].material = XkGameCtrl.GetInstance().m_CaiPiaoLiZiNumATouMing;
            }
            else
            {
                //m_UISpriteArray[i].enabled = true;
                powVal = (int)Mathf.Pow(10, max - i - 1);
                valTmp = numVal / powVal;
                //UnityLog("ShowNumUI -> valTmp ====== " + valTmp);
                m_NumRenderArray[i].material = XkGameCtrl.GetInstance().m_NpcCaiPiaoNumArray[valTmp];
                //m_UISpriteArray[i].spriteName = valTmp.ToString();
                numVal -= valTmp * powVal;
            }
        }
    }
 public void Init(XKNpcHealthCtrl npcHealth)
 {
     if (npcHealth != null)
     {
         float xueLiang = npcHealth.GetHealthValue();
         mNpcHealth = npcHealth;
         ShowZuDangXuTiaoVal(xueLiang);
     }
 }
 /// <summary>
 /// 产生阻挡血条UI界面.
 /// </summary>
 public void SpawnZuDangXueTiaoUI(XKNpcHealthCtrl npcHealth)
 {
     if (mZuDangXueTiaoUI == null)
     {
         GameObject obj = (GameObject)Instantiate((GameObject)ZuDangXueTiaoUIPrefab, transform);
         mZuDangXueTiaoUI = obj.GetComponent <ZuDangXueTiaoUI>();
         mZuDangXueTiaoUI.Init(npcHealth);
     }
 }
    void OnTriggerEnter(Collider other)
    {
        XKNpcHealthCtrl healthScript = other.gameObject.GetComponent <XKNpcHealthCtrl>();

        if (healthScript == null)
        {
            return;
        }
        CheckAudioCount();
    }
Ejemplo n.º 10
0
 public void SetXieZiShouBiInfo(Transform pathTr = null)
 {
     NpcParentTr              = transform.parent;
     NpcObj                   = gameObject;
     NpcPathTr                = pathTr;
     NpcPathTr.parent         = XkGameCtrl.MissionCleanup;
     HealthScript             = GetComponent <XKNpcHealthCtrl>();
     HealthScript.IsCanHitNpc = false;
     HealthScript.SetIsDeathNpc(true);
     CannonScript         = GetComponent <XKCannonCtrl>();
     CannonScript.FireDis = 0f;
     Invoke("DelayMoveXieZiShouBi", 30f);
 }
    void Awake()
    {
        XKNpcHealthCtrl healthScript = GetComponentInChildren <XKNpcHealthCtrl>();

        if (healthScript != null)
        {
            healthScript.SetXKDaPaoScript(this);
        }
        NpcMoveScript = GetComponentInParent <XKNpcMoveCtrl>();
        NetViewCom    = GetComponent <NetworkView>();
        if (Network.peerType == NetworkPeerType.Disconnected)
        {
            if (NetViewCom != null)
            {
                NetViewCom.enabled = false;
            }
        }
    }
Ejemplo n.º 12
0
    public void AddYouTongScript(XKNpcHealthCtrl youTongScript)
    {
        if (youTongScript == null)
        {
            return;
        }
        //Add Damage Npc num to PlayerInfo.
        if (youTongScript.IsYouTongNpc)
        {
            if (YouTongScriptList == null)
            {
                YouTongScriptList = new List <XKNpcHealthCtrl>();
            }

            if (!YouTongScriptList.Contains(youTongScript))
            {
                YouTongScriptList.Add(youTongScript);
            }
        }
    }
Ejemplo n.º 13
0
    IEnumerator PlayPaoGuanAnimation()
    {
        CountPaoGuanAni++;
        if (CountPaoGuanAni > 1)
        {
            //Debug.LogWarning("Unity:"+"PlayPaoGuanAnimation -> CountPaoGuanAni "+CountPaoGuanAni);
            yield break;
        }

        int   count         = 0;
        int   maxCount      = 1;
        float speed         = PaoGuanZhenFu / maxCount;
        bool  isBackPaoGuan = false;
        bool  isFireAmmo    = false;

        IsPlayPaoGuanAnimation = true;
        do
        {
            if (IsDeathNpc || GameOverCtrl.IsShowGameOver)
            {
                yield break;
            }

            if (IsStopAnimation ||
                !IsDoFireAnimation ||
                Time.realtimeSinceStartup - TimeStartSpawn < TimeFireDelay ||
                JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask())
            {
                yield return(new WaitForSeconds(0.1f));

                continue;
            }

            if (!isBackPaoGuan)
            {
                PaoGuan.position -= PaoGuan.forward * speed;
                count++;
                if (count >= maxCount)
                {
                    isBackPaoGuan = true;
                }

                if (count == 1 && !isFireAmmo)
                {
                    isFireAmmo = true;
                    PlayAudioCannonFire();

                    PlayerAmmoCtrl ammoPlayerScript = DaPaoAmmo.GetComponent <PlayerAmmoCtrl>();
                    if (ammoPlayerScript != null && !XkGameCtrl.GetInstance().IsCartoonShootTest)
                    {
                        yield break;
                    }

                    GameObject obj = GetNpcAmmoFromList(SpawnAmmoPoint[0]);
                    if (obj == null)
                    {
                        yield break;
                    }

                    NpcAmmoCtrl AmmoScript = obj.GetComponent <NpcAmmoCtrl>();
                    Transform   tran       = obj.transform;
                    tran.parent = XkGameCtrl.NpcAmmoArray;
                    if (AmmoScript != null)
                    {
                        AmmoScript.SetIsAimFeiJiPlayer(false);
                    }
                    else
                    {
                        PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();
                        if (ammoScript != null)
                        {
                            Vector3 startPos    = tran.position;
                            Vector3 firePos     = tran.position;
                            Vector3 ammoForward = tran.forward;
                            firePos = Random.Range(300f, 400f) * ammoForward + startPos;
                            float      fireDisVal = Vector3.Distance(firePos, startPos);
                            RaycastHit hit;
                            LayerMask  FireLayer = XkGameCtrl.GetInstance().PlayerAmmoHitLayer;
                            if (Physics.Raycast(startPos, ammoForward, out hit, fireDisVal, FireLayer.value))
                            {
                                //Debug.Log("Unity:"+"npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                                firePos = hit.point;
                                XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                                if (healthScript != null)
                                {
                                    healthScript.OnDamageNpc(ammoScript.DamageNpc, PlayerEnum.Null);
                                }

                                BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                                if (buJiBaoScript != null)
                                {
                                    buJiBaoScript.RemoveBuJiBao(PlayerEnum.Null);                                     //buJiBaoScript
                                }
                            }
                            ammoScript.StartMoveAmmo(firePos, PlayerEnum.Null, AmmoMovePath);
                        }
                    }

                    if (!XkGameCtrl.IsNoFireLiZi)
                    {
                        obj  = (GameObject)Instantiate(DaPaoAmmoLiZi, SpawnAmmoPoint[0].position, SpawnAmmoPoint[0].rotation);
                        tran = obj.transform;
                        XkGameCtrl.CheckObjDestroyThisTimed(obj);
                        tran.parent = SpawnAmmoPoint[0];
                    }
                }
            }
            else
            {
                PaoGuan.position += PaoGuan.forward * speed;
                count--;
                if (count <= 0)
                {
                    IsPlayPaoGuanAnimation = false;
                    isBackPaoGuan          = false;
                    isFireAmmo             = false;
                    count = 0;

                    yield return(new WaitForSeconds(TimeDanGuanFire));

                    IsPlayPaoGuanAnimation = true;
                    continue;
                }
            }
            yield return(new WaitForSeconds(PaoGuanShenSuoSD));
        } while (true);
    }
    void StartSpawnNpcAmmo()
    {
        if (AudioNpcFire != null)
        {
            if (AudioNpcFire.isPlaying)
            {
                AudioNpcFire.Stop();
            }
            AudioNpcFire.Play();
        }

        GameObject obj  = null;
        Transform  tran = null;

        if (AmmoLiZiPrefab != null)
        {
            obj = SpawnParticleCom.SpawnParticleObject(AmmoLiZiPrefab, AmmoSpawnTran.position, AmmoSpawnTran.rotation);
            if (obj.transform.parent != XkGameCtrl.NpcAmmoArray)
            {
                obj.transform.parent = XkGameCtrl.NpcAmmoArray;
            }
        }

        PlayerAmmoCtrl ammoPlayerScript = AmmoPrefab.GetComponent <PlayerAmmoCtrl>();

        if (ammoPlayerScript != null && !XkGameCtrl.GetInstance().IsCartoonShootTest)
        {
            return;
        }

        obj = GetNpcAmmoFromList(AmmoSpawnTran);
        if (obj == null)
        {
            return;
        }

        tran        = obj.transform;
        tran.parent = XkGameCtrl.NpcAmmoArray;
        NpcAmmoCtrl AmmoScript = obj.GetComponent <NpcAmmoCtrl>();

        if (AmmoScript != null)
        {
            AmmoScript.SetNpcScriptInfo(NpcScript);
            AmmoScript.SetIsAimFeiJiPlayer(IsAimFeiJiPlayer);
        }
        else
        {
            PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();
            if (ammoScript != null)
            {
                Vector3 startPos    = tran.position;
                Vector3 firePos     = tran.position;
                Vector3 ammoForward = tran.forward;
                firePos = Random.Range(300f, 400f) * ammoForward + startPos;
                float      fireDisVal = Vector3.Distance(firePos, startPos);
                RaycastHit hit;
                LayerMask  FireLayer = XkGameCtrl.GetInstance().PlayerAmmoHitLayer;
                if (Physics.Raycast(startPos, ammoForward, out hit, fireDisVal, FireLayer.value))
                {
                    //Debug.Log("npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                    firePos = hit.point;
                    XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                    if (healthScript != null)
                    {
                        healthScript.OnDamageNpc(ammoScript.AmmoType, PlayerEnum.Null);
                    }

                    BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                    if (buJiBaoScript != null)
                    {
                        buJiBaoScript.RemoveBuJiBao(PlayerEnum.Null);                         //buJiBaoScript
                    }
                }
                ammoScript.StartMoveAmmo(firePos, PlayerEnum.Null);
            }
        }
    }
Ejemplo n.º 15
0
    void CheckPlayerTwoFireBt()
    {
        if (XKPlayerCamera.IndexPlayerNum != 1)
        {
            SetQianGuanTwRot(PlayerEnum.PlayerTwo, false);
            return;
        }

        if (!ScreenDanHeiCtrl.IsStartGame)
        {
            SetQianGuanTwRot(PlayerEnum.PlayerTwo, false);
            return;
        }

        if (!XkGameCtrl.IsActivePlayerTwo)
        {
            SetQianGuanTwRot(PlayerEnum.PlayerTwo, false);
            return;
        }

        if (!IsActiveFireBtTwo)
        {
            SetQianGuanTwRot(PlayerEnum.PlayerTwo, false);
            return;
        }
        SetQianGuanTwRot(PlayerEnum.PlayerTwo, true);

//		if (DaoJiShiCtrl.GetInstance().GetIsPlayDaoJishi()) {
//			return;
//		}

        if (!XkGameCtrl.IsTiaoGuoStartCartoon)
        {
            if (!ZhunXingCtrl.GetInstanceTwo().GetActiveZhunXing() || !ZhunXingTeXiaoCtrl.IsOverTeXiaoZhunXing)
            {
                return;
            }
        }

        if (Camera.main == null)
        {
            return;
        }

//		if (GameOverCtrl.IsShowGameOver || JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask()) {
//			IsActiveFireBtTwo = false;
//			return;
//		}

//		if (PlayerStEnum == PlayerTypeEnum.FeiJi && XkGameCtrl.GameJiTaiSt != GameJiTaiType.FeiJiJiTai) {
//			IsActiveFireBtTwo = false;
//			return;
//		}

//		if (PlayerStEnum == PlayerTypeEnum.TanKe && XkGameCtrl.GameJiTaiSt != GameJiTaiType.TanKeJiTai) {
//			IsActiveFireBtTwo = false;
//			return;
//		}

        if (XkGameCtrl.GaoBaoDanNumPTwo <= 0 &&
            Time.time < LastFireTimeTwo + 1f / Frequency)
        {
            return;
        }

        if (XkGameCtrl.GaoBaoDanNumPTwo > 0 &&
            Time.time < LastFireTimeTwo + 1f / FrequencyGaoBao)
        {
            return;
        }
        LastFireTimeTwo = Time.time;
        Vector3    ammoSpawnPos = AmmoStartPosTwo[0].position;
        GameObject obj          = null;

        CheckFireAudioPlayerTwo();

        bool isSpawnGaoBaoDan = false;

        if (XkGameCtrl.GaoBaoDanNumPTwo <= 0)
        {
            if (AmmoParticle[0] != null)
            {
                obj = SpawnParticleCom.SpawnParticleObject(AmmoParticle[0], ammoSpawnPos, AmmoStartPosTwo[0].rotation);
                obj.transform.parent = AmmoStartPosTwo[0];
            }
            obj = GetPlayerAmmo(PlayerAmmoType.PuTongAmmo, ammoSpawnPos, AmmoStartPosTwo[0].rotation);
        }
        else
        {
            isSpawnGaoBaoDan = true;
            if (GaoBaoAmmoParticle[0] != null)
            {
                obj = SpawnParticleCom.SpawnParticleObject(GaoBaoAmmoParticle[0], ammoSpawnPos, AmmoStartPosTwo[0].rotation);
                obj.transform.parent = AmmoStartPosTwo[0];
            }
            XkGameCtrl.GetInstance().SubGaoBaoDanNumPTwo();
            obj = GetPlayerAmmo(PlayerAmmoType.GaoBaoAmmo, ammoSpawnPos, AmmoStartPosTwo[0].rotation);
        }
        obj.transform.parent = XkGameCtrl.PlayerAmmoArray;
        PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();

        ammoScript.SetIsDonotHurtNpc(false);

        Vector3    mousePosInput = pcvr.GetPlayerMousePos(PlayerEnum.PlayerTwo);
        Vector3    firePos       = Vector3.zero;
        Vector3    mousePos      = mousePosInput + Vector3.forward * OffsetForward;
        Vector3    posTmp        = Camera.main.ScreenToWorldPoint(mousePos);
        Vector3    ammoForward   = Vector3.Normalize(posTmp - ammoSpawnPos);
        Ray        ray           = Camera.main.ScreenPointToRay(mousePosInput);
        RaycastHit hit;

        if (!IsPSAutoFire)
        {
            //firePos = FirePosValTmp * ammoForward + ammoSpawnPos;
            if (Physics.Raycast(ray, out hit, FireRayDirLen, FireLayer.value))
            {
                //Debug.Log("Player fire obj -> "+hit.collider.name);
                //firePos = hit.point;
                if (ammoScript.AmmoType == PlayerAmmoType.PuTongAmmo)
                {
                    XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                    if (healthScript != null && !healthScript.GetIsDeathNpc())
                    {
                        healthScript.OnDamageNpc(ammoScript.AmmoType, PlayerEnum.PlayerTwo);
                    }
                }

                BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                if (buJiBaoScript != null)
                {
                    buJiBaoScript.RemoveBuJiBao(PlayerEnum.PlayerTwo);                     //buJiBaoScript
                }
            }
            firePos = GunLaser[1].PlayerCursorTr.position;
        }
        else
        {
            ammoForward = obj.transform.forward;
            firePos     = FirePosValTmp * ammoForward + ammoSpawnPos;
            if (Physics.Raycast(ammoSpawnPos, ammoForward, out hit, FireRayDirLen, FireLayer.value))
            {
                //Debug.Log("Player fire obj -> "+hit.collider.name);
                firePos = hit.point;
                if (ammoScript.AmmoType == PlayerAmmoType.PuTongAmmo)
                {
                    XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                    if (healthScript != null && !healthScript.GetIsDeathNpc())
                    {
                        healthScript.OnDamageNpc(ammoScript.AmmoType, PlayerEnum.PlayerTwo);
                    }
                }

                BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                if (buJiBaoScript != null)
                {
                    buJiBaoScript.RemoveBuJiBao(PlayerEnum.PlayerTwo);                     //buJiBaoScript
                }
            }
        }

        if (hit.collider == null)
        {
            ammoScript.StartMoveAmmo(firePos, PlayerEnum.PlayerTwo);
        }
        else
        {
            ammoScript.StartMoveAmmo(firePos, PlayerEnum.PlayerTwo, null, hit.collider.gameObject);
        }

        if (isSpawnGaoBaoDan)
        {
            //Call OtherPort Show AmmoParticle
            PlayerScript.CallOtherPortSpawnPlayerAmmoParticle(2, 2, firePos);
        }
        else
        {
            //Call OtherPort Show AmmoParticle
            PlayerScript.CallOtherPortSpawnPlayerAmmoParticle(2, 0, firePos);
        }
    }
Ejemplo n.º 16
0
    void SpawnAmmoParticleObj()
    {
        GameObject objParticle = null;
        GameObject obj         = null;
        Transform  tran        = null;
        Vector3    hitPos      = transform.position;

        RaycastHit hit;

        if (!IsHandleRpc)
        {
            AmmoEndPos   = transform.position;
            AmmoStartPos = transform.position - transform.forward * 3f;
            Physics.Raycast(AmmoStartPos, transform.forward, out hit, 1000f, PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
                AmmoEndPos = hit.point;
            }
        }

        Vector3 forwardVal = Vector3.Normalize(AmmoEndPos - AmmoStartPos);

        if (AmmoType == PlayerAmmoType.PuTongAmmo)
        {
//			float disVal = Vector3.Distance(AmmoEndPos, AmmoStartPos) + 10f;
//			Physics.Raycast(AmmoStartPos, forwardVal, out hit, disVal, PlayerAmmoHitLayer);

            Vector3 startPos = Vector3.zero;
            Vector3 backVal  = -10f * transform.forward;
            if (GameTypeCtrl.IsTankVRStatic)
            {
                startPos = transform.position + backVal;
            }
            else
            {
                float   disAmmoOffset = AmmoSanSheDis;
                float   randKay       = Random.Range(0, 100) % 2 == 0 ? -1 : 1;
                Vector3 upVal         = randKay * Random.Range(0f, disAmmoOffset) * transform.up;
                randKay = Random.Range(0, 100) % 2 == 0 ? -1 : 1;
                Vector3 rightVal = randKay * Random.Range(0f, disAmmoOffset) * transform.right;
                startPos = transform.position + upVal + rightVal + backVal;
            }

            Physics.Raycast(startPos, transform.forward, out hit, 20f, PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
                hitPos = hit.point;
                XKAmmoParticleCtrl ammoParticleScript = hit.collider.GetComponent <XKAmmoParticleCtrl>();
                if (ammoParticleScript != null && ammoParticleScript.PuTongAmmoLZ != null)
                {
                    objParticle = ammoParticleScript.PuTongAmmoLZ;
                }
                else
                {
                    string tagHitObj = hit.collider.tag;
                    switch (tagHitObj)
                    {
                    case "metal":
                        if (MetalParticle != null)
                        {
                            objParticle = MetalParticle;
                        }
                        break;

                    case "concrete":
                        if (ConcreteParticle != null)
                        {
                            objParticle = ConcreteParticle;
                        }
                        break;

                    case "dirt":
                        if (DirtParticle != null)
                        {
                            objParticle = DirtParticle;
                        }
                        break;

                    case "wood":
                        if (WoodParticle != null)
                        {
                            objParticle = WoodParticle;
                        }
                        break;

                    case "water":
                        if (WaterParticle != null)
                        {
                            objParticle = WaterParticle;
                        }
                        break;

                    case "sand":
                        if (SandParticle != null)
                        {
                            objParticle = SandParticle;
                        }
                        break;

                    case "glass":
                        if (GlassParticle != null)
                        {
                            objParticle = GlassParticle;
                        }
                        break;
                    }

                    if (objParticle == null)
                    {
                        objParticle = AmmoExplode;
                    }
                }

                if (IsHandleRpc &&
                    !IsDonotHurtNpc &&
                    Network.peerType != NetworkPeerType.Server &&
                    AmmoType == PlayerAmmoType.PuTongAmmo)
                {
                    XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                    if (healthScript != null)
                    {
                        if (HitNpcObj == null || HitNpcObj != hit.collider.gameObject)
                        {
                            //Debug.Log("playerAmmo hit npc, npc is "+hit.collider.name);
                            healthScript.OnDamageNpc(AmmoType, PlayerState);
                        }
                    }
                }
            }
            else
            {
                objParticle = AmmoExplode;
            }
        }
        else
        {
            float disVal = Vector3.Distance(AmmoEndPos, AmmoStartPos) + 10f;
            Physics.Raycast(AmmoStartPos, forwardVal, out hit, disVal, PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
//				if (AmmoType == PlayerAmmoType.GaoBaoAmmo) {
//					Debug.Log("hit.collider "+hit.collider.name);
//				}
                hitPos = hit.point;
                string tagHitObj = hit.collider.tag;
                switch (tagHitObj)
                {
                case "dirt":
                    if (DirtParticle != null)
                    {
                        objParticle = DirtParticle;
                    }
                    break;

                case "water":
                    if (WaterParticle != null)
                    {
                        objParticle = WaterParticle;
                    }
                    break;
                }

                if (objParticle == null)
                {
                    objParticle = AmmoExplode;
                }
            }
            else
            {
                objParticle = AmmoExplode;
            }
        }

        if (objParticle == null)
        {
            return;
        }

        if (AmmoType == PlayerAmmoType.DaoDanAmmo)
        {
            Vector3 AmmoPos = transform.position - (transform.forward * 3f);
            Physics.Raycast(AmmoPos, forwardVal, out hit, 13f, XkGameCtrl.GetInstance().LandLayer);
            if (hit.collider != null)
            {
                hitPos = hit.point;
                Vector3    normalVal = hit.normal;
                Quaternion rotVal    = Quaternion.LookRotation(normalVal);
                obj = SpawnParticleCom.SpawnParticleObject(objParticle, hitPos, rotVal);
                obj.transform.up = normalVal;
            }
            else
            {
                obj = SpawnParticleCom.SpawnParticleObject(objParticle, hitPos, transform.rotation);
            }
        }
        else
        {
            obj = SpawnParticleCom.SpawnParticleObject(objParticle, hitPos, transform.rotation);
        }
        tran        = obj.transform;
        tran.parent = XkGameCtrl.PlayerAmmoArray;
        XkGameCtrl.CheckObjDestroyThisTimed(obj);

        XkAmmoTieHuaCtrl tieHuaScript = obj.GetComponent <XkAmmoTieHuaCtrl>();

        if (tieHuaScript != null && tieHuaScript.TieHuaTran != null)
        {
            Transform tieHuaTran = tieHuaScript.TieHuaTran;
            Vector3   AmmoPos    = transform.position - (transform.forward * 3f);
            Physics.Raycast(AmmoPos, forwardVal, out hit, 13f, XkGameCtrl.GetInstance().PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
                tieHuaTran.up = hit.normal;
            }
        }
    }
Ejemplo n.º 17
0
//	public void SetNpcIsDoFire(NpcMark script)
//	{
//		//Debug.Log("Unity:"+"SetNpcIsDoFire -> IsFireFeiJiNpc "+script.IsFireFeiJiNpc);
//		if (!NpcScript.IsAniMove) {
//			return;
//		}
//
//		if (SpawnPointScript == null) {
//			return;
//		}
//
//		Transform npcPath = SpawnPointScript.NpcPath;
//		Transform markPar = script.transform.parent;
//		if (npcPath != markPar) {
//			return;
//		}
//		//Debug.Log("Unity:"+"***********SetNpcIsDoFire -> IsFireFeiJiNpc "+script.IsFireFeiJiNpc);
//		NpcScript.SetIsDoFireAnimation(script.IsFireFeiJiNpc);
//		NpcScript.SetFeiJiMarkInfo(script);
//	}

    void Update()
    {
        if (!XkGameCtrl.IsMoveOnPlayerDeath)
        {
            if (!XkGameCtrl.IsActivePlayerOne && !XkGameCtrl.IsActivePlayerTwo)
            {
                return;
            }
        }

        if (IsDeathNPC)
        {
            return;
        }

        if (!IsTeShuFireNpc)
        {
            return;
        }

        if (TimeTeShuFire.Length < 1)
        {
            return;
        }

        //if (Network.peerType == NetworkPeerType.Server) {
        //	return;
        //}

        if ((JiFenJieMianCtrl.GetInstance() != null && JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask()) ||
            GameOverCtrl.IsShowGameOver)
        {
            return;
        }

        if (!NpcScript.GetIsDoFireAnimation())
        {
            return;
        }

        if (XkGameCtrl.CheckNpcIsMoveToCameraBack(transform))
        {
            return;
        }

        if (XkGameCtrl.GetInstance().IsCreatAmmoOnBoss == false)
        {
            if (XkPlayerCtrl.GetInstanceFeiJi().m_SpawnNpcManage.GetIsHaveCaiPiaoBoss() == true)
            {
                if (NpcScript != null && NpcScript.IsCaiPiaoZhanChe == true)
                {
                }
                else
                {
                    //有彩票boss产生,不再继续发射子弹.
                    return;
                }
            }
        }

        GameObject obj  = null;
        Transform  tran = null;

        for (int i = 0; i < TimeTeShuFire.Length; i++)
        {
            TimeTeShuFire[i] += Time.deltaTime;
            if (TimeTeShuFire[i] >= TimeFireAmmo[i])
            {
                TimeTeShuFire[i] = 0f;                 //fire ammo
//				Debug.Log("Unity:"+"teShuFireNpc -> i = "+i);

                if (i < AudioTeShuNpcFire.Length && AudioTeShuNpcFire[i] != null)
                {
                    if (AudioTeShuNpcFire[i].isPlaying)
                    {
                        AudioTeShuNpcFire[i].Stop();
                    }
                    AudioTeShuNpcFire[i].Play();
                }

                //if (AmmoLZPrefabTeShu != null && AmmoLZPrefabTeShu[i] != null && AmmoLZObjTeShu[i] == null) {
                if (AmmoLZPrefabTeShu != null && AmmoLZPrefabTeShu[i] != null)
                {
                    obj = (GameObject)Instantiate(AmmoLZPrefabTeShu[i],
                                                  AmmoSpawnTranTeShu[i].position, AmmoSpawnTranTeShu[i].rotation);

                    tran = obj.transform;
                    //AmmoLZObjTeShu[i] = obj;
                    XkGameCtrl.CheckObjDestroyThisTimed(obj);
                    tran.parent = AmmoSpawnTranTeShu[i];
                }

                PlayerAmmoCtrl ammoPlayerScript = AmmoPrefabTeShu[i].GetComponent <PlayerAmmoCtrl>();
                if (ammoPlayerScript != null && !XkGameCtrl.GetInstance().IsCartoonShootTest)
                {
                    continue;
                }

                obj = GetNpcAmmoFromList(AmmoSpawnTranTeShu[i], AmmoPrefabTeShu[i]);
                if (obj == null)
                {
                    return;
                }
                tran        = obj.transform;
                tran.parent = XkGameCtrl.NpcAmmoArray;

                NpcAmmoCtrl ammoNpcScript = obj.GetComponent <NpcAmmoCtrl>();
                if (ammoNpcScript != null)
                {
                    ammoNpcScript.SetNpcScriptInfo(NpcScript);
                    ammoNpcScript.SetIsAimFeiJiPlayer(IsAimFeiJiPlayer);
                }
                else
                {
                    PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();
                    if (ammoScript != null)
                    {
                        Vector3 startPos    = tran.position;
                        Vector3 firePos     = tran.position;
                        Vector3 ammoForward = tran.forward;
                        firePos = Random.Range(300f, 400f) * ammoForward + startPos;
                        float      fireDisVal = Vector3.Distance(firePos, startPos);
                        RaycastHit hit;
                        LayerMask  FireLayer = XkGameCtrl.GetInstance().PlayerAmmoHitLayer;
                        if (Physics.Raycast(startPos, ammoForward, out hit, fireDisVal, FireLayer.value))
                        {
                            //Debug.Log("Unity:"+"npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                            firePos = hit.point;
                            XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                            if (healthScript != null)
                            {
                                healthScript.OnDamageNpc(ammoScript.DamageNpc, PlayerEnum.Null);
                            }

                            BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                            if (buJiBaoScript != null)
                            {
                                buJiBaoScript.RemoveBuJiBao(PlayerEnum.Null);                                 //buJiBaoScript
                            }
                        }
                        ammoScript.StartMoveAmmo(firePos, PlayerEnum.Null, null, AmmoMovePath);
                    }
                }

//				if (AmmoLiZiPrefab != null) {
//					obj = (GameObject)Instantiate(AmmoLiZiPrefab, AmmoSpawnTran.position, AmmoSpawnTran.rotation);
//					tran = obj.transform;
//					tran.parent = XkGameCtrl.MissionCleanup;
//				}
            }
        }
    }
Ejemplo n.º 18
0
    void StartSpawnNpcAmmo()
    {
        if (XkGameCtrl.CheckNpcIsMoveToCameraBack(transform))
        {
            return;
        }

        if (AudioNpcFire != null)
        {
            if (AudioNpcFire.isPlaying)
            {
                AudioNpcFire.Stop();
            }
            AudioNpcFire.Play();
        }

        GameObject obj  = null;
        Transform  tran = null;

        if (AmmoLiZiPrefab != null && AmmoLiZiObj == null)
        {
            obj         = (GameObject)Instantiate(AmmoLiZiPrefab, AmmoSpawnTran.position, AmmoSpawnTran.rotation);
            tran        = obj.transform;
            tran.parent = XkGameCtrl.NpcAmmoArray;
            AmmoLiZiObj = obj;
            XkGameCtrl.CheckObjDestroyThisTimed(obj);
        }

        if (AmmoPrefab == null)
        {
            return;
        }

        PlayerAmmoCtrl ammoPlayerScript = AmmoPrefab.GetComponent <PlayerAmmoCtrl>();

        if (ammoPlayerScript != null && !XkGameCtrl.GetInstance().IsCartoonShootTest)
        {
            return;
        }

        obj = GetNpcAmmoFromList(AmmoSpawnTran);
        if (obj == null)
        {
            return;
        }

        tran        = obj.transform;
        tran.parent = XkGameCtrl.NpcAmmoArray;
        NpcAmmoCtrl AmmoScript = obj.GetComponent <NpcAmmoCtrl>();

        if (AmmoScript != null)
        {
            AmmoScript.SetNpcScriptInfo(NpcScript);
            AmmoScript.SetIsAimFeiJiPlayer(IsAimFeiJiPlayer);
            for (int i = 0; i < AmmoSpawnArray.Length; i++)
            {
                if (AmmoSpawnArray[i] != null)
                {
                    obj = (GameObject)Instantiate(AmmoPrefab,
                                                  AmmoSpawnArray[i].position,
                                                  AmmoSpawnArray[i].rotation);
                    tran        = obj.transform;
                    tran.parent = XkGameCtrl.NpcAmmoArray;
                    AmmoScript  = obj.GetComponent <NpcAmmoCtrl>();
                    AmmoScript.SetNpcScriptInfo(NpcScript);
                    AmmoScript.SetIsAimFeiJiPlayer(IsAimFeiJiPlayer);
                }
            }
        }
        else
        {
            PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();
            if (ammoScript != null)
            {
                Vector3 startPos    = tran.position;
                Vector3 firePos     = tran.position;
                Vector3 ammoForward = tran.forward;
                firePos = Random.Range(300f, 400f) * ammoForward + startPos;
                float      fireDisVal = Vector3.Distance(firePos, startPos);
                RaycastHit hit;
                LayerMask  FireLayer = XkGameCtrl.GetInstance().PlayerAmmoHitLayer;
                if (Physics.Raycast(startPos, ammoForward, out hit, fireDisVal, FireLayer.value))
                {
                    //Debug.Log("Unity:"+"npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                    firePos = hit.point;
                    XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                    if (healthScript != null)
                    {
                        healthScript.OnDamageNpc(ammoScript.DamageNpc, PlayerEnum.Null);
                    }

                    BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                    if (buJiBaoScript != null)
                    {
                        buJiBaoScript.RemoveBuJiBao(PlayerEnum.Null);                         //buJiBaoScript
                    }
                }
                ammoScript.StartMoveAmmo(firePos, PlayerEnum.Null);
            }
        }
    }
    bool CheckAmmoHitObj(GameObject hitObjNpc, PlayerEnum playerIndex)
    {
//		BuJiBaoCtrl buJiBaoScript = hitObjNpc.GetComponent<BuJiBaoCtrl>();
//		if (buJiBaoScript != null) {
//			buJiBaoScript.RemoveBuJiBao(playerIndex); //buJiBaoScript
//			return;
//		}

        bool isStopCheckHit = false;

        if (AmmoType != PlayerAmmoType.PaiJiPaoAmmo)
        {
            XKPlayerCheckCamera checkCam = hitObjNpc.GetComponent <XKPlayerCheckCamera>();
            if (checkCam != null)
            {
                MoveAmmoOnCompelteITween();
                return(true);
            }
        }

        XKNpcHealthCtrl healthScript = hitObjNpc.GetComponent <XKNpcHealthCtrl>();

        if (healthScript != null && !healthScript.GetIsDeathNpc())
        {
            /*Debug.Log("CheckAmmoHitObj -> OnDamageNpc: "
             +"AmmoType "+AmmoType
             +", AmmoName "+AmmoTran.name
             +", NpcName "+healthScript.GetNpcName()
             +", AmmoDamageDis "+AmmoDamageDis);*/
            bool isHitNpc = false;
            switch (AmmoType)
            {
            case PlayerAmmoType.ChuanTouAmmo:
            case PlayerAmmoType.PaiJiPaoAmmo:
                if (NpcHealthList == null)
                {
                    NpcHealthList = new List <XKNpcHealthCtrl>();
                }

                if (!NpcHealthList.Contains(healthScript))
                {
                    NpcHealthList.Add(healthScript);
                    isHitNpc = true;
                }
                break;

            default:
                MoveAmmoOnCompelteITween();
                isStopCheckHit = true;
                isHitNpc       = true;
                break;
            }

            if (isHitNpc)
            {
                healthScript.OnDamageNpc(DamageNpc, PlayerState, AmmoType);
                SpawnAmmoParticleObj();
            }
        }

        if (hitObjNpc != null)
        {
            NpcAmmoCtrl npcAmmoScript = hitObjNpc.GetComponent <NpcAmmoCtrl>();
            if (npcAmmoScript != null)
            {
                npcAmmoScript.MoveAmmoOnCompelteITween();
            }

            if (AmmoType == PlayerAmmoType.DaoDanAmmo ||
                AmmoType == PlayerAmmoType.GaoBaoAmmo ||
                AmmoType == PlayerAmmoType.PuTongAmmo ||
                AmmoType == PlayerAmmoType.SanDanAmmo)
            {
                if (hitObjNpc.layer != LayerMask.NameToLayer("Default"))
                {
                    MoveAmmoOnCompelteITween();
                    isStopCheckHit = true;
                }
            }
        }
        return(isStopCheckHit);
    }
    void OnTriggerEnter(Collider other)
    {
        if (ZuDangState == ZuDangType.Null)
        {
            gameObject.SetActive(false);
            return;
        }

        if (JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask())
        {
            return;
        }

        if (Network.peerType == NetworkPeerType.Server)
        {
            return;
        }

        mPlayerScript = other.GetComponent <XkPlayerCtrl>();
        if (mPlayerScript == null || !mPlayerScript.GetIsHandleRpc())
        {
            return;
        }

        if (!CheckIsMovePlayer())
        {
            IsActiveTrigger         = true;
            KongXiDt.TimeLastKongXi = KongXiDt.TimeLastKongXiDaoJiShi = Time.time;
            //打开提示框UI.
            switch (ZuDangState)
            {
            case ZuDangType.PuTong:
            {
                XkGameCtrl.GetInstance().SetIsStopMovePlayer(true);
                XkGameCtrl.GetInstance().SetIsActiveZuDangTrigger(true);
                if (GameUICenterCtrl.GetInstance() != null)
                {
                    GameUICenterCtrl.GetInstance().SpawnZuDangUI();
                    if (ZuDangArray[0] != null)
                    {
                        XKNpcHealthCtrl npcHealth = ZuDangArray[0].GetComponent <XKNpcHealthCtrl>();
                        if (npcHealth != null)
                        {
                            GameUICenterCtrl.GetInstance().SpawnZuDangXueTiaoUI(npcHealth);
                        }
                    }
                }
                break;
            }

            case ZuDangType.KongXi:
            {
                if (GameUICenterCtrl.GetInstance() != null)
                {
                    GameUICenterCtrl.GetInstance().SpawnKongXiZuDangUI();
                    GameUICenterCtrl.GetInstance().SpawnKongXiDaoJiShiUI((int)KongXiDt.TimeSpawnDaoDan);
                }
                break;
            }
            }
        }
        else
        {
            gameObject.SetActive(false);
        }
    }
    IEnumerator PlayPaoGuanAnimation()
    {
        int   count         = 0;
        int   maxCount      = 1;
        float speed         = PaoGuanZhenFu / maxCount;
        bool  isBackPaoGuan = false;
        bool  isFireAmmo    = false;

        IsPlayPaoGuanAnimation = true;
        do
        {
//			if (JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask()
//			    || IsDeathNpc
//			    || GameOverCtrl.IsShowGameOver) {
//				yield break;
//			}

            if (IsStopAnimation)
            {
                yield return(new WaitForSeconds(0.3f));

                continue;
            }

            if (!isBackPaoGuan)
            {
                PaoGuan.position -= PaoGuan.forward * speed;
                count++;
                if (count >= maxCount)
                {
                    isBackPaoGuan = true;
                }

                if (count == 1 && !isFireAmmo)
                {
                    isFireAmmo = true;
                    PlayAudioCannonFire();

                    PlayerAmmoCtrl ammoPlayerScript = DaPaoAmmo.GetComponent <PlayerAmmoCtrl>();
                    if (ammoPlayerScript != null && !XkGameCtrl.GetInstance().IsCartoonShootTest)
                    {
                        yield break;
                    }

                    GameObject obj = GetNpcAmmoFromList(SpawnAmmoPoint[0]);
                    if (obj == null)
                    {
                        yield break;
                    }

                    NpcAmmoCtrl AmmoScript = obj.GetComponent <NpcAmmoCtrl>();
                    Transform   tran       = obj.transform;
                    tran.parent = XkGameCtrl.NpcAmmoArray;
                    if (AmmoScript != null)
                    {
                        AmmoScript.SetIsAimPlayer(false);
                        AmmoScript.SetIsAimFeiJiPlayer(false);
                    }
                    else
                    {
                        PlayerAmmoCtrl ammoScript = obj.GetComponent <PlayerAmmoCtrl>();
                        if (ammoScript != null)
                        {
                            Vector3 startPos    = tran.position;
                            Vector3 firePos     = tran.position;
                            Vector3 ammoForward = tran.forward;
                            firePos = Random.Range(300f, 400f) * ammoForward + startPos;
                            float      fireDisVal = Vector3.Distance(firePos, startPos);
                            RaycastHit hit;
                            LayerMask  FireLayer = XkGameCtrl.GetInstance().PlayerAmmoHitLayer;
                            if (Physics.Raycast(startPos, ammoForward, out hit, fireDisVal, FireLayer.value))
                            {
                                //Debug.Log("npc fire PlayerAmmo, fire obj -> "+hit.collider.name);
                                firePos = hit.point;
                                XKNpcHealthCtrl healthScript = hit.collider.GetComponent <XKNpcHealthCtrl>();
                                if (healthScript != null)
                                {
                                    healthScript.OnDamageNpc(ammoScript.AmmoType, PlayerEnum.Null);
                                }

                                BuJiBaoCtrl buJiBaoScript = hit.collider.GetComponent <BuJiBaoCtrl>();
                                if (buJiBaoScript != null)
                                {
                                    buJiBaoScript.RemoveBuJiBao(PlayerEnum.Null);                                     //buJiBaoScript
                                }
                            }
                            ammoScript.StartMoveAmmo(firePos, PlayerEnum.Null, AmmoMovePath);
                        }
                    }

                    if (DaPaoAmmoLiZi != null)
                    {
                        obj  = SpawnParticleCom.SpawnParticleObject(DaPaoAmmoLiZi, SpawnAmmoPoint[0].position, SpawnAmmoPoint[0].rotation);
                        tran = obj.transform;
                    }

                    if (!SpawnAmmoPoint[0].gameObject.activeSelf)
                    {
                        SpawnAmmoPoint[0].gameObject.SetActive(true);
                    }
                    tran.parent = SpawnAmmoPoint[0];
                }
            }
            else
            {
                PaoGuan.position += PaoGuan.forward * speed;
                count--;
                if (count <= 0)
                {
                    //break;
                    IsPlayPaoGuanAnimation = false;
                    isBackPaoGuan          = false;
                    isFireAmmo             = false;
                    count = 0;
                    if (IsDoFireAnimation)
                    {
                        yield return(new WaitForSeconds(TimeDanGuanFire));

                        IsPlayPaoGuanAnimation = true;
                        continue;
                    }
                }
            }
            yield return(new WaitForSeconds(PaoGuanShenSuoSD));
//			Debug.Log("dp****************"+Time.deltaTime);
        } while (IsDoFireAnimation);
    }
Ejemplo n.º 22
0
 /// <summary>
 /// 保存代金券npc的血条脚本.
 /// </summary>
 internal void SaveDaiJinQuanHealth(XKNpcHealthCtrl health)
 {
     m_DaiJinQuanHealth = health;
 }
Ejemplo n.º 23
0
    internal void CheckPlayerBaoJiDengJi(PlayerAmmoType ammoType, PlayerEnum indexPlayer, XKNpcHealthCtrl npcHealth)
    {
        int indexVal = (int)indexPlayer - 1;

        if (indexVal >= 0 && indexVal <= 3)
        {
            if (m_TestBaoJiangData != null)
            {
                if (m_TestBaoJiangData.IsOpenTest == true)
                {
                    if (m_TestBaoJiangData.IndexBaoJi >= 0 && m_TestBaoJiangData.IndexBaoJi <= 3)
                    {
                        //测试暴击数据信息.
                        indexVal = m_TestBaoJiangData.IndexBaoJi;
                        m_PlayerBaoJiDt[indexVal].BaoJiDengJi = indexVal;
                        return;
                    }
                }
            }

            switch (ammoType)
            {
            case PlayerAmmoType.DaoDanAmmo:
            case PlayerAmmoType.PaiJiPaoAmmo:
            case PlayerAmmoType.ChuanTouAmmo:
            case PlayerAmmoType.SanDanAmmo:
            case PlayerAmmoType.ChongJiBoAmmo:
            {
                if (Time.time - m_PlayerBaoJiDt[indexVal].TimeBaoJi > 0.05f)
                {
                    //玩家导弹暴击间隔时间必须大于导弹发射的冷却时间.
                    if (npcHealth != null && npcHealth.GetIsDaiJinQuanNpc() == true)
                    {
                        //只有代金券Npc才可以被暴击.
                        if (Time.time - m_PlayerBaoJiDt[indexVal].TimeBaoJi <= m_TimeBaoJi)
                        {
                            //暴击间隔时间必须小于设定数值.
                            m_PlayerBaoJiDt[indexVal].ShiWuCount = 0;
                            if (m_PlayerBaoJiDt[indexVal].BaoJiDengJi < 3)
                            {
                                //最高4档.
                                m_PlayerBaoJiDt[indexVal].BaoJiDengJi++;
                            }

                            if (m_PlayerBaoJiDt[indexVal].BaoJiDengJi > 3)
                            {
                                m_PlayerBaoJiDt[indexVal].BaoJiDengJi = 3;
                            }
                        }
                        else
                        {
                            m_PlayerBaoJiDt[indexVal].ShiWuCount++;
                        }
                        //SSDebug.LogWarning("npcHealth ===================== " + npcHealth
                        //    + ", BaoJiDengJi ==== " + m_PlayerBaoJiDt[indexVal].BaoJiDengJi
                        //    + ", ShiWuCount ==== " + m_PlayerBaoJiDt[indexVal].ShiWuCount
                        //    + ", time ==== " + Time.time.ToString("f3"));

                        m_PlayerBaoJiDt[indexVal].TimeBaoJi = Time.time;
                        if (m_PlayerBaoJiDt[indexVal].ShiWuCount >= 1)
                        {
                            //失误次数超过n次重置暴击等级信息.
                            //暴击失效.
                            m_PlayerBaoJiDt[indexVal].Reset();
                        }
                    }
                }
                break;
            }
            }
        }
    }
    public void RemoveNpcObj()
    {
        if (!IsZaiTiNpc)
        {
            return;
        }

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

        ZaiTiNpcAni.enabled = false;
        if (DeathExplode != null)
        {
            GameObject objExplode = null;
            if (DeathExplodePoint != null)
            {
                objExplode = (GameObject)Instantiate(DeathExplode, DeathExplodePoint.position, DeathExplodePoint.rotation);
            }
            else
            {
                objExplode = (GameObject)Instantiate(DeathExplode, transform.position, transform.rotation);
            }
            objExplode.transform.parent = XkGameCtrl.NpcAmmoArray;
            //XkGameCtrl.CheckObjDestroyThisTimed(objExplode);

            if (Network.peerType != NetworkPeerType.Disconnected)
            {
                XKNpcHealthCtrl healthScript = GetComponent <XKNpcHealthCtrl>();
                if (healthScript != null)
                {
                    healthScript.CheckHiddenNpcObjArray();
                }
            }
        }

        if (NpcObj != null)
        {
            if (ZaiTiNpcBuWaWa != null && !IsZaiTiNpc)
            {
                Rigidbody rigCom = NpcObj.GetComponent <Rigidbody>();
                if (rigCom == null)
                {
                    rigCom = NpcObj.AddComponent <Rigidbody>();
                }
                rigCom.isKinematic = false;
                rigCom.AddForce(transform.forward * 5f, ForceMode.Impulse);
                ZaiTiNpcBuWaWa.gameObject.SetActive(true);
                ZaiTiNpcBuWaWa.AddForce(transform.forward * 95f, ForceMode.Impulse);
                //Destroy(NpcObj, 2f);
            }
            else
            {
                Rigidbody rigCom = NpcObj.GetComponent <Rigidbody>();
                if (rigCom == null)
                {
                    rigCom = NpcObj.AddComponent <Rigidbody>();
                }
                rigCom.isKinematic = false;
                rigCom.AddForce(transform.forward * 5f, ForceMode.Impulse);
                //Destroy(NpcObj, 2f);
            }
        }
        ResetZaiTiNpcInfo();
    }
Ejemplo n.º 25
0
    bool CheckAmmoHitObj(GameObject hitObjNpc, PlayerEnum playerIndex)
    {
//		BuJiBaoCtrl buJiBaoScript = hitObjNpc.GetComponent<BuJiBaoCtrl>();
//		if (buJiBaoScript != null) {
//			buJiBaoScript.RemoveBuJiBao(playerIndex); //buJiBaoScript
//			return;
//		}

        bool isStopCheckHit = false;

        if (AmmoType != PlayerAmmoType.PaiJiPaoAmmo)
        {
            XKPlayerCheckCamera checkCam = hitObjNpc.GetComponent <XKPlayerCheckCamera>();
            if (checkCam != null)
            {
                IsHitNpcAmmo = true;
                //SSDebug.LogWarning("MoveAmmoOnCompelteITween ============== 55555555555555555");
                MoveAmmoOnCompelteITween();
                return(true);
            }
        }

        XKNpcHealthCtrl healthScript = hitObjNpc.GetComponent <XKNpcHealthCtrl>();

        if (healthScript != null && !healthScript.GetIsDeathNpc())
        {
            /*Debug.Log("Unity:"+"CheckAmmoHitObj -> OnDamageNpc: "
             +"AmmoType "+AmmoType
             +", AmmoName "+AmmoTran.name
             +", NpcName "+healthScript.GetNpcName()
             +", AmmoDamageDis "+AmmoDamageDis);*/
            bool isHitNpc = false;
            switch (AmmoType)
            {
            case PlayerAmmoType.ChuanTouAmmo:
            case PlayerAmmoType.PaiJiPaoAmmo:
            {
                if (NpcHealthList == null)
                {
                    NpcHealthList = new List <XKNpcHealthCtrl>();
                }

                if (!NpcHealthList.Contains(healthScript))
                {
                    NpcHealthList.Add(healthScript);
                    isHitNpc = true;
                }
                break;
            }

            default:
            {
                IsHitNpcAmmo = true;
                //MoveAmmoOnCompelteITween();
                isStopCheckHit = true;
                isHitNpc       = true;
                break;
            }
            }

            if (isHitNpc)
            {
                int baoJiDamage = 0;
                if (AmmoType == PlayerAmmoType.ChuanTouAmmo ||
                    AmmoType == PlayerAmmoType.DaoDanAmmo ||
                    AmmoType == PlayerAmmoType.PaiJiPaoAmmo ||
                    AmmoType == PlayerAmmoType.SanDanAmmo ||
                    AmmoType == PlayerAmmoType.ChongJiBoAmmo)
                {
                    //获取玩家对代金券npc的暴击伤害.
                    XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.CheckPlayerBaoJiDengJi(AmmoType, PlayerState, healthScript);
                    if (XkGameCtrl.GetInstance().m_CaiPiaoHealthDt != null && healthScript.GetIsDaiJinQuanNpc() == true)
                    {
                        baoJiDamage = XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.GetBaoJiDamage(PlayerState);
                    }
                }

                //if (XkGameCtrl.GetInstance().m_CaiPiaoHealthDt != null && healthScript.GetIsDaiJinQuanNpc() == true)
                //{
                //    if (AmmoType == PlayerAmmoType.ChuanTouAmmo
                //        || AmmoType == PlayerAmmoType.DaoDanAmmo
                //        || AmmoType == PlayerAmmoType.PaiJiPaoAmmo
                //        || AmmoType == PlayerAmmoType.SanDanAmmo)
                //    {
                //        //获取玩家对代金券npc的暴击伤害.
                //        XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.CheckPlayerBaoJiDengJi(AmmoType, PlayerState, healthScript);
                //        baoJiDamage = XkGameCtrl.GetInstance().m_CaiPiaoHealthDt.GetBaoJiDamage(PlayerState);
                //    }
                //}
                healthScript.OnDamageNpc(DamageNpc + baoJiDamage, PlayerState, AmmoType, IsAiFireAmmo);
                SpawnAmmoParticleObj(healthScript);
            }

            if (isStopCheckHit == true)
            {
                //停止子弹的伤害检测.
                if (AmmoType == PlayerAmmoType.ChongJiBoAmmo)
                {
                    //冲击波子弹不允许调用MoveAmmoOnCompelteITween.
                }
                else
                {
                    //SSDebug.LogWarning("MoveAmmoOnCompelteITween ============== 44444444444444444");
                    MoveAmmoOnCompelteITween();
                }
            }
        }

        if (hitObjNpc != null)
        {
            NpcAmmoCtrl npcAmmoScript = hitObjNpc.GetComponent <NpcAmmoCtrl>();
            if (npcAmmoScript != null)
            {
                npcAmmoScript.MoveAmmoOnCompelteITween();
            }

            if (AmmoType == PlayerAmmoType.DaoDanAmmo ||
                AmmoType == PlayerAmmoType.GaoBaoAmmo ||
                AmmoType == PlayerAmmoType.PuTongAmmo ||
                AmmoType == PlayerAmmoType.SanDanAmmo ||
                AmmoType == PlayerAmmoType.ChongJiBoAmmo)
            {
                if (hitObjNpc.layer != LayerMask.NameToLayer("Default"))
                {
                    //SSDebug.Log("hitObjNpc ===================================== " + hitObjNpc.name);
                    IsHitNpcAmmo = true;
                    if (AmmoType == PlayerAmmoType.ChongJiBoAmmo)
                    {
                        //冲击波子弹不允许在这里调用MoveAmmoOnCompelteITween,否则会被瞬间删除.
                    }
                    else
                    {
                        //SSDebug.LogWarning("MoveAmmoOnCompelteITween ============== 333333333333333");
                        MoveAmmoOnCompelteITween();
                    }
                    isStopCheckHit = true;
                }
            }
        }
        return(isStopCheckHit);
    }
Ejemplo n.º 26
0
    //static int TestCount = 0;
    void SpawnAmmoParticleObj(XKNpcHealthCtrl healthScript = null)
    {
        if (AmmoType != PlayerAmmoType.ChuanTouAmmo)
        {
            //不是穿甲弹.
            if (IsCreatAmmoParticle == true)
            {
                //已经创建过爆炸粒子.
                return;
            }
            IsCreatAmmoParticle = true;
        }

        //if (AmmoType == PlayerAmmoType.DaoDanAmmo)
        //{
        //    TestCount++;
        //    SSDebug.LogWarning("SpawnAmmoParticleObj -> healthScript ============= " + healthScript
        //        + ", TestCount == " + TestCount
        //        + ", time == " + Time.time.ToString("f3"));
        //}

        //if (TestCount >= 100)
        //{
        //    TestCount = 0;
        //}

#if USE_SPHERE_HIT
        GameObject objParticle = null;
        GameObject hitObj      = CheckPlayerAmmoOverlapSphereHit(1);
        if (hitObj == null)
        {
            switch (AmmoType)
            {
            case PlayerAmmoType.PuTongAmmo:
                break;

            default:
                objParticle = AmmoExplode;
                break;
            }
        }
        else
        {
            string tagHitObj = hitObj.tag;
            switch (AmmoType)
            {
            case PlayerAmmoType.PuTongAmmo:
                XKAmmoParticleCtrl ammoParticleScript = hitObj.GetComponent <XKAmmoParticleCtrl>();
                if (ammoParticleScript != null && ammoParticleScript.PuTongAmmoLZ != null)
                {
                    objParticle = ammoParticleScript.PuTongAmmoLZ;
                }
                else
                {
                    switch (tagHitObj)
                    {
                    case "metal":
                        objParticle = MetalParticle;
                        break;

                    case "concrete":
                        objParticle = ConcreteParticle;
                        break;

                    case "dirt":
                        objParticle = DirtParticle;
                        break;

                    case "wood":
                        objParticle = WoodParticle;
                        break;

                    case "water":
                        objParticle = WaterParticle;
                        break;

                    case "sand":
                        objParticle = SandParticle;
                        break;

                    case "glass":
                        objParticle = GlassParticle;
                        break;

                    default:
                        objParticle = AmmoExplode;
                        break;
                    }
                }
                break;

            default:
                switch (tagHitObj)
                {
                case "dirt":
                    objParticle = DirtParticle;
                    break;

                case "water":
                    objParticle = WaterParticle;
                    break;

                default:
                    objParticle = AmmoExplode;
                    break;
                }
                break;
            }
        }

        if (objParticle == null)
        {
            return;
        }

        Vector3    pos = AmmoTran.position;
        Quaternion rot = AmmoTran.rotation;
        if (AmmoType == PlayerAmmoType.ChongJiBoAmmo)
        {
            if (healthScript != null)
            {
                //获取距离冲击波子弹最近的爆炸产生点.
                Transform tr = healthScript.GetAmmoLiZiMinDisSpawnPoint(transform);
                if (tr != null)
                {
                    //冲击波子弹.
                    pos = tr.position;
                    rot = tr.rotation;
                }
            }
            else
            {
                //冲击波子弹没有击中npc时不产生自爆粒子.
                return;
            }
        }
        GameObject obj  = (GameObject)Instantiate(objParticle, pos, rot);
        Transform  tran = obj.transform;
        tran.parent = XkGameCtrl.PlayerAmmoArray;
        XkGameCtrl.CheckObjDestroyThisTimed(obj);

        SSPlayerAmmoBaoJi baoJiAmmo = obj.GetComponent <SSPlayerAmmoBaoJi>();
        if (baoJiAmmo != null)
        {
            bool isDisplayBaoJi = false;
            if (healthScript != null)
            {
                if (healthScript.GetIsDaiJinQuanNpc() == true)
                {
                    //代金券npc.
                    isDisplayBaoJi = true;
                }

                //if (XkGameCtrl.GetInstance().m_SSDebugBaoJi != null)
                //{
                //    //测试爆击代金券npc.
                //    XkGameCtrl.GetInstance().m_SSDebugBaoJi.IsHitDaiJinQuanNpc = healthScript.GetIsDaiJinQuanNpc();
                //}
            }
            //else
            //{
            //    if (XkGameCtrl.GetInstance().m_SSDebugBaoJi != null)
            //    {
            //        //测试爆击代金券npc.
            //        XkGameCtrl.GetInstance().m_SSDebugBaoJi.IsHitDaiJinQuanNpc = false;
            //    }
            //}

            if (isDisplayBaoJi == true)
            {
                //初始化子弹爆炸粒子上的暴击效果.
                baoJiAmmo.Init(PlayerState);
            }
            else
            {
                //隐藏子弹爆炸粒子上的暴击效果.
                baoJiAmmo.HiddenBaoJi();
            }
        }
#else
        GameObject objParticle = null;
        GameObject obj         = null;
        Transform  tran        = null;
        Vector3    hitPos      = transform.position;
        RaycastHit hit;
        Vector3    forwardVal = Vector3.Normalize(AmmoEndPos - AmmoStartPos);
        if (AmmoType == PlayerAmmoType.PuTongAmmo)
        {
            float disVal = Vector3.Distance(AmmoEndPos, AmmoStartPos) + 10f;
            Physics.Raycast(AmmoStartPos, forwardVal, out hit, disVal, PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
                XKAmmoParticleCtrl ammoParticleScript = hit.collider.GetComponent <XKAmmoParticleCtrl>();
                if (ammoParticleScript != null && ammoParticleScript.PuTongAmmoLZ != null)
                {
                    objParticle = ammoParticleScript.PuTongAmmoLZ;
                }
                else
                {
                    string tagHitObj = hit.collider.tag;
                    switch (tagHitObj)
                    {
                    case "metal":
                        if (MetalParticle != null)
                        {
                            objParticle = MetalParticle;
                        }
                        break;

                    case "concrete":
                        if (ConcreteParticle != null)
                        {
                            objParticle = ConcreteParticle;
                        }
                        break;

                    case "dirt":
                        if (DirtParticle != null)
                        {
                            objParticle = DirtParticle;
                        }
                        break;

                    case "wood":
                        if (WoodParticle != null)
                        {
                            objParticle = WoodParticle;
                        }
                        break;

                    case "water":
                        if (WaterParticle != null)
                        {
                            objParticle = WaterParticle;
                        }
                        break;

                    case "sand":
                        if (SandParticle != null)
                        {
                            objParticle = SandParticle;
                        }
                        break;

                    case "glass":
                        if (GlassParticle != null)
                        {
                            objParticle = GlassParticle;
                        }
                        break;
                    }

                    if (objParticle == null)
                    {
                        objParticle = AmmoExplode;
                    }
                }
            }
            else
            {
                objParticle = AmmoExplode;
            }
        }
        else
        {
            float disVal = Vector3.Distance(AmmoEndPos, AmmoStartPos) + 10f;
            Physics.Raycast(AmmoStartPos, forwardVal, out hit, disVal, PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
                string tagHitObj = hit.collider.tag;
                switch (tagHitObj)
                {
                case "dirt":
                    if (DirtParticle != null)
                    {
                        objParticle = DirtParticle;
                    }
                    break;

                case "water":
                    if (WaterParticle != null)
                    {
                        objParticle = WaterParticle;
                    }
                    break;
                }

                if (objParticle == null)
                {
                    objParticle = AmmoExplode;
                }
            }
            else
            {
                objParticle = AmmoExplode;
            }
        }

        if (objParticle == null)
        {
            return;
        }

        hitPos = explodePos;
        switch (AmmoType)
        {
        case PlayerAmmoType.DaoDanAmmo:
            Vector3 AmmoPos = transform.position - (transform.forward * 3f);
            Physics.Raycast(AmmoPos, forwardVal, out hit, 13f, XkGameCtrl.GetInstance().LandLayer);
            if (hit.collider != null)
            {
                Vector3    normalVal = hit.normal;
                Quaternion rotVal    = Quaternion.LookRotation(normalVal);
                obj = (GameObject)Instantiate(objParticle, hitPos, rotVal);
                obj.transform.up = normalVal;
            }
            else
            {
                obj = (GameObject)Instantiate(objParticle, hitPos, transform.rotation);
            }
            break;

        case PlayerAmmoType.ChuanTouAmmo:
            obj = (GameObject)Instantiate(objParticle, explodePos, transform.rotation);
            break;

        default:
            obj = (GameObject)Instantiate(objParticle, hitPos, transform.rotation);
            break;
        }
        tran        = obj.transform;
        tran.parent = XkGameCtrl.PlayerAmmoArray;
        XkGameCtrl.CheckObjDestroyThisTimed(obj);

        XkAmmoTieHuaCtrl tieHuaScript = obj.GetComponent <XkAmmoTieHuaCtrl>();
        if (tieHuaScript != null && tieHuaScript.TieHuaTran != null)
        {
            Transform tieHuaTran = tieHuaScript.TieHuaTran;
            Vector3   AmmoPos    = transform.position - (transform.forward * 3f);
            Physics.Raycast(AmmoPos, forwardVal, out hit, 13f, XkGameCtrl.GetInstance().PlayerAmmoHitLayer);
            if (hit.collider != null)
            {
                tieHuaTran.up = hit.normal;
            }
        }
#endif
    }