/// <summary>
    /// 检测玩家是否进入空袭警戒范围.
    /// </summary>
    void CheckPlayerIsIntoKongXiJingJie()
    {
        if (!XkGameCtrl.IsActivePlayerOne && !XkGameCtrl.IsActivePlayerTwo)
        {
            return;
        }

        if (IsPlayerIntoKongXiJingJie)
        {
            return;
        }

        Vector3 pos1 = KongXiDt.KongXiDianObj.transform.position;
        Vector3 pos2 = XkPlayerCtrl.GetInstanceTanKe().transform.position;

        pos1.y = pos2.y = 0f;
        if (Vector3.Distance(pos1, pos2) <= KongXiDt.DamageDis)
        {
            IsPlayerIntoKongXiJingJie = true;
            if (GameUICenterCtrl.GetInstance() != null)
            {
                GameUICenterCtrl.GetInstance().SpawnKongXiShanHongUI();
            }
        }
    }
    /// <summary>
    /// 循环产生空袭导弹.
    /// </summary>
    IEnumerator LoopSpawnKongXiDaoDan(GameObject playerDaoDan)
    {
        bool isDamagePlayer = false;

        do
        {
            if (KongXiDt.IsRemoveKongXiZuDang)
            {
                Debug.Log("LoopSpawnKongXiDaoDan -> stop!");
                yield break;
            }

            Debug.Log("LoopSpawnKongXiDaoDan -> time " + Time.time);
            int max = KongXiDt.AmmoPointTr.Length;
            for (int i = 0; i < max; i++)
            {
                if (mPlayerScript != null && KongXiDt.AmmoPointTr[i] != null)
                {
                    KongXiDt.AmmoPointTr[i].gameObject.SetActive(false);
                    mPlayerScript.SpawnPlayerDaoDan(KongXiDt.AmmoPointTr[i], playerDaoDan);
                }
            }

            if (!isDamagePlayer)
            {
                Vector3 pos1 = KongXiDt.KongXiDianObj.transform.position;
                Vector3 pos2 = XkPlayerCtrl.GetInstanceTanKe().transform.position;
                pos1.y = pos2.y = 0f;
                if (Vector3.Distance(pos1, pos2) <= KongXiDt.DamageDis)
                {
                    isDamagePlayer = true;
                    XkGameCtrl.GetInstance().SubPlayerYouLiang(PlayerEnum.PlayerOne, KongXiDt.PlayerDamage);
                    XkGameCtrl.GetInstance().SubPlayerYouLiang(PlayerEnum.PlayerTwo, KongXiDt.PlayerDamage);
                    if (GameUICenterCtrl.GetInstance() != null)
                    {
                        GameUICenterCtrl.GetInstance().RemoveKongXiZuDangUI();
                        GameUICenterCtrl.GetInstance().RemoveKongXiShanHongUI();
                        GameUICenterCtrl.GetInstance().RemoveKongXiDaoJishiUI();
                        GameUICenterCtrl.GetInstance().SpawnKongXiJiZhongUI();
                    }

                    if (mPlayerScript.GetPlayerCameraScript() != null)
                    {
                        //画面开始变黑白.
                        mPlayerScript.GetPlayerCameraScript().mCameraColorChange.Init();
                    }
                }
            }
            yield return(new WaitForSeconds(KongXiDt.TimeLoopDaoDan));
        }while (!KongXiDt.IsRemoveKongXiZuDang);
    }
Esempio n. 3
0
    /// <summary>
    /// 被空袭击中UI提示动画结束事件响应.
    /// </summary>
    public void OnAnimationEnvent()
    {
        if (GameUICenterCtrl.GetInstance() != null)
        {
            GameUICenterCtrl.GetInstance().RemoveKongXiJiZhongUI();
        }

        if (!JiFenJieMianCtrl.GetInstance().GetIsShowFinishTask())
        {
            DaoJiShiCtrl.GetInstance().StartPlayDaoJiShi();
        }
        XkGameCtrl.SetActivePlayerOne(false);
        XkGameCtrl.SetActivePlayerTwo(false);
    }
    /// <summary>
    /// 产生空袭闪红UI.
    /// </summary>
    void SpawnKongXiShanHongUI()
    {
        if (!XkGameCtrl.IsActivePlayerOne && !XkGameCtrl.IsActivePlayerTwo)
        {
            return;
        }

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

        if (GameUICenterCtrl.GetInstance() != null)
        {
            GameUICenterCtrl.GetInstance().SpawnKongXiShanHongUI();
        }
    }
Esempio n. 5
0
 /// <summary>
 /// 动画事件回调.
 /// </summary>
 public void OnAnimationTrigger()
 {
     GameUICenterCtrl.GetInstance().RemoveZuDangJiangLiUI();
 }
    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);
        }
    }
    void Update()
    {
        if (IsActiveTrigger)
        {
            if (ZuDangState == ZuDangType.KongXi)
            {
                //if (!IsPlayerIntoKongXiJingJie)
                //{
                //    CheckPlayerIsIntoKongXiJingJie();
                //}

                if (!KongXiDt.IsCreatKongXiDaoDan)
                {
                    if (Time.time - KongXiDt.TimeLastKongXi >= KongXiDt.TimeSpawnDaoDan)
                    {
                        if (GameUICenterCtrl.GetInstance() != null)
                        {
                            GameUICenterCtrl.GetInstance().RemoveKongXiDaoJishiUI();
                        }
                        KongXiDt.IsCreatKongXiDaoDan = true;
                        KongXiDt.TimeLastKongXi      = Time.time;
                        //产生空袭导弹.
                        SpawnKongXiDaoDan(KongXiDt.DaoDanPrefab);
                    }
                    else
                    {
                        if (Time.time - KongXiDt.TimeLastKongXiDaoJiShi >= 1f)
                        {
                            KongXiDt.TimeLastKongXiDaoJiShi = Time.time;
                            KongXiDt.DaoJiShiVal--;
                            if (KongXiDt.DaoJiShiVal == 3 && !IsPlayerIntoKongXiJingJie)
                            {
                                SpawnKongXiShanHongUI();
                            }

                            if (GameUICenterCtrl.GetInstance() != null)
                            {
                                GameUICenterCtrl.GetInstance().mKongXiDaoJiShiUI.ShwoTimeVal(KongXiDt.DaoJiShiVal);
                            }
                        }
                    }
                }

                if (KongXiDt.IsCreatKongXiDaoDan && !KongXiDt.IsRemoveKongXiZuDang && Time.time - KongXiDt.TimeLastKongXi >= KongXiDt.TimeRemoveZuDang)
                {
                    KongXiDt.IsRemoveKongXiZuDang = true;
                    Debug.Log("removeKongXiZuDang -> time " + Time.time);
                    if (!CheckIsMovePlayer())
                    {
                        //删除空袭阻挡.
                        //RemoveAllZuDang();
                        //删除空袭点.
                        if (KongXiDt.KongXiDianObj != null)
                        {
                            Destroy(KongXiDt.KongXiDianObj);
                        }
                        //使玩家可以继续移动,当敌人空袭完成后.
                        KongXiDt.IsMovePlayer = true;
                    }
                }
            }

            if (CheckIsMovePlayer())
            {
                gameObject.SetActive(false);
                XkGameCtrl.GetInstance().SetIsActiveZuDangTrigger(false);
                //关闭提示框UI.
                switch (ZuDangState)
                {
                case ZuDangType.PuTong:
                {
                    if (XkGameCtrl.GetInstance().MoveBtState == ButtonState.DOWN)
                    {
                        XkGameCtrl.GetInstance().SetIsStopMovePlayer(false);
                    }

                    if (GameUICenterCtrl.GetInstance() != null)
                    {
                        GameUICenterCtrl.GetInstance().RemoveZuDangUI();
                        GameUICenterCtrl.GetInstance().RemoveZuDangXueTiaoUI();
                        GameUICenterCtrl.GetInstance().SpawnZuDangJiangLiUI();
                    }
                    break;
                }

                case ZuDangType.KongXi:
                {
                    if (GameUICenterCtrl.GetInstance() != null)
                    {
                        GameUICenterCtrl.GetInstance().RemoveKongXiZuDangUI();
                        GameUICenterCtrl.GetInstance().RemoveKongXiShanHongUI();
                    }
                    break;
                }
                }
            }
        }
    }