Esempio n. 1
0
        public override MParty Build(PartyBuildParams arg)
        {
            var characterFactory = new CharacterFactory();

            if (PartyTable.Instance.Table[arg.Culture].ContainsKey(arg.Name))
            {
                var party      = new MParty();
                var subParties = PartyTable.Instance.Table[arg.Culture][arg.Name];
                foreach (var subParty in subParties)
                {
                    var subPartyParams = new SubPartyBuildParams();
                    subPartyParams.culture   = arg.Culture;
                    subPartyParams.Name      = subParty.X;
                    subPartyParams.Remaining = (subParty.Y * arg.Difficulty);
                    var subPartyCharacters = this._subPartyBuilder.Build(subPartyParams);
                    if (subPartyCharacters != null)
                    {
                        foreach (var character in subPartyCharacters)
                        {
                            var model      = characterFactory.CreateNewCharacter(character.X);
                            var controller = new CChar();
                            var proxy      = new PChar(model);
                            proxy.StartCol = character.Y;
                            controller.SetProxy(proxy);
                            party.AddChar(controller);
                        }
                    }
                }
                return(party);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
 public List <Pair <PreCharParams, EStartCol> > Build(SubPartyBuildParams arg)
 {
     try
     {
         if (SubpartyTable.Instance.Table[arg.culture].ContainsKey(arg.Name))
         {
             var buildList      = new List <Pair <PreCharParams, EStartCol> >();
             var subPartyParams = SubpartyTable.Instance.Table[arg.culture][arg.Name];
             for (int i = 0; i < 10; i++)
             {
                 var sub = subPartyParams[RNG.Instance.Next(0, subPartyParams.Count)];
                 if (sub.Difficulty <= arg.Remaining)
                 {
                     arg.Remaining -= sub.Difficulty;
                     var charParams = PredefinedCharTable.Instance.Table[sub.Name];
                     buildList.Add(new Pair <PreCharParams, EStartCol>(charParams, sub.Row));
                 }
             }
             if (buildList.Count == 0)
             {
                 var sub        = subPartyParams[RNG.Instance.Next(0, subPartyParams.Count)];
                 var charParams = PredefinedCharTable.Instance.Table[sub.Name];
                 buildList.Add(new Pair <PreCharParams, EStartCol>(charParams, sub.Row));
             }
             return(buildList);
         }
         else
         {
             return(null);
         }
     }
     catch (KeyNotFoundException e)
     {
         Debug.LogError(e);
         Debug.LogError("SubParty not found: " + " Name: " + arg.Name + " Culture: " + arg.culture);
         return(null);
     }
 }