コード例 #1
0
ファイル: HeroState.cs プロジェクト: allenm84/mg-feh
 public HeroState(int teamId, Hero hero, MapCellLocation location)
 {
     TeamId       = teamId;
     Hero         = hero;
     CurrentStats = hero.BaseStats;
     Location     = location;
 }
コード例 #2
0
        public override IEnumerable <IMove> ValidMovesFor(MapCellLocation location, HeroState owner, HeroState target, MapState map)
        {
            var potentialPlaces = map.Neighbors(location, 1);

            foreach (var(cell, depth, distance) in potentialPlaces)
            {
                if (map.CanMoveTo(target, cell))
                {
                    // we can reposition the target to this spot
                    yield return(new MoveHeroTo(target, 1, cell, map));
                }
            }
        }
コード例 #3
0
ファイル: Shove.cs プロジェクト: allenm84/mg-feh
        public override IEnumerable <IMove> ValidMovesFor(MapCellLocation location, HeroState owner, HeroState target, MapState map)
        {
            var(dr, dc)    = MapCellLocation.Diff(target.Location, location);
            (int r, int c) = target.Location;
            dr             = Math.Sign(dr);
            dc             = Math.Sign(dc);

            // can we push the target 1 space away?
            if (map.CanMoveTo(target, (r + dr, c + dc), out MapCellState cell))
            {
                yield return(new MoveHeroTo(target, 1, cell, map, true));
            }
        }
コード例 #4
0
ファイル: DrawBack.cs プロジェクト: allenm84/mg-feh
        public override IEnumerable <IMove> ValidMovesFor(MapCellLocation location, HeroState owner, HeroState target, MapState map)
        {
            // can the target move to the cell we're on?
            if (map.CanMoveTo(target, location, out MapCellState currentCell))
            {
                yield break;
            }

            // if the target can move to my position, I need to be able to move
            // in the same direction to the next cell
            var(dr, dc)    = MapCellLocation.Diff(location, target.Location);
            (int r, int c) = location;
            if (map.CanMoveTo(owner, (r + dr, c + dc), out MapCellState desiredCell))
            {
                var moveTargetBack = new MoveHeroTo(target, 1, currentCell, map);
                var moveMeBack     = new MoveHeroTo(owner, 1, desiredCell, map);
                yield return(new AggregateMove(moveMeBack, moveTargetBack));
            }
        }
コード例 #5
0
ファイル: Swap.cs プロジェクト: allenm84/mg-feh
        public override IEnumerable <IMove> ValidMovesFor(MapCellLocation location, HeroState owner, HeroState target, MapState map)
        {
            // can the owner move to the target's position?
            if (!map.CanMoveTo(owner, target.Location, out MapCellState targetCell))
            {
                yield break;
            }

            // can the target move to the owner's position?
            if (!map.CanMoveTo(target, location, out MapCellState ownerCell))
            {
                yield break;
            }

            // the swap can be done!
            var moveOwnerToTarget = new MoveHeroTo(owner, 1, targetCell, map);
            var moveTargetToOwner = new MoveHeroTo(target, 1, ownerCell, map);

            yield return(new AggregateMove(moveOwnerToTarget, moveTargetToOwner));
        }
コード例 #6
0
ファイル: Smite.cs プロジェクト: allenm84/mg-feh
        public override IEnumerable <IMove> ValidMovesFor(MapCellLocation location, HeroState owner, HeroState target, MapState map)
        {
            var(dr, dc)    = MapCellLocation.Diff(target.Location, location);
            (int r, int c) = target.Location;
            dr             = Math.Sign(dr);
            dc             = Math.Sign(dc);

            // can we push the target 2 spaces away?
            var distance = 2;

            if (!map.CanMoveTo(target, (r + dr + dr, c + dc + dc), out MapCellState cell))
            {
                // no? Can we push them one square away?
                distance = 1;
                if (!map.CanMoveTo(target, (r + dr, c + dc), out cell))
                {
                    yield break;
                }
            }

            // we can push the target 2/1 squares away
            yield return(new MoveHeroTo(target, distance, cell, map, true));
        }
コード例 #7
0
ファイル: MapCellState.cs プロジェクト: allenm84/mg-feh
 public MapCellState(MapCell cell, MapCellLocation location)
 {
     Cell     = cell;
     Location = location;
 }
コード例 #8
0
ファイル: AssistSkill.cs プロジェクト: allenm84/mg-feh
 public abstract IEnumerable <IMove> ValidMovesFor(MapCellLocation location, HeroState owner, HeroState target, MapState map);
コード例 #9
0
 public override IEnumerable <IMove> ValidMovesFor(MapCellLocation location, HeroState owner, HeroState target, MapState map)
 {
     yield return(new Heal(this, owner, target));
 }
コード例 #10
0
 public MapCell this[MapCellLocation loc]
 {
     get => _cells[loc.Row, loc.Column];