private List <GameObject> columnBomb(int column) { List <GameObject> dots = new List <GameObject>(); for (int i = 0; i < board.height; i++) { if (board.allDots[column, i] != null) { Dots dot = board.allDots[column, i].GetComponent <Dots>(); if (dot.isRowBomb == true) { dots.Union(RowBomb(i)).ToList(); } else if (dot.isBigBomb == true) { dots.Union(bigBomb(column, i)).ToList(); } else if (dot.isColorBomb == true) { FindSameColor(board.allDots[column, 0].tag); } dots.Add(board.allDots[column, i]); dot.isMatched = true; } } return(dots); }
private List <GameObject> RowBomb(int row) { List <GameObject> dots = new List <GameObject>(); for (int i = 0; i < board.width; i++) { if (board.allDots[i, row] != null) { Dots dot = board.allDots[i, row].GetComponent <Dots>(); if (dot.isColumnBomb == true) { dots.Union(columnBomb(i)).ToList(); } else if (dot.isBigBomb == true) { dots.Union(bigBomb(i, row)).ToList(); } else if (dot.isColorBomb == true) { FindSameColor(board.allDots[0, row].tag); } dots.Add(board.allDots[i, row]); dot.isMatched = true; } } return(dots); }
public void OnDeserialization() { // This algorithm also likely has an runtime of O(n^2) foreach (Line line in Lines) { line.From = Dots.ElementAt(lineReferences.ElementAt(0)); line.From.connectedLines.Add(line); lineReferences.RemoveAt(0); line.To = Dots.ElementAt(lineReferences.ElementAt(0)); line.To.connectedLines.Add(line); lineReferences.RemoveAt(0); } foreach (Class _class in Classes) { _class.Dots = new List <Dot>(); int i = classReferences.ElementAt(0); // Reference first index of this class' 4 dots. for (int a = 0; a < 4; a++) // Loop through all 4 dots { _class.Dots.Add(this.Dots.ElementAt(i + a)); } foreach (Dot dot in _class.Dots) { dot.attachedClass = _class; } classReferences.RemoveAt(0); _class.OnMoveEnd(); } }
public void Render(Graphics g) { this.Dots.Clear(); float x = 0; float y = 0; for (int i = 0; i < RowCount; i++) { for (int j = 0; j < ColumnCount; j++) { { Dot dot = new Dot(); dot.Location = new PointF(x, y); using (SolidBrush brush = new SolidBrush(ColorTranslator.FromHtml("#009aff"))) { g.FillEllipse(brush, dot.Location.X, dot.Location.Y, DotRadius, DotRadius); } x += (DotRadius + ColumnSpacing); Dots.Add(dot); } } x = 0; y += (DotRadius + this.RowSpacing); } }
private IEnumerator FillDotsOnBoard() { yield return(new WaitForSeconds(refillDelay)); RefillBoard(); while (MatchesDotsOnBoard()) { streakValue++; DestoryMatch(); yield break; // yield return new WaitForSeconds(2*refillDelay); } currentDot = null; CheckToMakeSlime(); if (IsDeadlocked()) { StartCoroutine(ShuffleBoard()); //Debug.Log("DeadLoack"); } yield return(new WaitForSeconds(refillDelay)); System.GC.Collect(); playState = PlayState.Move; makeSlime = true; streakValue = 1; //Debug.Log(playState); }
void IPointerUpHandler.OnPointerUp(PointerEventData eventData) { if (isPressed) { currentDot = null; if (connectedDotsList.Count < 2) { //we need to set it again to false, else the dot is marked which will prevent connection foreach (GameObject g in connectedDotsList) { g.GetComponent <Dots>().isAlreadyConnected = false; } connectedDotsList.Clear(); connector.TotalDotsConnected = 0; connector.ChangeColor(Color.white); isPressed = false; return; } CheckStatus(); connectedDotsList.Clear(); connector.TotalDotsConnected = 0; connector.lineRenderer.positionCount = 2; //we don't want to leave a trace of the line renderer when the dots are done connector.ChangeColor(Color.white); connector.Reset(); isPressed = false; isSquare = false; } }
private IEnumerator ShuffleBoard() { yield return(new WaitForSeconds(0.5f)); //Create a list of game objects List <GameObject> newBoard = new List <GameObject>(); //Add every piece to this list for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { if (allDots[i, j] != null) { newBoard.Add(allDots[i, j]); } } } yield return(new WaitForSeconds(0.5f)); //for every spot on the board. . . for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { //if this spot shouldn't be blank if (!blankSpaces[i, j] && !concreteTiles[i, j] && !slimeTiles[i, j]) { //Pick a random number int pieceToUse = Random.Range(0, newBoard.Count); //Assign the column to the piece int maxIterations = 0; while (MatchAt(i, j, newBoard[pieceToUse]) && maxIterations < 100) { pieceToUse = Random.Range(0, newBoard.Count); maxIterations++; Debug.Log(maxIterations); } //Make a container for the piece Dots piece = newBoard[pieceToUse].GetComponent <Dots>(); maxIterations = 0; piece.column = i; //Assign the row to the piece piece.row = j; //Fill in the dots array with this new piece allDots[i, j] = newBoard[pieceToUse]; //Remove it from the list newBoard.Remove(newBoard[pieceToUse]); } } } //Check if it's still deadlocked if (IsDeadlocked()) { StartCoroutine(ShuffleBoard()); } }
private void pointAToolStripMenuItem_Click(object sender, EventArgs e) { pointAToolStripMenuItem.Checked = !pointAToolStripMenuItem.Checked; Dots d = Check(); EventAB ev = new EventAB(); ev.choise = d; ChangeAB(containers[0].ID, ev); }
public async Task <Dots> Load() { var gameResponse = await _gameState.LoadGame(Game.GameType, Game.Id.ToString()); Game = Converter <Dots> .FromJson(gameResponse); return(Game); }
} //1.2 private IEnumerator findMatches() //butun matriste gezerek her bir noktanin (alt ve ustunun) ve (sag ve solunun) eslesme kontrolu { yield return(new WaitForSeconds(.2f)); for (int i = 0; i < board.width; i++) { for (int j = 0; j < board.height; j++) { GameObject dot = board.allDots[i, j]; if (dot != null) { Dots dotDot = dot.GetComponent <Dots>(); if (i > 0 && i < board.width - 1) //x ekseninde sag ve sol { GameObject rightDot = board.allDots[i + 1, j]; GameObject leftDot = board.allDots[i - 1, j]; if (leftDot != null & rightDot != null) { if (leftDot.tag == dot.tag && rightDot.tag == dot.tag) { if (rightDot != null && leftDot != null) { Dots rightDotDot = rightDot.GetComponent <Dots>(); //oyun objesi olarak atayinca null reference hatasi aliyordum. ikinci bir dot nesnesi atamasi gerekti. Dots leftDotDot = leftDot.GetComponent <Dots>(); matches.Union(isRowBomb(leftDotDot, rightDotDot, dotDot)); matches.Union(isColumnBomb(leftDotDot, rightDotDot, dotDot)); matches.Union(isBigBomb(leftDotDot, rightDotDot, dotDot)); fillTHeList(leftDot, rightDot, dot); } } } } if (j > 0 && j < board.height - 1) { GameObject DownDot = board.allDots[i, j - 1]; GameObject upDot = board.allDots[i, j + 1]; if (upDot != null & DownDot != null) //y ekseninde { if (upDot.tag == dot.tag && DownDot.tag == dot.tag) { if (upDot != null && DownDot != null) { Dots upDotDot = upDot.GetComponent <Dots>(); Dots downDotDot = DownDot.GetComponent <Dots>(); matches.Union(isColumnBomb(upDotDot, downDotDot, dotDot)); matches.Union(isRowBomb(upDotDot, downDotDot, dotDot)); matches.Union(isBigBomb(upDotDot, downDotDot, dotDot)); fillTHeList(upDot, DownDot, dot); } } } } } } } }
public GetStarted5() { InitializeComponent(); Dots.SelectCircle(5); ManipulationMode = ManipulationModes.TranslateX; ManipulationStarted += Manipulation_Started; ManipulationCompleted += Manipulation_Completed; }
private void Start() { //Fetch the Raycaster from the GameObject (the Canvas) raycaster = GetComponent <GraphicRaycaster>(); //Fetch the Event System from the Scene eventSystem = GetComponent <EventSystem>(); currentDot = null; }
//добавление элемента из архива //public void AddBefore(MomentValue dot) //{ // if (dot.Undef % 2 != 0) dot.ToMomentReal().Mean = Dots.ParamsCount != 0 ? Dots.Last().ToMomentReal().Mean : 0; // Dots.Insert(0, dot); //} //public void AddBefore(List<MomentValue> dots) //{ // if (dots[0].Undef % 2 != 0) dots.Insert(0, new MomentReal(dots[0].Time, 0, -1, 0, 0)); // for (int index = dots.ParamsCount-1; index >= 0; index--) // { // var momentValue = dots[index]; // if (momentValue.Undef % 2 != 0) momentValue.ToMomentReal().Mean = dots[index + 1].ToMomentReal().Mean; // Dots.Insert(0, momentValue); // } //} //добавление элемента public void AddValues(MomentValue dot) { if (!IsUpdated) { IsUpdated = true; NumberOfFirstWaiting = Dots.Count; } //if (dot.Nd % 2 != 0) dot.ToMomentReal().Mean = Dots.Count != 0 ? Dots.Last().ToMomentReal().Mean : 0; Dots.Add(dot); }
public void ChangeTrajectoryParams(int ID, Dots choise) { MechanismInfo mi = FindMechanismInfo(ID); if (mi.mechanism != null) { mi.choise = choise; } // else throw new Exception("Error: element not found"); }
void CheckToMakeBombs() { //How many objects are in findMatches currentMatches? if (matchFinder.currentMatches.Count > 3) { //What type of match? MatchType typeOfMatch = ColumnOrRow(); if (typeOfMatch.type == 1) { //Make a color bomb //is the current dot matched? if (currentDot != null && currentDot.isMatched && currentDot.tag == typeOfMatch.color) { currentDot.isMatched = false; currentDot.MakeColorBomb(); } else { if (currentDot.otherDot != null) { Dots otherDot = currentDot.otherDot.GetComponent <Dots>(); if (otherDot.isMatched && otherDot.tag == typeOfMatch.color) { otherDot.isMatched = false; otherDot.MakeColorBomb(); } } } } else if (typeOfMatch.type == 2) { //Make a adjacent bomb //is the current dot matched? if (currentDot != null && currentDot.isMatched && currentDot.tag == typeOfMatch.color) { currentDot.isMatched = false; currentDot.MakeAdjacentBomb(); } else if (currentDot.otherDot != null) { Dots otherDot = currentDot.otherDot.GetComponent <Dots>(); if (otherDot.isMatched && otherDot.tag == typeOfMatch.color) { otherDot.isMatched = false; otherDot.MakeAdjacentBomb(); } } } else if (typeOfMatch.type == 3) { matchFinder.CheckBombs(typeOfMatch); } } }
// 카드 기능 함수 public void CardFunction(int num) { switch (num) { case 0: Dots.SetActive(true); wallCard = 0; CardCover.SetActive(true); UIArray_N[2].SetActive(true); break; case 1: Dots.SetActive(true); wallCard = 1; CardCover.SetActive(true); UIArray_N[2].SetActive(true); break; case 2: Dots.SetActive(true); wallCard = 2; CardCover.SetActive(true); UIArray_N[2].SetActive(true); break; case 3: Wild(); break; case 4: PlaySoundU(20); Provoke(); break; case 5: On_Scrow(); break; case 6: On_Catnip(); break; case 7: On_SOS(); break; case 8: wallCard = 8; rw.canRemove = true; CardCover.SetActive(true); UIArray_N[3].SetActive(true); break; } }
//returns the number of dots connected below the said dot. //This will essentially help us find how may rows will the above dots fall private int GetConnectedDotsUnderConnectedDot(Dots dot) { int count = 0; GetSpecificDots(dot.ColumnNumber, (otherDot) => { if (otherDot.isAlreadyConnected == true && otherDot.RowNumber < dot.RowNumber) { count++; } }); return(count); }
static void Test(Dot[] X, Dot[][] ℳ, bool verbose) { Dots.compute(ℳ, X); for (int l = 0; l < ℳ.Length; l++) { Inspect($"H{l}", ℳ[l], ConsoleColor.White, verbose); } Inspect("X", X, ConsoleColor.Green, verbose); Console.WriteLine(); }
//Добавить значение на график public void AddDot(MomentReal dot) { Dots.Add(dot); if ((_minValue == null) || (dot.Mean < _minValue)) { _minValue = dot.Mean; } if ((_maxValue == null) || (dot.Mean > _maxValue)) { _maxValue = dot.Mean; } }
public void OnSerialization() { // Runtime of this algorithm is about O(n^2) foreach (Class _class in Classes) { classReferences.Add(Dots.FindIndex(a => a == _class.Dots.ElementAt(0))); } foreach (Line line in Lines) { lineReferences.Add(Dots.FindIndex(a => a == line.From)); lineReferences.Add(Dots.FindIndex(a => a == line.To)); } }
//bombalarin islevleri ve diger bombalari tetikleme fonksiyonlari private List <GameObject> bigBomb(int column, int row) { List <GameObject> dots = new List <GameObject>(); for (int i = column - 1; i <= column + 1; i++) { for (int j = row - 1; j <= row + 1; j++) { if (i >= 0 && i < board.width && j >= 0 && j < board.height) { if (board.allDots[i, j] != null) { Dots dot = board.allDots[i, j].GetComponent <Dots>(); if (dot.isRowBomb == true) { for (int x = 0; x < board.width; x++) { if (board.allDots[x, j] != null) { Dots forRowBomb = board.allDots[x, j].GetComponent <Dots>(); dots.Add(board.allDots[x, j]); forRowBomb.isMatched = true; } } } else if (dot.isColumnBomb == true) { for (int y = 0; y < board.height; y++) { if (board.allDots[i, y] != null) { Dots forColumnBomb = board.allDots[i, y].GetComponent <Dots>(); dots.Add(board.allDots[i, y]); forColumnBomb.isMatched = true; } } } else if (dot.isColorBomb == true) { FindSameColor(board.allDots[column, row].tag); } dots.Add(board.allDots[i, j]); dot.isMatched = true; } } } } return(dots); }
private void drawToolStripMenuItem_Click(object sender, EventArgs e) { EventDraw ed = new EventDraw(); ed.Graphics = containers[0].g; Draw(this, ed); Dots d = Check(); if (d != Dots.None) { EventAB ev = new EventAB(); ev.choise = d; ChangeAB(containers[0].ID, ev); } }
public void FindSameColor(string color) //colorBomb un eslestigi renkleri oyun alaninda bulan kod parcasi { for (int i = 0; i < board.width; i++) { for (int j = 0; j < board.height; j++) { if (board.allDots[i, j] != null) { if (board.allDots[i, j].tag == color) { Dots dot = board.allDots[i, j].GetComponent <Dots>(); if (dot.isRowBomb == true) { for (int x = 0; x < board.width; x++) { if (board.allDots[x, j] != null) { board.allDots[x, j].GetComponent <Dots>().isMatched = true; } } } else if (dot.isColumnBomb == true) { for (int y = 0; y < board.height; y++) { if (board.allDots[i, y] != null) { board.allDots[i, y].GetComponent <Dots>().isMatched = true; } } } else if (dot.isBigBomb == true) { for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { board.allDots[x, y].GetComponent <Dots>().isMatched = true; } } } dot.isMatched = true; } } } } }
public DotsGame(IHandleGameState gameState, Guid?id = null) { _gameState = gameState; if (id == null) { Game = new Dots(); Game.Id = Guid.NewGuid(); Game.CreatedOn = DateTime.UtcNow; Game.GameState = GameState.New; Game.Groups = new List <GolfGroup>(); } else { Load((Guid)id); } }
public void AddValues(List <MomentValue> dots) { //if (dots[0].Nd % 2 != 0) dots.Insert(0, new MomentReal(dots[0].Time.AddMilliseconds(-1), 0, 0)); if (!IsUpdated) { IsUpdated = true; NumberOfFirstWaiting = Dots.Count; } foreach (var momentValue in dots) { //if (momentValue.Nd % 2 != 0) momentValue.ToMomentReal().Mean = Dots.Last().ToMomentReal().Mean; Dots.Add(momentValue); } //Dots.Sort(CompareMomentVal); }
private List <GameObject> isColumnBomb(Dots dot1, Dots dot2, Dots dot3) { List <GameObject> currentDots = new List <GameObject>(); if (dot1.isColumnBomb) { matches.Union(columnBomb(dot1.column)); } if (dot2.isColumnBomb) { matches.Union(columnBomb(dot2.column)); } if (dot3.isColumnBomb) { matches.Union(columnBomb(dot3.column)); } return(currentDots); }
private List <GameObject> isRowBomb(Dots dot1, Dots dot2, Dots dot3) { List <GameObject> currentDots = new List <GameObject>(); if (dot1.isRowBomb) { matches.Union(RowBomb(dot1.row)); } if (dot2.isRowBomb) { matches.Union(RowBomb(dot2.row)); } if (dot3.isRowBomb) { matches.Union(RowBomb(dot3.row)); } return(currentDots); }
} //5.1 private int BombType() //eslemenin sayisina ve sekline gore olusacak bomba cesidini belirliyor { List <GameObject> matchCopy = find.matches as List <GameObject>; for (int i = 0; i < matchCopy.Count; i++) { Dots thisDot = matchCopy[i].GetComponent <Dots>(); int column = thisDot.column; int row = thisDot.row; int columnMatch = 0; int rowMatch = 0; for (int j = 0; j < matchCopy.Count; j++) { Dots nextDot = matchCopy[j].GetComponent <Dots>(); if (nextDot == thisDot) { continue; } if (nextDot.column == thisDot.column && nextDot.CompareTag(thisDot.tag)) { columnMatch++; } if (nextDot.row == thisDot.row && nextDot.CompareTag(thisDot.tag)) { rowMatch++; } } if (columnMatch == 4 || rowMatch == 4) { return(1); //colorBomb } if ((columnMatch == 2 || rowMatch == 2) && (matchCopy.Count == 5 || matchCopy.Count == 8)) { return(2); //bigbomb } if ((columnMatch == 3 || rowMatch == 3) && (matchCopy.Count == 4 || matchCopy.Count == 7)) { return(3); //row or column bomb } } return(0); } //3.1
}//GetColumnPieces List <GameObject> GetRowPieces(int row) { List <GameObject> dots = new List <GameObject>(); for (int i = 0; i < board.width; i++) { if (board.allDots[i, row] != null) { Dots dot = board.allDots[i, row].GetComponent <Dots>(); if (dot.isColumnBomb) { dots.Union(GetColumnPieces(i)).ToList(); } dots.Add(board.allDots[i, row]); dot.isMatched = true; } } return(dots); }//GetRowPieces
}//GetRowPieces public void CheckBombs(MatchType matchType) { //Did the player move something? if (board.currentDot != null) { //Is the piece they moved matched? if (board.currentDot.isMatched && board.currentDot.tag == matchType.color) { //make it unmatched board.currentDot.isMatched = false; if ((board.currentDot.swipeAngle > -45 && board.currentDot.swipeAngle <= 45) || (board.currentDot.swipeAngle < -135 || board.currentDot.swipeAngle >= 135)) { board.currentDot.MakeRowBomb(); } else { board.currentDot.MakeColumnBomb(); } } //Is the other piece matched? else if (board.currentDot.otherDot != null) { Dots otherDot = board.currentDot.otherDot.GetComponent <Dots>(); //Is the other Dot matched? if (otherDot.isMatched && otherDot.tag == matchType.color) { //Make it unmatched otherDot.isMatched = false; if ((board.currentDot.swipeAngle > -45 && board.currentDot.swipeAngle <= 45) || (board.currentDot.swipeAngle < -135 || board.currentDot.swipeAngle >= 135)) { otherDot.MakeRowBomb(); } else { otherDot.MakeColumnBomb(); } } } } }
static void Main() { string command = string.Empty; char[,] field = CreatePlayingField(); char[,] bombs = InsertBombs(); int counter = 0; bool explode = false; List<Dots> champions = new List<Dots>(6); int row = 0; int col = 0; bool flag = true; const int maximum = 35; bool flag2 = false; do { if (flag) { Console.WriteLine("Hajde da igraem na “Mini4KI”. Probvaj si kasmeta da otkriesh fieldteta bez mini4ki." + " command 'top' pokazva klasiraneto, 'restart' po4va nova igra, 'exit' izliza i hajde 4ao!"); Result(field); flag = false; } Console.Write("Daj row i col : "); command = Console.ReadLine().Trim(); if (command.Length >= 3) { if (int.TryParse(command[0].ToString(), out row) && int.TryParse(command[2].ToString(), out col) && row <= field.GetLength(0) && col <= field.GetLength(1)) { command = "turn"; } } switch (command) { case "top": Ranking(champions); break; case "restart": field = CreatePlayingField(); bombs = InsertBombs(); Result(field); explode = false; flag = false; break; case "exit": Console.WriteLine("4a0, 4a0, 4a0!"); break; case "turn": if (bombs[row, col] != '*') { if (bombs[row, col] == '-') { YourTurn(field, bombs, row, col); counter++; } if (maximum == counter) { flag2 = true; } else { Result(field); } } else { explode = true; } break; default: Console.WriteLine("\nGreshka! nevalidna command\n"); break; } if (explode) { Result(bombs); Console.Write("\nHrrrrrr! Umria gerojski s {0} to4ki. " + "Daj si niknejm: ", counter); string niknejm = Console.ReadLine(); Dots t = new Dots(niknejm, counter); if (champions.Count < 5) { champions.Add(t); } else { for (int i = 0; i < champions.Count; i++) { if (champions[i].numOfDots < t.numOfDots) { champions.Insert(i, t); champions.RemoveAt(champions.Count - 1); break; } } } champions.Sort((Dots r1, Dots r2) => r2.name.CompareTo(r1.name)); champions.Sort((Dots r1, Dots r2) => r2.numOfDots.CompareTo(r1.numOfDots)); Ranking(champions); field = CreatePlayingField(); bombs = InsertBombs(); counter = 0; explode = false; flag = true; } if (flag2) { Console.WriteLine("\nBRAVOOOS! Otvri 35 kletki bez kapka kryv."); Result(bombs); Console.WriteLine("Daj si imeto, batka: "); string name = Console.ReadLine(); Dots playerDots = new Dots(name, counter); champions.Add(playerDots); Ranking(champions); field = CreatePlayingField(); bombs = InsertBombs(); counter = 0; flag2 = false; flag = true; } } while (command != "exit"); Console.WriteLine("Made in Bulgaria - Uauahahahahaha!"); Console.WriteLine("AREEEEEEeeeeeee."); Console.Read(); }