public void RemovePiece(Piece piece) { if (piece != null && ActivePieces.Contains(piece)) { ActivePieces.Remove(piece); } }
public void AddPiece(Piece piece) { if (piece != null && !ActivePieces.Contains(piece) && piece.TeamColor == TeamColor) { ActivePieces.Add(piece); } }
public PieceContainer DeepCopy() { List <PieceInfo> allPieces = AllPieces; List <PieceInfo> activePieces = ActivePieces.DeepCopy(); List <PieceInfo> inactivePieces = InactivePieces.DeepCopy(); PieceInfo flag = activePieces.Find(piece => piece.Rank == PieceRank.Flag); return(new PieceContainer(allPieces, activePieces, inactivePieces, flag)); }
private IEnumerator Spawn() { //TODO: Play spawn VFX/particles yield return(spawnDelay); var currentPieceData = NextPieceData; var pieceController = Instantiate(currentPieceData.prefab, spawnPosition, Quaternion.identity).GetComponent <PieceController>(); ActivePieces.AddNewPiece(pieceController); NextPieceData = GetRandomData(); }
//Object is destroyed by OnBecameInvisible (script attached to the child obj (w/MeshRenderer)) private void OnDestroy() //TODO: consider to create specific component for this too { if (canMove) //free fall: piece didnt touch the base or any other piece before become invisible { //The piece fell without touching the base or another piece! (Spawner is observing this event) OnPieceFell.Raise(); } //Anyway, touching the base/another piece or not, if the piece falls, the player loses a life ActivePieces.RemovePiece(this); OnPieceDestroyed.Raise(); }
public void OnPiecePlacedHandler() { var height = ActivePieces.GetHighestActivePiece(); if (height > currentTowerHeight.value + highestHeightThreshould) { currentTowerHeight.value = height; OnHeightIncreased.Raise(); } if (height > currentMilestoneHeight.value) { currentMilestoneHeight.value += difficultyFactor; StartCoroutine(MoveWinningMarker()); OnMilestoneReached.Raise(); } }