void Awake() { landNeighbors = new int[]{0,0,0,0,0,0}; neighbors = new TerrainProperties[6]; obj = gameObject; type = TileTypes.WATER; }
public Wall(Index2D start, Index2D end, TileTypes t, Element theme, bool move = false) { StartCell = start; EndCell = end; Type = t; Theme = theme; Traversable = move; }
//Std constructor public Tile(int x, int y, int movementSpeed, TileTypes type, GameObject visualPrefab) { this.x = x; this.y = y; this.movementCost = movementSpeed; this.type = type; this.VisualTile = GameObject.Instantiate (visualPrefab); }
private void TileContextMenuClick(object sender, RoutedEventArgs e) { var mitem = sender as MenuItem; if (mitem == null) return; TileTypes res; if (!Enum.TryParse(mitem.Header as string, true, out res)) return; _selectedTileType = res; }
public bool ObjectOnTile(GameObject _object, TileTypes _tile) { int objectPos = (int)((_object.transform.position.y) + (rows/2) + 1); if (tileStructure [objectPos] == _tile) { return true; } return false; }
public bool PositionOnTile(int _position, TileTypes _tile) { _position = (int)(_position + (rows/2) + 1); if (tileStructure [_position] == _tile) { return true; } return false; }
public void OnMouseInteraction() { if (EventSystem.current.IsPointerOverGameObject()) { if (EventSystem.current.currentSelectedGameObject != null && EventSystem.current.currentSelectedGameObject.GetComponent<Button>()) { return; } } if (Input.GetMouseButtonDown(0)) { isMouseDown = true; // define new tile type if (game.tool == GameTools.TILE) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.transform !=null && hit.transform.tag == "Tile") { Tile tile = hit.transform.GetComponent<Tile>(); newTileType = tile.type == TileTypes.WATER ? TileTypes.GROUND : TileTypes.WATER; } } } if (Input.GetMouseButtonUp(0)) { isMouseDown = false; lastX = -1; lastY = -1; DeselectSelectedEntity(); } if (isMouseDown) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.transform != null) { switch (hit.transform.tag) { case "Tile": // interact with tiles ClickOnTile(hit.transform.GetComponent<Tile>()); break; case "Entity": if (selectedEntity) { return; } // interact with entities Entity entity = hit.transform.GetComponent<Entity>(); if (Input.GetKey(KeyCode.LeftShift)) { DeleteEntity(entity); } else { SelectEntity(entity); } break; } } } }
public BuildQuest(ref TileTypes passbackRoomType, int timeLimit) : base(timeLimit) { listOfQuests = new string[1]; string roomToBuild = getRoom(); listOfQuests[0] = @"I bid you good tidings my friends. I bear grave news of an attack that is being plotted against you by the foul knights. You must expand your lair to prepare for their coming! I implore you to build " + roomToBuild + " You have " + timeLimit + " seconds! Get to it!"; questText = listOfQuests[UnityEngine.Random.Range(0, listOfQuests.Length)]; passbackRoomType = roomType; }
/// <summary> /// Board generation creates the board for play. The board uses a doubly linked list for its design. /// </summary> /// <param name="boardSize">Board size is the total size of the board</param> /// <param name="initialReachable">The number of spaces that are reachable without accounting for special tiles</param> /// <param name="minMove">The min movement a player can make in a turn</param> /// <param name="maxMove">The max movement a player can make in a turn</param> /// <param name="moveBackCount">The number of move back spaces</param> /// <param name="moveForwardCount">The number of move forward spaces</param> /// <param name="prizes">All the game prizes</param> /// <param name="moveForward">How far move forward tiles will move you</param> /// <param name="moveBack">How far move back tiles will move you</param> /// <returns>Returns the first tile of the board.</returns> public ITile GenerateBoard(int boardSize, int initialReachable, int minMove, int maxMove, int moveBackCount, int moveForwardCount, PrizeLevels.PrizeLevels prizes, int moveForward = 1, int moveBack = 1) { int numberOfCollectionSpots = 0; foreach (PrizeLevels.PrizeLevel p in prizes.prizeLevels) { if ( _threadCancel != null && _threadCancel.Cancel ) return null; numberOfCollectionSpots += p.numCollections; } FillInBlankBoardTiles(boardSize); if ( _threadCancel != null && _threadCancel.Cancel ) return null; TileTypes[] specialTiles = new TileTypes[moveBackCount + moveForwardCount]; TileTypes[] collectionTiles = new TileTypes[numberOfCollectionSpots]; for ( int i = 0; i < collectionTiles.Length && !( _threadCancel != null && _threadCancel.Cancel ); ++i ) { collectionTiles[i] = TileTypes.collection; } if ( _threadCancel != null && _threadCancel.Cancel ) return null; int index = 0; while ( index < specialTiles.Length && !( _threadCancel != null && _threadCancel.Cancel ) ) { if (index < moveForwardCount) { specialTiles[index] = TileTypes.moveForward; } else { specialTiles[index] = TileTypes.moveBack; } ++index; } if ( _threadCancel != null && _threadCancel.Cancel ) return null; specialTiles = ArrayShuffler<TileTypes>.Shuffle(specialTiles); if ( _threadCancel != null && _threadCancel.Cancel ) return null; FillInSpecialTiles(initialReachable, minMove, maxMove, moveForward, moveBack, specialTiles); if ( _threadCancel != null && _threadCancel.Cancel ) return null; FillInSpecialTiles(initialReachable, minMove, maxMove, moveForward, moveBack, collectionTiles); if ( _threadCancel != null && _threadCancel.Cancel ) return null; FillInCollectionTileValues(minMove, numberOfCollectionSpots, prizes); if ( _threadCancel != null && _threadCancel.Cancel ) return null; ConnectTiles(boardSize, minMove, maxMove, moveBack, moveForward); return _firstTile; }
/// <summary> /// Changes the tile at position x and y to the TileType "type" /// </summary> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> /// <param name="type">New type</param> public void changeTileAtPosition(int x, int y, TileTypes type) { Tile t = tiles [x, y]; if (t != null) { if (t.type == type) return; t.destroy (); } t = tileFactory.MakeTile (x, y, type); tiles [x, y] = t; }
public Tile(char type,int xPoint, int yPoint , Map map ) { _xPoint = xPoint; _yPoint = yPoint; Elem = PokeElem.None; Status = TileState.Unknow; this.MapContent = map; switch (type) { case 'G': _type = TileTypes.Grass; break; case 'M': _type = TileTypes.Mountain; break; case 'L': _type = TileTypes.Volcano; break; case 'A': _type = TileTypes.Water; break; case 'C': _type = TileTypes.Cave; break; default: break; } }
public virtual void Init(Grid grid, TileTypes type, int x, int y, Color color) { this.grid = grid; this.type = type; this.x = x; this.y = y; this.color = color; // locate tile float ratio = grid.tileHeight / (float)grid.tileWidth; transform.localPosition = new Vector3(x, y * ratio, 0); // set tile image img = transform.Find("Sprite").GetComponent<SpriteRenderer>(); img.sortingOrder = grid.height - y - 10; img.material.color = color; }
public Tile MakeTile(int x, int y, TileTypes type) { TileCreationData retData = null; foreach (TileCreationData tcd in tileData) { if (tcd.type == type) { retData = tcd; break; } } if (retData == null) { Debug.LogError ("Trying to create tile of type '" + type + "' but TileFactory has no data about it"); return null; } return new Tile (x, y, retData.movementSpeed, type, retData.tilePrefab); }
private string getRoom() { int type = UnityEngine.Random.Range(0, 4); numOfRoomsToBuild = UnityEngine.Random.Range(1, 4); switch (type) { case 0: roomType = TileTypes.Dorm; return "a bunk room."; case 1: roomType = TileTypes.MessHall; return "a mess hall."; case 2: roomType = TileTypes.SummonRoom; return "a summoning room."; case 3: roomType = TileTypes.Dungeon; return "a prison room."; default: return "f*****g nothing because the code is f****d!. "; } }
public void Init(GameGrid grid, TileTypes type, int x, int y) { this.grid = grid; this.type = type; this.x = x; this.y = y; // locate tile float ratio = grid.tileHeight / (float)grid.tileWidth; transform.localPosition = new Vector3(x, y * ratio, 0); // create images dictionary: images will be accessible by state key for (int i = 0; i < tileSprites.Length; i++) { sprites.Add(tileSprites[i].state, tileSprites[i].sprite); } // set tile image img = transform.Find("Sprite").GetComponent<SpriteRenderer>(); img.sortingOrder = grid.height - y; // set tile state SetState(TileStates.NORMAL); }
public Floor(Index2D start, Index2D end, TileTypes t, Element theme, bool move = true, FloorTypes f = FloorTypes.Themed) { StartCell = start; EndCell = end; Type = t; Theme = theme; Traversable = move; FloorType = f; }
void SetupSpawner(float _yPos, TileTypes _type) { //Determine spawner position !!!Needs to be altered as larger objects pop onto screen Vector3 spawnerPos; Spawner.SpawnDirection dir; if (Random.value <= 0.5f) { spawnerPos = new Vector3(columns + 2, _yPos, 0); dir = Spawner.SpawnDirection.LEFT; } else { spawnerPos = new Vector3(-3, _yPos, 0); dir = Spawner.SpawnDirection.RIGHT; } //If a position for a spawner has been designated, then instantiate it and pass in the mapscale. GameObject spawnerInstance = Instantiate(spawnerPrefab, spawnerPos, Quaternion.identity) as GameObject; Spawner spawner = spawnerInstance.GetComponent<Spawner>(); //tileSpawnerChoices[(int)_type] SpawnChoices[] choices = tileSpawnerChoices[(int)_type].spawnChoices; int totalWeightedChance = tileSpawnerChoices [(int)_type].totalWeightedChance; int currentChance = 0; int rand = Random.Range (0, totalWeightedChance); for (int i = 0; i < choices.Length; ++i) { currentChance += choices[i].chance; if(rand <= currentChance) { int choicesLength = choices[i].objectTypes.Length; spawner.SetupSpawnerBasics(choicesLength, mapScale, dir); for(int j = 0; j < choicesLength; ++j) { spawner.SetupSpawnableObject(choices[i].objectTypes[j]); } break; } } //The types of things that can be spawned on each tile type /*switch(_type) { case TileTypes.WATER: //tileSpawnerChoices //Can spawn 1 type of object spawner.SetupSpawnerBasics(1, mapScale, dir); //Random variation for what objects to use float rand = Random.value; if(rand <= 0.3) { spawner.SetupSpawnableObject(ObjectType.SMALL_LOG); } else if(rand <= 0.7) { spawner.SetupSpawnableObject(ObjectType.MEDIUM_LOG); } else { spawner.SetupSpawnableObject(ObjectType.BIG_LOG); } break; case TileTypes.ROAD: spawner.SetupSpawnerBasics(2, mapScale, dir); float rand2 = Random.value; if(rand2 <= 0.3) { spawner.SetupSpawnableObject(ObjectType.CAR1); spawner.SetupSpawnableObject(ObjectType.CAR2); } else if(rand2 <= 0.7) { spawner.SetupSpawnableObject(ObjectType.CAR3); spawner.SetupSpawnableObject(ObjectType.CAR2); } else { spawner.SetupSpawnableObject(ObjectType.CAR2); spawner.SetupSpawnableObject(ObjectType.CAR3); } break; }*/ //Alters position of spawner based on largest object it can spawn spawner.AdjustPosition (); //Parent spawners to the map spawnerInstance.transform.SetParent(mapHolder); spawner.SpawnInitialObjects (); }
// Assumes tile coordinates // Retuurns true if we did place said tile public bool placeTile(Vector2 pos, TileTypes type, bool overwrite=false) { if(overwrite){ // Remove the tile before we begni if there is already one at that position Tile oldTile = level.removeTile(pos); if (oldTile != null){ Destroy(oldTile.go); } }else{ Tile t = level.getTileAt(pos); if(t != null){ return false; } } Vector3 realPos = new Vector3(pos.x * tileSize, pos.y * tileSize, 0); GameObject prefab; switch(type){ case TileTypes.black: prefab = blackTile; break; case TileTypes.white: prefab = whitetile; break; default: prefab = whitetile; break; } Tile tile = new Tile(); tile.x = pos.x; tile.y = pos.y; tile.type = type; GameObject tObj = Instantiate(prefab, realPos, Quaternion.identity) as GameObject; tile.go = tObj; level.setTile(tile); return true; }
public Wall(Index2D start, Index2D end, Orientations or, TileTypes t, Element theme = Element.DEFAULT, bool move = false) { StartCell = start; EndCell = end; Type = t; Theme = theme; Traversable = move; Orientation = or; }
public void ChangeTile(Tile tile, TileTypes type, Color color) { SetTile(tile.x, tile.y, CreateTile(tile.x, tile.y, type, color)); Destroy(tile.gameObject); }
public TileInformation() { go = null; tileType = TileTypes.ground; }
/// <summary> /// Returns a tileinfo from a list of tiles that has a specific type /// </summary> /// <param name="tiles"></param> /// <param name="exitDirectionBits"></param> /// <returns></returns> private static TileInfo GetTileInfo(Dictionary <int, TileInfo> tiles, TileTypes tileType) { var tilesWithRightType = (from pair in tiles where (pair.Value.TileType == (int)tileType) select pair.Value); return(RandomHelper.RandomItem(tilesWithRightType, x => 1)); }
// This resets the tile's TileData properties to their defaults. Match and // checked flags will be both false and the type will be None if type // parameter is not specified. public void ResetTile( int x, int y, TileTypes type = TileTypes.None ) { ResetTile( GetTileIndex( x, y ), type ); }
// Constructors public Tile(TileTypes _baseType) { this.baseType = _baseType; init(); }
private static bool ContainsTileType(Dictionary <Vector3D, TileInfo> worldTiles, TileTypes tileType) { foreach (var tileInfo in worldTiles) { if (tileInfo.Value.TileType == (int)tileType) { return(true); } } return(false); }
public void OnMouseInteraction() { if (EventSystem.current.IsPointerOverGameObject()) { if (EventSystem.current.currentSelectedGameObject != null && EventSystem.current.currentSelectedGameObject.GetComponent <Button>()) { return; } } if (Input.GetMouseButtonDown(0)) { isMouseDown = true; // define new tile type if (game.tool == GameTools.TILE) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.transform != null && hit.transform.tag == "Tile") { Tile tile = hit.transform.GetComponent <Tile>(); newTileType = tile.type == TileTypes.WATER ? TileTypes.GROUND : TileTypes.WATER; } } } if (Input.GetMouseButtonUp(0)) { isMouseDown = false; lastX = -1; lastY = -1; DeselectSelectedEntity(); } if (isMouseDown) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.transform != null) { switch (hit.transform.tag) { case "Tile": // interact with tiles ClickOnTile(hit.transform.GetComponent <Tile>()); break; case "Entity": if (selectedEntity) { return; } // interact with entities Entity entity = hit.transform.GetComponent <Entity>(); if (Input.GetKey(KeyCode.LeftShift)) { DeleteEntity(entity); } else { SelectEntity(entity); } break; } } } }
public LevelTile(TileTypes type) { Type = type; }
public TileInformation(GameObject _go, TileTypes _type) { go = _go; tileType = _type; }
public Tile() { occupied = true; id = 0; tileType = TileTypes.Normal; }
private void SetTile(int x, int y, TileTypes tileType) { }
public Tile MakeTile(Position position, TileTypes type) { return this.MakeTile (position.x, position.y, type); }
//Returns a tile control if passed a value from tile types enum public static Tile extractControlFromType(TileTypes tileType, Zone zone) { TileTypes baseType; if (zone == Zone.Cave) { baseType = TileTypes.Stone; } else { baseType = TileTypes.Grass; } switch (tileType) { case TileTypes.Grass: { return(new Grass()); } case TileTypes.Stone: { return(new Stone()); } case TileTypes.Tree: { return(new Tree(baseType)); } case TileTypes.Sticks: { return(new Sticks(baseType)); } case TileTypes.Rocks: { return(new Rocks(baseType)); } case TileTypes.Bush: { return(new Bush()); } case TileTypes.Water: { return(new Water()); } case TileTypes.Ravine: { return(new Ravine()); } case TileTypes.Bridge: { if (zone == Zone.Cave) { baseType = TileTypes.Ravine; } else { baseType = TileTypes.Water; } return(new Bridge(baseType)); } case TileTypes.Cave: { return(new Cave(baseType)); } case TileTypes.Hostile: { return(new HostileAnimal(baseType)); } case TileTypes.Passive: { return(new PassiveAnimal(baseType)); } case TileTypes.Treasure: { return(new Treasure(baseType)); } case TileTypes.Chest: { return(new Chest(baseType)); } case TileTypes.Home: { return(new HomeVillage(baseType)); } default: // Defaults to base type if (zone == Zone.Cave) { return(new Stone()); } else { return(new Grass()); } } ; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.LabelField(new Rect(position.xMin, position.yMin, position.width * 0.3f, 32f * 0.45f), label); SerializedProperty tt = property.FindPropertyRelative("m_type"); TileTypes newVal = (TileTypes)EditorGUI.EnumPopup(new Rect(position.xMin, position.yMin + 32f * 0.5f, position.width * 0.3f, 32f * 0.45f), (TileTypes)tt.enumValueIndex); tt.enumValueIndex = (int)newVal; SerializedProperty tile = property.FindPropertyRelative("m_tile"); tile.objectReferenceValue = EditorGUI.ObjectField(new Rect(position.xMin + position.width * 0.33f, position.yMin, position.width * 0.66f, 32f * 0.45f), tile.objectReferenceValue, typeof(GameObject), false); SerializedProperty blown = property.FindPropertyRelative("m_blownTile"); blown.objectReferenceValue = EditorGUI.ObjectField(new Rect(position.xMin + position.width * 0.33f, position.yMin + 32f * 0.5f, position.width * 0.66f, 32f * 0.45f), blown.objectReferenceValue, typeof(GameObject), false); GUIStyle newStyle = new GUIStyle(EditorStyles.miniLabel); newStyle.alignment = TextAnchor.MiddleRight; newStyle.fontSize = 10; newStyle.padding = new RectOffset(0, 0, 0, 0); newStyle.margin = new RectOffset(0, 0, 0, 0); SerializedProperty isBlown = property.FindPropertyRelative("m_isBlown"); EditorGUI.LabelField(new Rect(position.xMin + position.width * 0.33f, position.yMin + 28f, position.width * 0.3f - 15f, 14f), "Blown", newStyle); isBlown.boolValue = EditorGUI.Toggle(new Rect(position.xMin + position.width * 0.33f + position.width * 0.3f - 30f, position.yMin + 28f, 14f, 14f), isBlown.boolValue); SerializedProperty isBurn = property.FindPropertyRelative("m_isBurning"); EditorGUI.LabelField(new Rect(position.xMin + position.width * 0.66f, position.yMin + 28f, position.width * 0.3f - 15f, 14f), "Burning", newStyle); isBurn.boolValue = EditorGUI.Toggle(new Rect(position.xMin + position.width * 0.66f + position.width * 0.3f - 30f, position.yMin + 28f, 14f, 14f), isBurn.boolValue); EditorGUI.DrawRect(new Rect(position.xMin, 38f, position.width, 2f), Color.grey); }
public Tile(VectorInt2 position, TileTypes tileType) { X = position.X; Y = position.Y; TileType = tileType; }
public HitInfo(TileTypes tile, bool powered) { TileType = tile; Powered = powered; }
public Tile(int x, int y, TileTypes tileType) { X = x; Y = y; TileType = tileType; }
/// <summary> /// Sets the different attributes /// </summary> /// <param name="type">The type of tile</param> /// <param name="hasCrump">Whether the tile has a crump</param> /// <param name="hasPowerPill">Whether the tile has a power pill</param> public Tile(TileTypes type, bool hasCrump, bool hasPowerPill, Point position) { type_ = type; hasCrump_ = hasCrump; if (hasCrump) { Grid.NumCrumps++; } hasPowerPill_ = hasPowerPill; position_ = position; }
public Tile newTileOnSamePosition(TileTypes newType) { return(new Tile(Position, newType)); }
public Room(Index2D start, Index2D end, Element theme, TileTypes f = TileTypes.Floor, bool move = true) { StartCell = start; EndCell = end; FloorType = f; Theme = theme; Traversable = move; }
void DrawTerrainAndBuildingsGUI(int WindowID) { // //Draw Buttons and catch the button on which is pressed in these new ints int terrainListEntry = -1; int buildingsListEntry = -1; //Terrain GUI.Label(new Rect(10, 20, 200, 20), "Terrain"); terrainListEntry = GUI.SelectionGrid(new Rect(10, 40, 200, 160), -1, TileTypes.TerrainGUIContentList, 3); //Buildings GUI.Label(new Rect(10, 210, 200, 20), "Buildings"); _selectedBuildingsColour = (TeamsInfo.Colour)GUI.SelectionGrid(new Rect(10, 230, 200, 20), (int)_selectedBuildingsColour, TeamsInfo.ColourGUIContentList, 7); buildingsListEntry = GUI.SelectionGrid(new Rect(10, 260, 200, 80), -1, TileTypes.BuildingsGUIContentList, 3); // //See if any button was hit this time if (terrainListEntry != -1 || buildingsListEntry != -1) { //If left button was pressed if (Event.current.button == 0) //LEFT { //Convert terrain id to list id int id = TileTypes.TerrainIDToListID(terrainListEntry); //See if it is a proper ListID if (id >= 0) { //Set the left type _leftType = TileTypes.GetTileInfo(id); } //If it is not a proper listID try the same for buildingsListEntry else { id = TileTypes.BuildingsIDToListID(buildingsListEntry); if (id >= 0) { _leftType = TileTypes.GetTileInfo(id); } } //Remember id to be able to draw the mouse icons. _leftListEntry = id; } //And the same for the right button else if (Event.current.button == 1) //RIGHT { int id = TileTypes.TerrainIDToListID(terrainListEntry); if (id >= 0) { _rightType = TileTypes.GetTileInfo(id); } else { id = TileTypes.BuildingsIDToListID(buildingsListEntry); if (id >= 0) { _rightType = TileTypes.GetTileInfo(id); } } //Remember id to be able to draw the mouse icons. _rightListEntry = id; } } // //Draw the mouse icons on the correct button //------------------------------------------------------------------------------------ Rect leftPos = new Rect(0, 0, 11, 14), rightPos = new Rect(0, 0, 11, 14); //Calculate the x-positions int step = 68; int offset = -6; if (_leftListEntry < TileTypes.NumberOfTerrainTypes()) { leftPos.x = (_leftListEntry % 3 + 1) * step + offset; } else { leftPos.x = ((_leftListEntry - TileTypes.NumberOfTerrainTypes()) % 3 + 1) * step + offset; } if (_rightListEntry < TileTypes.NumberOfTerrainTypes()) { rightPos.x = (_rightListEntry % 3 + 1) * step + offset; } else { rightPos.x = ((_rightListEntry - TileTypes.NumberOfTerrainTypes()) % 3 + 1) * step + offset; } //Now calculate the y-positions int stepY = 41; int buildingsY = 220; int extraY = 3; int rightExtraY = 16; if (_leftListEntry < TileTypes.NumberOfTerrainTypes()) { leftPos.y = (_leftListEntry / 3 + 1) * stepY + extraY; } else { leftPos.y = ((_leftListEntry - TileTypes.NumberOfTerrainTypes()) / 3 + 1) * stepY + buildingsY + extraY; } if (_rightListEntry < TileTypes.NumberOfTerrainTypes()) { rightPos.y = (_rightListEntry / 3 + 1) * stepY + rightExtraY + extraY; } else { rightPos.y = ((_rightListEntry - TileTypes.NumberOfTerrainTypes()) / 3 + 1) * stepY + buildingsY + rightExtraY + extraY; } //Draw Left GUI.DrawTexture(leftPos, _mouseLeft); //Draw Right GUI.DrawTexture(rightPos, _mouseRight); DrawGUIWindowCloseButton(ref _drawTerrainAndBuildingsWindow); GUI.DragWindow(new Rect(0, 0, 10000, 20)); }
private static (int matches, int maxMatches) FindMatches(this List <List <TileTypes> > input, int x, int y, TileTypes match, bool processAllVisible = false) { var maxMatches = 0; var matches = 0; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i == 0 && j == 0) { continue; } TileTypes?element = processAllVisible ? GetFirstSeat(input, x, y, i, j) : GetFirstSeatAdjacent(input, x, y, i, j); if (element == TileTypes.FLOOR || element == null) { continue; } maxMatches++; matches += (element == match) ? 1 : 0; } } return(matches, maxMatches); }
private static bool ContainsTileType(Dictionary<Vector3D, TileInfo> worldTiles, TileTypes tileType) { foreach (var tileInfo in worldTiles) { if (tileInfo.Value.TileType == (int)tileType) return true; } return false; }
public void SetTileType(TileTypes newType) { tileType = newType; }
/// <summary> /// Constructor /// </summary> /// <param name="startLat"></param> /// <param name="startLon"></param> /// <param name="targetLat"></param> /// <param name="targetLon"></param> /// <param name="body"></param> /// <param name="types"></param> internal PathFinder(double startLat, double startLon, double targetLat, double targetLon, CelestialBody body, TileTypes types) { startLatitude = startLat; startLongitude = startLon; targetLatitude = targetLat; targetLongitude = targetLon; mainBody = body; tileTypes = types; estimate = Estimate; tiles = new List <Hex>(); directions = new Dictionary <int, Point> { { 0, new Point(0, -1) }, // 0 degree { 60, new Point(1, -1) }, // 60 { 120, new Point(1, 0) }, // 120 { 180, new Point(0, 1) }, // 180 { 240, new Point(-1, 1) }, // 240 { 300, new Point(-1, 0) } // 300 }; }
public Tile(int newID) { occupied = true; id = newID; tileType = TileTypes.Normal; }
/* Set in-editor state */ private void Start() { LevelManager.Instance.IsInEditor = true; currentBrushType = (TileTypes)Enum.GetValues(typeof(TileTypes)).GetValue(0); }
// Base_Tile() Constructor public Base_Tile(Texture2D texture, float xPos, float yPos, Color colorOverlay, TileTypes tileType) : base(texture, xPos, yPos, colorOverlay) { this.tileType = tileType; }
//creates a grid of path nodes //if noRotation true then level will generate with non-rotatable tiles void GridInit(bool noRotation) { float XTcounter = 0; //adjusts spawn rate of X and T based on how many already spawned Random.InitState(seed); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { List <int> connections = new List <int>(); //weighted randomness, I and L are more common than X and T int typeNum = (int)Mathf.Floor(Mathf.Pow(Random.value, 2) * (4 - (XTcounter / 10))); if (typeNum > 4) { typeNum = 4; } TileTypes type = (TileTypes)typeNum; switch (type) { case TileTypes.L: XTcounter -= .15f; connections.Add(3); connections.Add(2); break; case TileTypes.T: XTcounter++; connections.Add(0); connections.Add(3); connections.Add(2); break; case TileTypes.I: XTcounter -= .15f; connections.Add(0); connections.Add(2); break; case TileTypes.X: XTcounter++; connections.Add(3); connections.Add(2); connections.Add(1); connections.Add(0); break; default: break; } bool noRot = false; if (noRotation) { if (Random.value < .08f) //5% chance of tile being no rotation { noRot = true; } } pathNodes[x, y] = new PathNode(connections); //TileManager.Instance.AddTile(x, y, type, noRot); int rotations = Random.Range(0, 4); switch (rotations) { case 0: TileManager.Instance.AddTile(x, y, type, noRot); break; case 1: StartCoroutine(TileManager.Instance.AddTile(x, y, type, noRot).RotateOverTime(true, 0.01f, 90)); break; case 2: StartCoroutine(TileManager.Instance.AddTile(x, y, type, noRot).RotateOverTime(true, 0.01f, 180)); break; case 3: StartCoroutine(TileManager.Instance.AddTile(x, y, type, noRot).RotateOverTime(true, 0.01f, 270)); break; } } } }
/// <summary> /// Creates a tile of the specified type. /// </summary> /// <param name="type">The type of tile to create.</param> public static Tile TileFactory( TileTypes type ) { switch( type ) { case TileTypes.Empty: return new EmptyTile(); case TileTypes.Field: return new FieldTile(); case TileTypes.Room: return new RoomTile(); case TileTypes.Pasture: return new PastureTile(); default: throw new ArgumentOutOfRangeException(); } }
public Tile(int x, int y, TileTypes tileType) { TileType = tileType; xLoc = x; yLoc = y; }
// Refer to above description. public void ResetTile( int index, TileTypes type = TileTypes.None ) { TileData tile = GetTile( index ); if( tile != null ) { tile.m_isChecked = false; tile.m_isMatched = false; tile.m_type = type; } }
public Map(TileTypes v, int s) { this.tileType = v; size = s; InitialiseTiles(); }
// =============================================================== // Tiles // =============================================================== public Tile CreateTile(int x, int y, TileTypes type, Color color) { Transform parent = container.Find("Tiles/" + type.ToString()); GameObject obj = (GameObject)Instantiate(prefabs.tiles[type]); obj.transform.SetParent(parent, false); obj.name = type.ToString(); //"Tile " + x + " " + y; Tile tile = obj.GetComponent<Tile>(); tile.Init(this, type, x, y, color); SetTile(x, y, tile); return tile; }
protected virtual void Awake() { _type = new TileTypes(); _type.Type = TileTypes.ESubState.blue; //Needs randomization; _image = gameObject.GetComponent <Image>(); }
public TileCreationData(TileTypes type, int movementSpeed, GameObject prefab) { this.type = type; this.movementSpeed = movementSpeed; this.tilePrefab = prefab; }
public override bool CanDo(Game g) { if (PrevX == -1 && PrevY == -1) { return(true); // Initialisation du Board } if (g.MoveBallCount == 1 && PrevX != -1 && PrevY != -1) { return(false); } TileTypes tile = g.Board.Tiles[PrevX, PrevY]; bool okay = true; if (NextX == PrevX) // déplacement en colonne { for (int i = Math.Min(PrevY, NextY) + 1; i < Math.Max(PrevY, NextY); i++) { if (g.Board.Tiles[NextX, i] != TileTypes.Default) { okay = false; } } } else if (NextY == PrevY) // déplacement en ligne { for (int i = Math.Min(PrevX, NextX) + 1; i < Math.Max(PrevX, NextX); i++) { if (g.Board.Tiles[i, NextY] != TileTypes.Default) { okay = false; } } } else if (PrevY < NextY && PrevX < NextX) // diagonale BasDroite { for (int i = 1; i < NextY - PrevY; i++) { if (g.Board.Tiles[PrevX + i, PrevY + i] != TileTypes.Default) { okay = false; } } } else if (PrevY > NextY && PrevX > NextX) // diagonale HautGauche { for (int i = 1; i < PrevY - NextY; i++) { if (g.Board.Tiles[PrevX - i, PrevY - i] != TileTypes.Default) { okay = false; } } } else if (PrevY < NextY && PrevX > NextX) // diagonale BasGauche { for (int i = 1; i < NextY - PrevY; i++) { if (g.Board.Tiles[PrevX - i, PrevY + i] != TileTypes.Default) { okay = false; } } } else if (PrevY > NextY && PrevX < NextX) // diagonale HautDroit { for (int i = 1; i < NextX - PrevX; i++) { if (g.Board.Tiles[PrevX + i, PrevY - i] != TileTypes.Default) { okay = false; } } } switch (tile) // Chelou ? { case TileTypes.BallPlayer0: if (g.Board.Tiles[NextX, NextY] == TileTypes.PiecePlayer0) { if (okay) { return(true); } } else { return(false); } break; case TileTypes.BallPlayer1: if (g.Board.Tiles[NextX, NextY] == TileTypes.PiecePlayer1) { if (okay) { return(true); } } else { return(false); } break; default: return(false); } return(false); }
void ChangeBoardSize(int newNumCols, int newNumRows, int dir, TileInfo tileInfo) { // 0=UL 1=UM 2=UR // 3=L 4=M 5=R // 6=LL 7=LM 8=LR //Check if there is a resizing if (newNumCols == _boardScript.GetNumberOfColumns() && newNumRows == _boardScript.GetNumberOfRows()) { return; } //Backup the old array BasicTile[,] backupArr = (BasicTile[, ])_boardScript.BoardTiles.Clone(); //Set begin position for copy depending on the direction // COLUMNS // int beginColNew; int beginColBackup; if (newNumCols == _boardScript.GetNumberOfColumns()) { beginColNew = 0; beginColBackup = 0; } else if (newNumCols > _boardScript.GetNumberOfColumns()) { if (dir == 0 || dir == 3 || dir == 6) { beginColNew = 0; } else if (dir == 1 || dir == 4 || dir == 7) { beginColNew = (newNumCols - _boardScript.GetNumberOfColumns()) / 2; } else { beginColNew = newNumCols - _boardScript.GetNumberOfColumns(); } beginColBackup = 0; } else { if (dir == 0 || dir == 3 || dir == 6) { beginColBackup = 0; } else if (dir == 1 || dir == 4 || dir == 7) { beginColBackup = (_boardScript.GetNumberOfColumns() - newNumCols) / 2; } else { beginColBackup = _boardScript.GetNumberOfColumns() - newNumCols; } beginColNew = 0; } // ROWS // int beginRowNew; int beginRowBackup; if (newNumRows == _boardScript.GetNumberOfRows()) { beginRowNew = 0; beginRowBackup = 0; } else if (newNumRows > _boardScript.GetNumberOfRows()) { if (dir == 6 || dir == 7 || dir == 8) // || newNumRows <= _boardScript.GetNumberOfRows()) { beginRowNew = 0; } else if (dir == 3 || dir == 4 || dir == 5) { beginRowNew = (newNumRows - _boardScript.GetNumberOfRows()) / 2; } else { beginRowNew = newNumRows - _boardScript.GetNumberOfRows(); } beginRowBackup = 0; } else { if (dir == 6 || dir == 7 || dir == 8) // || newNumRows <= _boardScript.GetNumberOfRows()) { beginRowBackup = 0; } else if (dir == 3 || dir == 4 || dir == 5) { beginRowBackup = (_boardScript.GetNumberOfRows() - newNumRows) / 2; } else { beginRowBackup = _boardScript.GetNumberOfRows() - newNumRows; } beginRowNew = 0; } //Create the new board CreateNewBoard(newNumCols, newNumRows, tileInfo); //To copy (when reducing size) int colsToCopy = Mathf.Min(backupArr.GetLength(0), newNumCols); int rowsToCopy = Mathf.Min(backupArr.GetLength(1), newNumRows);; //Copy backup into new with proper begin position for (int col = 0; col < colsToCopy; ++col) { for (int row = 0; row < rowsToCopy; ++row) { TileInfo oldTileInfo = TileTypes.GetTileInfo(backupArr[beginColBackup + col, beginRowBackup + row].tag); TeamsInfo.Colour oldColour = backupArr[beginColBackup + col, beginRowBackup + row].Colour; ChangeTileToType(oldTileInfo, oldColour, beginColNew + col, beginRowNew + row); } } }
public Sprite TileSpriteChange(TileTypes _tiletype) { return(Resources.Load <Sprite>(_tiletype.ToString())); }
/// <summary> /// Returns a tileinfo from a list of tiles that has a specific type /// </summary> /// <param name="tiles"></param> /// <param name="exitDirectionBits"></param> /// <returns></returns> private static TileInfo GetTileInfo(Dictionary<int, TileInfo> tiles, TileTypes tileType) { var tilesWithRightType = (from pair in tiles where (pair.Value.TileType == (int)tileType) select pair.Value); return RandomHelper.RandomItem(tilesWithRightType, x => 1); }
/* Set the active brush for painting */ public void SetActiveBrush(TileTypes brush) { currentBrushType = brush; }