Example #1
0
    private void OnScaleTweenComplete()
    {
        GameManager.Instance.CurrentScore += _toDestroy.Count;

        foreach (HexCell cell in _toDestroy)
        {
            Destroy(cell.piece.gameObject);
            cell.piece = null;
        }

        if (_destructionState == DestructionState.LaserPieces)
        {
            // Begin phase 2 of destruction - destroy all isolated pieces.
            _destructionState = DestructionState.IsolatedPieces;
            _toDestroy.Clear();

            foreach (HexCell cell in GameManager.Instance.Grid)
            {
                if (cell.IsIsolated)
                {
                    _toDestroy.Add(cell);
                }
            }

            BeginDestruction(_toDestroy);
        }
    }
Example #2
0
    public void DestroyConnectingCellsOfType(HexCell startingCell)
    {
        var toDestroy = new List <HexCell>();

        foreach (HexCell startingCellNeighbour in startingCell.neighbours)
        {
            if (startingCellNeighbour.IsEmpty || startingCellNeighbour.piece.Type == HexType.Magnet)
            {
                continue;
            }

            var     toCheck         = new Stack <HexCell>();
            var     haveChecked     = new List <HexCell>();
            HexType destructionType = startingCellNeighbour.piece.Type;

            toCheck.Push(startingCell);
            HexCell current;

            while (toCheck.Count > 0)
            {
                current = toCheck.Pop();

                haveChecked.Add(current);

                if (!toDestroy.Contains(current))
                {
                    toDestroy.Add(current);
                }

                foreach (HexCell neighbour in current.neighbours)
                {
                    if (haveChecked.Contains(neighbour) || toCheck.Contains(neighbour))
                    {
                        continue;
                    }

                    if (neighbour.piece != null && neighbour.piece.Type == destructionType && neighbour.piece.Type != HexType.Magnet) // Don't destroy the magnet...
                    {
                        toCheck.Push(neighbour);
                    }
                }
            }
        }

        _destructionState = DestructionState.LaserPieces;
        BeginDestruction(toDestroy);
    }
Example #3
0
 public FortModel()
 {
     CurrentHealth     = MaxHP;
     CurrentDestrState = DestructionState.None;
 }