示例#1
0
 public void RemovePiece(Piece piece)
 {
     if (piece != null && ActivePieces.Contains(piece))
     {
         ActivePieces.Remove(piece);
     }
 }
示例#2
0
 public void AddPiece(Piece piece)
 {
     if (piece != null && !ActivePieces.Contains(piece) && piece.TeamColor == TeamColor)
     {
         ActivePieces.Add(piece);
     }
 }
示例#3
0
    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));
    }
示例#4
0
    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();
        }
    }