Пример #1
0
        public bool TryRevive(LevelItem item, List <LevelItem> allItems, out ITimeFunction hydratedElement)
        {
            if (item.HasValueTag("ammo") == false || item.HasValueTag("amount") == false)
            {
                hydratedElement = null;
                return(false);
            }

            var weaponTypeName = item.GetTagValue("ammo");
            var weaponType     = Type.GetType(weaponTypeName, false, true);

            if (weaponType == null)
            {
                weaponType = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(Weapon)) && t.Name == weaponTypeName).SingleOrDefault();
            }

            if (weaponType == null)
            {
                weaponType = Assembly.GetEntryAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(Weapon)) && t.Name == weaponTypeName).SingleOrDefault();
            }

            if (weaponType == null)
            {
                throw new ArgumentException("Could not resolve weapon type: " + weaponTypeName);
            }

            var amount = int.Parse(item.GetTagValue("amount"));

            var weapon = Activator.CreateInstance(weaponType) as Weapon;

            weapon.AmmoAmount = amount;

            hydratedElement = new LooseWeapon(weapon);
            return(true);
        }
Пример #2
0
        public bool TryRevive(LevelItem item, List <LevelItem> allItems, out ITimeFunction hydratedElement)
        {
            if (item.HasValueTag("trigger") == false)
            {
                hydratedElement = null;
                return(false);
            }

            var range   = item.HasValueTag("range") && float.TryParse(item.GetTagValue("range"), out float result) ? result : 5f;
            var trigger = new Trigger()
            {
                Id = item.GetTagValue("trigger"), Range = range
            };

            hydratedElement = trigger;
            return(true);
        }
Пример #3
0
        public bool TryRevive(LevelItem item, List <LevelItem> allItems, out ITimeFunction hydratedElement)
        {
            if (item.HasValueTag("cutscene") == false)
            {
                hydratedElement = null;
                return(false);
            }

            var scene = SceneFactory.CreateInstance <ICutScene>(item.GetTagValue("cutscene"));

            hydratedElement = TimeFunction.Create(null, init: scene.Start);
            return(true);
        }
Пример #4
0
        public bool TryRevive(LevelItem item, List <LevelItem> allItems, out ITimeFunction hydratedElement)
        {
            if (item.HasValueTag("destination") == false)
            {
                hydratedElement = null;
                return(false);
            }

            hydratedElement = new Portal();

            try
            {
                (hydratedElement as Portal).LevelId = item.GetTagValue("destination");
            }
            catch (Exception ex)
            {
            }
            return(true);
        }
Пример #5
0
        public bool TryRevive(LevelItem item, List <LevelItem> allItems, out ITimeFunction hydratedElement)
        {
            var text = string.Empty;

            if (item.HasSimpleTag(EffectName) || item.HasValueTag(EffectName))
            {
                for (var x = 0; x < 500; x++)
                {
                    var next = allItems.Where(i => i.X == item.X + x && i.Y == item.Y).FirstOrDefault();
                    if (next != null)
                    {
                        next.Ignore = true;
                        text       += next.Symbol;
                    }
                    else
                    {
                        break;
                    }
                }


                var delay = item.HasValueTag(EffectName) && int.TryParse(item.GetTagValue(EffectName), out int result) ? result : 0;
                var stay  = item.HasValueTag("stay") && int.TryParse(item.GetTagValue("stay"), out int stayResult) ? stayResult : 10000;


                var effect = SceneFactory.CreateInstance <TextEffect>(EffectName);
                effect.Options = new TextEffectOptions()
                {
                    Left = item.X,
                    Top  = item.Y,
                    Text = text,
                    DurationMilliseconds = stay,
                };

                if (item.HasValueTag("triggerId") == false)
                {
                    hydratedElement = TimeFunction.CreateDelayed(delay, null, init: effect.Start);
                    return(true);
                }
                else
                {
                    hydratedElement = TimeFunction.Create(null, () =>
                    {
                        var id      = item.GetTagValue("triggerId");
                        var trigger = SpaceTime.CurrentSpaceTime.Elements.WhereAs <Trigger>().Where(t => t.Id == id).SingleOrDefault();

                        if (trigger == null)
                        {
                            throw new ArgumentException("No trigger with id: " + id);
                        }

                        trigger.Fired.SubscribeOnce((notused) =>
                        {
                            effect.Start();
                        });
                    });

                    return(true);
                }
            }

            hydratedElement = null;
            return(false);
        }