Ejemplo n.º 1
0
        private void GenerateHero(uint p)
        {
            SkillArea.position = oriposition;
            for (int i = 0; i < SkillArea.childCount; i++)
            {
                Destroy(SkillArea.GetChild(i).gameObject);
            }
            var prefab = AssetBundleManager.Instance.LoadAsset("lobby", "HeroIco");

            for (uint a = 1; a < 33; a++)
            {
                uint i = a;
                if (a == 32)
                {
                    i = 108;
                }
                var role = RoleFactory.Create(i);
                if (p == 0 || role.RoleProperty == (Card.CardProperty)p)
                {
                    var go = Instantiate(prefab);
                    go.transform.SetParent(SkillArea);
                    go.transform.localScale = new Vector3(1, 1, 1);
                    go.transform.GetComponent <Image>().sprite = AssetBundleManager.Instance.LoadAsset <Sprite>("hero_h", i.ToString() + "h");
                    go.transform.GetComponent <Button>().onClick.AddListener(
                        () => { GameManager.UIInstance.PushWindow(Framework.UI.WindowType.InfomationUI, Framework.UI.WinMsg.None, -1, Vector3.zero, role); });
                    go.transform.GetChild(0).GetComponent <Text>().text = role.RoleName;
                }
            }
        }
Ejemplo n.º 2
0
 public override void Awake()
 {
     foreach (var v in RoleChoose.Instance.RoleIDs)
     {
         roleList.options.Add(new Dropdown.OptionData()
         {
             text = RoleFactory.Create(v).RoleName + "(" + v.ToString() + ")"
         });
     }
     roleList.RefreshShownValue();
     base.Awake();
 }
Ejemplo n.º 3
0
        public override bool CanSelect(uint uiState, SinglePlayerInfo player)
        {
            switch (uiState)
            {
            case 1201:
                return(player.team != BattleData.Instance.MainPlayer.team);

            case 13:
                var r = RoleFactory.Create(player.role_id);
                return(player.team == BattleData.Instance.MainPlayer.team && r.MaxEnergyCount > player.gem + player.crystal);
            }
            return(base.CanSelect(uiState, player));
        }
Ejemplo n.º 4
0
 public override bool CheckExtract(uint uiState)
 {
     if (uiState == 10)
     {
         foreach (var v in BattleData.Instance.PlayerInfos)
         {
             var r = RoleFactory.Create(v.role_id);
             if (v.team == BattleData.Instance.MainPlayer.team && r.MaxEnergyCount > v.gem + v.crystal)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 5
0
        public override bool CanSelect(uint uiState, SinglePlayerInfo player)
        {
            switch (uiState)
            {
            case 1201:
                if (BattleData.Instance.MainPlayer.ex_cards.Contains(1001))
                {
                    if (player.role_id != (uint)RoleID.YongZhe)
                    {
                        return(false);
                    }
                }
                return(BattleData.Instance.Agent.SelectCards.Count == qizhaSelectCard &&
                       player.team != BattleData.Instance.MainPlayer.team);

            case 13:
                var r = RoleFactory.Create(player.role_id);
                return(player.team == BattleData.Instance.MainPlayer.team && r.MaxEnergyCount > player.gem + player.crystal);
            }
            return(base.CanSelect(uiState, player));
        }
Ejemplo n.º 6
0
        public override void UIStateChange(uint state, UIStateMsg msg, params object[] paras)
        {
            List <List <uint> > selectList;
            List <string>       explainList;

            switch (state)
            {
            case 10:
                additionalState = 0;
                break;

            case 12:
                if (BattleData.Instance.Gem[BattleData.Instance.MainPlayer.team] + BattleData.Instance.Crystal[BattleData.Instance.MainPlayer.team] == 4)
                {
                    BattleData.Instance.Agent.PlayerRole.Buy(1, 0);
                    BattleData.Instance.Agent.FSM.ChangeState <StateIdle>(UIStateMsg.Init, true);
                }
                else if (BattleData.Instance.Gem[BattleData.Instance.MainPlayer.team] + BattleData.Instance.Crystal[BattleData.Instance.MainPlayer.team] == 5)
                {
                    if (msg == UIStateMsg.ClickArgs)
                    {
                        MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseNewArgsUI);

                        BattleData.Instance.Agent.PlayerRole.Buy(0, 0);
                        BattleData.Instance.Agent.FSM.ChangeState <StateIdle>(UIStateMsg.Init, true);
                        return;
                    }
                    CancelAction = () =>
                    {
                        MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseNewArgsUI);

                        BattleData.Instance.Agent.FSM.BackState(UIStateMsg.ClickBtn);
                    };
                    selectList = new List <List <uint> >()
                    {
                        new List <uint>()
                        {
                            0, 0
                        }
                    };
                    explainList = new List <string>()
                    {
                        "不增加星石"
                    };
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.ShowNewArgsUI, selectList, explainList);
                }
                else
                {
                    BattleData.Instance.Agent.PlayerRole.Buy(2, 0);
                    BattleData.Instance.Agent.FSM.ChangeState <StateIdle>(UIStateMsg.Init, true);
                }
                break;

            case 13:
                if (msg == UIStateMsg.ClickArgs)
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseNewArgsUI);

                    sendActionMsg(BasicActionType.ACTION_SPECIAL_SKILL, BattleData.Instance.MainPlayer.id,
                                  BattleData.Instance.Agent.SelectPlayers, null, 1202, BattleData.Instance.Agent.SelectArgs);
                    return;
                }
                ;
                CancelAction = () =>
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseNewArgsUI);

                    BattleData.Instance.Agent.FSM.BackState(UIStateMsg.Init);
                };
                if (msg == UIStateMsg.ClickPlayer)
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseNewArgsUI);

                    if (BattleData.Instance.Agent.SelectPlayers.Count > 0)
                    {
                        var s            = BattleData.Instance.GetPlayerInfo(BattleData.Instance.Agent.SelectPlayers[0]);
                        var tGem         = BattleData.Instance.Gem[BattleData.Instance.MainPlayer.team];
                        var tCrystal     = BattleData.Instance.Crystal[BattleData.Instance.MainPlayer.team];
                        var maxEnergyCnt = RoleFactory.Create(s.role_id).MaxEnergyCount;
                        selectList  = new List <List <uint> >();
                        explainList = new List <string>();
                        if (maxEnergyCnt - s.gem - s.crystal >= 2)
                        {
                            if (tGem >= 2)
                            {
                                selectList.Add(new List <uint>()
                                {
                                    2, 0
                                });
                                explainList.Add("2个宝石");
                            }
                            if (tGem >= 1 && tCrystal >= 1)
                            {
                                selectList.Add(new List <uint>()
                                {
                                    1, 1
                                });
                                explainList.Add("1个宝石1个水晶");
                            }
                            if (tCrystal >= 2)
                            {
                                selectList.Add(new List <uint>()
                                {
                                    0, 2
                                });
                                explainList.Add("2个水晶");
                            }
                        }
                        if (maxEnergyCnt - s.gem - s.crystal >= 1)
                        {
                            if (tGem >= 1)
                            {
                                selectList.Add(new List <uint>()
                                {
                                    1, 0
                                });
                                explainList.Add("1个宝石");
                            }
                            if (tCrystal >= 1)
                            {
                                selectList.Add(new List <uint>()
                                {
                                    0, 1
                                });
                                explainList.Add("1个水晶");
                            }
                        }
                        MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.ShowNewArgsUI, selectList, explainList);

                        MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.SendHint, StateHint.GetHint(1202));
                    }
                }
                if (BattleData.Instance.Agent.SelectPlayers.Count <= 0)
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.SendHint, StateHint.GetHint(1202, 1));
                }
                return;

            case 1201:
                CancelAction = () =>
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseNewArgsUI);

                    BattleData.Instance.Agent.FSM.BackState(UIStateMsg.Init);
                };
                selectList = new List <List <uint> >()
                {
                    new List <uint>()
                    {
                        45
                    }, new List <uint>()
                    {
                        133
                    },
                    new List <uint>()
                    {
                        87
                    }, new List <uint>()
                    {
                        66
                    }, new List <uint>()
                    {
                        110
                    }
                };
                explainList = new List <string>()
                {
                    "地", "水", "火", "风", "雷"
                };
                if (Util.HasCard("same", BattleData.Instance.MainPlayer.hands, 3))
                {
                    selectList.Insert(0, new List <uint>()
                    {
                        39
                    });
                    explainList.Insert(0, "暗");
                }
                if (BattleData.Instance.Agent.SelectArgs.Count == 0)
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseNewArgsUI);

                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.ShowNewArgsUI, selectList, explainList);

                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.SendHint, StateHint.GetHint(state));
                }
                else
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseNewArgsUI);

                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.SendHint,
                                                                          string.Format(StateHint.GetHint(state, 1), explainList[selectList.FindIndex(c => c[0].Equals(BattleData.Instance.Agent.SelectArgs[0]))]));

                    if (BattleData.Instance.Agent.SelectArgs[0] == 39)
                    {
                        qizhaSelectCard = 3;
                    }
                    else
                    {
                        qizhaSelectCard = 2;
                    }
                    if (BattleData.Instance.Agent.SelectCards.Count == qizhaSelectCard && BattleData.Instance.Agent.SelectPlayers.Count == 1)
                    {
                        sendActionMsg(BasicActionType.ACTION_ATTACK_SKILL, BattleData.Instance.MainPlayer.id,
                                      BattleData.Instance.Agent.SelectPlayers, BattleData.Instance.Agent.SelectCards, state,
                                      BattleData.Instance.Agent.SelectArgs);
                        BattleData.Instance.Agent.FSM.ChangeState <StateIdle>(UIStateMsg.Init, true);
                    }
                }
                return;

            case 1203:
            case 1204:
                OKAction = () =>
                {
                    sendActionMsg(BasicActionType.ACTION_MAGIC_SKILL, BattleData.Instance.MainPlayer.id, null, null, state);
                    BattleData.Instance.Agent.FSM.ChangeState <StateIdle>(UIStateMsg.Init, true);
                };
                CancelAction = () => { BattleData.Instance.Agent.FSM.BackState(UIStateMsg.Init); };
                MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.SendHint, StateHint.GetHint(state));

                return;
            }
            base.UIStateChange(state, msg, paras);
        }
Ejemplo n.º 7
0
        public override void OnEventTrigger(MessageType eventType, params object[] parameters)
        {
            switch (eventType)
            {
            case MessageType.PICKBAN:
                bool changed = false;
                for (int i = 0; i < RoleChoose.Instance.RoleIDs.Count; i++)
                {
                    pools[i].HeroID = RoleChoose.Instance.RoleIDs[i];
                    if (RoleChoose.Instance.options[i] > 0)
                    {
                        start = true;
                        if (!pools[i].Selected)
                        {
                            pools[i].Selected = true;
                            changed           = true;
                            lastChosen        = i;
                        }
                    }
                    pools[i].canselect = (RoleChoose.Instance.oprater == BattleData.Instance.PlayerID) && !pools[i].Selected;
                }
                if (RoleChoose.Instance.oprater == BattleData.Instance.PlayerID && RoleChoose.Instance.opration == 4)
                {
                    CancelBtn.gameObject.SetActive(true);
                }
                if (RoleChoose.Instance.opration != 1)
                {
                    string who = (RoleChoose.Instance.oprater == BattleData.Instance.PlayerID) ? "轮到你" :
                                 (("等待<color=#ff0>" + BattleData.Instance.GetPlayerInfo(RoleChoose.Instance.oprater).nickname) + "</color>");
                    string what = "";

                    switch (RoleChoose.Instance.opration)
                    {
                    case 2:
                        what = "<color=#ff0000>禁用</color>";
                        break;

                    case 3:
                        what = "选择";
                        break;

                    case 4:
                        what = "选择是否额外<color=#ff0000>禁用</color>";
                        break;
                    }
                    info.text = who + what + "角色";
                }
                if (RoleChoose.Instance.opration == 1 && changed)
                {
                    if (RoleChoose.Instance.RoleStrategy == network.ROLE_STRATEGY.ROLE_STRATEGY_CM)
                    {
                        string what2 = "";
                        switch (RoleChoose.Instance.options[lastChosen])
                        {
                        case 12:
                        case 15:
                            what2 = " 禁用了 ";
                            break;

                        case 14:
                        case 17:
                            what2 = " 选择了 ";
                            break;

                        case 13:
                        case 16:
                            what2 = " 额外禁用了 ";
                            break;
                        }
                        log.text += "<color=#ff0>" + BattleData.Instance.GetPlayerInfo(RoleChoose.Instance.oprater).nickname + "</color>" + what2 + "<color=#ff0>" + RoleFactory.Create(RoleChoose.Instance.RoleIDs[lastChosen]).RoleName + "</color>" + "\n";
                    }
                    if (RoleChoose.Instance.RoleStrategy == network.ROLE_STRATEGY.ROLE_STRATEGY_BP)
                    {
                        int isPick = ((RoleChoose.Instance.options[lastChosen] - 1) / 2) % 2;
                        log.text += "<color=#ff0>" + BattleData.Instance.GetPlayerInfo(RoleChoose.Instance.oprater).nickname + "</color>" + (isPick == 0 ? " 禁用了 " : " 选择了 ") + "<color=#ff0>" + RoleFactory.Create(RoleChoose.Instance.RoleIDs[lastChosen]).RoleName + "</color>" + "\n";
                    }
                }
                if (!start)
                {
                    start     = true;
                    log.text += "以下角色响应了召集 ";
                    foreach (var v in RoleChoose.Instance.RoleIDs)
                    {
                        log.text += "<color=#ff0>" + RoleFactory.Create(v).RoleName + "</color> ";
                    }
                    log.text += "\n";
                }
                break;

            case MessageType.GAMEINFO:
                var BPInfo = parameters[0] as network.GameInfo;
                int count  = 1;
                foreach (var v in BPInfo.player_infos)
                {
                    foreach (var c in players)
                    {
                        if (c.ID == v.id)
                        {
                            if (v.role_id != 0 && c.HeroID == 0)
                            {
                                if (BattleData.Instance.GetPlayerInfo(c.ID).team == 0)
                                {
                                    blueHero.sprite = AssetBundleManager.Instance.LoadAsset <Sprite>("hero_l", v.role_id + "L");
                                }
                                else
                                {
                                    redHero.sprite = AssetBundleManager.Instance.LoadAsset <Sprite>("hero_l", v.role_id + "L");
                                }
                            }
                            c.HeroID           = v.role_id;
                            Hname[c.Seat].text = RoleFactory.Create(v.role_id).ShortName;
                        }
                    }
                    if (v.role_id != 0)
                    {
                        count++;
                    }
                }
                int a = count / 2;
                if (count % 2 == 0)
                {
                    pointer.transform.localPosition = new Vector3(-250 + ((players[a - 1].Seat) * 100), pointer.transform.localPosition.y, pointer.transform.localPosition.z);
                }
                else
                {
                    pointer.transform.localPosition = new Vector3(-250 + ((players[a + players.Count / 2].Seat) * 100), pointer.transform.localPosition.y, pointer.transform.localPosition.z);
                }
                break;

            case MessageType.ChatChange:
                chatChange();
                break;
            }
            base.OnEventTrigger(eventType, parameters);
        }
Ejemplo n.º 8
0
        public void OnEventTrigger(MessageType eventType, params object[] parameters)
        {
            network.SinglePlayerInfo srcPlayer, dstPlayer;
            RoleBase r1, r2;

            switch (eventType)
            {
            case MessageType.HITMSG:
                var hitMsg = parameters[0] as network.HitMsg;
                srcPlayer = BattleData.Instance.GetPlayerInfo(hitMsg.src_id);
                dstPlayer = BattleData.Instance.GetPlayerInfo(hitMsg.dst_id);
                r1        = RoleFactory.Create(srcPlayer.role_id);
                r2        = RoleFactory.Create(dstPlayer.role_id);
                Log      += string.Format("{0}攻击了{1}" + Environment.NewLine, r1.RoleName, r2.RoleName);
                break;

            case MessageType.HURTMSG:
                var hurtMsg = parameters[0] as network.HurtMsg;
                srcPlayer = BattleData.Instance.GetPlayerInfo(hurtMsg.src_id);
                r1        = RoleFactory.Create(srcPlayer.role_id);
                Log      += r1.RoleName;
                if (hurtMsg.dst_idSpecified)
                {
                    dstPlayer = BattleData.Instance.GetPlayerInfo(hurtMsg.dst_id);
                    r2        = RoleFactory.Create(dstPlayer.role_id);
                    Log      += "对" + r2.RoleName;
                }
                Log += string.Format("造成{0}点伤害" + Environment.NewLine, hurtMsg.hurt);
                break;

            case MessageType.CARDMSG:
                var cardMsg = parameters[0] as network.CardMsg;
                srcPlayer = BattleData.Instance.GetPlayerInfo(cardMsg.src_id);
                r1        = RoleFactory.Create(srcPlayer.role_id);
                Log      += r1.RoleName;
                if (cardMsg.dst_idSpecified)
                {
                    dstPlayer = BattleData.Instance.GetPlayerInfo(cardMsg.dst_id);
                    r2        = RoleFactory.Create(dstPlayer.role_id);
                    Log      += "对" + r2.RoleName + "使用了";
                }
                else
                {
                    Log += "展示了";
                }
                foreach (var v in cardMsg.card_ids)
                {
                    var c = Card.GetCard(v);
                    Log += c.Name + ",";
                }
                Log += Environment.NewLine;
                break;

            case MessageType.SKILLMSG:
                var skillMsg = parameters[0] as network.SkillMsg;
                srcPlayer = BattleData.Instance.GetPlayerInfo(skillMsg.src_id);
                r1        = RoleFactory.Create(srcPlayer.role_id);
                Log      += r1.RoleName;
                if (skillMsg.dst_ids.Count > 0)
                {
                    Log += "对";
                }
                foreach (var v in skillMsg.dst_ids)
                {
                    dstPlayer = BattleData.Instance.GetPlayerInfo(v);
                    if (dstPlayer != null)
                    {
                        r2   = RoleFactory.Create(dstPlayer.role_id);
                        Log += r2.RoleName + ",";
                    }
                }
                var s = Skill.GetSkill(skillMsg.skill_id);
                if (s != null)
                {
                    Log += string.Format("使用了技能{0}" + Environment.NewLine, s.SkillName);
                }
                else
                {
                    Log += string.Format("使用了技能{0}" + Environment.NewLine, skillMsg.skill_id);
                }
                break;

            case MessageType.GOSSIP:
                var gossip = parameters[0] as network.Gossip;
                srcPlayer = BattleData.Instance.GetPlayerInfo(gossip.id);
                if (srcPlayer.role_idSpecified)
                {
                    r1   = RoleFactory.Create(srcPlayer.role_id);
                    Log += string.Format("[{0}]: {1}" + Environment.NewLine, r1.RoleName, gossip.txt);
                }
                else
                {
                    Log += string.Format("[{0}]: {1}" + Environment.NewLine, srcPlayer.nickname, gossip.txt);
                }
                break;

            case MessageType.PlayerLeave:
                Log += string.Format("玩家[{0}]离开房间" + Environment.NewLine, (int)parameters[0]);
                break;
            }
        }
Ejemplo n.º 9
0
        public void OnEventTrigger(MessageType eventType, params object[] parameters)
        {
            network.SinglePlayerInfo srcPlayer, dstPlayer;
            RoleBase r1, r2;

            str.Remove(0, str.Length);
            switch (eventType)
            {
            case MessageType.HITMSG:
                var hitMsg = parameters[0] as network.HitMsg;
                srcPlayer = BattleData.Instance.GetPlayerInfo(hitMsg.src_id);
                dstPlayer = BattleData.Instance.GetPlayerInfo(hitMsg.dst_id);
                r1        = RoleFactory.Create(srcPlayer.role_id);
                r2        = RoleFactory.Create(dstPlayer.role_id);
                str.Append(string.Format("{0}命中了{1}" + Environment.NewLine, r1.RoleName, r2.RoleName));
                Log += "<color=#ffffff>" + str.ToString() + "</color>";
                MessageSystem <MessageType> .Notify(MessageType.SendHint, str.ToString());

                break;

            case MessageType.HURTMSG:
                var hurtMsg = parameters[0] as network.HurtMsg;
                srcPlayer = BattleData.Instance.GetPlayerInfo(hurtMsg.src_id);
                r1        = RoleFactory.Create(srcPlayer.role_id);
                str.Append(r1.RoleName);
                if (hurtMsg.dst_idSpecified)
                {
                    dstPlayer = BattleData.Instance.GetPlayerInfo(hurtMsg.dst_id);
                    r2        = RoleFactory.Create(dstPlayer.role_id);
                    str.Append("对" + r2.RoleName);
                }
                str.Append(string.Format("造成{0}点伤害" + Environment.NewLine, hurtMsg.hurt));
                Log += string.Format("<color=#ffffff>" + str.ToString() + "</color>");
                MessageSystem <MessageType> .Notify(MessageType.SendHint, str.ToString());

                break;

            case MessageType.CARDMSG:
                var cardMsg = parameters[0] as network.CardMsg;
                srcPlayer = BattleData.Instance.GetPlayerInfo(cardMsg.src_id);
                r1        = RoleFactory.Create(srcPlayer.role_id);
                str.Append(r1.RoleName);
                bool sent = true;
                if (cardMsg.dst_idSpecified)
                {
                    dstPlayer = BattleData.Instance.GetPlayerInfo(cardMsg.dst_id);
                    r2        = RoleFactory.Create(dstPlayer.role_id);
                    str.Append("对" + r2.RoleName + "使用了");
                }
                else
                {
                    str.Append("展示了");
                    sent = false;
                }
                foreach (var v in cardMsg.card_ids)
                {
                    var c = Card.GetCard(v);
                    if (c.Type == Card.CardType.attack || c.Name == Card.CardName.圣光)
                    {
                        str.Append(c.Name + "-" + c.Property.ToString() + " ");
                    }
                    else
                    {
                        str.Append(c.Name + "-" + ChineseElement(c.Element) + " ");
                    }
                }
                str.Append(Environment.NewLine);
                Log += str.ToString();
                if (sent)
                {
                    MessageSystem <MessageType> .Notify(MessageType.SendHint, str.ToString());
                }
                break;

            case MessageType.SKILLMSG:
                var skillMsg = parameters[0] as network.SkillMsg;
                srcPlayer = BattleData.Instance.GetPlayerInfo(skillMsg.src_id);
                r1        = RoleFactory.Create(srcPlayer.role_id);
                str.Append(r1.RoleName);
                if (skillMsg.dst_ids.Count > 0)
                {
                    str.Append("对");
                }
                foreach (var v in skillMsg.dst_ids)
                {
                    dstPlayer = BattleData.Instance.GetPlayerInfo(v);
                    if (dstPlayer != null)
                    {
                        r2 = RoleFactory.Create(dstPlayer.role_id);
                        str.Append(r2.RoleName + ",");
                    }
                }
                var s = Skill.GetSkill(skillMsg.skill_id);
                if (s != null)
                {
                    str.Append(string.Format("使用了技能{0}" + Environment.NewLine, s.SkillName));
                }
                else
                {
                    str.Append(string.Format("使用了技能{0}" + Environment.NewLine, skillMsg.skill_id));
                }
                log += string.Format("<color=#ffffff>" + str.ToString() + "</color>");
                MessageSystem <MessageType> .Notify(MessageType.SendHint, str.ToString());

                break;

            case MessageType.GOSSIP:
                var gossip = parameters[0] as network.Gossip;
                srcPlayer = BattleData.Instance.GetPlayerInfo(gossip.id);
                if (srcPlayer.role_idSpecified)
                {
                    Chat.Add(new ChatPerson()
                    {
                        ID = srcPlayer.id, RoleID = srcPlayer.role_id, msg = gossip.txt.Replace(" ", "\u00a0")
                    });
                }
                else
                {
                    Chat.Add(new ChatPerson()
                    {
                        ID = srcPlayer.id, msg = gossip.txt
                    });
                }
                MessageSystem <MessageType> .Notify(MessageType.ChatChange);

                break;

            case MessageType.PlayerLeave:
                Log += string.Format("<color=#FF0000FF>玩家[{0}]离开房间</color>" + Environment.NewLine,
                                     BattleData.instance.GetPlayerInfo((uint)(int)parameters[0]).nickname);
                break;

            case MessageType.TURNBEGIN:
                Log += "<color=#606060>---------------------------------</color>" + Environment.NewLine;
                break;

            case MessageType.ACTION:
                var act = parameters[0] as network.Action;
                srcPlayer = BattleData.Instance.GetPlayerInfo(act.src_id);
                r1        = RoleFactory.Create(srcPlayer.role_id);
                if (act.action_type == 9)
                {
                    str.Append(r1.RoleName + "宣告了无法行动" + Environment.NewLine);
                }
                else
                {
                    str.Append(string.Format("{0}进行了", r1.RoleName));
                    switch (act.action_id)
                    {
                    case 0:
                        str.Append("购买" + Environment.NewLine);
                        break;

                    case 1:
                        str.Append("合成" + Environment.NewLine);
                        break;

                    case 2:
                        str.Append("提炼" + Environment.NewLine);
                        break;

                    default:
                        str.Append("奇怪的行动" + Environment.NewLine);
                        break;
                    }
                }
                log += str.ToString();
                MessageSystem <MessageType> .Notify(MessageType.SendHint, str.ToString());

                break;
            }
        }
Ejemplo n.º 10
0
 public PlayerAgent(uint roleID) : base()
 {
     PlayerRole = RoleFactory.Create(roleID);
 }
Ejemplo n.º 11
0
        public override void UIStateChange(uint state, UIStateMsg msg, params object[] paras)
        {
            List <List <uint> > selectList;

            switch (state)
            {
            case 10:
                additionalState = 0;
                break;

            case 12:
                if (BattleData.Instance.Gem[BattleData.Instance.MainPlayer.team] + BattleData.Instance.Crystal[BattleData.Instance.MainPlayer.team] == 4)
                {
                    BattleData.Instance.Agent.PlayerRole.Buy(1, 0);
                    BattleData.Instance.Agent.FSM.ChangeState <StateIdle>(UIStateMsg.Init, true);
                }
                else
                {
                    BattleData.Instance.Agent.PlayerRole.Buy(2, 0);
                    BattleData.Instance.Agent.FSM.ChangeState <StateIdle>(UIStateMsg.Init, true);
                }
                return;

            case 13:
                OKAction = () =>
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseArgsUI);

                    sendActionMsg(BasicActionType.ACTION_SPECIAL_SKILL, BattleData.Instance.MainPlayer.id,
                                  BattleData.Instance.Agent.SelectPlayers, null, 1202, BattleData.Instance.Agent.SelectArgs);
                };
                CancelAction = () =>
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseArgsUI);

                    BattleData.Instance.Agent.FSM.BackState(UIStateMsg.ClickBtn);
                };
                if (msg == UIStateMsg.ClickPlayer)
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseArgsUI);

                    if (BattleData.Instance.Agent.SelectPlayers.Count > 0)
                    {
                        var s            = BattleData.Instance.GetPlayerInfo(BattleData.Instance.Agent.SelectPlayers[0]);
                        var tGem         = BattleData.Instance.Gem[BattleData.Instance.MainPlayer.team];
                        var tCrystal     = BattleData.Instance.Crystal[BattleData.Instance.MainPlayer.team];
                        var maxEnergyCnt = RoleFactory.Create(s.role_id).MaxEnergyCount;
                        selectList = new List <List <uint> >();
                        if (maxEnergyCnt - s.gem - s.crystal >= 2)
                        {
                            if (tGem >= 2)
                            {
                                selectList.Add(new List <uint>()
                                {
                                    2, 0
                                });
                            }
                            if (tGem >= 1 && tCrystal >= 1)
                            {
                                selectList.Add(new List <uint>()
                                {
                                    1, 1
                                });
                            }
                            if (tCrystal >= 2)
                            {
                                selectList.Add(new List <uint>()
                                {
                                    0, 2
                                });
                            }
                        }
                        if (maxEnergyCnt - s.gem - s.crystal >= 1)
                        {
                            if (tGem >= 1)
                            {
                                selectList.Add(new List <uint>()
                                {
                                    1, 0
                                });
                            }
                            if (tCrystal >= 1)
                            {
                                selectList.Add(new List <uint>()
                                {
                                    0, 1
                                });
                            }
                        }
                        MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.ShowArgsUI, "Energy", selectList);

                        MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.SendHint,
                                                                              string.Format("{0}: 请选择要提炼的能量", Skills[1202].SkillName));
                    }
                }
                if (BattleData.Instance.Agent.SelectPlayers.Count <= 0)
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.SendHint,
                                                                          string.Format("{0}: 请选择能量要给予的对象", Skills[1202].SkillName));
                }
                return;

            case 1201:
                OKAction = () =>
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseArgsUI);

                    if (BattleData.Instance.Agent.SelectCards.Count == 3)
                    {
                        BattleData.Instance.Agent.SelectArgs = new List <uint>()
                        {
                            39
                        }
                    }
                    ;
                    sendActionMsg(BasicActionType.ACTION_ATTACK_SKILL, BattleData.Instance.MainPlayer.id,
                                  BattleData.Instance.Agent.SelectPlayers, BattleData.Instance.Agent.SelectCards, state,
                                  BattleData.Instance.Agent.SelectArgs);
                    BattleData.Instance.Agent.FSM.ChangeState <StateIdle>(UIStateMsg.Init, true);
                };
                CancelAction = () =>
                {
                    MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseArgsUI);

                    BattleData.Instance.Agent.FSM.BackState(UIStateMsg.Init);
                };
                MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.CloseArgsUI);

                selectList = new List <List <uint> >()
                {
                    new List <uint>()
                    {
                        45
                    }, new List <uint>()
                    {
                        133
                    },
                    new List <uint>()
                    {
                        87
                    }, new List <uint>()
                    {
                        66
                    }, new List <uint>()
                    {
                        110
                    }
                };
                var mList = new List <string>()
                {
                    "地", "水", "火", "风", "雷"
                };
                MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.ShowArgsUI, "欺诈属性", selectList, mList);

                MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.SendHint,
                                                                      string.Format("{0}: 请选择目标玩家, 同系卡牌以及属性。三张默认为暗灭", Skills[state].SkillName));

                return;

            case 1203:
            case 1204:
                OKAction = () =>
                {
                    sendActionMsg(BasicActionType.ACTION_MAGIC_SKILL, BattleData.Instance.MainPlayer.id, null, null, state);
                    BattleData.Instance.Agent.FSM.ChangeState <StateIdle>(UIStateMsg.Init, true);
                };
                CancelAction = () => { BattleData.Instance.Agent.FSM.BackState(UIStateMsg.Init); };
                MessageSystem <Framework.Message.MessageType> .Notify(Framework.Message.MessageType.SendHint,
                                                                      string.Format("是否发动{0}", Skills[state].SkillName));

                return;
            }
            base.UIStateChange(state, msg, paras);
        }