Example #1
0
        private void _ToGame(GamePlayerRecord record, Realm.Map map)
        {
            var player = EntityProvider.Create(record.Entity);

            var itemProvider = new ItemProvider();
            var itemAxe      = itemProvider.MakeItem("Axe1", 0.5f);
            var itemSword1   = itemProvider.MakeItem("Sword1", 0.5f);
            var itemSword2   = itemProvider.MakeItem("Sword2", 0.5f);
            var itemShield1  = itemProvider.MakeItem("Shield1", 0.5f);

            player.Bag.Add(itemAxe);
            player.Bag.Add(itemSword1);
            player.Bag.Add(itemSword2);
            player.Bag.Add(itemShield1);

            foreach (var item in record.Items)
            {
                player.Bag.Add(item);
            }

            var stage = new GameStage(this._Binder, map.Finder, map.Gate, player);

            stage.ExitEvent     += () => { };
            stage.TransmitEvent += _ToRealm;
            _Machine.Push(stage);
        }
        public void TestBuildItemEffect()
        {
            var ip = new ItemProvider();
            var item = new Item() ;
            var effects = new ItemEffect[]
            {
                new ItemEffect() { Quality = 100 , Effects = new []
                {
                    new Effect() { Type = EFFECT_TYPE.ATTACK_ADD , Value = 10},
                    new Effect() { Type = EFFECT_TYPE.ATTACK_ADD , Value = 1}
                }},
                new ItemEffect() { Quality = 80 , Effects = new []
                {
                    new Effect() { Type = EFFECT_TYPE.ATTACK_ADD , Value = 8},
                    new Effect() { Type = EFFECT_TYPE.ATTACK_ADD , Value = 2}
                }},
                new ItemEffect() { Quality = 0 , Effects = new []
                {
                    new Effect() { Type = EFFECT_TYPE.ATTACK_ADD , Value = 7},
                    new Effect() { Type = EFFECT_TYPE.ATTACK_ADD , Value = 3}
                }}

            };
            item = ip.BuildItem(80, item, effects);

            Assert.AreEqual(EFFECT_TYPE.ATTACK_ADD , item.Effects[0].Type );
            Assert.AreEqual(20, item.Effects[0].Value);
        }
Example #3
0
        Guid[] IMapGate.SpawnField(ENTITY[] types)
        {
            foreach (var type in types)
            {
                if (_EntityFieldResource[type] <= 0)
                {
                    return(new Guid[0]);
                }
            }
            List <Guid> ids = new List <Guid>();

            foreach (var type in types)
            {
                if (_EntityFieldResource[type] > 0)
                {
                    var itemProvider = new ItemProvider();
                    var aboriginal   = _Create(_Map, type, itemProvider);
                    _EntityFieldResource[type]--;
                    _Join(aboriginal);
                    aboriginal.DoneEvent += () =>
                    {
                        _EntityFieldResource[type]++;

                        _Left(aboriginal.Entity.Id);
                    };
                    ids.Add(aboriginal.Entity.Id);
                }
            }
            return(ids.ToArray());
        }
Example #4
0
        void IDevelopActor.CreateItem(string name, int count)
        {
            var ip   = new ItemProvider();
            var item = ip.CreateItem(name, count);

            Bag.Add(item);
        }
Example #5
0
 private void _Supplement()
 {
     if (this.Count() <= 1)
     {
         var idx          = Regulus.Utility.Random.Instance.NextInt(0, _Items.Length);
         var itemProvider = new ItemProvider();
         Add(itemProvider.CreateItem(_Items[idx].Name));
     }
 }
 private void _Supplement()
 {
     if ( this.Count() <= 1  )
     {
         var idx = Regulus.Utility.Random.Instance.NextInt(0, _Items.Length);
         var itemProvider = new ItemProvider();
         Add(itemProvider.CreateItem(_Items[idx].Name));
     }
 }
        private void _Create(ItemFormula key, int[] amounts)
        {
            var quality = ItemProvider.GetQuality(key, amounts);

            var itemProvider = new ItemProvider();
            var item         = itemProvider.BuildItem(quality, key.Item, key.Effects);

            _Player.Bag.Add(item);
        }
Example #8
0
        Guid IMapGate.Spawn(ENTITY type)
        {
            var itemProvider = new ItemProvider();
            var aboriginal   = _Create(_Map, type, itemProvider);

            aboriginal.DoneEvent += () =>
            {
                _Left(aboriginal.Entity.Id);
            };
            _Join(aboriginal);
            return(aboriginal.Entity.Id);
        }
Example #9
0
        private Aboriginal _Create(Map map, ENTITY type, ItemProvider item_provider)
        {
            var entiry = EntityProvider.Create(type);
            var items  = item_provider.FromStolen();

            foreach (var item in items)
            {
                entiry.Bag.Add(item);
            }
            var wisdom     = new StandardWisdom(entiry);
            var aboriginal = new Aboriginal(map, this, entiry, wisdom);

            return(aboriginal);
        }
Example #10
0
        void IDevelopActor.MakeItem(string name, float quality)
        {
            var formulas = Resource.Instance.Formulas;
            var formula  = (from f in formulas where f.Id == name select f).FirstOrDefault();

            if (formula == null)
            {
                return;
            }

            var ip   = new ItemProvider();
            var item = ip.BuildItem(quality, formula.Item, formula.Effects);

            Bag.Add(item);
        }
        void IBootable.Launch()
        {
            var provider = new ItemProvider();
            _Actor.Bag.Add(provider.BuildItem(1 , "AidKit1" , new [] {new ItemEffect()
            {
                Effects = new []{ new Effect() { Type =  EFFECT_TYPE.AID , Value = 10 } },
                Quality = 0.5f
            } }));

            _Actor.Bag.Add(provider.BuildItem(1, "Axe1", new[] {new ItemEffect()
            {
                Effects = new []{ new Effect() { Type =  EFFECT_TYPE.ATTACK_ADD , Value = 1 } },
                Quality = 0.5f
            } }));
            _ToGame(_Map);
        }
Example #12
0
        private void _Create(ItemFormula key, int[] amounts)
        {
            var items = key.NeedItems;

            var total1      = items.Sum(i => i.Max);
            var itemScales1 = (from i in items
                               select new
            {
                Item = i,
                Value = i.Max,
                Scale = i.Max / (float)total1
            }).ToArray();

            var total2      = amounts.Sum();
            var itemScales2 = (from i in amounts
                               select new
            {
                Value = i,
                Scale = i / (float)total2
            }).ToArray();

            var maxScale = 0.0f;

            for (int i = 0; i < itemScales2.Length && i < itemScales1.Length; i++)
            {
                var scale1 = itemScales1[i].Scale;
                var scale2 = itemScales2[i].Scale;
                var ms     = scale2 / scale1;
                if (ms > maxScale)
                {
                    maxScale = ms;
                }
            }


            var quality = 0.0f;

            for (int i = 0; i < itemScales2.Length && i < itemScales1.Length; i++)
            {
                quality += itemScales1[i].Scale * (itemScales2[i].Scale / itemScales1[i].Scale / maxScale);
            }

            var itemProvider = new ItemProvider();
            var item         = itemProvider.BuildItem(quality, key.Item, key.Effects);

            _Player.Bag.Add(item);
        }
Example #13
0
 Guid IMapGate.SpawnEnterance(ENTITY type)
 {
     if (_EntityEnteranceResource[type] > 0)
     {
         var itemProvider = new ItemProvider();
         var aboriginal   = _Create(_Map, type, itemProvider);
         _EntityEnteranceResource[type]--;
         _Join(aboriginal);
         aboriginal.DoneEvent += () =>
         {
             _EntityEnteranceResource[type]++;
             _Left(aboriginal.Entity.Id);
         };
         return(aboriginal.Entity.Id);
     }
     return(Guid.Empty);
 }
        void IBootable.Launch()
        {
            var provider = new ItemProvider();

            _Actor.Bag.Add(provider.BuildItem(1, "AidKit", new [] { new ItemEffect()
                                                                    {
                                                                        Effects = new [] { new Effect()
                                                                                           {
                                                                                               Type = EFFECT_TYPE.AID, Value = 10
                                                                                           } },
                                                                        Quality = 0.5f
                                                                    } }));

            _Actor.Bag.Add(provider.BuildItem(1, "Axe", new[] { new ItemEffect()
                                                                {
                                                                    Effects = new [] { new Effect()
                                                                                       {
                                                                                           Type = EFFECT_TYPE.ATTACK_ADD, Value = 1
                                                                                       } },
                                                                    Quality = 0.5f
                                                                } }));
            _ToGame(_Map);
        }
 Guid IMapGate.SpawnEnterance(ENTITY type)
 {
     if (_EntityEnteranceResource[type] > 0)
     {
         var itemProvider = new ItemProvider();
         var aboriginal = _Create(_Map, type, itemProvider);
         _EntityEnteranceResource[type]--;
         _Join(aboriginal);
         aboriginal.DoneEvent += () =>
         {
             _EntityEnteranceResource[type]++;
             _Left(aboriginal.Entity.Id);
         };
         return aboriginal.Entity.Id;
     }
     return Guid.Empty;
 }
 Guid IMapGate.Spawn(ENTITY type)
 {
     var itemProvider = new ItemProvider();
     var aboriginal = _Create(_Map, type, itemProvider);
     aboriginal.DoneEvent += () =>
     {
         _Left(aboriginal.Entity.Id);
     };
     _Join(aboriginal);
     return aboriginal.Entity.Id;
 }
 private Aboriginal _Create(Map map,ENTITY type, ItemProvider item_provider)
 {
     var entiry = EntityProvider.Create(type);
     var items = item_provider.FromStolen();
     foreach (var item in items)
     {
         entiry.Bag.Add(item);
     }
     var wisdom = new StandardWisdom(entiry);
     var aboriginal = new Aboriginal(map, this, entiry, wisdom);
     return aboriginal;
 }
Example #18
0
 void IDevelopActor.CreateItem(string name, int count)
 {
     var ip = new ItemProvider();
     var item = ip.CreateItem(name, count);
     Bag.Add(item);
 }
Example #19
0
        void IDevelopActor.MakeItem(string name, float quality)
        {
            var formulas = Resource.Instance.Formulas;
            var formula = (from f in formulas where f.Id == name select f).FirstOrDefault();
            if (formula == null)
                return;

            var ip = new ItemProvider();
            var item = ip.BuildItem(quality, formula.Item, formula.Effects);

            Bag.Add(item);
        }
Example #20
0
        private void _ToGame(GamePlayerRecord record , Realm.Map map)
        {
            var player = EntityProvider.Create(record.Entity);

            var itemProvider = new ItemProvider();
            var itemAxe = itemProvider.MakeItem( "Axe1" , 0.5f );
            var itemSword1 = itemProvider.MakeItem("Sword1" , 0.5f);
            var itemSword2 = itemProvider.MakeItem("Sword2" , 0.5f);
            var itemShield1 = itemProvider.MakeItem("Shield1", 0.5f);

            player.Bag.Add(itemAxe);
            player.Bag.Add(itemSword1);
            player.Bag.Add(itemSword2);
            player.Bag.Add(itemShield1);

            foreach (var item in record.Items)
            {
                player.Bag.Add(item);
            }

            var stage = new GameStage(this._Binder, map.Finder, map.Gate, player);
            stage.ExitEvent += () => { };
            stage.TransmitEvent += _ToRealm;
            _Machine.Push(stage);
        }
        Guid[] IMapGate.SpawnField(ENTITY[] types)
        {
            foreach (var type in types)
            {
                if(_EntityFieldResource[type] <= 0)
                    return new Guid[0];
            }
            List<Guid> ids = new List<Guid>();
            foreach (var type in types)
            {
                if (_EntityFieldResource[type] > 0)
                {
                    var itemProvider = new ItemProvider();
                    var aboriginal = _Create(_Map, type, itemProvider);
                    _EntityFieldResource[type]--;
                    _Join(aboriginal);
                    aboriginal.DoneEvent += () =>
                    {
                        _EntityFieldResource[type]++;

                        _Left(aboriginal.Entity.Id);

                    };
                    ids.Add(aboriginal.Entity.Id);
                }
            }
            return ids.ToArray();
        }