//Message from another object to add the sent object to its list public void AddPolygon(TessellationPolygon t) { if (!adjacentPolygons.Contains(t)) { adjacentPolygons.Add(t); } }
/// <summary> /// Removes a polygon from the list. /// </summary> /// <param name='p'> /// P. /// </param> void DeletePolygon(TessellationPolygon p) { Debug.Log("deleting polygon"); if (polygons.Contains(p)) { polygons.Remove(p); } numOfPolygons--; checkIfAllPolygonsSpawned(); }
/// <summary> /// Called by message when a polygon is flipped. Checks for win condition. /// </summary> void PolygonFlipped(TessellationPolygon p) { //StartCoroutine(shakeCamera()); numOfFlips += 1 + p.getAdjacentPolygons().Count; numOfMoves++; updateMovesDisplay(); if (checkForWin()) { Debug.Log("*****WINNER*****"); disablePolygons(); StartCoroutine(win()); } //AdjacencyMatrix adj = new AdjacencyMatrix(polygons); //Debug.Log (adj.ToString()); }
/// <summary> /// Adds a polygon to the polygons list. Called by a message when the polygon is instantiated /// </summary> /// <param name='p'> /// The polygon being instantiated /// </param> void AddPolygon(TessellationPolygon p) { if (polygons.Contains(p)) { return; } //Debug.Log ("Adding polygon: " + p.transform.parent.name); p.transform.parent.name = "Polygon " + polygons.Count; p.setID(polygons.Count); polygons.Add(p); Debug.Log(polygons.Count + " of " + numOfPolygons + " registered."); checkIfAllPolygonsSpawned(); }
/// <summary> /// Sends a message to all of the adjacent polygons for them to delete this polygon from their lists /// </summary> private void deletePolygon(TessellationPolygon t) { adjacentPolygons.Remove(t); }