public void ChangeSelectedTilesState(TileStates to) { foreach (Point p in selectedTiles) { tiles[p.X, p.Y].State = to; } }
private bool cellStateCheck(FrameworkElement curCellInterrogated) { int curCellC = (int)curCellInterrogated.GetValue(Grid.ColumnProperty); int curCellR = (int)curCellInterrogated.GetValue(Grid.RowProperty); TileStates curCellTS = new TileStates(); curCellTS = GameBoardManager.curTileState[curCellC, curCellR]; if (curCellTS == TileStates.Floor) { Debug.WriteLine("Cell state confirmed as floor!"); return(true); } else if (curCellTS == TileStates.Powerup) { Debug.WriteLine("Cell has a powerup."); return(true); } else { Debug.WriteLine("Cell state confirmed as not floor!"); DeleteHighlight(); return(false); } }
public void OpenTile() { if (!IsObstacle && !used) { tileState = TileStates.Open; } }
public void ChangeState(TileStates newState) { switch (newState) { case TileStates.Normal: targetAngle = new Vector3(0, 0, 0); break; case TileStates.Fire: targetAngle = new Vector3(-90, -90, 0); break; case TileStates.Water: targetAngle = new Vector3(0, -90, -90); break; case TileStates.Wind: targetAngle = new Vector3(90, -90, 0); break; } }
private TileStates NextState(TileStates currentState) { switch (currentState) { case TileStates.Stage1: return(TileStates.Stage2); break; case TileStates.Stage2: return(TileStates.Stage3); break; case TileStates.Stage3: return(TileStates.Stage1); break; default: return(TileStates.Stage1); break; } }
private TileStates state; // instance of the enum TileStates to indicate if it's been closed, open, or unchecked by the algorithim //Default constructor, most of the time, only the minimum Vector2 should be provided, and all other parameters left to their default value public Tile(Vector2 l, bool p = true, TileStates t = TileStates.Unchecked, int cS = 1) { location = l; passable = p; state = t; costScalar = cS; }
public NeighbourAction(TileStates state, ActionType action, Point offset) { this.State = state; this.Action = action; this.Offset = offset; this.LastVisit = 0; }
public Tile(Tile tile) { this.location = tile.location; // this.costFromStart = tile.costFromStart; this.passable = tile.passable; this.state = tile.state; this.costScalar = tile.costScalar; }
private TileStates state; // instance of the enum TileStates to indicate if it's been closed, open, or unchecked by the algorithim //Default constructor public Tile(Point location, /* double costFromStart = 0,*/ bool passable = true, TileStates state = TileStates.Unchecked, int cost = 1) { this.location = location; // this.costFromStart = costFromStart; this.passable = passable; this.state = state; this.costScalar = cost; }
public void OpenTile(Tile _tile) { if (!IsObstacle && !used) { parentTile = _tile; tileState = TileStates.Open; } }
public void SetState(TileStates state) { this.state = state; if (sprites.Count > 0) { img.sprite = sprites[state]; } }
public TileState CreateTileState(TileStates tileState) { switch (tileState) { case (TileStates.TwoPointMoving): return(_twoPointMovingFactory.Create()); } throw ModestTree.Assert.CreateException(); }
/// <summary> /// Reverts the decoration of specific tiles with the decoration proveded to normal. /// </summary> /// <param name="state">the state to target</param> public void ClearAllDecorationsOfType(TileStates state) { foreach (var tile in LocalTileCollection) { if (tile.Value.Decorator.AppliedState == state) { tile.Value.Decorator.ApplyTileState(TileStates.NORMAL); } } }
public Tile(Vector2 _position, TileStates _state, bool _isObstacle, Rect _area, uint _index, char _charFile) { isObstacle = _isObstacle; position = _position; tileState = originalState = _state; used = false; area = _area; index = _index; charFile = _charFile; }
/// <summary> /// Switches the decorations of the provided points, with the provided state. /// </summary> /// <param name="tilePositions">points of the desired tiles to be edited</param> /// <param name="state">the state to switch to</param> public void SwitchTileDecoration(HashSet <Point> tilePositions, TileStates state) { foreach (Point position in tilePositions) { if (WorldTileCollection.ContainsKey(position) == false) { continue; } WorldTileCollection[position].Decorator.ApplyTileState(state); } }
public void setTile(int x, int y, TileStates value) { if (boardData[x, y] != TileStates.Empty) { throw new TileOccupiedException(boardData[x, y]); } else { boardData[x, y] = value; } }
public void ChangeFieldState(TileStates newState, params Point[] offsets) { var halfGameFieldWidth = mMap.GetLength(0) / 2; var halfGameFieldHeight = mMap.GetLength(1) / 2; foreach (var offset in offsets) { var x = halfGameFieldWidth + offset.X; var y = halfGameFieldHeight + offset.Y; SetGameFieldState(x, y, newState); } }
public void ApplyTileState(TileStates state) { AppliedState = state; foreach (Renderer item in TileComponents) { if (Decoration == null) { Debug.Log($"[TILE DECORATOR] {state}, {name}", this); } MaterialProperties?.SetTexture(DecalTexture, Decoration?.GetStateTexture(state)); item.SetPropertyBlock(MaterialProperties); } }
public int CountTiles(TileStates tileState) { var count = 0; foreach (var tile in tiles) { if (tile == tileState) { count++; } } return(count); }
private void SetGameFieldState(int x, int y, TileStates state) { if (!IsFieldOnGameField(x, y)) { return; } mMap[x, y] = state; switch (state) { case TileStates.Blocked: mPathZones.Block(x, y); break; case TileStates.Free: mPathZones.Unblock(x, y); break; } }
private void SetCurrentSpikeStageToActive(TileStates currentState) { switch (currentState) { case TileStates.Stage1: spikeTrapStageContainer.GetChild(0).gameObject.SetActive(true); break; case TileStates.Stage2: spikeTrapStageContainer.GetChild(1).gameObject.SetActive(true); break; case TileStates.Stage3: spikeTrapStageContainer.GetChild(2).gameObject.SetActive(true); break; default: break; } }
public void setTile(string name, TileStates value) { switch (name) { case "c0_0": this.setTile(0, 0, value); break; case "c0_1": this.setTile(0, 1, value); break; case "c0_2": this.setTile(0, 2, value); break; case "c1_0": this.setTile(1, 0, value); break; case "c1_1": this.setTile(1, 1, value); break; case "c1_2": this.setTile(1, 2, value); break; case "c2_0": this.setTile(2, 0, value); break; case "c2_1": this.setTile(2, 1, value); break; case "c2_2": this.setTile(2, 2, value); break; } }
private IEnumerator ActivateTrap() { ToggleOffUnpressedButton(); SetCurrentSpikeStageToNonActive(spikeStates); spikeStates = NextState(spikeStates); SetCurrentSpikeStageToActive(spikeStates); yield return(new WaitForSeconds(trapInterval)); SetCurrentSpikeStageToNonActive(spikeStates); spikeStates = NextState(spikeStates); SetCurrentSpikeStageToActive(spikeStates); yield return(new WaitForSeconds(2.0f)); StartCoroutine(StartResettingTrapButton()); SetCurrentSpikeStageToNonActive(spikeStates); spikeStates = NextState(spikeStates); SetCurrentSpikeStageToActive(spikeStates); }
public override Texture GetStateTexture(TileStates state) { switch (state) { case TileStates.NORMAL: return(NormalDecal); case TileStates.ATTACK: return(BaseAttack); case TileStates.HIGHLIGHT: return(BaseHighlight); case TileStates.TARGET: return(SelectionAttack); case TileStates.BaseHighlight: return(BaseHighlight); case TileStates.ActiveHighlight: return(ActiveHighlight); case TileStates.SelectionHighlight: return(SelectionHighlight); case TileStates.BaseAttack: return(BaseAttack); case TileStates.ActiveAttack: return(ActiveAttack); case TileStates.SelectionAttack: return(SelectionAttack); default: return(NormalDecal); } }
/// <summary> /// Adds tiles to worldMap using file data generated by the map editor. /// </summary> /// <param name="directory"> /// The save location of the file generated by the map editor. /// </param> /// <param name="mapSheet"> /// The sprite sheet used to draw the map. /// </param> public void PopulateMap(string directory, Texture2D mapSheet) { tileList = LoadFromFile(directory); for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { int tileIndex = mapWidth * y + x; TileStates tempState = tileList[tileIndex]; Vector2 tempVector = new Vector2(x * 32, y * 32); worldMap.Add(new Map(mapSheet, tempVector, tempState)); //Adds walls to a list of rectangles for border collision if (tempState == TileStates.Wall) { wallBoundaries.Add(new Rectangle(x * 32, y * 32, 32, 32)); } } } // Populating professorTileRectangles foreach (Map tile in worldMap) { if (tile.TilePlaced == TileStates.Professor) { professorTileRectangles.Add(new Rectangle( (int)tile.X, (int)tile.Y, Map.tileWidth, Map.tileHeight)); } } }
public Tile(TileStates tileState, int lastVisit, int lastClean) { this.State = tileState; this.LastVisit = lastVisit; this.LastClean = lastClean; }
private void Awake() { spikeStates = TileStates.Stage1; }
//Created based on square location and setted to Passable public Tile(int squareX, int squareY) { _Position = new Point(squareX, squareY); _State = TileStates.Passable; }
public Tile(TileStates tileState, int lastVisit) { this.State = tileState; this.LastVisit = lastVisit; }
public FOWTile() { Blocker = false; CurrentState = TileStates.NeverSeen; }
/// <summary> /// Map discovery phase /// </summary> /// <returns>action for robot to perform</returns> private ActionType Phase1Iteration() { Tile[,] hugeMap = HugeMap; Point currentPos = CurrentPos; bool followPath = false; //If it's first iteration in the phase if (Phase1Preparing) { //set all tiles as black (unexplored) TileStates black = TileStates.TopNV | TileStates.RightNV | TileStates.BottomNV | TileStates.LeftNV; for (int i = 0; i < hugeMap.GetLength(0); ++i) { for (int j = 0; j < hugeMap.GetLength(1); ++j) { hugeMap[i, j] = new Tile(black, -1); } } //set initial tile as grey tile hugeMap[currentPos.Row - 1, currentPos.Col].State &= ~TileStates.BottomNV; hugeMap[currentPos.Row, currentPos.Col + 1].State &= ~TileStates.LeftNV; hugeMap[currentPos.Row + 1, currentPos.Col].State &= ~TileStates.TopNV; hugeMap[currentPos.Row, currentPos.Col - 1].State &= ~TileStates.RightNV; hugeMap[currentPos.Row, currentPos.Col].State |= TileStates.Visited; Phase1Preparing = false; } Tile currentTile = hugeMap[currentPos.Row, currentPos.Col]; ActionType action = ActionType.actIDLE; //if we are not following path to nearest grey tile generated by A* if (GoingToGrey == null) { //if current tile is grey (has unexplored neighbours) if ((currentTile.State & GreyTileSign) != 0) { if ((currentTile.State & TileStates.TopNV) != 0) { --currentPos.Row; action = ActionType.actUP; } else if ((currentTile.State & TileStates.RightNV) != 0) { ++currentPos.Col; action = ActionType.actRIGHT; } else if ((currentTile.State & TileStates.BottomNV) != 0) { ++currentPos.Row; action = ActionType.actDOWN; } else if ((currentTile.State & TileStates.LeftNV) != 0) { --currentPos.Col; action = ActionType.actLEFT; } hugeMap[currentPos.Row - 1, currentPos.Col].State &= ~TileStates.BottomNV; hugeMap[currentPos.Row, currentPos.Col + 1].State &= ~TileStates.LeftNV; hugeMap[currentPos.Row + 1, currentPos.Col].State &= ~TileStates.TopNV; hugeMap[currentPos.Row, currentPos.Col - 1].State &= ~TileStates.RightNV; hugeMap[currentPos.Row, currentPos.Col].State |= TileStates.Visited; PossiblePos = currentPos; return(action); } else { //if no current tile has no unexplored neighbours and there are still grey tiles on map if (GreyExists()) { //A* to search for nearest grey GetPathToGrey(); followPath = true; } else { //Finishing phase 1 //Rewrting HugeMap contents to SmallMap int minRow = int.MaxValue, minCol = int.MaxValue; for (int row = 0; row < hugeMap.GetLength(0); ++row) { for (int col = 0; col < hugeMap.GetLength(1); ++col) { if ((hugeMap[row, col].State & TileStates.Visited) != 0) { minRow = System.Math.Min(minRow, row); minCol = System.Math.Min(minCol, col); } else { hugeMap[row, col].State |= TileStates.Wall; } } } Tile[,] smallMap = SmallMap; for (int row = 0; row < Environment.mazeSize_; ++row) { for (int col = 0; col < Environment.mazeSize_; ++col) { smallMap[row, col] = hugeMap[row + minRow, col + minCol]; } } CurrentPos.Row -= minRow; CurrentPos.Col -= minCol; HugeMap = null; Fringe = null; Phase1Running = false; } } } else { followPath = true; } if (followPath) { //Following path generated by A* on some previous step Point dest = GoingToGrey.Value; GoingToGrey = GoingToGrey.Parent; PossiblePos = dest; if (dest.Row < currentPos.Row) { return(ActionType.actUP); } if (dest.Col > currentPos.Col) { return(ActionType.actRIGHT); } if (dest.Row > currentPos.Row) { return(ActionType.actDOWN); } if (dest.Col < currentPos.Col) { return(ActionType.actLEFT); } } return(ActionType.actIDLE); }
public virtual void OnLeavingAState(TileStates state) { }
public virtual void OnEnteringAState(TileStates state) { }