예제 #1
0
    private IEnumerator EndOfRound()
    {
        CombatantCell[] playerCells   = playerBoard.GetComponentsInChildren <CombatantCell>();
        CombatantCell[] opponentCells = opponentBoard.GetComponentsInChildren <CombatantCell>();
        int             cellCount     = playerCells.Length;

        if (opponentCells.Length > cellCount)
        {
            cellCount = opponentCells.Length;
        }

        for (int i = 0; i < cellCount; i++)
        {
            if ((playerCells.Length > i) && (playerCells[i] != null))
            {
                CombatantCell pc = playerCells[i];
                if ((pc.GetCellData() != null) && (pc.GetCellData().bRoundEndAbility))
                {
                    pc.GetCellData().RoundEndAbility(pc);
                }
            }

            if ((opponentCells.Length > i) && (opponentCells[i] != null))
            {
                CombatantCell oc = opponentCells[i];
                if ((oc.GetCellData() != null) && (oc.GetCellData().bRoundEndAbility))
                {
                    oc.GetCellData().RoundEndAbility(oc);
                }
            }

            yield return(new WaitForSeconds(0.11f));
        }
    }
예제 #2
0
    public void FinishMoveToSlot()
    {
        CombatantBoard myBoard = parentRectTransform.parent.GetComponentInParent <CombatantBoard>();

        if (myBoard != null)
        {
            bool      bGoodMove        = false;
            Transform closestTransform = myBoard.GetClosestSlotTo(transform.position);
            if (closestTransform != null)
            {
                CellSlot closestSlot = closestTransform.GetComponent <CellSlot>();
                if (closestSlot != cellSlot)
                {
                    transform.SetParent(closestTransform);
                    transform.localPosition = Vector3.zero;
                    transform.localScale    = Vector3.one;

                    //if ((moveOriginSlot != null) && (moveOriginSlot.GetCell() != null))
                    //{
                    //	CellData cellData = moveOriginSlot.GetCell().GetCellData();
                    //	if (cellData != null)
                    //		combatCell.LoadCellData(cellData);
                    //}

                    bGoodMove = true;
                    cellSlot  = closestSlot;
                    cellSlot.LoadCell(combatCell, movingCellData, false);
                    combatCell.SetSlot(cellSlot);

                    /// On Move Ability
                    if ((combatCell != null) && (combatCell.GetCellData() != null) &&
                        (combatCell.GetCellData().bOnMoveAbility))
                    {
                        combatCell.GetCellData().OnMoveAbility(cellSlot);
                    }
                }
                else
                {
                    /// move ended up at origin
                    transform.SetParent(cellSlot.transform);
                    transform.localPosition = Vector3.zero;
                    transform.localScale    = Vector3.one;
                }
            }

            if (bGoodMove)
            {
                if (moveCounter != null)
                {
                    moveCounter.SpendMoveToken(1);
                }

                moveOriginSlot.ClearCell(false);
            }
        }
    }
예제 #3
0
 public void TakeDamage(int value)
 {
     if ((combatCell != null) && (combatCell.GetCellData() != null))
     {
         combatCell.TakeDamage(value);
     }
     //else
     //{
     //	board.TakeDamage(value);
     //	slotDamageParticles.Play();
     //}
 }
예제 #4
0
 public void OnPointerUp(PointerEventData data)
 {
     if ((movingCell != null) && (movingCell.GetCellData() != null))
     {
         movingCell.LoadCellData(movingCell.GetCellData());
         combatCell = movingCell;
         LoadCell(movingCell, movingCell.GetCellData(), false);
         combatCell.GetComponent <CombatCellMover>().SetMoving(false, this);
         combatCell.ShowCanvasGroup(true);
         combatCell.GetComponent <CombatCellMover>().FinishMoveToSlot();
         RecordMovingCell(null, null);
     }
 }
예제 #5
0
    public void LoadBoard(List <CellData> cells)
    {
        if (slotList != null)
        {
            for (int i = 0; i < cells.Count; i++)
            {
                if ((cells[i] != null) && (slotList.Count > i))
                {
                    CombatantCell combatCell = SpawnCombatCell(cells[i], slotList[i]);
                    slotList[i].LoadCell(combatCell, combatCell.GetCellData(), false);
                }
            }
        }

        if (health != null)
        {
            int cellCount = slotList.Count;
            health.InitHealth(cellCount);
        }

        BoardEditor be = FindObjectOfType <BoardEditor>();

        if (be != null)
        {
            be.LoadSlots();
        }
    }
예제 #6
0
    void ResolveCellPair(CellSlot cellSlotA, CellSlot cellSlotB)
    {
        cellSlotA.HighlightForDuration(0.5f);
        cellSlotB.HighlightForDuration(0.5f);

        CellData      cellA       = null;
        CombatantCell combatCellA = null;

        if (cellSlotA.GetCell() != null)
        {
            combatCellA = cellSlotA.GetCell();
            cellA       = combatCellA.GetCellData();
        }
        CellData      cellB       = null;
        CombatantCell combatCellB = null;

        if (cellSlotB.GetCell() != null)
        {
            combatCellB = cellSlotB.GetCell();
            cellB       = combatCellB.GetCellData();
        }

        if (cellA != null)
        {
            if (cellA.bAttackAbility)
            {
                cellA.AttackAbility(cellSlotA, cellSlotB);
            }

            int cellADamage = combatCellA.GetDamage();
            if (cellADamage > 0)
            {
                combatCellA.GetComponent <CellArsenal>().StartHitAfterDelay(cellSlotA.transform, cellSlotB.transform, cellADamage);
            }
        }

        if (cellB != null)
        {
            if (cellB.bAttackAbility)
            {
                cellB.AttackAbility(cellSlotB, cellSlotA);
            }

            int cellBDamage = combatCellB.GetDamage();
            if (cellBDamage > 0)
            {
                combatCellB.GetComponent <CellArsenal>().StartHitAfterDelay(cellSlotB.transform, cellSlotA.transform, cellBDamage);
            }
        }
    }
예제 #7
0
    private void HitCell(Transform attackerTransform, Transform targetTransform, int damage)
    {
        attackParticles.transform.SetParent(targetTransform);
        attackParticles.transform.localPosition = Vector3.zero;
        int particleDamageScale = Mathf.Clamp(damage, 1, 20);

        attackParticles.transform.localScale = Vector3.one * particleDamageScale;
        attackParticles.Play();

        bool bAttackThrough = true;

        CombatantCell targetCell = targetTransform.GetComponent <CombatantCell>();

        if (!targetCell)
        {
            targetCell = targetTransform.GetComponentInChildren <CombatantCell>();
        }
        if (targetCell != null)
        {
            if (targetCell != null)
            {
                CellData targetCellData = targetCell.GetCellData();
                if ((targetCellData != null) && targetCellData.bOnAttackedAbility)
                {
                    CellSlot slotA = attackerTransform.GetComponent <CellSlot>();
                    CellSlot slotB = targetTransform.GetComponent <CellSlot>();
                    bAttackThrough = targetCellData.OnAttackedAbility(slotB, slotA);
                }
            }

            if (bAttackThrough)
            {
                targetCell.TakeDamage(damage);
                battleUI.ToastInteraction(targetCell.transform.position, damage, 0, "--");
                battle.TestBattleOver();
            }
        }
        else
        {
            battleUI.ToastInteraction(targetTransform.position, damage, 0, "--");
            battle.TestBattleOver();
        }
    }
예제 #8
0
    public void MirrorBoard()
    {
        // 1 - store & clear the top and bottom rows
        /// top
        List <CombatantCell> topRowCells = new List <CombatantCell>();

        for (int i = 0; i < boardColumnCount; i++)
        {
            CellSlot slot = slotList[i];
            if (slot != null)
            {
                CombatantCell cell = slot.GetCell();
                if ((cell != null) && (cell.GetCellData() != null))
                {
                    topRowCells.Add(cell);
                }
            }
        }
        /// bottom
        List <CombatantCell> bottomRowCells = new List <CombatantCell>();

        for (int i = 0; i < boardColumnCount; i++)
        {
            int      mirrorIndex = i + (boardColumnCount * 2);
            CellSlot slot        = slotList[mirrorIndex];
            if (slot != null)
            {
                CombatantCell cell = slot.GetCell();
                if ((cell != null) && (cell.GetCellData() != null))
                {
                    bottomRowCells.Add(cell);
                }
            }
        }

        // 2 - load exchanged rows
        /// top
        for (int i = 0; i < boardColumnCount; i++)
        {
            if ((i < bottomRowCells.Count) && (bottomRowCells[i] != null))
            {
                CellSlot      slot = slotList[i];
                CombatantCell cell = bottomRowCells[i];
                CellData      data = cell.GetCellData();

                slot.LoadCell(cell, data, false);
                cell.LoadCellData(data);
                cell.transform.SetParent(slot.transform);
                cell.transform.localPosition = Vector3.zero;
                transform.localScale         = Vector3.one;
                cell.SetSlot(slot);
            }
        }
        /// bottom
        for (int i = 0; i < boardColumnCount; i++)
        {
            if ((i < topRowCells.Count) && (topRowCells[i] != null))
            {
                int           mirrorIndex = i + (boardColumnCount * 2);
                CellSlot      slot        = slotList[mirrorIndex];
                CombatantCell cell        = topRowCells[i];
                CellData      data        = cell.GetCellData();

                slot.LoadCell(cell, data, false);
                cell.LoadCellData(data);
                cell.transform.SetParent(slot.transform);
                cell.transform.localPosition = Vector3.zero;
                transform.localScale         = Vector3.one;
                cell.SetSlot(slot);
            }
        }
    }