Exemple #1
0
        public bool TryRevive(LevelItem item, List <LevelItem> allItems, out ITimeFunction hydratedElement)
        {
            if (item.HasSimpleTag("friendly") == false)
            {
                hydratedElement = null;
                return(false);
            }

            var friendly = new Friendly();

            friendly.Inventory.Items.Add(new Pistol()
            {
                AmmoAmount = 100, HealthPoints = 10,
            });
            hydratedElement = friendly;
            new Bot(friendly, new List <IBotStrategy> {
                new AvoidEnemies()
            });
            return(true);
        }
Exemple #2
0
        public bool TryRevive(LevelItem item, List <LevelItem> allItems, out ITimeFunction hydratedElement)
        {
            if (item.Symbol == 'd' && item.HasSimpleTag("door"))
            {
                var isDoorAboveMe    = allItems.Where(i => i != item && i.Symbol == 'd' && i.Y == item.Y - 1 && item.X == item.X).Any();
                var isDoorToLeftOfMe = allItems.Where(i => i != item && i.Symbol == 'd' && i.X == item.X - 1 && item.Y == item.Y).Any();

                if (isDoorAboveMe == false && isDoorToLeftOfMe == false)
                {
                    var bigDoor = new Door();
                    hydratedElement = bigDoor;

                    var rightCount = CountAndRemoveDoorsToRight(allItems, item);
                    var belowCount = CountAndRemoveDoorsBelow(allItems, item);

                    if (rightCount > 0)
                    {
                        item.Width           = rightCount + 1;
                        bigDoor.ClosedBounds = PowerArgs.Cli.Physics.RectangularF.Create(item.X, item.Y, item.Width, item.Height);
                        bigDoor.OpenBounds   = PowerArgs.Cli.Physics.RectangularF.Create(bigDoor.ClosedBounds.Left + item.Width, bigDoor.ClosedBounds.Top, item.Width, item.Height);
                    }
                    else if (belowCount > 0)
                    {
                        item.Height          = belowCount + 1;
                        bigDoor.ClosedBounds = PowerArgs.Cli.Physics.RectangularF.Create(item.X, item.Y, item.Width, item.Height);
                        bigDoor.OpenBounds   = PowerArgs.Cli.Physics.RectangularF.Create(bigDoor.ClosedBounds.Left, bigDoor.ClosedBounds.Top + item.Height, item.Width, item.Height);
                    }
                    else
                    {
                        throw new Exception("Lonely door");
                    }


                    return(true);
                }
            }

            hydratedElement = null;
            return(false);
        }
Exemple #3
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);
        }