/// <summary> /// Gets the tile index according to the number of specified neighbor roads /// </summary> /// <returns> /// The index. /// </returns> /// <param name='f'> /// The directions of neighboring roads. /// </param> public int GetRoadIndex(Facing[] f) { if(f.Count() > 4) throw new Exception("There cannot be more than 4 possible neighbors"); else if(f.Count() == 4) return Tiles.ROAD4WAY; else if(f.Count() == 3) return Tiles.ROAD3WAY; else if(f.Count() == 2){ if((f.Contains(Facing.North) && f.Contains(Facing.West)) || (f.Contains(Facing.South) && f.Contains(Facing.East))) return Tiles.CORNER; else if((f.Contains(Facing.South) && f.Contains(Facing.West)) || (f.Contains(Facing.North) && f.Contains(Facing.East))) return Tiles.CORNER2; else if((f.Contains(Facing.North) && f.Contains(Facing.South)) || (f.Contains(Facing.West) && f.Contains(Facing.East))) return Tiles.ROAD; } //If f.Count == 1 or 0 return Tiles.ROAD; }
//TODO: Fix the road flip values to reflect Facing North = x-- public bool[] GetRoadFlip(Facing[] f) { if (f.Count() > 4) throw new Exception ("Cannot have more than 4 possible neighbors!"); //If we know its a 4way. else if (f.Count() == 4) return new bool[]{false,false}; //Check the 3ways else if (f.Count() == 3) { if (f.Contains (Facing.North) && f.Contains (Facing.West) && f.Contains (Facing.East)) return new bool[]{true,true}; else if (f.Contains (Facing.North) && f.Contains (Facing.West) && f.Contains (Facing.South)) return new bool[]{true,false}; else if (f.Contains (Facing.North) && f.Contains (Facing.South) && f.Contains (Facing.East)) return new bool[]{false,true}; else if (f.Contains (Facing.West) && f.Contains (Facing.South) && f.Contains (Facing.East)) return new bool[]{false,false}; } //Check the corners and roads else if (f.Count() == 2) { //Corner if (f.Contains (Facing.North) && f.Contains (Facing.West)) return new bool[]{false,false}; else if (f.Contains (Facing.South) && f.Contains (Facing.East)) return new bool[]{false,true}; //Corner2 else if (f.Contains (Facing.North) && f.Contains (Facing.East)) return new bool[]{false,false}; else if (f.Contains (Facing.South) && f.Contains (Facing.West)) return new bool[]{true,false}; //Roads else if (f.Contains (Facing.North) && f.Contains (Facing.South)) return new bool[]{false,false}; else if (f.Contains (Facing.East) && f.Contains (Facing.West)) return new bool[]{false,true}; } else if (f.Count() == 1) { if (f.Contains (Facing.North) || f.Contains (Facing.South)) return new bool[]{false,false}; else if (f.Contains (Facing.West) || f.Contains (Facing.East)) return new bool[]{false,true}; } else if(f.Count () == 0) return new bool[]{false,false}; throw new Exception("Array was malformed, contained duplicates, or just plain wrong."); }