public void MoveGameObject(ref GameObject obj, MapPosition position) { MapPosition old = obj.Position; obj.Position = position; DisplayBlock(old); DisplayBlock(position); }
public GameObject GetGameObject(MapPosition Position) { foreach (GameObject item in this.MapObjects) { if (item.Position.Equals(Position)) { return(item); } } return(null); }
public void SetBlock(MapPosition Target ,MapBlock Block) { MapBlocks[Target.X][Target.Y] = Block; float Screen_X = Target.X * -_nextX + _startX;//取得X軸起點(X,0)座標 float Screen_Y = Target.X * _nextY + _startY; Screen_X += Target.Y * _nextX;//加入Y軸偏移 Screen_Y += Target.Y * _nextY; MapBlocks[Target.X][Target.Y].Margin = new Thickness(Screen_X ,Screen_Y ,0 ,0); }
public void SetBlock(MapPosition Target, MapBlock Block) { MapBlocks[Target.X][Target.Y] = Block; float Screen_X = Target.X * -_nextX + _startX;//取得X軸起點(X,0)座標 float Screen_Y = Target.X * _nextY + _startY; Screen_X += Target.Y * _nextX;//加入Y軸偏移 Screen_Y += Target.Y * _nextY; MapBlocks[Target.X][Target.Y].Margin = new Thickness(Screen_X, Screen_Y, 0, 0); }
public async Task DisplayBlock(MapPosition Target) { if (MapBlocks[Target.X][Target.Y] == null) { return; } await this.Dispatcher.InvokeAsync(() => { #region 側面顯示 if (MapBlocks.Length - 1 == Target.X) { MapBlocks[Target.X][Target.Y].LeftSideVisable = true; } else { MapBlocks[Target.X][Target.Y].LeftSideVisable = false; } if (MapBlocks[Target.X].Length - 1 == Target.Y) { MapBlocks[Target.X][Target.Y].RightSideVisable = true; } else { MapBlocks[Target.X][Target.Y].RightSideVisable = false; } if (Target.X < MapBlocks.Length - 1) { if (MapBlocks[Target.X + 1][Target.Y] == null) { MapBlocks[Target.X][Target.Y].LeftSideVisable = true; } else { MapBlocks[Target.X][Target.Y].LeftSideVisable = false; } } if (Target.Y < MapBlocks[Target.Y].Length - 1) { if (MapBlocks[Target.X][Target.Y + 1] == null) { MapBlocks[Target.X][Target.Y].RightSideVisable = true; } else { MapBlocks[Target.X][Target.Y].RightSideVisable = false; } } #endregion try { try { MainGrid.Children.Add(MapBlocks[Target.X][Target.Y]); }catch { } GameObject OBJ = GetGameObject(new MapPosition() { X = Target.X, Y = Target.Y }); if (OBJ != null) { Thickness blockposition = MapBlocks[Target.X][Target.Y].Margin; OBJ.Margin = new Thickness( blockposition.Left, blockposition.Top - 68, 0, 0 ); MainGrid.Children.Add(OBJ); } } catch { } MapBlocks[Target.X][Target.Y].Display(); }); }
public MapBlock GetBlock(MapPosition Target) { return(MapBlocks[Target.X][Target.Y]); }
public MapBlock GetBlock(MapPosition Target) { return MapBlocks[Target.X][Target.Y]; }
public async Task DisplayBlock(MapPosition Target) { if(MapBlocks[Target.X][Target.Y] == null) return; await this.Dispatcher.InvokeAsync(() => { #region 側面顯示 if(MapBlocks.Length - 1 == Target.X) { MapBlocks[Target.X][Target.Y].LeftSideVisable = true; } else { MapBlocks[Target.X][Target.Y].LeftSideVisable = false; } if(MapBlocks[Target.X].Length - 1 == Target.Y) { MapBlocks[Target.X][Target.Y].RightSideVisable = true; } else { MapBlocks[Target.X][Target.Y].RightSideVisable = false; } if(Target.X < MapBlocks.Length - 1) { if(MapBlocks[Target.X + 1][Target.Y] == null) { MapBlocks[Target.X][Target.Y].LeftSideVisable = true; } else { MapBlocks[Target.X][Target.Y].LeftSideVisable = false; } } if(Target.Y < MapBlocks[Target.Y].Length - 1) { if(MapBlocks[Target.X][Target.Y+1] == null) { MapBlocks[Target.X][Target.Y].RightSideVisable = true; } else { MapBlocks[Target.X][Target.Y].RightSideVisable = false; } } #endregion try { try { MainGrid.Children.Add(MapBlocks[Target.X][Target.Y]); }catch { } GameObject OBJ = GetGameObject(new MapPosition() { X = Target.X, Y = Target.Y }); if(OBJ != null) { Thickness blockposition = MapBlocks[Target.X][Target.Y].Margin; OBJ.Margin = new Thickness( blockposition.Left, blockposition.Top - 68, 0, 0 ); MainGrid.Children.Add(OBJ); } } catch { } MapBlocks[Target.X][Target.Y].Display(); }); }
private async Task DisplayBlocks(MapPosition[] Target) { foreach(MapPosition item in Target) { Thread.Sleep(1); await DisplayBlock(item); } }
private MapPosition[] GetNextDisplay(MapPosition Ref,int[][] DisplayRecode) { int[,] Next = {{1,0},{0,1},{-1,0},{0,-1}};//上下左右 ArrayList result = new ArrayList(); for(int i = 0; i < Next.GetLength(0); i++) { int new_X = Ref.X + Next[i ,0]; int new_Y = Ref.Y + Next[i ,1]; if(new_X < 0 || new_Y < 0) continue; if(MapBlocks.Length <= new_X || MapBlocks[new_X].Length <= new_Y) continue; if(DisplayRecode[new_X][new_Y] != 0) continue; if(this.MapBlocks[new_X][new_Y] == null) continue; result.Add(new MapPosition() { X = new_X ,Y = new_Y }); } return result.ToArray<MapPosition>(); }
public GameObject GetGameObject(MapPosition Position) { foreach(GameObject item in this.MapObjects) { if(item.Position.Equals(Position)) { return item; } } return null; }