public void PlaceTileInteraction(TileInteraction tileInteraction) { if (tileInteraction == null) { Debug.LogError("Tile: PlaceRoomObject tileInteraction is null"); return; } if (myTileInteraction != null) { if (myTileInteraction != tileInteraction) { Debug.LogError("Tile: PlaceRoomObject tileInteraction exists"); return; } } // if everything's okay, set myFurniture myTileInteraction = tileInteraction; }
private void InteractionOverlay_TextChanged(object sender, TextChangedEventArgs e) { TileInteraction selectedInteraction = (TileInteraction)InteractionList.SelectedItem; if (selectedInteraction != null) { try { TileBlockOverlay overlay = JsonConvert.DeserializeObject <TileBlockOverlay>(InteractionOverlay.Text); if (overlay != null && (overlay.PaletteIndex < 0 || overlay.PaletteIndex >= 8)) { throw new Exception(); } InteractionOverlay.Foreground = new SolidColorBrush(Colors.White); selectedInteraction.Overlay = overlay; BlockSelector.Update(tileIndex: BlockSelector.SelectedBlockValue); UpdateTileBlock(); SetUnsaved(); } catch { InteractionOverlay.Foreground = new SolidColorBrush(Colors.Red); } } }
private void HandleGridCreation(MazeNode node, TileInteraction tileInteraction) { mazeNodes[node.Row, node.Column] = node; int[] pos = { node.Row, node.Column }; tileInteraction.SetGridPosition(pos); tileInteraction.OnButtonClick += OnTileClicked; tileInteraction.OnPlayerEnter += AssignCurrentPlayerTile; }
internal override void TemplateAfterAwake() { base.TemplateAfterAwake(); _InteractionComponent = gameObject.AddComponent <TileInteraction>(); _VisualizationComponent = GetComponent <TileVisualization>(); VisualizationComponent.rendererGO.gameObject.AddComponent <TileInputHandler>().SetExternalCustomEntity(this); }
// Constructor for flipped furniture public TileInteraction(Room room, TileInteraction tileInt) { this.x = room.MyGrid.myWidth - 1 - tileInt.x - ((int)tileInt.mySize.x - 1); this.y = tileInt.y; this.mySize = tileInt.mySize; this.walkable = tileInt.walkable; }
public void StopOnCurrentTile() { DestTileTB = CurrentTile; if (CurrentPath != null) { CurrentPath[0] = CurrentTile; } }
public void DestinationReached() { OriginTileTB.Reset(); OriginTileTB = DestTileTB; OriginTileTB.SetAsOrigin(); DestTileTB = null; //GridBoard.Instance.BdVisualization.ErasePath(IndicatorsCollector); }
public static void Invoke_cb_editorTileInteractioneModelChanged(TileInteraction tileInteraction) { if (cb_editorTileInteractioneModelChanged != null) { cb_editorTileInteractioneModelChanged(tileInteraction); } Invoke_cb_tileLayoutChanged(); }
public static void Invoke_cb_tileInteractionChanged(TileInteraction tileInt) { if (cb_tileInteractionChanged != null) { cb_tileInteractionChanged(tileInt); } Invoke_cb_tileLayoutChanged(); }
static double estimate(TileInteraction tile, TileInteraction destTile) { float dx = Mathf.Abs(destTile.GridTile.X - tile.GridTile.X); float dy = Mathf.Abs(destTile.GridTile.Y - tile.GridTile.Y); int z1 = -(tile.GridTile.X + tile.GridTile.Y); int z2 = -(destTile.GridTile.X + destTile.GridTile.Y); float dz = Mathf.Abs(z2 - z1); return(Mathf.Max(dx, dy, dz)); }
public void PlaceTileIntInTiles(TileInteraction tileInt, Room room, Grid grid) { List <Tile> tempTileList = room.GetMyTiles(grid, tileInt.mySize, tileInt.x, tileInt.y); foreach (Tile myTile in tempTileList) { myTile.myTileInteraction = tileInt; } EventsHandler.Invoke_cb_tileLayoutChanged(); }
public void AddInteraction(TileInteraction item) { if (Interactions == null) { Interactions = new List <TileInteraction>(); } else if (Interactions.Contains(item)) { return; } Interactions.Add(item); }
public void ShowPreviewObject(TileInteraction tInteraction) { if (previewGO == null) { var go = Instantiate(Resources.Load <GameObject>(UiController.CurrentCharacterTag.ToString())); previewGO = go; var bidp = go.AddComponent <BuildItemDragPreview>(); bidp.Init(tInteraction.GridTile.X, tInteraction.GridTile.Y); } }
public void OriginTileChanged(TileInteraction tileBehaviour) { //deselect origin tile if user clicks on current origin tile if (tileBehaviour == OriginTileTB) { OriginTileTB = null; tileBehaviour.Reset(); return; } //if origin tile is not specified already mark this tile as origin OriginTileTB = tileBehaviour; tileBehaviour.SetAsOrigin(); }
public void SetNewDestination(TileInteraction tile) { if (tile.GridTile == OriginTileTB.GridTile) //|| originTileTB == null) { OriginTileChanged(tile); } else { DestTileChanged(tile); } GenerateAndShowPath(); }
public void PlaceTileIntInTiles(TileInteraction tileInt, Room room, Grid grid) { List <Tile> tempTileList = room.GetMyTiles(grid, tileInt.mySize, tileInt.x, tileInt.y); Debug.Log("tile list count" + tempTileList.Count); foreach (Tile myTile in tempTileList) { Debug.Log("tile x " + myTile.x + "y " + myTile.y); myTile.myTileInteraction = tileInt; } EventsHandler.Invoke_cb_tileLayoutChanged(); }
private void InteractionList_SelectionChanged(object sender, SelectionChangedEventArgs e) { TileInteraction selectedIteraction = (TileInteraction)InteractionList.SelectedItem; if (selectedIteraction != null) { BlockSelector.SelectedTileBlock.Property = ((TileTerrain)TerrainList.SelectedItem).Value | selectedIteraction.Value; InteractionOverlay.Text = JsonConvert.SerializeObject(selectedIteraction.Overlay, Formatting.Indented); BlockSelector.Update(tileIndex: BlockSelector.SelectedBlockValue); UpdateTileBlock(); SetUnsaved(); } }
public BonusTile(int x, int y) { hp = Random.Range(1, 20); tick = 1; //Random.Range(1, 3); amount = (int)hp; MainColour = ColourManager.getRandomColour(); Interaction = TileInteraction.Stand; //(TileInteraction)Random.Range (0, 2); Reward = (TileReward)Random.Range(0, 2); this.x = x; this.y = y; CleanTools.GetInstance().SubscribeCleanable(this); InitGameObject(); }
public void AddInteraction(ushort other, TileInteraction item) { if (!TileInteractions.ContainsKey(other)) { TileInteractions[other] = new List <TileInteraction>(); } if (TileInteractions[other].Contains(item)) { return; } else { TileInteractions[other].Add(item); } }
public void Init(TileInteraction originTile, cCards characterType) { MoveComponent.Init(originTile.GridTile.Location.X, originTile.GridTile.Location.Y); switch (characterType) { case cCards.Beetle: gameObject.AddComponent <BeetleBehaviour>(); break; case cCards.RedBeetle: gameObject.AddComponent <RedBeetleBehaviour>(); break; } }
public void DeleteTileInteraction() { Debug.Log("delete tile interaction"); TileInteraction tileInt = InspectorManager.instance.chosenTileInteraction; Tile tile = EditorRoomManager.instance.room.MyGrid.GetTileAt(tileInt.x, tileInt.y); EditorRoomManager.instance.room.myTileInteractionList.Remove(tileInt); tile.myTileInteraction = null; InspectorManager.instance.chosenTileInteraction = null; EventsHandler.Invoke_cb_tileLayoutChanged(); //DestroyTileInspector (); }
public void ColorTiles() { // First - Clean tile layout foreach (GameObject obj in tileGameObjectMap.Values) { obj.GetComponent <SpriteRenderer> ().color = new Color(1f, 1f, 1f, 0.05f); } // Color furniture tiles foreach (Tile tile in RoomManager.instance.myRoom.MyGrid.gridArray) { Tile mapTile = RoomManager.instance.myRoom.myGrid.GetTileAt(tile.x, tile.y); if (tile.myTileInteraction != null) { TileInteraction tileInt = tile.myTileInteraction; for (int x = 0; x < tileInt.mySize.x; x++) { for (int y = 0; y < tileInt.mySize.y; y++) { Tile tempTile = RoomManager.instance.myRoom.myGrid.GetTileAt(tileInt.x + x, tileInt.y + y); tileGameObjectMap [tempTile].GetComponent <SpriteRenderer> ().color = new Color(0.9f, 0.2f, 0.2f, 0.8f); } } } if (tile.myCharacter != null) { tileGameObjectMap [mapTile].GetComponent <SpriteRenderer> ().color = Color.magenta; } if (tile.myFurniture != null) { tileGameObjectMap [mapTile].GetComponent <SpriteRenderer> ().color = ( tile.myFurniture.hidden ? new Color(0.2f, 0.2f, 0.9f, 0.3f) : new Color(0.2f, 0.2f, 0.9f, 0.8f) ); } } }
public void DestTileChanged(TileInteraction tileBehaviour) { //deselect destination tile if user clicks on current destination tile if (tileBehaviour == DestTileTB) { DestTileTB = null; tileBehaviour.Reset(); return; } //if there was other tile marked as destination, change its material to default (fully transparent) one if (DestTileTB != null) { DestTileTB.Reset(); } DestTileTB = tileBehaviour; //tileBehaviour.ChangeColor(Color.blue); }
// Tile Interaction // public void OnHitTileInteraction(Tile tile) { TileInteraction tileInt = tile.myTileInteraction; if (currentTileInteraction != tileInt) { currentTileInteraction = tileInt; if (currentTileInteraction != null) { // Check if passed the conditions if (Utilities.EvaluateConditions(tileInt.mySubInt.ConditionList)) { tileInt.mySubInt.SubInteract(); } } } }
public static void SetTileInteractionPersistency(bool isPersistent, TileInteraction tileInt) { DestroyAllInteractablesInPos(tileInt.x, tileInt.y); if (isPersistent == true) { EditorRoomManager.instance.room.myMirrorRoom.myTileInteractionList_Persistant.Add(tileInt); } else { if (EditorRoomManager.instance.room.myMirrorRoom.inTheShadow == true) { EditorRoomManager.instance.room.myMirrorRoom.myTileInteractionList_Shadow.Add(tileInt); } else { EditorRoomManager.instance.room.myTileInteractionList.Add(tileInt); } } }
/* * // Color furniture tiles inside game * * public void ColorTiles(Interactable interactable) * { * * //Debug.Log ("ColorTiles"); * * * List<Tile> InteractableTiles = RoomManager.instance.myRoom.GetMyTiles(RoomManager.instance.myRoom.MyGrid, interactable.mySize, interactable.x, interactable.y); * * * // light the tiles * * * foreach (Tile tile in InteractableTiles) { * * TileManager.instance.tileGameObjectMap [tile].GetComponent<SpriteRenderer> ().color = new Color (0.1f, 0.3f, 0.2f, 0.4f); * * } * * * } */ public void ColorTiles() { //Debug.Log ("ColorTiles"); // First - Clean tile layout foreach (GameObject obj in tileGameObjectMap.Values) { obj.GetComponent <SpriteRenderer> ().color = new Color(1f, 1f, 1f, 0.1f); } // Color furniture tiles foreach (Tile tile in RoomManager.instance.myRoom.MyGrid.gridArray) { if (tile.myTileInteraction != null) { TileInteraction tileInt = tile.myTileInteraction; for (int x = 0; x < tileInt.mySize.x; x++) { for (int y = 0; y < tileInt.mySize.y; y++) { Tile tempTile = RoomManager.instance.myRoom.MyGrid.GetTileAt(tileInt.x + x, tileInt.y + y); tileGameObjectMap [tempTile].GetComponent <SpriteRenderer> ().color = Color.yellow; } } } if (tile.myCharacter != null) { tileGameObjectMap [tile].GetComponent <SpriteRenderer> ().color = Color.magenta; } if (tile.myFurniture != null) { tileGameObjectMap [tile].GetComponent <SpriteRenderer> ().color = Color.blue; } } }
public void DeleteTileInteraction() { Room room = EditorRoomManager.instance.room; TileInteraction tileInt = InspectorManager.instance.chosenTileInteraction; // remove from all lists room.myTileInteractionList.Remove(tileInt); if (room.myMirrorRoom != null) { room.myMirrorRoom.myTileInteractionList_Persistant.Remove(tileInt); room.myMirrorRoom.myTileInteractionList_Shadow.Remove(tileInt); } Tile tile = EditorRoomManager.instance.room.MyGrid.GetTileAt(tileInt.x, tileInt.y); tile.myTileInteraction = null; InspectorManager.instance.chosenTileInteraction = null; EventsHandler.Invoke_cb_tileLayoutChanged(); }
public static Path <TileInteraction> FindPath( TileInteraction start, TileInteraction destination) { var closed = new HashSet <TileInteraction>(); var queue = new PriorityQueue <double, Path <TileInteraction> >(); queue.Enqueue(0, new Path <TileInteraction>(start)); while (!queue.IsEmpty) { var path = queue.Dequeue(); if (closed.Contains(path.LastStep)) { continue; } if (path.LastStep.Equals(destination)) { return(path); } closed.Add(path.LastStep); //Debug.Log(" last step: " + path.LastStep.X+" "+path.LastStep.Y); foreach (TileInteraction n in path.LastStep.GridTile.Neighbours) { //Debug.Log(" nb: " + n.X + " " + n.Y); double d = 1;// distance(path.LastStep.GridTile, n); var newPath = path.AddStep(n, d); queue.Enqueue(newPath.TotalCost + estimate(n, destination), newPath); } //Debug.Log("---------------"); } return(null); }
public void RenderTiles(int blockX = 0, int blockY = 0, int blockWidth = Level.BLOCK_WIDTH, int blockHeight = Level.BLOCK_HEIGHT) { int maxRow = blockY + blockHeight; int maxCol = blockX + blockWidth; if (maxRow > Level.BLOCK_HEIGHT) { maxRow = Level.BLOCK_HEIGHT; } if (maxCol > Level.BLOCK_WIDTH) { maxCol = Level.BLOCK_WIDTH; } for (int row = blockY; row < maxRow; row++) { for (int col = blockX; col < maxCol; col++) { int tileValue = _levelDataAccessor.GetData(col, row); if (tileValue < 0) { continue; } int paletteIndex = (tileValue & 0XC0) >> 6; TileBlock tile = _tileSet.TileBlocks[tileValue]; int x = col * 16, y = row * 16; RenderTile(x, y, _graphicsAccessor.GetRelativeTile(tile.UpperLeft), _buffer, _palette.RgbColors[paletteIndex]); RenderTile(x + 8, y, _graphicsAccessor.GetRelativeTile(tile.UpperRight), _buffer, _palette.RgbColors[paletteIndex]); RenderTile(x, y + 8, _graphicsAccessor.GetRelativeTile(tile.LowerLeft), _buffer, _palette.RgbColors[paletteIndex]); RenderTile(x + 8, y + 8, _graphicsAccessor.GetRelativeTile(tile.LowerRight), _buffer, _palette.RgbColors[paletteIndex]); if (_withTerrainOverlay) { TileTerrain terrain = _terrain.Where(t => t.HasTerrain(tile.Property)).FirstOrDefault(); if (terrain != null) { TileBlockOverlay overlay = terrain.Overlay; if (overlay != null) { RenderTile(x, y, _graphicsAccessor.GetOverlayTile(0, overlay.UpperLeft), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .75); RenderTile(x + 8, y, _graphicsAccessor.GetOverlayTile(0, overlay.UpperRight), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .75); RenderTile(x, y + 8, _graphicsAccessor.GetOverlayTile(0, overlay.LowerLeft), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .75); RenderTile(x + 8, y + 8, _graphicsAccessor.GetOverlayTile(0, overlay.LowerRight), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .75); } } } if (_withInteractionOverlay) { TileInteraction interaction = _terrain.Where(t => t.HasTerrain(tile.Property)).FirstOrDefault()?.Interactions.Where(i => i.HasInteraction(tile.Property)).FirstOrDefault(); if (interaction != null) { TileBlockOverlay overlay = interaction.Overlay; if (overlay != null) { RenderTile(x, y, _graphicsAccessor.GetOverlayTile(0, overlay.UpperLeft), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .85); RenderTile(x + 8, y, _graphicsAccessor.GetOverlayTile(0, overlay.UpperRight), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .85); RenderTile(x, y + 8, _graphicsAccessor.GetOverlayTile(0, overlay.LowerLeft), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .85); RenderTile(x + 8, y + 8, _graphicsAccessor.GetOverlayTile(0, overlay.LowerRight), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .85); } } } } } }
//only intended to be used by core if2 classes public static void SendTileApply(TileApply tileApply, InteractableTiles interactableTiles, TileInteraction tileInteraction, int tileInteractionIndex) { //if we are client and the interaction has client prediction, trigger it. //Note that client prediction is not triggered for server player. if (!CustomNetworkManager.IsServer) { Logger.LogTraceFormat("Predicting TileApply interaction {0}", Category.Interaction, tileApply); tileInteraction.ClientPredictInteraction(tileApply); } if (!tileApply.Performer.Equals(PlayerManager.LocalPlayer)) { Logger.LogError("Client attempting to perform an interaction on behalf of another player." + " This is not allowed. Client can only perform an interaction as themselves. Message" + " will not be sent.", Category.NetMessage); return; } var msg = new RequestInteractMessage() { ComponentType = typeof(InteractableTiles), InteractionType = typeof(TileApply), ProcessorObject = interactableTiles.GetComponent <NetworkIdentity>().netId, Intent = tileApply.Intent, TargetVector = tileApply.TargetVector, TileInteractionIndex = tileInteractionIndex }; msg.Send(); }