Beispiel #1
0
    private Dictionary <Unit, UnitDisplacement> GetAggregatedDisplacements(List <Player> players, List <KeyValuePair <Unit, Command> > commands, Board board)
    {
        Dictionary <Unit, UnitDisplacement> results = new Dictionary <Unit, UnitDisplacement>();

        foreach (KeyValuePair <Unit, Command> pair in commands)
        {
            Unit             unit         = pair.Key;
            Command          command      = pair.Value;
            Direction        absDir       = command.GetAbsoluteDir();
            UnitDisplacement displacement = command.frame.effect.GetDisplacement(unit, absDir, board);
            if (results.ContainsKey(unit))
            {
                results[unit] += displacement;
            }
            else
            {
                results.Add(unit, displacement);
            }
        }

        //Add all units who wait
        foreach (Player player in players)
        {
            foreach (Unit unit in player.units)
            {
                if (!results.ContainsKey(unit))
                {
                    results.Add(unit, new AbsoluteDisplacement(unit, unit.tile.coordinate));
                }
            }
        }

        return(results);
    }
 public SimulatedDisplacement(UnitDisplacement displacement)
 {
     this.displacement = displacement;
     this.result       = displacement.GetTargetCoordinate();
     this.current      = displacement.GetStartCoordinate();
     this.conflict     = false;
     this.outOfBounds  = false;
 }