Esempio n. 1
0
            public ctor Init(string objType, State rootState, params ILootDef[] defs)
            {
                var d = new Dictionary <string, State>();

                rootState.Resolve(d);
                rootState.ResolveChildren(d);
                var dat = InitDb.Manager.Resources.GameData;

                if (defs.Length > 0)
                {
                    var loot = new Loot(defs);
                    rootState.Death += (sender, e) => loot.Handle((Enemy)e.Host, e.Time);
                    if (dat.IdToObjectType.ContainsKey(objType))
                    {
                        InitDb.Definitions.Add(dat.IdToObjectType[objType], new Tuple <State, Loot>(rootState, loot));
                    }
                }
                else
                {
                    if (dat.IdToObjectType.ContainsKey(objType))
                    {
                        InitDb.Definitions.Add(dat.IdToObjectType[objType], new Tuple <State, Loot>(rootState, null));
                    }
                }
                return(this);
            }
Esempio n. 2
0
            public ctor Init(string id, State rootState, params MobDrops[] defs)
            {
                var d = new Dictionary <string, State>();

                rootState.Resolve(d);
                rootState.ResolveChildren(d);
                var dat = InitDb.Manager.Resources.GameData;

                if (!dat.IdToObjectType.ContainsKey(id))
                {
                    Log.Error($"Failed to add behavior: {id}. Xml data not found.");
                    return(this);
                }

                if (defs.Length > 0)
                {
                    var loot = new Loot(defs);
                    rootState.Death += (sender, e) => loot.Handle((Enemy)e.Host, e.Time);
                    InitDb.Definitions.Add(dat.IdToObjectType[id], new Tuple <State, Loot>(rootState, loot));
                }
                else
                {
                    InitDb.Definitions.Add(dat.IdToObjectType[id], new Tuple <State, Loot>(rootState, null));
                }
                return(this);
            }
Esempio n. 3
0
 public ctor Init(string objType, State rootState, params ILootDef[] defs)
 {
     var d = new Dictionary<string, State>();
     rootState.Resolve(d);
     rootState.ResolveChildren(d);
     var dat = InitDb.Manager.GameData;
     if (defs.Length > 0)
     {
         var loot = new Loot(defs);
         rootState.Death += (sender, e) => loot.Handle((Enemy)e.Host, e.Time);
         InitDb.Definitions.Add(dat.IdToObjectType[objType], new Tuple<State, Loot>(rootState, loot));
     }
     else
         InitDb.Definitions.Add(dat.IdToObjectType[objType], new Tuple<State, Loot>(rootState, null));
     return this;
 }