コード例 #1
0
ファイル: BaseController.cs プロジェクト: kinpauln/LD
        /// <summary>
        /// 执行增,删,改操作后跳转到公共提示画面
        /// </summary>
        /// <param name="key">操作信息对应的key</param>
        /// <param name="param">参数数组</param>
        /// <param name="jsParam">通过Js跳转的URL</param>
        /// <returns>公共提示画面</returns>
        public ActionResult OperateTooltip(string key, string[] param, string jsParam = "", string view = "")
        {
            //获取操作信息对象
            OperateMsg msg = OperateMsg.getInstance();

            //获取操作信息
            string operateMsg = "";

            //判断参数
            if (string.IsNullOrEmpty(jsParam))
            {
                if (param == null)
                {
                    operateMsg = msg.GetValue(key);
                }
                else
                {
                    operateMsg = msg.GetValue(key, param);
                }
            }
            else
            {
                param      = jsParam.Split(';');
                operateMsg = msg.GetValue(key, param);
            }

            //将操作信息添加到ViewBag中供页面获取
            ViewBag.operateMsg = operateMsg;

            //将html的ID放入viewbag中供画面获取
            ViewBag.ids = msg.GetIds(key);;

            //判断是操作成功还是失败
            if (key.Contains("Fail"))
            {
                ViewBag.isSuccess = false;
            }
            else
            {
                ViewBag.isSuccess = true;
            }
            if (string.IsNullOrEmpty(view))
            {
                return(View("~/Views/Common/OperateMsg.cshtml"));
            }
            else
            {
                return(View(view));
            }
        }
コード例 #2
0
 void OnSkicked(OperateMsg msg)
 {
     if (msg.KillTarget == NetWorkBattle.Ins.PlayerId)
     {
         Timer.once(0.1f, OnDisconnected);
     }
     else
     {
         MeteorUnit unit = U3D.GetUnit((int)msg.KillTarget);
         if (unit != null)
         {
             U3D.InsertSystemMsg(string.Format("{0}被踢出房间,不允许加入", unit.name));
         }
     }
 }
コード例 #3
0
    private void dealOpera(QueueMsg msg)
    {
        OperateMsg operaMsg = JsonUtility.FromJson <OperateMsg> (msg.msg);

        if (string.IsNullOrEmpty(operaMsg.data.operateId))
        {
            return;
        }
        Debug.Log("opera:" + msg.msg);

        double now = (DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds;

        Debug.Log("now time : " + now);
        Debug.Log("use time : " + (now - operaMsg.data.t));
        GameObject tPlayer = GameObject.Find(operaMsg.data.operateId);

        if (tPlayer == null)
        {
            Debug.Log("update opera fail :[" + operaMsg.data.operateId + "] not found");
        }
        tPlayer.GetComponent <NetObject> ().setForce(new Vector3(operaMsg.data.x, operaMsg.data.y, operaMsg.data.z));
    }
コード例 #4
0
ファイル: CheatCode.cs プロジェクト: WeeirJoe/Joe
    //使用作弊码
    public static bool UseCheatCode(string cheatcode)
    {
        bool    ret         = false;
        int     param1      = -1;
        int     param2      = -1;
        string  stringparam = "";
        Vector3 pos         = Vector3.zero;

        if (CheatOK(cheatcode, "check"))
        {
            U3D.ShowTargetBlood();
            return(true);
        }
        else if (CheatOK(cheatcode, "skill"))
        {
            if (U3D.IsMultiplyPlayer())
            {
                return(false);
            }
            if (FightState.Exist())
            {
                FightState.Instance.ShowSkillBar();
            }
            return(true);
        }
        else if (CheatParam2(cheatcode, "follow", ref param1, ref param2))
        {
            MeteorUnit unit = U3D.GetUnit(param1 - 1);
            if (unit != null && unit.StateMachine != null)
            {
                MeteorUnit target = U3D.GetUnit(param2 - 1);
                U3D.InsertSystemMsg(string.Format("{0}开始跟随{1}", unit.name, target.name));
                unit.FollowTarget = target;
            }
            return(true);
        }
        else if (CheatParam2(cheatcode, "chase", ref param1, ref param2))
        {
            MeteorUnit unit = U3D.GetUnit(param1 - 1);
            if (unit != null)
            {
                MeteorUnit target = U3D.GetUnit(param2 - 1);
                if (target != null && !target.SameCamp(unit))
                {
                    U3D.InsertSystemMsg(string.Format("{0}开始追杀{1}", unit.name, target.name));
                    unit.Kill(target);
                }
            }
            return(true);
        }
        else if (CheatParam(cheatcode, "wait", ref param1))
        {
            MeteorUnit unit = U3D.GetUnit(param1 - 1);
            if (unit != null && unit.StateMachine != null)
            {
                U3D.InsertSystemMsg(string.Format("{0}空闲下来了", unit.name));
                unit.StateMachine.ChangeState(unit.StateMachine.WaitState);
            }
            return(true);
        }
        else if (CheatOK(cheatcode, "god"))
        {
            U3D.GodLike();
            ret = true;
        }
        else if (CheatOK(cheatcode, "box"))
        {
            U3D.Box();
            ret = true;
        }
        else if (CheatParam(cheatcode, "kill", ref param1))
        {
            if (U3D.IsMultiplyPlayer())
            {
                if (FrameReplay.Ins.Started)
                {
                    MeteorUnit unit = U3D.GetUnit(param1 - 1);
                    if (unit == null)
                    {
                        return(false);
                    }
                    OperateMsg msg = new OperateMsg();
                    msg.Operate    = (int)OperateType.Kill;
                    msg.KillTarget = (uint)unit.InstanceId;
                    FrameSyncServer.Ins.NetEvent(MeteorMsg.Command.Kill, msg);
                }
            }
            else
            {
                U3D.Kill(param1 - 1);
                MeteorUnit u = U3D.GetUnit(param1 - 1);
                if (u != null)
                {
                    U3D.InsertSystemMsg(string.Format("{0}遭遇击杀", u.name));
                }
            }
            ret = true;
        }
        else if (CheatParam(cheatcode, "pose", ref param1))
        {
            if (U3D.IsMultiplyPlayer())
            {
                return(false);
            }
            if (Main.Ins.LocalPlayer != null && Main.Ins.LocalPlayer.ActionMgr != null)
            {
                Main.Ins.LocalPlayer.ActionMgr.ChangeAction(param1, 0.1f);
            }
            ret = true;
        }
        else if (CheatParam(cheatcode, "pause", ref param1))
        {
            MeteorUnit unit = U3D.GetUnit(param1 - 1);
            if (unit != null && unit.StateMachine != null)
            {
                unit.AIPause(true, float.MaxValue);
                U3D.InsertSystemMsg(string.Format("{0}无法动弹", unit.name));
            }
            ret = true;
        }
        else if (CheatParam(cheatcode, "resume", ref param1))
        {
            MeteorUnit unit = U3D.GetUnit(param1 - 1);
            if (unit != null && unit.StateMachine != null)
            {
                unit.AIPause(false, 0);
                U3D.InsertSystemMsg(string.Format("{0}恢复了", unit.name));
            }
            ret = true;
        }
        else if (CheatParam(cheatcode, "kick", ref param1))
        {
            if (U3D.IsMultiplyPlayer())
            {
                //检查自己是否房间主人,是则向主机发送指令
                if (FrameReplay.Ins.Started)
                {
                    MeteorUnit unit = U3D.GetUnit(param1 - 1);
                    if (unit == null)
                    {
                        return(false);
                    }
                    OperateMsg msg = new OperateMsg();
                    msg.Operate    = (int)OperateType.Kick;
                    msg.KillTarget = (uint)unit.InstanceId;
                    FrameSyncServer.Ins.NetEvent(MeteorMsg.Command.Kick, msg);
                }
            }
            ret = true;
        }
        else if (CheatParam(cheatcode, "skick", ref param1))
        {
            if (U3D.IsMultiplyPlayer())
            {
                //检查自己是否房间主人,是则向主机发送指令
                if (FrameReplay.Ins.Started)
                {
                    MeteorUnit unit = U3D.GetUnit(param1 - 1);
                    if (unit == null)
                    {
                        return(false);
                    }
                    OperateMsg msg = new OperateMsg();
                    msg.Operate    = (int)OperateType.Skick;
                    msg.KillTarget = (uint)unit.InstanceId;
                    FrameSyncServer.Ins.NetEvent(MeteorMsg.Command.Skick, msg);
                }
            }
            ret = true;
        }
        else if (CheatParamString(cheatcode, "ai", ref stringparam))
        {
            if (U3D.IsMultiplyPlayer())
            {
                return(false);
            }
            if (Main.Ins.GameBattleEx != null)
            {
                int r = U3D.AddNPC(stringparam);
                ret = r > 0;
            }
            return(true);
        }
        else if (CheatOK(cheatcode, "fps"))
        {
            bool show = GameStateMgr.Ins.gameStatus.ShowFPS;
            show = !show;
            Main.Ins.ShowFps(show);
            return(true);
        }
        else if (CheatOK(cheatcode, "position"))
        {
            if (FightState.Exist())
            {
                FightState.Instance.ShowPosition();
            }
            return(true);
        }
        else if (CheatOK(cheatcode, "mhp"))
        {
            //不支持这个指令了.
            //if (FightState.Exist()) {
            //    FightState.Instance.ShowPlayerInfo();
            //}
            return(true);
        }
        else if (CheatOK(cheatcode, "mnet") || CheatOK("cheatcode", "serverinfo"))
        {
            //显示网络数据传送情况
            return(true);
        }
        else if (CheatOK(cheatcode, "quit"))
        {
            if (U3D.IsMultiplyPlayer())
            {
                return(false);
            }
            Application.Quit();
            return(true);
        }
        else if (CheatParamVector3(cheatcode, "moveto", ref pos))
        {
            if (Main.Ins.LocalPlayer != null && !Main.Ins.LocalPlayer.Dead)
            {
                Main.Ins.LocalPlayer.SetPosition(pos);
            }
            return(true);
        }
        else if (CheatParam(cheatcode, "ang", ref param1))
        {
            if (U3D.IsMultiplyPlayer())
            {
                return(false);
            }
            MeteorUnit target = U3D.GetUnit(param1 - 1);
            if (target != null)
            {
                target.angryMax = !target.angryMax;
                U3D.InsertSystemMsg(string.Format("{0}真气{1}", target.name, target.angryMax ? "满":"空"));
            }
            return(true);
        }
        else if (CheatParam(cheatcode, "weapon", ref param1))
        {
            if (Main.Ins.LocalPlayer != null)
            {
                InventoryItem w = GameStateMgr.Ins.MakeEquip(param1);
                if (w == null)
                {
                    U3D.InsertSystemMsg("找不到编号为:" + param1 + "的武器");
                    return(true);
                }
                Main.Ins.LocalPlayer.ChangeWeaponCode(param1);
            }
            return(true);
        }
        else if (CheatParam(cheatcode, "use", ref param1))
        {
            if (U3D.IsMultiplyPlayer())
            {
                return(false);
            }
            if (Main.Ins.LocalPlayer != null)
            {
                Option it = MenuResLoader.Ins.GetItemInfo(param1);
                if (it == null)
                {
                    U3D.InsertSystemMsg("找不到编号为:" + param1 + "的物品");
                    return(true);
                }
                Main.Ins.LocalPlayer.GetItem(param1);
            }
            return(true);
        }
        else if (CheatParam(cheatcode, "drop", ref param1))
        {
            if (U3D.IsMultiplyPlayer())
            {
                if (Main.Ins.LocalPlayer != null)
                {
                    MeteorUnit player = Main.Ins.LocalPlayer;
                    DropMsg    msg    = new DropMsg();
                    msg.forward    = new _Vector3();
                    msg.forward.x  = Mathf.FloorToInt(player.transform.forward.x * 1000);
                    msg.forward.y  = Mathf.FloorToInt(player.transform.forward.y * 1000);
                    msg.forward.z  = Mathf.FloorToInt(player.transform.forward.z * 1000);
                    msg.position   = new _Vector3();
                    msg.position.x = Mathf.FloorToInt(player.transform.position.x * 1000);
                    msg.position.y = Mathf.FloorToInt(player.transform.position.y * 1000);
                    msg.position.z = Mathf.FloorToInt(player.transform.position.z * 1000);
                    msg.item       = (uint)param1;
                    FrameSyncServer.Ins.NetEvent(MeteorMsg.Command.Drop, msg);
                }
                return(true);
            }
            if (Main.Ins.LocalPlayer != null)
            {
                Option it = MenuResLoader.Ins.GetItemInfo(param1);
                if (it == null)
                {
                    U3D.InsertSystemMsg("找不到编号为:" + param1 + "的物品");
                    return(true);
                }
                DropMng.Ins.DropItem(Main.Ins.LocalPlayer, it);
            }
            return(true);
        }
        else if (CheatOK(cheatcode, "win"))
        {
            if (U3D.IsMultiplyPlayer())
            {
                return(false);
            }
            if (Main.Ins.GameBattleEx != null)
            {
                Main.Ins.GameBattleEx.GameOver(1);
            }
            return(true);
        }
        else if (CheatOK(cheatcode, "lose"))
        {
            if (U3D.IsMultiplyPlayer())
            {
                return(false);
            }
            if (Main.Ins.GameBattleEx != null)
            {
                Main.Ins.GameBattleEx.GameOver(-1);
            }
        }
        return(ret);
    }
コード例 #5
0
 void Kill(OperateMsg msg)
 {
     U3D.Kill((int)msg.KillTarget);
 }
コード例 #6
0
    public override void Update()
    {
        for (int i = 0; i < packets.Count; i++)
        {
            SortedDictionary <int, byte[]> pack = packets[i];
            lock (pack) {
                try {
                    //在这个循环里,不能跑去修改这个packet,所有重要消息,都通过计时器处理.
                    foreach (var each in pack)
                    {
                        ms.SetLength(0);
                        ms.Write(each.Value, 0, each.Value.Length);
                        ms.Seek(0, SeekOrigin.Begin);
                        switch (each.Key)
                        {
                        //UDP消息
                        case (int)MeteorMsg.Command.ServerSync:
                            GameFrame frame = Serializer.Deserialize <GameFrame>(ms);
                            OnSyncPlayers(frame);
                            break;

                        case (int)MeteorMsg.Command.NewTurn:
                            if (!FrameReplay.Ins.Started)
                            {
                                return;
                            }
                            if (Main.Ins.GameBattleEx != null)
                            {
                                Main.Ins.GameBattleEx.NetGameOver();
                            }
                            break;

                        case (int)MeteorMsg.Command.GetItem:
                            //ms = new MemoryStream(each.Value);
                            GetItemMsg getitem = Serializer.Deserialize <GetItemMsg>(ms);
                            OnItemPickuped(getitem);
                            break;

                        case (int)MeteorMsg.Command.Drop:
                            //ms = new MemoryStream(each.Value);
                            DropMsg dropItem = Serializer.Deserialize <DropMsg>(ms);
                            OnItemDropped(dropItem);
                            break;

                        case (int)MeteorMsg.Command.Kill:
                            //ms = new MemoryStream(each.Value);
                            OperateMsg kill = Serializer.Deserialize <OperateMsg>(ms);
                            Kill(kill);
                            break;

                        case (int)MeteorMsg.Command.Kick:
                            //ms = new MemoryStream(each.Value);
                            OperateMsg kick = Serializer.Deserialize <OperateMsg>(ms);
                            OnKicked(kick);
                            break;

                        case (int)MeteorMsg.Command.Skick:
                            //ms = new MemoryStream(each.Value);
                            OperateMsg skick = Serializer.Deserialize <OperateMsg>(ms);
                            OnSkicked(skick);
                            break;
                        }
                    }
                } catch (Exception exp) {
                    UnityEngine.Debug.LogError(exp.Message + exp.StackTrace);
                } finally {
                    pack.Clear();
                }
            }
        }

        //lock (messageQueue) {
        //    int length = messageQueue.Count;
        //    for (int i = 0; i < length; i++) {
        //        switch (messageQueue[i].Message) {
        //            case (short)LocalMsgType.Connect: OnConnect(messageQueue[i].Result, messageQueue[i].message); break;
        //        }
        //    }
        //    messageQueue.Clear();
        //}
    }