Exemplo n.º 1
0
 private Move(TurnPlan owner, RelativeDirection direction, TileVector destination, int energyCost)
 {
     Owner       = owner;
     Direction   = direction;
     Destination = destination;
     EnergyCost  = energyCost;
 }
Exemplo n.º 2
0
	    public override bool Equals(object obj)
	    {
		    // Check for null values and compare run-time types.
		    if (obj == null || GetType() != obj.GetType())
			    return false;

		    TileVector t = (TileVector) obj;
		    return W == t.W && E == t.E;
	    }
Exemplo n.º 3
0
        public readonly UnitAvatar Avatar;              // Unity representation

        public Unit(UnitAvatar avatar, Player owner, TileVector position, CardinalDirection facing, bool mirrored)
        {
            // IMPLEMENTATION NOTE: Unit construction should not have any side effects. if you need to keep track
            //						of new units being created, you should call that from WorldController.AddUnit.
            Avatar = avatar;

            _moveMethod = Avatar.Ai.GetMovementPlan;
            Owner       = owner;

            Position = position;
            Facing   = facing;

            MaxHealth = Avatar.MaxHealth;
            Health    = MaxHealth;

            MaxEnergy = Avatar.MaxEnergy;
            Energy    = MaxEnergy;

            Mirrored = mirrored;
        }
Exemplo n.º 4
0
        /*public World(int map, int mapsize)
         * {
         *  W = mapsize;
         *  E = mapsize;
         *  _terrain = new Hex[mapsize, mapsize];
         *  String filename = "map" + map + ".txt";
         *  StreamReader reader = File.OpenText(filename);
         *  string line;
         *  int i = 0;
         *  while ((line = reader.ReadLine()) != null)
         *  {
         *      //just hextype
         *      string[] mapline = line.Split('\t');
         *      for(int j = 0; j < mapline.Length; j++)
         *      {
         *          if(mapline[j] == "-")
         *          {
         *                  //Do nothing
         *          }
         *          else if(mapline[j] == "o")
         *          {
         *              _terrain[i, j] = new Hex(HexType.Dirt, 1);
         *          }
         *          else
         *          {
         *              HexType type = (HexType)int.Parse(mapline[j]);
         *              _terrain[i, j] = new Hex(type);
         *          }
         *      }
         *      i++;
         *  }
         * }*/


        public Hex this[TileVector pos]
        {
            get { return(this[pos.W, pos.E]); }
        }
Exemplo n.º 5
0
 public CardinalDirection?GetApproximateDirectionTo(TileVector other)
 {
     return((other - this).GetApproximateDirection());
 }
Exemplo n.º 6
0
//	    public float GetBearing()
//	    {
//		    if (W == 0 && E == 0) return float.NaN;
//		    var mean = 0.0f;
//
//		    // negate negative components to simplify possibility space
//		    if (W >= 0) mean += CardinalDirection.Southwest.GetBearing() * W;
//		    else        mean -= CardinalDirection.Northeast.GetBearing() * W;
//		    if (E >= 0) mean += CardinalDirection.Southeast.GetBearing() * E;
//		    else        mean -= CardinalDirection.Northwest.GetBearing() * E;
//
//		    mean /= Math.Abs(W) + Math.Abs(E);              // take the mean angle
//
//		    if (W < 0 && E < 0)         // edge case: move interval midpoint from 180 to 0 degrees
//		    {
//			    mean = -180 - mean;
//			    while (mean < 0)		// correct negative values
//			    {
//				    mean += 360;
//			    }
//			}
//
//		    //Utils.Printf("{0}=>{1}", this, mean);
//		    return mean;
//	    }

        /// <summary>
        /// Get distance
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static int Distance(TileVector a, TileVector b)
        {
            TileVector diff = b - a;

            return(Math.Max(diff.W, diff.E));
        }