void LoadMovieLevel()
    {
        if (IsLoadMovie)
        {
            return;
        }
        IsLoadMovie = true;

        if (Network.peerType == NetworkPeerType.Client)
        {
            NetworkServerNet.GetInstance().RemoveClientHost();
        }

        if (Network.peerType == NetworkPeerType.Server)
        {
            NetworkServerNet.GetInstance().RemoveMasterServerHost();
        }

        if (SSGameCtrl.GetInstance().eGameMode == NetworkRootMovie.GameMode.Link)
        {
            //重置网络玩家索引信息.
            NetworkServerNet.GetInstance().SetIndexSpawnPlayer(0);
            //重置选择联机游戏的玩家数量.
            NetworkServerNet.GetInstance().LinkServerPlayerNum_Movie = 0;
        }
        StartCoroutine(CheckUnloadUnusedAssets());
    }
Esempio n. 2
0
    /// <summary>
    /// 初始化Npc人物模型.
    /// </summary>
    void InitNpcMode(int index)
    {
        Debug.Log("InitNpcMode -> index == " + index);
        for (int i = 0; i < NpcObjArray.Length; i++)
        {
            NpcObjArray[i].SetActive(index == i ? true : false);
            if (index == i && mNpcDataArray[i] != null)
            {
                PenQiAniAy = mNpcDataArray[i].PenQiAniAy;
            }
        }
        mRankDt = SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mGameData.RankDtManage.AddRankDt((RankManage.RankEnum)index, false);


        if (PenQiAniAy != null && PenQiAniAy.Length > 0)
        {
            for (int i = 0; i < PenQiAniAy.Length; i++)
            {
                if (PenQiAniAy[i] != null)
                {
                    PenQiAniAy[i].transform.localScale = Vector3.zero;
                }
            }
        }
    }
    void Awake()
    {
        Debug.Log("SSGameRoot::Awake -> peerType " + Network.peerType + ", eGameMode " + SSGameCtrl.GetInstance().eGameMode);
        SSGameCtrl.GetInstance().mSSGameRoot            = this;
        NetworkServerNet.GetInstance().mNetworkRootGame = mNetworkRootGame;

        switch (SSGameCtrl.GetInstance().eGameMode)
        {
        case NetworkRootMovie.GameMode.Null:
        case NetworkRootMovie.GameMode.NoLink:
        {
            mSSGameDataManage.mGameData.SpawnPlayer(0);
            mSSGameDataManage.mGameData.SpawnNpc(1);
            mSSGameDataManage.mGameData.SpawnNpc(2);
            mSSGameDataManage.mGameData.SpawnNpc(3);
            mUIController.SetActiveUIRoot(true);
            break;
        }

        case NetworkRootMovie.GameMode.Link:
        {
            mUIController.SetActiveUIRoot(false);
            mSSTimeUpCom = gameObject.AddComponent <SSTimeUpCtrl>();
            mSSTimeUpCom.OnTimeUpOverEvent += OnTimeUpOverNotConnectEvent;
            mSSTimeUpCom.Init(35f);
            break;
        }
        }
        NetworkEvent.GetInstance().OnServerInitializedEvent             += OnServerInitializedEvent;
        NetworkEvent.GetInstance().OnPlayerConnectedEvent               += OnPlayerConnectedEvent;
        NetworkEvent.GetInstance().OnConnectedToServerEvent             += OnConnectedToServerEvent;
        NetworkEvent.GetInstance().OnFailedToConnectToMasterServerEvent += OnFailedToConnectToMasterServerEvent;
    }
    void UpdateInsertCoin()
    {
        int n    = 1;
        int num  = m_InserNum;
        int temp = num;

        SSGameCtrl.GetInstance().mPlayerDataManage.PlayerCoinNum = m_InserNum;
        while (num > 9)
        {
            num /= 10;
            n++;
        }

        if (n > 2)
        {
            m_InsertNumS.spriteName = "9";
            m_InsertNumG.spriteName = "9";
        }
        else if (n == 2)
        {
            int shiwei = (int)(temp / 10);
            int gewei  = (int)(temp - shiwei * 10);
            m_InsertNumS.spriteName = shiwei.ToString();
            m_InsertNumG.spriteName = gewei.ToString();
        }
        else if (n == 1)
        {
            m_InsertNumS.spriteName = "0";
            m_InsertNumG.spriteName = temp.ToString();
        }
    }
    void Start()
    {
        if (SSGameCtrl.GetInstance().mSSGameRoot != null)
        {
            if (SSGameCtrl.GetInstance().eGameMode == NetworkRootMovie.GameMode.Link)
            {
                m_pGameTime = SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mGameData.m_pGameTimeNet;
            }
            else
            {
                m_pGameTime = SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mGameData.m_pGameTime;
            }
            Distance      = SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mGameData.DistancePath;
            TimeNetEndVal = SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mGameData.TimeNetEndVal;
        }
        //m_pGameTime = 120.0f;   //gzknu
        //m_pMiaoshiwei.spriteName = "2"; //gzknu

        chile            = 0;
        m_pScale.enabled = false;
        m_totalTime      = (int)m_pGameTime;
        //XkGameCtrl.IsLoadingLevel = false;
        ShowJiFenInfo(0);
        UpdateDianLiangUI(1f);
        UpdatePlayerMoveSpeed(0);
        ChongDianObj.SetActive(false);

        m_pGameTime += 1f;
        UpdateGameTime();
    }
Esempio n. 6
0
    /// <summary>
    /// 获取主角控制脚本.
    /// </summary>
    PlayerController GetPlayerController()
    {
        int count = SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mPlayerControllerList.Count;

        if (count == 0)
        {
            return(null);
        }

        int randVal = UnityEngine.Random.Range(0, 100) % count;

        return(SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mPlayerControllerList[randVal]);
    }
 void Start()
 {
     if (DaoJuState == DaoJuType.ZhangAiWu)
     {
         if (SSGameCtrl.GetInstance().mPlayerDataManage.mDaoJuZhangAiWuData != null)
         {
             int rv = SSGameCtrl.GetInstance().mPlayerDataManage.mDaoJuZhangAiWuData.AddZhangAiWuTr(transform);
             if (rv != -1)
             {
                 IndexZhangAiWu = rv;
             }
         }
     }
 }
    /// <summary>
    /// 产生使用超级加速UI.
    /// </summary>
    public void SpawnChaoJiJiaSuUI()
    {
        if (SSGameCtrl.GetInstance().mPlayerDataManage.PlayerCoinNum < SSGameCtrl.GetInstance().mPlayerDataManage.CoinNumFeiXing)
        {
            return;
        }

        if (ChaoJiJiaSuObj != null)
        {
            return;
        }
        Debug.Log("SpawnChaoJiJiaSuUI -> time " + Time.time);
        RemoveFaSheDaoDanUI();
        ChaoJiJiaSuObj = (GameObject)Instantiate(ChaoJiJiaSuPrefab, mUICamera.transform);
    }
Esempio n. 9
0
    void Start()
    {
        m_NpcPath = SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mNpcDt.m_NpcPathArray[(int)NpcState - 1];
        m_player  = GetPlayerController();
        SSGameCtrl.GetInstance().mPlayerDataManage.mAiNpcData.AddAiNpcTr(transform);

        m_NpcPathPoint = new Vector3[m_NpcPath.childCount];
        for (int i = 0; i < m_NpcPath.childCount; i++)
        {
            string str = (i + 1).ToString();
            m_NpcPathPoint[i] = m_NpcPath.FindChild(str).position;
            mask = 1 << (LayerMask.NameToLayer("shexianjiance"));
        }
        //TimeAddSpeedVal = TimmerSet * 2f;
        TimeSubSpeedVal = TimmerSet;
    }
 void OnFailedToConnectToMasterServerEvent()
 {
     if (!IsFailedToConnectMasterServer && SSGameCtrl.GetInstance().eGameMode == NetworkRootMovie.GameMode.Link)
     {
         Debug.Log("SSGameRoot -> OnFailedToConnectToMasterServerEvent...");
         NetworkServerNet.GetInstance().LinkServerPlayerNum_Movie = 0;
         NetworkServerNet.GetInstance().LinkServerPlayerNum_Game  = 0;
         SSGameCtrl.GetInstance().eGameMode = NetworkRootMovie.GameMode.NoLink; //强制修改联机状态.
         //玩家链接主服务器失败.
         mSSGameDataManage.mGameData.SpawnPlayer(0);
         mSSGameDataManage.mGameData.SpawnNpc(1);
         mSSGameDataManage.mGameData.SpawnNpc(2);
         mSSGameDataManage.mGameData.SpawnNpc(3);
         mUIController.SetActiveUIRoot(true);
     }
 }
Esempio n. 11
0
 // Update is called once per frame
 void Update()
 {
     if (pcvr.bIsHardWare)
     {
         if (GlobalData.GetInstance().CoinCur != SSGameCtrl.GetInstance().mPlayerDataManage.PlayerCoinNum&& GameMode == ReadGameInfo.GameMode.Oper.ToString())
         {
             SSGameCtrl.GetInstance().mPlayerDataManage.PlayerCoinNum = GlobalData.GetInstance().CoinCur - 1;
             OnClickInsertBt();
         }
     }
     else
     {
         if (Input.GetKeyDown(KeyCode.T) && GameMode == ReadGameInfo.GameMode.Oper.ToString())
         {
             OnClickInsertBt();
         }
     }
 }
Esempio n. 12
0
    void ClickSetEnterBtEvent(InputEventCtrl.ButtonState val)
    {
        if (val == InputEventCtrl.ButtonState.DOWN)
        {
            return;
        }

        if (Network.peerType == NetworkPeerType.Server || Network.peerType == NetworkPeerType.Client)
        {
            if (SSGameCtrl.GetInstance().mSSGameRoot != null)
            {
                //联机游戏中,不允许进入设置界面.
                return;
            }
        }
        //XkGameCtrl.IsLoadingLevel = true;
        Resources.UnloadUnusedAssets();
        GC.Collect();
        Application.LoadLevel(5);
    }
    IEnumerator OnNetCallPlayerIntoGame(int level)
    {
        float timeVal = Network.peerType == NetworkPeerType.Server ? 3f : 0f;

        mLoadSceneCount = level;
        mGameLinkPlayer.OnClickStartBt();
        yield return(new WaitForSeconds(timeVal));

        if (m_IsBeginOk && !m_HasBegin)
        {
            //开始联机游戏.
            Debug.Log("Start link game, timeVal == " + timeVal + ", peerType " + Network.peerType);
            SSGameCtrl.GetInstance().eGameMode = NetworkRootMovie.GameMode.Link;
            NetworkRootMovie.GetInstance().ePlayerGameNetState = NetworkServerNet.PlayerGameNetType.MovieIntoGame;
            if (NetworkServerNet.GetInstance() != null)
            {
                NetworkServerNet.GetInstance().mRequestMasterServer.SetMasterServerComment(RequestMasterServer.MasterServerComment.GameNet);
                if (Network.peerType == NetworkPeerType.Server)
                {
                    NetworkServerNet.GetInstance().ePlayerPortState = NetworkServerNet.PlayerPortType.Server;
                    NetworkServerNet.GetInstance().RemoveMasterServerHost();
                }

                if (Network.peerType == NetworkPeerType.Client)
                {
                    NetworkServerNet.GetInstance().ePlayerPortState = NetworkServerNet.PlayerPortType.Client;
                    NetworkServerNet.GetInstance().RemoveClientHost();
                }
            }

            m_BeginSource.Play();
            m_Loading.SetActive(true);
            timmerstar = true;
            m_HasBegin = true;
        }
    }
    void OnClickBeginBt()
    {
        switch (NetworkRootMovie.GetInstance().eNetState)
        {
        case NetworkRootMovie.GameNetType.Link:
        {
            if (mGameModeSelect == null)
            {
                if (GameMode == ReadGameInfo.GameMode.Oper.ToString())
                {
                    if (m_InserNum >= Convert.ToInt32(CoinNumSet))
                    {
                        //创建游戏模式选择UI界面.
                        SpawnGameModeUI();
                        m_BeginSource.Play();
                        m_IsStartGame = true;
                        m_InserNum   -= Convert.ToInt32(CoinNumSet);
                        UpdateInsertCoin();
                        ReadGameInfo.GetInstance().WriteInsertCoinNum(m_InserNum.ToString());
                        if (pcvr.bIsHardWare)
                        {
                            pcvr.GetInstance().mPcvrTXManage.SubPlayerCoin(Convert.ToInt32(CoinNumSet), pcvrTXManage.PlayerCoinEnum.player01);
                        }
                        m_Tishi.SetActive(false);
                    }
                }
                else
                {
                    //创建游戏模式选择UI界面.
                    SpawnGameModeUI();
                    m_BeginSource.Play();
                    m_IsStartGame = true;
                    m_Tishi.SetActive(false);
                }
            }
            else
            {
                if (mGameModeSelect.eGameMode == NetworkRootMovie.GameMode.NoLink)
                {
                    //玩家选择单机游戏.
                    if (mLevelSelectUI == null)
                    {
                        //产生选择游戏场景UI.
                        SpawnLevelSelectUI();
                        m_BeginSource.Play();
                        m_IsStartGame = true;
                        m_Tishi.SetActive(false);
                        mGameModeSelect.HiddenSelf();
                    }
                    else
                    {
                        if (m_IsBeginOk && !m_HasBegin)
                        {
                            m_BeginSource.Play();
                            m_Loading.SetActive(true);
                            timmerstar = true;
                            m_HasBegin = true;
                            mLevelSelectUI.HiddenSelf();
                            SSGameCtrl.GetInstance().eGameMode = NetworkRootMovie.GameMode.NoLink;
                            NetworkRootMovie.GetInstance().ePlayerSelectGameMode = NetworkRootMovie.GameMode.NoLink;
                            NetworkServerNet.GetInstance().mRequestMasterServer.SetIsNetScene(false);
                            NetworkServerNet.GetInstance().RemoveMasterServerHost();
                        }
                    }
                }

                if (mGameModeSelect.eGameMode == NetworkRootMovie.GameMode.Link)
                {
                    //玩家选择联机游戏.
                    if (mGameLinkPlayer == null)
                    {
                        NetworkRootMovie.GetInstance().ePlayerSelectGameMode = NetworkRootMovie.GameMode.Link;
                        m_BeginSource.Play();
                        mGameModeSelect.HiddenSelf();
                        SpawnGameLinkPlayerUI();
                    }
                    else
                    {
                        if (mLevelSelectUI.StartBtObj.activeInHierarchy)
                        {
                            //联机游戏,主服务器选择游戏关卡.
                            mLevelSelectUI.HiddenSelf();
                            mGameLinkPlayer.SetActiveLinkNameParent(true);
                            mGameLinkPlayer.SetAcitveStartBt(true);
                            //mGameLinkPlayer.ChangeUINameScale(0);
                            mGameLinkPlayer.SetUIPanelBeiJing(0);
                        }
                        else
                        {
                            if (mGameLinkPlayer.StartBtObj.activeInHierarchy)
                            {
                                //发送网络消息-开始联机游戏.
                                NetworkRootMovie.GetInstance().mNetworkRpcMsgScript.NetSendLoadLevel(mLevelSelectUI.mSelectLevel);
                            }
                        }
                    }
                }
            }
            break;
        }

        case NetworkRootMovie.GameNetType.NoLink:
        {
            if (PlayerControllerForMoiew.IsLoadMovieLevel)
            {
                return;
            }

            if (mLevelSelectUI == null)
            {
                if (GameMode == ReadGameInfo.GameMode.Oper.ToString())
                {
                    //运营模式.
                    if (m_InserNum >= Convert.ToInt32(CoinNumSet))
                    {
                        //产生选择游戏场景UI.
                        SpawnLevelSelectUI();
                        m_BeginSource.Play();
                        m_IsStartGame = true;
                        m_InserNum   -= Convert.ToInt32(CoinNumSet);
                        UpdateInsertCoin();
                        ReadGameInfo.GetInstance().WriteInsertCoinNum(m_InserNum.ToString());
                        if (pcvr.bIsHardWare)
                        {
                            pcvr.GetInstance().mPcvrTXManage.SubPlayerCoin(Convert.ToInt32(CoinNumSet), pcvrTXManage.PlayerCoinEnum.player01);
                        }
                        m_Tishi.SetActive(false);
                    }
                }
                else
                {
                    //免费模式.
                    //产生选择游戏场景UI.
                    SpawnLevelSelectUI();
                    m_BeginSource.Play();
                    m_IsStartGame = true;
                    m_Tishi.SetActive(false);
                }
            }
            else
            {
                if (m_IsBeginOk && !m_HasBegin)
                {
                    mLevelSelectUI.HiddenSelf();
                    m_BeginSource.Play();
                    m_Loading.SetActive(true);
                    timmerstar = true;
                    m_HasBegin = true;
                    SSGameCtrl.GetInstance().eGameMode = NetworkRootMovie.GameMode.NoLink;
                }
            }
            break;
        }
        }
    }
Esempio n. 15
0
    void OnTimeDownStepEventCheckFire(float timeCur)
    {
        //if (name == "Npc01")
        //{
        //    Debug.Log("timeCur ==== " + timeCur + ", npc == " + name + ", realtimeSinceStartup " + Time.realtimeSinceStartup);
        //}

        if (PlayerController.GetInstance().m_UIController.m_IsGameOver || PlayerController.GetInstance().m_IsFinished)
        {
            if (mSSTimeDownCom != null)
            {
                mSSTimeDownCom.DestroySelf();
            }
            return;
        }

        if (PlayerController.GetInstance().timmerstar <= 5f)
        {
            return;
        }

        if (Time.realtimeSinceStartup - mLastFireTime < TimeLengQueFire)
        {
            return;
        }

        GameObject aimPlayer = SSGameCtrl.GetInstance().mPlayerDataManage.mAiNpcData.FindPlayer(transform, mMaxFireDis, mMinFireDis);

        if (aimPlayer != null)
        {
            mLastFireTime = Time.realtimeSinceStartup;
            float randVal = UnityEngine.Random.Range(0, 100) / 100f;
            if (randVal > mRandFireVal)
            {
                //概率没有随机上.
                //Debug.Log("cannot fire to player!");
                return;
            }

            //Debug.Log("Npc fire to player! player is " + aimPlayer.name);
            if (mDaoDanPrefab == null || mDaoDanSpawnTr == null)
            {
                return;
            }

            GameObject ammo = null;
            if (Network.peerType == NetworkPeerType.Server)
            {
                ammo = (GameObject)Network.Instantiate(mDaoDanPrefab, mDaoDanSpawnTr.position, mDaoDanSpawnTr.rotation, 0);
            }
            else
            {
                ammo = (GameObject)Instantiate(mDaoDanPrefab, mDaoDanSpawnTr.position, mDaoDanSpawnTr.rotation);
            }

            AmmoMoveCtrl ammoMoveCom = ammo.GetComponent <AmmoMoveCtrl>();
            ammoMoveCom.SetIsNetControlPort(true);
            AmmoMoveCtrl.AmmoDt ammoDt = new AmmoMoveCtrl.AmmoDt();
            ammoDt.AmmoState = AmmoMoveCtrl.AmmoType.GenZongDan;
            ammoDt.PosHit    = aimPlayer.transform.position;
            ammoDt.AimTr     = aimPlayer.transform;
            ammoMoveCom.InitMoveAmmo(ammoDt);
        }
    }
Esempio n. 16
0
 void OnClickInsertBt()
 {
     m_TbSource.Play();
     SSGameCtrl.GetInstance().mPlayerDataManage.PlayerCoinNum++;
     UpdateInsertCoin();
 }
Esempio n. 17
0
    /// <summary>
    /// 显示排行榜UI.
    /// </summary>
    public void ShowRankListUI()
    {
        RankManage.RankData rankDt = null;
        SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mGameData.RankDtManage.SortRankDtList();
        float pathDis = SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mGameData.DistancePath;
        float wangChengDuTmp = 1000f;
        int   disValTmp      = 0;

        for (int i = 0; i < 4; i++)
        {
            mRankDtUIArray[i].gameObject.SetActive(true);
            if (SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mGameData.RankDtManage.RankDtList.Count > i)
            {
                rankDt = SSGameCtrl.GetInstance().mSSGameRoot.mSSGameDataManage.mGameData.RankDtManage.RankDtList[i];
                if (rankDt.IsPlayerData)
                {
                    mRankDtUIArray[i].ShowPlayerRankBeiJingUI(mPlayerBJTexture);
                    mRankDtUIArray[i].transform.localScale += new Vector3(0.1f, 0.1f, 0f);
#if UNITY_EDITOR
                    Debug.Log("ShowRankListUI -> PlayerTimeUsed " + rankDt.TimeUsedVal.ToString("f2")
                              + ", disMove " + rankDt.DisMoveVal.ToString("f2"));
#endif
                }

                //#if UNITY_EDITOR
                Debug.Log("ShowRankListUI -> index " + i + ", RankType " + rankDt.RankType);
                //#endif

                int   disVal     = (int)(pathDis - rankDt.DisMoveVal);
                float wanChengDu = rankDt.DisMoveVal / pathDis;
                if (rankDt.IsMoveToFinishPoint)
                {
                    wanChengDu = 1f;
                }
                else
                {
                    wanChengDu = wanChengDu > 1f ? 1f : wanChengDu;
                }

                if (disVal < disValTmp)
                {
                    disVal = disValTmp;
                }
                disValTmp = disVal;

                if (wanChengDu > wangChengDuTmp)
                {
                    wanChengDu = wangChengDuTmp;
                }
                wangChengDuTmp = wanChengDu;
                mRankDtUIArray[i].ShowWanChengDuInfo((int)(wanChengDu * 100f));

                if (rankDt.IsMoveToFinishPoint || wanChengDu >= 1f)
                {
                    mRankDtUIArray[i].ShowTimeUsedVal((int)rankDt.TimeUsedVal);
                }
                else
                {
                    mRankDtUIArray[i].HiddenTimeUI();
                }

                if (rankDt.IsMoveToFinishPoint || wanChengDu >= 1f)
                {
                    mRankDtUIArray[i].ShowShengYuDisMoveInfo(0);
                }
                else
                {
                    mRankDtUIArray[i].ShowShengYuDisMoveInfo(disVal < 0 ? 0 : disVal);
                }
            }
            else
            {
                Debug.Log("rankDataList was wrong! i == " + i);
                mRankDtUIArray[i].ShowWanChengDuInfo(2);
                mRankDtUIArray[i].ShowShengYuDisMoveInfo((int)pathDis - 60);
            }
        }
        gameObject.SetActive(true);
    }