Esempio n. 1
0
        public static GameResource Parse(string str)
        {
            GameResource res = new GameResource();

            string[] datas = str.Split('|');
            foreach (string data in datas)
            {
                if (data == "")
                {
                    break;
                }

                string[] infos = data.Split(';');

                int value = int.Parse(infos[1]);
                switch (int.Parse(infos[0]))
                {
                case 1: res.Gold += value; break;

                case 2: res.Lumber += value; break;

                case 3: res.Stone += value; break;

                case 4: res.Mercury += value; break;

                case 5: res.Carbuncle += value; break;

                case 6: res.Sulfur += value; break;

                case 7: res.Gem += value; break;
                }
            }
            return(res);
        }
Esempio n. 2
0
        public static GameResource Parse(string str)
        {
            GameResource res = new GameResource();
            string[] datas = str.Split('|');
            foreach (string data in datas)
            {
                if (data == "")
                    break;

                string[] infos = data.Split(';');

                int value = int.Parse(infos[1]);
                switch (int.Parse(infos[0]))
                {
                    case 1: res.Gold += value; break;
                    case 2: res.Lumber += value; break;
                    case 3: res.Stone += value; break;
                    case 4: res.Mercury += value; break;
                    case 5: res.Carbuncle += value; break;
                    case 6: res.Sulfur += value; break;
                    case 7: res.Gem += value; break;
                }
            }
            return res;
        }
Esempio n. 3
0
 public static void ParseCommand(string cmd)
 {
     string[] data = cmd.Split(' ');
     if (data.Length == 0) return;
     try
     {
         switch (data[0])
         {
             case "exp": if (data.Length == 2) UserProfile.InfoBasic.AddExp(int.Parse(data[1])); break;
             case "cad": if (data.Length == 2) UserProfile.InfoCard.AddCard(int.Parse(data[1])); break;
             case "atp": if (data.Length == 2) UserProfile.InfoBasic.AttrPoint += int.Parse(data[1]); break;
             case "mov": if (data.Length == 2) Scene.Instance.ChangeMap(int.Parse(data[1])); break;
             case "eqp": if (data.Length == 2) UserProfile.InfoEquip.AddEquip(int.Parse(data[1])); break;
             case "itm": if (data.Length == 3) UserProfile.InfoBag.AddItem(int.Parse(data[1]), int.Parse(data[2])); break;
             case "emys": foreach (int peopleId in ConfigData.PeopleDict.Keys)
                 {
                     RivalState rival = new RivalState(peopleId);
                     rival.Avail = true;
                     UserProfile.InfoRival.Rivals[peopleId] = rival;
                 }
                 break;
             case "gold": if (data.Length == 2)
                 {
                     GameResource res = new GameResource();
                     res.Gold = int.Parse(data[1]);
                     UserProfile.InfoBag.AddResource(res.ToArray());
                 } break;
             case "dmd": if (data.Length == 2) UserProfile.InfoBag.AddDiamond(int.Parse(data[1])); break;
             case "tsk": if (data.Length == 2) UserProfile.InfoTask.BeginTask(int.Parse(data[1])); break;
             case "acv": if (data.Length == 2) UserProfile.Profile.InfoAchieve.SetAchieve(int.Parse(data[1])); break;
             case "view": if (data.Length == 3) PeopleBook.ViewMatch(int.Parse(data[1]), int.Parse(data[2]), "default", TileConfig.Indexer.DefaultTile); break;
             case "fbat": if (data.Length == 3)
                 {
                     FastBattle.Instance.StartGame(int.Parse(data[1]), int.Parse(data[2]), "default", TileConfig.Indexer.DefaultTile);
                     MainForm.Instance.AddTip(string.Format("{0} {1}合", FastBattle.Instance.LeftWin ? "左胜" : "右胜", BattleManager.Instance.BattleInfo.Round), "White");
                 } break;
             case "cbat":
                 if (data.Length == 4)
                 {
                     var result = CardFastBattle.Instance.StartGame(int.Parse(data[1]), int.Parse(data[2]), int.Parse(data[3]));
                     MainForm.Instance.AddTip(string.Format("{0} {1}合", result, BattleManager.Instance.BattleInfo.Round), "White");
                 }break;
             case "scr": if (data.Length == 2)
                 {
                     switch (data[1])
                     {
                         case "Vs": GmScript.MonsterVsBatch();break;
                     }
                 } break;
         }
     }
     catch (FormatException) { }
 }
Esempio n. 4
0
 public InfoBag()
 {
     Resource = new GameResource();
     Items = new IntPair[50];
 }
Esempio n. 5
0
        static public void Award(int id)
        {
            TaskConfig taskConfig = ConfigData.GetTaskConfig(id);
            Profile user = UserProfile.Profile;

            GameResource res = GameResource.Parse(taskConfig.Resource);
            res.Add(GameResourceType.Gold, GetMoneyReal(id));
            if (taskConfig.Card != 0 && CardConfigManager.GetCardConfig(taskConfig.Card).Id>0)
            {
                user.InfoCard.AddCard(taskConfig.Card);
            }
            if (taskConfig.Item.Count > 0)
            {
                for (int i = 0; i < taskConfig.Item.Count; i++)
                {
                    if (taskConfig.Item[i].Value == 1)
                        user.InfoBag.AddItem(taskConfig.Item[i].Id, 1);
                    else
                        user.InfoEquip.AddEquip(taskConfig.Item[i].Id);
                }
            }
            user.InfoBag.AddResource(res.ToArray());
            user.InfoBasic.AddExp(GetExpReal(id));

            if (taskConfig.Type == TaskTypes.Item)
            {
                for (int i = 0; i < taskConfig.NeedItemId.Length; i ++)
                {
                    user.InfoBag.DeleteItem(taskConfig.NeedItemId[i], taskConfig.NeedItemCount[i]);
                }
            }
            else if (taskConfig.Type == TaskTypes.Resource)
            {
                GameResource subres = new GameResource();
                subres.Add((GameResourceType)(taskConfig.NeedResourceId - 1), taskConfig.NeedResourceCount);
                user.InfoBag.SubResource(subres.ToArray());
            }
        }
Esempio n. 6
0
        static public bool CanFinish(int id)
        {
            int state = UserProfile.InfoTask.GetTaskStateById(id);
            if (state == 0 || state == 3)
                return false;

            TaskConfig taskConfig = ConfigData.GetTaskConfig(id);
            switch (taskConfig.Type)
            {
                case TaskTypes.Item: return CheckItem(id);
                case TaskTypes.Fight: return state == 2;
                case TaskTypes.Talk: return true;
                case TaskTypes.Level: return UserProfile.InfoBasic.Level >= taskConfig.NeedLevel;
                case TaskTypes.Teach: return true;
                case TaskTypes.Won: return UserProfile.InfoTask.GetTaskAddonById(id) >= taskConfig.WinCount;
                case TaskTypes.WonLevel: return UserProfile.InfoTask.GetTaskAddonById(id) >= taskConfig.WinCount;
                case TaskTypes.Resource:
                    GameResource res = new GameResource();
                    res.Add((GameResourceType)(taskConfig.NeedResourceId - 1), taskConfig.NeedResourceCount);
                    return UserProfile.InfoBag.CheckResource(res.ToArray());
                case TaskTypes.Special: return state == 2;
            }

            return false;
        }