Ejemplo n.º 1
0
        internal static Part BuildTeleporter()
        {
            var tiles = new RotateChar[9] {
                b4, b2, b4, b2, x, b2, b4, b2, b4
            };

            var target   = new TargetZone(TargetShape.Range, 5, 0, false, false);
            int cooldown = 25;

            ICommand teleport(Mech m, IEnumerable <Loc> targets)
            {
                var pos = targets.First();

                int  newTop   = m.PartHandler.Bounds.Top + pos.Y;
                int  newBot   = m.PartHandler.Bounds.Bottom + pos.Y;
                int  newLeft  = m.PartHandler.Bounds.Left + pos.X;
                int  newRight = m.PartHandler.Bounds.Right + pos.X;
                bool inBounds = newTop >= 0 && newLeft >= 0 && newBot < Game.MapHandler.Height && newRight < Game.MapHandler.Width;

                if (!inBounds)
                {
                    Game.MessagePanel.Add("[color=warn]Alert[/color]: Invalid coordinates, teleport modified");
                }

                Game.MapHandler.ForceSetMechPosition(m, pos);
                return(new WaitCommand(m));
            }

            var p = new Part("Portable Teleporter", 3, 3, tiles);

            p.Add(new StabilityComponent(30));
            p.Add(new HeatComponent(20, 0, 0, 0));
            p.Add(new ActivateComponent(target, teleport, cooldown));
            return(p);
        }
Ejemplo n.º 2
0
 public void RemoveZoneToGoTo(TargetZone zone)
 {
     if (zonesToGoTo.Contains(zone))
     {
         zonesToGoTo.Remove(zone);
     }
 }
Ejemplo n.º 3
0
        public TargettingState(Actor source, TargetZone zone, Func <IEnumerable <Loc>, ICommand> callback)
        {
            _source            = source;
            _targetZone        = zone;
            _callback          = callback;
            _targettableActors = new List <Actor>();

            Game.Overlay.DisplayText = "targetting mode";
            Game.Overlay.Clear();

            ICollection <Loc> tempRange = new HashSet <Loc>();

            _inRange = Game.Map.GetPointsInRadius(_source.Loc, _targetZone.Range).ToList();

            // Filter the targettable range down to only the tiles we have a direct line on.
            foreach (Loc point in _inRange)
            {
                Loc collision = point;
                foreach (Loc current in Game.Map.GetStraightLinePath(_source.Loc, point))
                {
                    if (!Game.Map.Field[current].IsWalkable)
                    {
                        collision = current;
                        break;
                    }
                }

                Game.Overlay.Set(collision.X, collision.Y, Colors.TargetBackground);
                tempRange.Add(collision);
            }

            // Pick out the interesting targets.
            // TODO: select items for item targetting spells
            foreach (Loc point in tempRange)
            {
                Game.Map.GetActor(point)
                .MatchSome(actor => _targettableActors.Add(actor));
            }

            // Add the current tile into the targettable range as well.
            tempRange.Add(source.Loc);
            Game.Overlay.Set(source.Loc.X, source.Loc.Y, Colors.TargetBackground);
            _inRange = tempRange;

            // Initialize the targetting to an interesting target.
            Actor firstActor = _targettableActors.FirstOrDefault();

            if (firstActor == null)
            {
                _target = source.Loc;
            }
            else
            {
                _target = firstActor.Loc;
            }
            DrawTargettedTiles();

            // Initialize the saved mouse position as well.
            _prevMouse = _target;
        }
Ejemplo n.º 4
0
        internal static Part BuildSmallMissile(bool left)
        {
            string name  = left ? "Missiles (Left)" : "Missiles (Right)";
            var    pos   = left ? new Loc(-2, 2) : new Loc(2, 2);
            var    tiles = left ?
                           new RotateChar[9] {
                b2, b4, sl, b2, b4, b4, sl, b2, b2
            } :
            new RotateChar[9] {
                sr, b4, b2, b4, b4, b2, b2, b2, sr
            };

            var target   = new TargetZone(TargetShape.Range, 20, 2);
            int cooldown = 6;

            ICommand attack(Mech m, IEnumerable <Loc> targets)
            {
                var anim = Option.Some <IAnimation>(new ExplosionAnimation(targets, Colors.Fire));

                return(new DelayAttackCommand(EngineConsts.TURN_TICKS * 2, new AttackCommand(m, EngineConsts.TURN_TICKS, 10, targets, anim)));
            }

            var p = new Part(name, 3, 3, tiles);

            p.Art    = _missileArt;
            p.Center = pos;
            p.Add(new StabilityComponent(50));
            p.Add(new HeatComponent(4, 0, 0, 0));
            p.Add(new SpeedComponent(15));
            p.Add(new AmmoComponent(2, 99, 10));
            p.Add(new ActivateComponent(target, attack, cooldown));
            return(p);
        }
Ejemplo n.º 5
0
        internal static Part BuildLargeMissile()
        {
            var tiles = new RotateChar[12] {
                trn, trn, trn, b2, b4, b2, b3, b3, b3, sl, b2, sr
            };

            var target   = new TargetZone(TargetShape.Range, 30, 3, false);
            int cooldown = 15;

            ICommand attack(Mech m, IEnumerable <Loc> targets)
            {
                var anim = Option.Some <IAnimation>(new ExplosionAnimation(targets, Colors.Fire));

                return(new DelayAttackCommand(240, new AttackCommand(m, EngineConsts.TURN_TICKS, 10, targets, anim)));
            }

            var p = new Part("Missiles (large)", 3, 4, tiles);

            p.Art = _missileArt;
            p.Add(new StabilityComponent(100));
            p.Add(new HeatComponent(10, 0, 0, 0));
            p.Add(new SpeedComponent(25));
            p.Add(new ActivateComponent(target, attack, cooldown));
            return(p);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Convenience function for handling a game object (NPC/player) entering the zone - passed to the objectives for the level
 /// </summary>
 public override void EntersZone(GameObject zoneObject, TargetZone zone)
 {
     for (int i = 0; i < m_LengthOfObjectivesArray; i++)
     {
         Objective objective = m_ObjectiveInstances[i];
         objective.EntersZone(zoneObject, zone);
     }
 }
Ejemplo n.º 7
0
 public DamageAction(int power, TargetZone targetZone,
                     int speed = Data.Constants.HALF_TURN, int energy = Data.Constants.FULL_TURN)
 {
     _power     = power;
     Speed      = speed;
     EnergyCost = energy;
     Area       = targetZone;
 }
Ejemplo n.º 8
0
        public ActivateComponent(TargetZone target, Func <Mech, IEnumerable <Loc>, ICommand> activate, int cooldown)
        {
            Target   = target;
            Activate = activate;
            Cooldown = cooldown;

            Group           = -1;
            CurrentCooldown = 0;
        }
Ejemplo n.º 9
0
        protected override async Task ProcessCoreAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (TargetZone.IsEmpty())
            {
                output.SuppressOutput();
                return;
            }

            if (output.Attributes.ContainsName("data-origin"))
            {
                var origin = output.Attributes["data-origin"];
                var x      = origin;
            }

            if (Key.HasValue() && _widgetProvider.ContainsWidget(TargetZone, Key))
            {
                output.SuppressOutput();
                return;
            }

            TagHelperContent childContent = await output.GetChildContentAsync();

            TagHelperContent content;

            if (output.TagName == "widget")
            {
                if (childContent.IsEmptyOrWhiteSpace)
                {
                    output.SuppressOutput();
                    return;
                }

                // Never render <widget> tag, only the content
                output.TagName = null;
                content        = childContent;
            }
            else
            {
                output.Content.SetHtmlContent(childContent);
                content = new DefaultTagHelperContent();
                output.CopyTo(content);
            }

            output.SuppressOutput();

            if (!content.IsEmptyOrWhiteSpace)
            {
                var widget = new HtmlWidgetInvoker(content)
                {
                    Order = Ordinal, Prepend = Prepend, Key = Key
                };
                _widgetProvider.RegisterWidget(TargetZone, widget);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Game is failed when the primary target enters the zone
        /// </summary>
        /// <param name="zoneObject">Zone object.</param>
        public override void EntersZone(GameObject zoneObject, TargetZone zone)
        {
            TargetNpc target = zoneObject.GetComponent <TargetNpc>();

            if (target == null)
            {
                return;
            }

            if (target.isPrimaryObjective)
            {
                Failed();
            }
        }
Ejemplo n.º 11
0
        public JsonResult GetTargetZone()
        {
            Guid?      gameId      = this.Session[MagicStrings.SessionGameId] as Guid?;
            string     email       = this.Session[MagicStrings.SessionPlayerEmail].ToString();
            TargetZone targetZone  = MvcApplication.GameHost.GetOpponentTargetZone(gameId.Value, email);
            double     blastRadius = GameHost.ShotBlastRadius;
            var        model       = new GetTargetZoneVModel()
            {
                Latitude    = targetZone.Center.Latitude,
                Longitude   = targetZone.Center.Longitude,
                Radius      = ConvertGeoDistanceToMeters(targetZone.Center, targetZone.Radius),
                BlastRadius = ConvertGeoDistanceToMeters(targetZone.Center, blastRadius)
            };

            return(this.Json(model, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 12
0
        public TargettingState(
            BaseMapHandler map,
            BaseActor source,
            Measure measure,
            TargetZone zone,
            Func <IEnumerable <Loc>, Option <ICommand> > callback)
        {
            _map               = map;
            _source            = source;
            _targetZone        = zone;
            _callback          = callback;
            _targettableActors = new List <BaseActor>();
            _targetted         = new List <Loc>();
            _path              = new List <Loc>();

            _measure = measure;
            var actor = (Mech)_source;

            _inRange = zone.GetAllValidTargets(actor.Pos, actor.Facing, _measure, true);

            // Pick out the interesting targets.
            // TODO: select items for item targetting spells
            foreach (Loc point in _inRange)
            {
                _map.GetActor(point)
                .MatchSome(actor =>
                           _targettableActors.Add(actor));
            }

            // Initialize the targetting to an interesting target.
            var firstActor = Option.None <BaseActor>();

            foreach (BaseActor target in _targettableActors)
            {
                if (!(target is Player) && _map.Field[target.Pos].IsVisible)
                {
                    firstActor = Option.Some(target);
                    break;
                }
            }

            firstActor.Match(
                some: first => _cursor = first.Pos,
                none: () => _cursor    = source.Pos);

            DrawTargettedTiles();
        }
Ejemplo n.º 13
0
        public void UpdateTargetZone(TargetZone targetZone)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var parameters = new
                {
                    targetZone.TargetZoneShape,
                    targetZone.TargetZoneX,
                    targetZone.TargetZoneY,
                    targetZone.TargetZoneZ
                };

                var sql = SqlCrudHelper.GetUpdateStatement(parameters, targetZone.GetType().Name);
                sql += " WHERE TargetZoneId = @TargetZoneId";

                db.Execute(sql, targetZone);
            }
        }
Ejemplo n.º 14
0
        //Used for collecting an item
        public override void EntersZone(GameObject zoneObject, TargetZone zone)
        {
            Collectible collectible = zone as Collectible;

            if (collectible != null)
            {
                return;
            }

            TankDisplay tank = zoneObject.GetComponent <TankDisplay>();

            if (tank == null)
            {
                return;
            }

            Achieved();
        }
Ejemplo n.º 15
0
        public Guid CreateTargetZone(TargetZone targetZone)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var parameters = new
                {
                    targetZone.TargetZoneShape,
                    targetZone.TargetZoneX,
                    targetZone.TargetZoneY,
                    targetZone.TargetZoneZ
                };

                var sql = SqlCrudHelper.GetInsertStatement(parameters, targetZone.GetType().Name, "TargetZoneId");

                Guid newId = db.ExecuteScalar <Guid>(sql, parameters);

                return(newId);
            }
        }
Ejemplo n.º 16
0
        public TargettingState(
            Actor.Actor source,
            TargetZone zone,
            int spellnum,
            Func <IEnumerable <Loc>, Option <ICommand> > callback)
        {
            _source            = source;
            _targetZone        = zone;
            CurrentSpell       = spellnum;
            _callback          = callback;
            _targettableActors = new List <Actor.Actor>();
            _targetted         = new List <Loc>();
            _path    = new List <Loc>();
            _inRange = zone.GetAllValidTargets(_source.Pos);

            // Pick out the interesting targets.
            // TODO: select items for item targetting spells
            foreach (Loc point in _inRange)
            {
                Game.MapHandler.GetActor(point)
                .MatchSome(actor =>
                           _targettableActors.Add(actor));
            }

            // Initialize the targetting to an interesting target.
            var firstActor = Option.None <Actor.Actor>();

            foreach (Actor.Actor target in _targettableActors)
            {
                if (!(target is Actor.Player) && Game.MapHandler.Field[target.Pos].IsVisible)
                {
                    firstActor = Option.Some(target);
                    break;
                }
            }

            firstActor.Match(
                some: first => _cursor = first.Pos,
                none: () => _cursor    = source.Pos);

            DrawTargettedTiles();
        }
        public override IEnumerable <Status> Run()
        {
            if (TargetZone == null)
            {
                yield return(Status.Fail);
            }
            else
            {
                Voxel v = TargetZone.GetNearestVoxel(Agent.Position);

                if (!v.IsEmpty)
                {
                    Agent.Blackboard.SetData(OutputVoxel, v);
                    yield return(Status.Success);
                }
                else
                {
                    Creature.DrawIndicator(IndicatorManager.StandardIndicators.Question);
                    yield return(Status.Fail);
                }
            }
        }
Ejemplo n.º 18
0
        internal static Part BuildSmallLaser()
        {
            var tiles = new RotateChar[4] {
                trn, b4, b3, b2
            };

            var target   = new TargetZone(TargetShape.Ray, 20, 1);
            int cooldown = 4;

            ICommand attack(Mech m, IEnumerable <Loc> targets)
            {
                var anim = Option.Some <IAnimation>(new FlashAnimation(targets, Colors.Fire));

                return(new DelayAttackCommand(10, new AttackCommand(m, EngineConsts.TURN_TICKS, 10, targets, anim, true)));
            }

            var p = new Part("Laser (small)", 1, 4, tiles);

            p.Add(new StabilityComponent(50));
            p.Add(new HeatComponent(2, 0, 0, 0));
            p.Add(new SpeedComponent(10));
            p.Add(new ActivateComponent(target, attack, cooldown));
            return(p);
        }
Ejemplo n.º 19
0
        internal static Part BuildFlak()
        {
            var tiles = new RotateChar[8] {
                vt, vt, vt, vt, b4, b4, b4, b4
            };

            var target   = new TargetZone(TargetShape.Range, 35, 3);
            int cooldown = 15;

            ICommand attack(Mech m, IEnumerable <Loc> targets)
            {
                var anim = Option.Some <IAnimation>(new ExplosionAnimation(targets, Colors.Fire));

                return(new DelayAttackCommand(60, new AttackCommand(m, EngineConsts.TURN_TICKS * 2, 15, targets, anim)));
            }

            var p = new Part("Flak Cannon", 2, 4, tiles);

            p.Add(new StabilityComponent(100));
            p.Add(new HeatComponent(20, 0, 0, 0));
            p.Add(new SpeedComponent(20));
            p.Add(new ActivateComponent(target, attack, cooldown));
            return(p);
        }
Ejemplo n.º 20
0
        internal static Part BuildSniper()
        {
            var tiles = new RotateChar[10] {
                vt, em, vt, em, vt, hz, vt, vt, sl, b3
            };

            var target   = new TargetZone(TargetShape.Ray, 50, 1);
            int cooldown = 15;

            ICommand attack(Mech m, IEnumerable <Loc> targets)
            {
                var anim = Option.Some <IAnimation>(new ExplosionAnimation(targets, Colors.Fire));

                return(new DelayAttackCommand(10, new AttackCommand(m, EngineConsts.TURN_TICKS * 3, 25, targets, anim, true)));
            }

            var p = new Part("Sniper", 2, 5, tiles);

            p.Add(new StabilityComponent(50));
            p.Add(new HeatComponent(1, 0, 0, 0));
            p.Add(new SpeedComponent(20));
            p.Add(new ActivateComponent(target, attack, cooldown));
            return(p);
        }
Ejemplo n.º 21
0
        internal static Part BuildLargeLaser()
        {
            var tiles = new RotateChar[8] {
                trn, trn, b4, b4, b3, b3, b2, b2
            };

            var target   = new TargetZone(TargetShape.Ray, 35, 2);
            var cooldown = 10;

            ICommand attack(Mech m, IEnumerable <Loc> targets)
            {
                var anim = Option.Some <IAnimation>(new ExplosionAnimation(targets, Colors.Fire));

                return(new DelayAttackCommand(60, new AttackCommand(m, EngineConsts.TURN_TICKS, 15, targets, anim, true)));
            }

            var p = new Part("Laser (large)", 2, 4, tiles);

            p.Add(new StabilityComponent(100));
            p.Add(new HeatComponent(8, 0, 0, 0));
            p.Add(new SpeedComponent(20));
            p.Add(new ActivateComponent(target, attack, cooldown));
            return(p);
        }
Ejemplo n.º 22
0
 public EnchantAction(TargetZone area)
 {
     Area = area;
 }
Ejemplo n.º 23
0
 public IgniteAction(TargetZone targetZone)
 {
     Area = targetZone;
 }
Ejemplo n.º 24
0
    public void RemoveZoneToGoTo(TargetZone removedZone)
    {
        remainingZones.Remove(removedZone);

        WaveConditionsChanged();
    }
Ejemplo n.º 25
0
 public void Remove(Card card, TargetZone targetZone)
 {
     throw new NotImplementedException("Ante.Remove");
 }
Ejemplo n.º 26
0
 // Do nothing here
 public override void EntersZone(GameObject zoneObject, TargetZone zone)
 {
 }
Ejemplo n.º 27
0
 public HookAction(int range)
 {
     Area = new TargetZone(TargetShape.Range, range);
 }
Ejemplo n.º 28
0
 public void FinishSpell()
 {
     TargetZone.Neutralize();
     CancelSpell();
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Handles a game object entering the zone
 /// </summary>
 /// <param name="zoneObject">Zone object.</param>
 /// <param name="zone">Zone.</param>
 public abstract void EntersZone(GameObject zoneObject, TargetZone zone);
Ejemplo n.º 30
0
        protected override async Task ProcessCoreAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (TargetZone.IsEmpty())
            {
                output.SuppressOutput();
                return;
            }

            if (Key.HasValue() && _widgetProvider.ContainsWidget(TargetZone, Key))
            {
                output.SuppressOutput();
                return;
            }

            if (ViewContext.HttpContext.Request.IsAjaxRequest())
            {
                // Don't re-inject content during AJAX requests, the target zones are most probably rendered already.
                // Just output the content in-place.
                if (output.TagName == "widget")
                {
                    output.TagName = null;
                }
                else if (output.TagName == "meta")
                {
                    output.SuppressOutput();
                }

                return;
            }

            TagHelperContent childContent = await output.GetChildContentAsync();

            TagHelperContent content;

            if (output.TagName == "widget")
            {
                if (childContent.IsEmptyOrWhiteSpace)
                {
                    output.SuppressOutput();
                    return;
                }

                // Never render <widget> tag, only the content
                output.TagName = null;
                content        = childContent;
            }
            else
            {
                output.Content.SetHtmlContent(childContent);
                content = new DefaultTagHelperContent();
                output.CopyTo(content);
            }

            output.SuppressOutput();

            if (!content.IsEmptyOrWhiteSpace)
            {
                var widget = new HtmlWidgetInvoker(content)
                {
                    Order = Ordinal, Prepend = Prepend, Key = Key
                };
                _widgetProvider.RegisterWidget(TargetZone, widget);
            }
        }