public IEnumerator setTilePrefab(string tileTypeName) { //Shrink existing tiles if (ground != null) { StartCoroutine(lerpObjToScale(ground, new Vector3(0f, 0, 0f), 0.25f)); } if (tile != null) { StartCoroutine(lerpObjToScale(tile, new Vector3(0f, 0, 0f), 0.25f)); } //Find new tilePrefab GameObject tilePrefab = getTilePrefab(tileTypeName); //Wait till existing tiles finish shrinking and delete while (tileIsChanging) { yield return(new WaitForSeconds(0.1f)); } Destroy(tile); tile = Instantiate(tilePrefab, transform.position, transform.rotation, transform); currentTileType = getTileTypeByName(tileTypeName); isTileBlank = false; tile.transform.localScale = Vector3.zero; StartCoroutine(lerpObjToScale(tile, new Vector3(0.1f, 1, 0.1f), 0.25f)); if (!tileTypeName.Contains("Blank")) { ground.transform.localScale = Vector3.zero; ground.SetActive(true); StartCoroutine(lerpObjToScale(ground, new Vector3(1.0f, 50.0f, 1.0f), 0.25f)); } yield return(null); }
public void setTileType(tileType type) { this.type = type; }
private tileType[,] genTiles() { tileType[,] tiles = new tileType[size.x, size.y]; Simplex.Noise.Seed = rngSeed; float scale = 0.005f; float[,] noiseMap = Simplex.Noise.Calc2D(size.x, size.y, scale); vector2f range = getRange(noiseMap); for (int x = 0; x < size.x; x++) { for (int y = 0; y < size.y; y++) { tiles[x, y] = tileType.water; if (isInHeight(noiseMap[x, y], range.y, 0.75f)) { tiles[x, y] = tileType.sand; } if (isInHeight(noiseMap[x, y], range.y, 0.65f)) { tiles[x, y] = tileType.grass; } if (isInHeight(noiseMap[x, y], range.y, 0.05f)) { tiles[x, y] = tileType.stone; } } } return(tiles); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.W)) { changePlacingTile(tiletypes[1]); activePlacement = true; } if (Input.GetKeyDown(KeyCode.E)) { changePlacingTile(tiletypes[0]); activePlacement = true; } if (Input.GetMouseButton(1)) { activePlacement = false; mouseIcon.sprite = null; } if (Input.GetMouseButtonDown(0) && activePlacement) { Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 10)); var tile = tiles.GetTile(tiles.WorldToCell(pos)); if (tile == airTile && tiles.GetTile(tiles.WorldToCell(pos) + new Vector3Int(0, -1, 0)) != airTile) { tiles.SetTile(tiles.WorldToCell(pos), placingBuilding.tile); var newRoom = new tileType(); newRoom.position = tiles.CellToWorld(tiles.WorldToCell(pos)); newRoom.cost = placingBuilding.cost; newRoom.time = placingBuilding.time; newRoom.occupied = false; RoomManager.instance.addRoom(newRoom); } } }
public void changedByButton(tileType newType) { Debug.Log("Change Type"); tType = newType; if (buttonActive) { buttonActive = false; if (tType == tileType.GateDown) { var mat = new Material[2]; mat[0] = gateMaterial[2]; mat[1] = gateMaterial[0]; objMeshRenderer.materials = mat; } } else { buttonActive = true; if (tType == tileType.GateUp) { var mat = new Material[2]; mat[0] = gateMaterial[2]; mat[1] = gateMaterial[1]; objMeshRenderer.materials = mat; } } }
private TileProperties[,] areasToTiles(tileType[,] mapAreas) { var mapTiles = new TileProperties[totalRows,totalCols]; var thisTile = StaticTiles.GrassTile; for (int ii=0; ii<totalRows; ii++) { for (int jj=0; jj<totalCols; jj++) { switch (mapAreas[ii,jj]) { case tileType.outdoor: thisTile = (rand.NextDouble() < 0.7) ? StaticTiles.GrassTile : StaticTiles.ForestTile; // eventually I need to make these into bunched forests break; case tileType.indoor: thisTile = StaticTiles.FloorTile; break; case tileType.door: thisTile = StaticTiles.FloorTile; break; case tileType.wall: thisTile = StaticTiles.WallTile; break; default: thisTile = StaticTiles.GrassTile; break; } mapTiles[ii,jj] = thisTile; } } return mapTiles; }
public void Init(Vector2 newCords, tileType newType) { cords = newCords; type = newType; anim.SetTrigger(type.ToString()); }
public GameObject createTile(tileType newTileType) { GameObject newTile = GameObject.Instantiate(genericTilePrefab); newTile.GetComponent <tileStatus> ().setTileType(newTileType); return(newTile); }
public Character(int tempHitPoints, int tempMaxHitPoints, int tempDamage, Tile[] tempCharacterVision, int x, int y, tileType typeTemp) : base(x, y, typeTemp) { //initialize character CharacterVision = tempCharacterVision; this.damage = tempDamage; this.hitPoints = tempHitPoints; this.maxHitPoints = tempMaxHitPoints; }
void Explore(bool bStartingTile = false) { // set variables this.exploration = 1.0f; this.state = tileState.IDLE; this.ressourceSpawnTime = GetSpawnTime(); GameObject.Find("Board").GetComponent <BoardBehavior>().bExploring = false; // update type if (bStartingTile) { this.type = tileType.PLAIN; } else { this.type = getRandomType(); this.progressBar.gameObject.SetActive(false); } // update material switch (this.type) { case tileType.FOREST: this.GetComponent <Renderer>().material = matForest; break; case tileType.HILL: this.GetComponent <Renderer>().material = matHill; break; case tileType.ROCKY: this.GetComponent <Renderer>().material = matRocky; break; case tileType.MOUNTAIN: this.GetComponent <Renderer>().material = matMountain; break; case tileType.PLAIN: this.GetComponent <Renderer>().material = matPlain; break; default: this.GetComponent <Renderer>().material = matUnexplored; break; } // create new neighbor if necessary foreach (location loc in location.GetValues(typeof(location))) { int x = GetNeighborX(loc); int y = GetNeighborY(loc); if (GameObject.Find("Tile_" + x + "_" + y) == null) { GameObject.Find("Board").GetComponent <BoardBehavior>().MakeTile(x, y); } } }
public userTileClass(int Xtemp, int Ytemp, tileType typetemp) { this.x = Xtemp; this.y = Ytemp; type = typetemp; }
public void setTileType(int typeValue) { if (typeValue >= 0 & typeValue <= 2) { thisTilesType = (tileType)typeValue; } else { thisTilesType = (tileType)0; } }
public void set(int x, int y, tileType t = tileType.unspecified, int id = -1000) { if (t != tileType.unspecified) { g[x + y * width.x].type = t; } if (id != -1000) { g[x + y * width.x].id = id; } }
public void copyTile(oldTile tileToCopy) { this.thisTilesEnergy = tileToCopy.thisTilesEnergy; this.thisTilesType = tileToCopy.thisTilesType; this.passable = tileToCopy.passable; this.tileRowNum = tileToCopy.tileRowNum; this.tileColumnNum = tileToCopy.tileColumnNum; this.worldPos = tileToCopy.worldPos; this.gridH = tileToCopy.gridH; this.gridW = tileToCopy.gridW; this.gridIndex = tileToCopy.gridIndex; }
public StoreObjectReference(GameObject obj, Sprite screenshot, string name_, tileType tileType_, int price_, int objectID_, int subID_) // Tile constructor { gameObject_ = obj; objectScreenshot = screenshot; productName = name_; objectID = objectID_; subID = subID_; objType = objectType.Tile; tilType = tileType_; boxWeight = -1; price = price_; }
public Tile(int id, int maxQuantity, Vector3 position, GameObject tileGameObj) { resourceType = type(id); maxResourceQuantity = maxQuantity; gridPosition = position; tileGameObject = tileGameObj; myType = rType(id); if (myType == tileType.empty) { movementCost = 10000; } }
public StoreObjectReference(GameObject obj, string name_, int objectID_, int subID_) // misc items constructor, not accessed by user but utilized ingame often { gameObject_ = obj; objectScreenshot = null; productName = name_; objectID = objectID_; subID = subID_; tilType = tileType.none; objType = objectType.Shelf; proType = productType.none; boxWeight = -1; price = 0; }
public StoreObjectReference(GameObject obj, Sprite screenshot, string name_, ContainerType type_, int price_, int objectID_, int subID_, int boxWeight_) { // Container constructor gameObject_ = obj; objectScreenshot = screenshot; productName = name_; objectID = objectID_; subID = subID_; boxWeight = boxWeight_; objType = objectType.Product; proType = productType.container; containerType = type_; tilType = tileType.none; price = price_; }
public StoreObjectReference(GameObject obj, Sprite screenshot, string name_, int price_, int objectID_, int subID_) // Store object addon constructor { gameObject_ = obj; objectScreenshot = screenshot; productName = name_; objectID = objectID_; subID = subID_; tilType = tileType.none; objType = objectType.StoreObjectAddon; proType = productType.none; containerType = ContainerType.none; boxWeight = -1; price = price_; }
public StoreObjectReference(GameObject obj, Sprite screenshot, string name_, productType type_, int price_, int objectID_, int subID_, int boxWeight_) // Product constructor { gameObject_ = obj; objectScreenshot = screenshot; productName = name_; objectID = objectID_; subID = subID_; boxWeight = boxWeight_; objType = objectType.Product; tilType = tileType.none; containerType = ContainerType.none; proType = type_; price = price_; color = ProductColor.GetRandomProductColor(); }
public IEnumerator bookRoom(tileType stay) { print("booked room"); stay.occupied = true; var guest = Instantiate(customer, stay.position, Quaternion.identity); yield return(new WaitForSeconds(stay.time)); stay.cost = stay.cost;//add price here FindObjectOfType <Try1>().addMoney((int)stay.cost); Destroy(guest); yield return(new WaitForSeconds(schedulingDelay)); stay.occupied = false; }
public void loadTile(XmlNode tileNode) { XmlAttributeCollection tileAttributes = tileNode.Attributes; setType = (tileType)typeNames.IndexOf(tileAttributes.GetNamedItem("type").Value); wealth = Convert.ToInt32(tileAttributes.GetNamedItem("wealth").Value); food = Convert.ToInt32(tileAttributes.GetNamedItem("food").Value); int waterMask = Convert.ToInt32(tileAttributes.GetNamedItem("RiverOnTile").Value); for (int i = 0; i < 6; i++) { bool water = Convert.ToBoolean(waterMask % 2); waterDirections[5 - i] = water; if (water) { hasWater = true; } waterMask = waterMask >> 1; } int ownerId = Convert.ToInt32(tileAttributes.GetNamedItem("Owner").Value); if (ownerId != -1) { owner = GameObject.Find("Player" + ownerId).GetComponent <Player>(); } XmlNode tileChildren = tileNode.FirstChild; bool city = Convert.ToBoolean(tileAttributes.GetNamedItem("City").Value); if (city) { GameObject newCity = Instantiate(Resources.Load <GameObject>("Prefabs/City")); newCity.transform.SetParent(transform, false); cityOnTile = newCity.GetComponent <City>(); cityOnTile.loadCity(tileChildren); owner.giveCity(cityOnTile); tileChildren = tileChildren.NextSibling; } while (tileChildren != null) { string unitType = tileChildren.Name; GameObject newUnit = (GameObject)Instantiate(Resources.Load("Prefabs/" + unitType)); newUnit.GetComponent <Unit>().loadUnit(tileChildren); tileChildren = tileChildren.NextSibling; } updateTileGraphics(); }
bool GenerateRoom(int roomWidth, int roomHeight, tileType roomType) { int row1 = Random.Range(1, floorArray.GetLength(0) - roomHeight - 2) / 2 * 2 + 1; int col1 = Random.Range(1, floorArray.GetLength(1) - roomWidth - 2) / 2 * 2 + 1; if (checkValidRoomGen(col1, row1, roomHeight, roomWidth)) { for (int xx = 0; xx < roomHeight; xx++) { for (int yy = 0; yy < roomWidth; yy++) { floorArray[col1 + xx, row1 + yy] = roomType; } } return(true); } return(false); }
protected void makeTile(tileType type, int y, int x) { float yPos = yInitial + (tileWidth * y); float xPos = xInitial + (tileWidth * x); GameObject newTile; if (type == tileType.Floor) { newTile = Instantiate(floorTile, transform, false); } else { newTile = Instantiate(wallTile, transform, false); } tiles[y, x] = newTile; newTile.transform.localPosition = new Vector3(xPos, yPos, 0.0f); }
public static List <GameObject> GetFieldsOfType_g(tileType type) { List <GameObject> result = new List <GameObject>(); for (int y = 0; y < landscape.GetLength(1); y++) { for (int x = 0; x < landscape.GetLength(0); x++) { Tile t = landscape[x, y].GetComponent <Tile>(); if (t.tile_type == type) { result.Add(landscape[x, y]); } } } return(result); }
public static List <HexaPos> GetFieldsOfType(tileType type) { List <HexaPos> result = new List <HexaPos>(); for (int y = 0; y < landscape.GetLength(1); y++) { for (int x = 0; x < landscape.GetLength(0); x++) { Tile t = landscape[x, y].GetComponent <Tile>(); if (t.tile_type == type) { HexaPos temp = new HexaPos(x, y); result.Add(temp); } } } return(result); }
public void TileSwitch(int trigger) { switch (trigger) { case 1: type = tileType.Empty; sprRen.sprite = empty; break; case 2: type = tileType.Open; sprRen.sprite = open; break; case 3: type = tileType.Locked; sprRen.sprite = locked; break; case 4: type = tileType.Wall; sprRen.sprite = wall; break; case 5: type = tileType.Target; sprRen.sprite = target; break; case 6: type = tileType.Path; sprRen.sprite = path; break; case 7: type = tileType.Teleporter; sprRen.sprite = teleporter; break; } }
public MapTile(int x, int y, int offsetX, int offsetY, StringName description, tileType type, char vis) { _x = x; _y = y; _sX = x + offsetX; _sY = y + offsetY; _Description = description; _type = type; visual = vis; _objects = new List<Object>(); if (_type == tileType.T_FLOOR || _type == tileType.T_OPENDOOR) { _isPassable = true; _blockVision = false; } else { _isPassable = false; _blockVision = true; } _Seen = false; }
public dungeonFeature( tileType _tile = tileType.NOTHING, dungeonLayers _layer = dungeonLayers.NO_LAYER, short _startProbability = 0, short _probabilityDecrement = 0, ulong _flags = 0, string _description = "", lightType _lightFlare = lightType.NO_LIGHT, color _flashColor = null, // its ok short _effectRadius = 0, tileType _propagationTerrain = tileType.NOTHING, dungeonFeatureTypes _subsequentDF = (dungeonFeatureTypes)0, // ?? bool _messageDisplayed = false ) { tile = _tile; layer = _layer; startProbability = _startProbability; probabilityDecrement = _probabilityDecrement; flags = _flags; description = _description; lightFlare = _lightFlare; flashColor = _flashColor; if (flashColor == null) { flashColor = Global.black; //Debug.LogError( "dungeonFeature flashColor not initialized :" + tile ); } effectRadius = _effectRadius; propagationTerrain = _propagationTerrain; subsequentDF = _subsequentDF; messageDisplayed = _messageDisplayed; } // constructure
private Hero Create(tileType Tile) { throw new NotImplementedException(); }
public GridTile() { type = tileType.empty; id = -1; }
public override void Terrashift(tileType type) { }
public Node(int x, int y, tileType tile) { this.x = x; this.y = y; this.tile = tile; }
void cleanLevelGrid() { int startingPosition = 0; int endingPosition = gridSize; bool foundOne = false; for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { if (levelGrid[y, x] == tileType.EMPTY) continue; else { foundOne = true; break; } } if (foundOne) break; startingPosition++; } foundOne = false; for (int x = gridSize-1; x >= 0; x--) { for (int y = 0; y < gridSize; y++) { if (levelGrid[y, x] == tileType.EMPTY) continue; else { foundOne = true; break; } } if (foundOne) break; endingPosition--; } int newXSize = endingPosition - startingPosition; if (newXSize == gridSize) return; tileType[,] newGrid = new tileType[gridSize, newXSize]; for (int y = 0; y < gridSize; y++) { for (int x = 0; x < newXSize; x++) newGrid[y, x] = levelGrid[y, x + startingPosition]; } levelGrid = newGrid; }
public void changeType(tileType newType) { _type = newType; switch (_type) { case tileType.T_CLOSEDDOOR: { _isPassable = false; _blockVision = true; visual = '+'; _Description = StringName.TILE_DESC_CLOSED_DOOR; break; } case tileType.T_EMPTY: { _isPassable = true; _blockVision = true; visual = ' '; break; } case tileType.T_FLOOR: { _isPassable = true; _blockVision = false; visual = '.'; break; } case tileType.T_OPENDOOR: { _isPassable = true; _blockVision = false; _Description = StringName.TILE_DESC_OPEN_DOOR; visual = '/'; break; } case tileType.T_WALL: { _isPassable = false; _blockVision = true; visual = '#'; break; } } }
public void ChangeTileType(tileType newType) { thisTileType = newType; UpdateMat(); if (myMask_reenforcement != null && newType == tileType.empty) { prop_levelOfReenforcement = 0; } }
private tileType[,] assignAreas() { var areas = new tileType[totalRows,totalCols]; for (int rr=0; rr<totalRows; rr++) { for (int cc=0; cc<totalCols; cc++) { areas[rr,cc] = tileType.outdoor; } } var sanityCheck = 0; var buildingsPlaced = 0; var randWid = 0; var randHei = 0; var randStartRow = 0; var randStartCol = 0; var placeFree = true; while (sanityCheck < insanityLevel && buildingsPlaced < maxBuildings) { randWid = rand.Next(gutter, (int)Math.Ceiling((totalCols-gutter)/buildingScale)); randHei = rand.Next(gutter, (int)Math.Ceiling((totalRows-gutter)/buildingScale)); randStartRow = rand.Next(0,totalRows-randHei-1); randStartCol = rand.Next(0,totalCols-randWid-1); placeFree = true; for (int rr=randStartRow; rr<=randStartRow+randHei; rr++) { for (int cc=randStartCol; cc<=randStartCol+randWid; cc++) { if (areas[rr,cc] == tileType.wall || areas[rr,cc] == tileType.indoor || areas[rr,cc] == tileType.spacer) { placeFree = false; break; } } } if (placeFree) { var doorsPlaced = 0; for (int rr=randStartRow; rr<=randStartRow+randHei; rr++) { for (int cc=randStartCol; cc<=randStartCol+randWid; cc++) { if (rr==randStartRow || rr==randStartRow+randHei || cc==randStartCol || cc==randStartCol+randWid) { areas[rr,cc] = tileType.wall; if ((rr==randStartRow || rr==randStartRow+randHei) ^ (cc==randStartCol || cc==randStartCol+randWid)) { if (rand.NextDouble() < 0.2 && doorsPlaced < 2) { areas[rr,cc] = tileType.door; doorsPlaced++; } } } else { areas[rr,cc] = tileType.indoor; } } } for (int rr=randStartRow; rr<=randStartRow+randHei; rr++) { if (randStartCol>0) { areas[rr,randStartCol-1] = tileType.spacer; } if (randStartCol+randWid+1 < totalCols-1) { areas[rr,randStartCol+randWid+1] = tileType.spacer; } } for (int cc=randStartCol; cc<=randStartCol+randWid; cc++) { if (randStartRow>0) { areas[randStartRow-1,cc] = tileType.spacer; } if (randStartRow+randHei+1 < totalRows-1) { areas[randStartRow+randHei+1,cc] = tileType.spacer; } } buildingsPlaced++; } sanityCheck++; } return areas; }
// Use this for initialization void Start() { // randomly convert stones to gems // this is a temporary implementation of "random" level generation if (thisTileType == tileType.rock & Random.Range(0, 35) == 0) { thisTileType = tileType.rockWithGem; } UpdateMat(); int[] thisTileXandY = GetTilePosition(); thisTileX = thisTileXandY[0]; thisTileY = thisTileXandY[1]; // specify which tile types are structural structureTypes.Add(tileType.structure); structureTypes.Add(tileType.structure_reenforced); structureTypes.Add(tileType.structure_reenforced_2); structureTypes.Add(tileType.structure_mining); structureTypes.Add(tileType.structure_factory); structureTypes.Add(tileType.structure_mill); structureTypes.Add(tileType.structure_residence); structureTypes.Add(tileType.structure_community); structureTypes.Add(tileType.structure_sonar); structureTypes.Add(tileType.structure_sonar_positive); // specify which tile types are non-load bearing structural structureTypesNonLoadBearing.Add(tileType.structure); structureTypesNonLoadBearing.Add(tileType.structure_mining); structureTypesNonLoadBearing.Add(tileType.structure_factory); structureTypesNonLoadBearing.Add(tileType.structure_mill); structureTypesNonLoadBearing.Add(tileType.structure_residence); structureTypesNonLoadBearing.Add(tileType.structure_community); structureTypesNonLoadBearing.Add(tileType.structure_sonar); structureTypesNonLoadBearing.Add(tileType.structure_sonar_positive); }
public Character(int tempX, int tempY, tileType typeTemp) : base(tempX, tempY, typeTemp) { }
//TileObject Constructor public TileObject(Vector2 position,tileType type) { this.position = position; this.type = type; }
public void setTileType( int x, int y, tileType type ){ grid_data[x,y] = type; }