Exemple #1
0
    public GameObject addEffect(string res, Vector2D position, float scale = 1)
    {
        GameObject go = ResFactory.getCacheEffect(res, this.clientRunTime);

        if (null == go)
        {
            MediatorSystem.log("effectLost", res);
            Debug.Log("没有资源" + res);
            return(go);
        }
        go.transform.SetParent(this.effectLayer, false);
        go.transform.localPosition = ViewUtils.logicToScene(position, this.clientRunTime.mapData.earthRadius, this.clientRunTime.mapData);

        Vector3 v = new Vector3(this.transform.position.x, go.transform.position.y, this.transform.position.z);

        go.transform.LookAt(v);
        if (1 != scale)
        {
            GameObjectScaler.Scale(go, scale);
        }
        return(go);
    }
    private void nextFrame()
    {
        if (this.stepIndex < this._steps.Count)
        {
            MediatorSystem.timeStart("serverAtc");
            this.dispatchEventWith(EventConstant.START);
            if (0 != this.fakeCount)
            {
                this.regainFake();                    //先回复到正常的状态。
            }
            object mapData = null;
            MediatorSystem.timeStart("parseData");
            if (null != this._steps[this.stepIndex])
            {
                List <Dictionary <string, object> > steps = this._steps[this.stepIndex];
                for (int i = 0, len = steps.Count; i < len; i++)
                {
                    this.parseData(steps[i]);
                }
                //上线的时候 不要保存数据 所以就扔了吧。 只保留数组长度。
                if (UnityEngine.Random.value > 100)
                {
                    this._steps[this.stepIndex] = null;
                }
                //mapData = steps[steps.Count - 1];
            }
            MediatorSystem.getRunTime("parseData");

            MediatorSystem.timeStart("onMapUpdate");
            this.onMapUpdate();
            MediatorSystem.getRunTime("onMapUpdate");

            if (FightMain.equal)
            {
                //if(( this.startStepIndex + this.stepIndex - 1) % 500 == 0 && NetAdapter.mapData.Count > 0) {
                //try {
                //object mapData = NetAdapter.mapData[0];
                //NetAdapter.mapData.RemoveAt(0);
                Dictionary <string, object> equalInfo = ViewUtils.equal(this.getData(), mapData, "");
                if (equalInfo.Count != 0)
                {
                    this.pause = true;
                    FightMain.instance.equalPanel.show(equalInfo);
                }
                //} catch(Exception e) {
                //    Debug.Log("equal出错了");
                //}
            }
            //}

            MediatorSystem.getRunTime("serverAtc");
        }
        else
        {
            if (0 == this.fakeCount)
            {
                this.saveFake();                    //记录当前虚假运行的。
            }
            this.fakeUpdate();
            MediatorSystem.log("fakeCount", this.stepIndex + "  " + this.fakeCount);
        }
    }
Exemple #3
0
    private void Socket_Check(float time)
    {
        if (test)
        {
            if (package.Count >= 2)
            {
                test = false;
            }
        }
        if (test)
        {
            return;
        }
        index++;
//		Debug.LogError ("Socket_Check -->> :: " + package.Count);
        if (package.Count >= 1)
        {
            count    = package.Count;
            maxCount = Math.Max(count, maxCount);
//            long offset = ( System.DateTime.Now.Ticks - tick ) / 10000;

            //			if (0 != tick) {
            //				MediatorSystem.log("socketUpdate", offset);
            //
            //				if (offset >= 150) {
            //					MediatorSystem.log("socket大", offset);
            //				}
            //
            //				if (offset <= 50) {
            //					MediatorSystem.log("socket小", offset);
            //				}
            //
            //
            //			}

            tick = System.DateTime.Now.Ticks;
        }
//		Debug.LogError ("Socket_Check");
        MediatorSystem.log("count", package.Count + "   " + count + "    " + maxCount);
        while (package.Count != 0)
        {
            VoPackage vo = null;
            lock (package) {
                vo = package[0];
                package.Remove(vo);
            }
            if (vo.isClear)
            {
//                LogMessage.instance.text.text += "此vo已经被清除过了!";
                continue;
            }
            VoSocket v = new VoSocket();
//            MediatorSystem.timeStart("SockettoDatas");
            v.toDatas(vo.body);
//            MediatorSystem.getRunTime("SockettoDatas");
//			Debug.LogError ("re -->> :: " + v.method);
//			if (v.method == NetBase.SOCKET_LOGIN) {
//				Check_Ping ();
//			}
//            if(v.method != NetBase.SOCKET_PING && v.method != "sync")
//                Log.debug("SocketReceive[" + this.ip + "]:" + JsonUtility.ToJson(v));
            if (!vo.isClear)
            {
                if (call.ContainsKey(v.method))
                {
//					Debug.LogError (v.method);
                    SocketListener sl = call[v.method];
                    //try {
//                    MediatorSystem.timeStart("execSocketData");
                    sl.Excute(v);
//                    MediatorSystem.getRunTime("execSocketData");
                    //} catch(Exception e) {
                    //    Debug.Log(e.HelpLink);
                    //}
                }
            }
            else
            {
//                Log.debug("Socket Data Is Clear");
            }
            vo.Clear();
        }
        if (index % 500 == 0)
        {
            maxCount = 0;
            tick2    = 0;
        }
    }
Exemple #4
0
    private void setTest()
    {
        this.getTestComponent <Button>("breakNet").onClick.AddListener(NetAdapter.sendQuitFight);
        this.getTestComponent <Button>("test").onClick.AddListener(FightMain.instance.changeTest);



        this.getTestComponent <Button>("goFrame").onClick.AddListener(() => {
            int totalIndex = int.Parse(this.stepInputText.text);
            FightMain.instance.autoRunClient.totalIndex = totalIndex;
            this.stepInputText.text            = FightMain.instance.autoRunClient.totalIndex.ToString();
            FightMain.instance.selection.pause = false;
        });
        this.getTestComponent <Button>("addPlayer").onClick.AddListener(() => {
            FightMain.instance.addUser(UnityEngine.Random.value.ToString(), FightMain.instance.selection.players.Count);
            //TimerManager.inst.flag = !TimerManager.inst.flag;
        });

        this.getTestComponent <Button>("pause").onClick.AddListener(() => {
            FightMain.instance.isPlay = !FightMain.instance.isPlay;
            FightMain.instance.cc     = 6;
        });

        this.getTestComponent <Button>("test1").onClick.AddListener(() => {
            //biggo修改
            FightMain.instance.selection.aiController.addUser();
        });
        this.getTestComponent <Button>("test2").onClick.AddListener(() => {
            //biggo修改
            FightMain.instance.selection.aiController.switchSelfAI();
        });
        this.getTestComponent <Button>("test3").onClick.AddListener(() => {
            //biggo修改
            string uid           = FightMain.instance.selection.uid;
            PlayerEntity cPlayer = FightMain.instance.selection.getPlayer(uid);
            PlayerEntity sPlayer = FightMain.instance.server.getPlayer(uid);
            Debug.Log("C:" + cPlayer.position + "  \nS:" + sPlayer.position);
        });
        this.getTestComponent <Button>("test4").onClick.AddListener(() => {
            //biggo修改
            //AIPlayer.SHOW_PATH = !AIPlayer.SHOW_PATH;
            TestValue.test4 = !TestValue.test4;

            for (int i = 0, len = FightMain.instance.selection.players.Count; i < len; i++)
            {
                FightMain.instance.selection.players[i].setJoystick(new Vector2D());
            }
        });

        List <int> cc = new List <int>();

        for (int i = 0, len = 100001; i < len; i++)
        {
            cc.Add(i);
        }
        this.getTestComponent <Button>("test5").onClick.AddListener(() => {
            //if(null != FightMain.instance.selection) FightMain.instance.selection.scene.beanLayer.gameObject.SetActive(!FightMain.instance.selection.scene.beanLayer.gameObject.activeSelf);
            MediatorSystem.log("testzzz", FightMain.instance.cc);
        });
        this.getTestComponent <Button>("test6").onClick.AddListener(() => {
            //if(null != FightMain.instance.selection) FightMain.instance.selection.scene.bulletLayer.gameObject.SetActive(!FightMain.instance.selection.scene.bulletLayer.gameObject.activeSelf);
            TestValue.test6 = !TestValue.test6;

            FightMain.instance.testUseCard();
        });
        this.getTestComponent <Button>("test7").onClick.AddListener(() => {
            //if(null != FightMain.instance.selection) FightMain.instance.selection.scene.bulletLayer.gameObject.SetActive(!FightMain.instance.selection.scene.bulletLayer.gameObject.activeSelf);
            TestValue.test7 = !TestValue.test7;
        });
        this.getTestComponent <Button>("test8").onClick.AddListener(() => {
            //if(null != FightMain.instance.selection) FightMain.instance.selection.scene.bulletLayer.gameObject.SetActive(!FightMain.instance.selection.scene.bulletLayer.gameObject.activeSelf);
            TestValue.test8 = !TestValue.test8;
        });

        this.getTestComponent <Slider> ("aiSlider").onValueChanged.AddListener((float value) => {
            //biggo添加
            AIConstant.IQ_DEFAULT           = value;
            FightMain.instance.server.AI_IQ = value;
            FightMain.instance.server.aiController.resetIQ(value);
        });
    }