SpotValue ParseSpotValue(int ndxRow) { string[] row = m_srcData[ndxRow]; int colPrice = m_colMapping[ColumnKey_t.Price]; int colTime = m_colMapping[ColumnKey_t.Date]; int colSession = m_colMapping[ColumnKey_t.SessionNber]; double price; DateTime tm; uint sessionNber; TRLabel lbl; ProductMapping mapping; if (!double.TryParse(row[colPrice], out price) || price <= 0.0 || !DateTime.TryParse(row[colTime], out tm) || !uint.TryParse(row[colSession], out sessionNber) || (mapping = ParseProductMapping(ndxRow)) == null || (lbl = ParseLabel(ndxRow, mapping.ProductNumber)) == null) { return(null); } SpotValue sp = null; if (FindSpotValue(mapping.ID, tm) == null) { sp = new SpotValue(AppContext.TableManager.TRSpotValues.CreateUniqID(), mapping.ID, lbl.ID, sessionNber, price, tm); Assert(m_pendingData.ContainsKey(AppContext.TableManager.TRSpotValues.ID) == false); m_pendingData[AppContext.TableManager.TRSpotValues.ID] = sp; } return(sp); }
private bool VerifyRow(int row, int col) { int count = 1; SpotValue value = Spots[row, col].Value; int curPosition = col - 1; while (curPosition >= 0) { if (Spots[row, curPosition].Value == value) { count++; } else { break; } curPosition--; } curPosition = col + 1; while (curPosition < RowCount) { if (Spots[row, curPosition].Value == value) { count++; } else { break; } curPosition++; } return(count >= 5); }
public void Start() { Console.WriteLine("Game Start!"); Console.WriteLine("Set the size of your board!"); Console.WriteLine("What is the number of rows?"); string rowCount = Console.ReadLine(); Console.WriteLine("What is the number of columns?"); string colCount = Console.ReadLine(); Board = new Board(Convert.ToInt32(rowCount), Convert.ToInt32(colCount)); bool isTurnPlayerOne = true; while (true) { Board.Print(); SpotValue spotValue = isTurnPlayerOne ? SpotValue.Black : SpotValue.White; string player = isTurnPlayerOne ? "Player 1" : "Player 2"; Console.WriteLine($"{player}, please place a chess:"); Console.WriteLine("Which row?"); int row = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Which column?"); int col = Convert.ToInt32(Console.ReadLine()); if (Board.PlaceChess(row, col, spotValue)) { if (Board.VerifyBoard(row, col)) { Console.WriteLine($"{player} wins!"); break; } isTurnPlayerOne = !isTurnPlayerOne; } } Console.WriteLine("Game ends!"); }
private void UpdateTexture() { currentTex = driver.CurrentTurn; if(currentTex == SpotValue.X) { renderer.material.mainTexture = texX; } else { renderer.material.mainTexture = texO; } }
//private: static string[] GetItemContent(SpotValue spotValue) { return(new string[] { spotValue.Product.Name, spotValue.SpotTime.ToShortDateString(), $"{spotValue.Price.ToString()} {spotValue.ValueContext.Currency.Name} / {spotValue.ValueContext.Unit.Name}", spotValue.ValueContext.Origin?.Name ?? "", spotValue.ValueContext.Incoterm?.Name ?? "", spotValue.ValueContext.Place?.Name ?? "", spotValue.Description.Text, spotValue.DataSupplier.Name }); }
public void MakeMark(SpotValue newValue) { value = newValue; if(value == SpotValue.X) { mark = Instantiate(prefabX) as GameObject; } else { mark = Instantiate(prefabO) as GameObject; } AudioSource.PlayClipAtPoint(throwSound, Camera.main.transform.position); mark.transform.parent = transform; markStartPos = Camera.main.transform.position; markStartPos += TinyBoard.IndexToCoordinate(board.GetIndex(this)); mark.transform.localPosition = markStartPos; mark.transform.rotation = Quaternion.Euler(markStartSpin); markStart = Time.time; }
public bool PlaceChess(int row, int col, SpotValue value) { if (row < 0 || row >= RowCount || col < 0 || col >= ColCount) { Console.WriteLine($"{row},{col} is a invalid postion to place chess."); return(false); } if (Spots[row, col].Value != SpotValue.Empty) { Console.WriteLine($"{row},{col} is occupied!"); return(false); } Spots[row, col].Value = value; Console.WriteLine($"{row},{col} is placed a chess {value.ToString()}."); return(true); }
SpotValue FindSpotValue(uint mappingID, DateTime tm) { SpotValue sv = null; List <IDataRow> data; if (m_importedData.TryGetValue(AppContext.TableManager.TRSpotValues.ID, out data)) { sv = data.Cast <SpotValue>().SingleOrDefault(d => d.ProductMappingID == mappingID && d.Time == tm); } if (sv == null) { sv = SpotValueMappingIDIndexer.Get(mappingID).Cast <SpotValue>().SingleOrDefault(d => d.Time == tm); } return(sv); }
private bool VerifyTiltUp(int row, int col) { int count = 1; SpotValue value = Spots[row, col].Value; int curRow = row + 1; int curCol = col - 1; while (curRow < RowCount && curCol >= 0) { if (Spots[curRow, curCol].Value == value) { count++; } else { break; } curRow++; curCol--; } curRow = row - 1; curCol = col + 1; while (curRow >= 0 && curCol < ColCount) { if (Spots[curRow, curCol].Value == value) { count++; } else { break; } curRow--; curCol++; } return(count >= 5); }
public Spot(int row, int col, SpotValue spotValue) { this.Row = row; this.Col = col; this.Value = spotValue; }
public SpotViewItem(SpotValue spotValue) : base(GetItemContent(spotValue)) { SpotValue = spotValue; }
public void Start() { currentTurn = SpotValue.X; tinySpotMask = 1 << LayerMask.NameToLayer("TinySpot"); }
public void MakeMove(TinySpot spot) { spot.MakeMark(currentTurn); spot.Board.MadeMove(spot); // check if this ends the game bigBoard.CheckWinner(); if(bigBoard.Winner != SpotValue.None) { switch(bigBoard.Winner) { case SpotValue.X: Debug.Log("Game Over, X won!"); break; case SpotValue.O: Debug.Log("Game Over, O won!"); break; case SpotValue.Tie: Debug.Log("Game Over, TIED!"); break; } isPlaying = false; } else { // find the next forced board int index = spot.Board.GetIndex(spot); TinyBoard targetBoard = bigBoard.GetSpot(index) as TinyBoard; forcedBoard = targetBoard; // but don't force it if it's already completed if(targetBoard.Winner != SpotValue.None) { forcedBoard = null; } highlight.Highlight(currentTurn, spot, targetBoard, targetBoard == forcedBoard); // next turn is opposite player's if(currentTurn == SpotValue.X) { currentTurn = SpotValue.O; } else { currentTurn = SpotValue.X; } } }