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)); } }
/// Francium absorbs health from damage public override bool OnAttackedAbility(CellSlot mySlot, CellSlot targetSlot) { base.OnAttackedAbility(mySlot, targetSlot); bool bAttackThrough = true; CombatantCell targetCell = targetSlot.GetComponentInChildren <CombatantCell>(); if (targetCell != null) { int targetCellDamage = targetCell.GetDamage(); CombatantCell myCell = mySlot.GetCell(); if (myCell != null) { if (!battleUI) { battleUI = FindObjectOfType <BattleUI>(); } battleUI.ToastInteraction(myCell.transform.position, targetCellDamage, 3, "hp +"); myCell.ModifyHealth(targetCellDamage); bAttackThrough = false; } } return(bAttackThrough); }
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(); } }
/// Caesium returns attacks back to the opponent public override bool OnAttackedAbility(CellSlot mySlot, CellSlot targetSlot) { base.OnAttackedAbility(mySlot, targetSlot); bool bAttackThrough = true; CombatantCell targetCell = targetSlot.GetComponentInChildren <CombatantCell>(); if (targetCell != null) { int targetCellDamage = targetCell.GetDamage(); CombatantCell myCell = mySlot.GetCell(); if (myCell != null) { if (!battleUI) { battleUI = FindObjectOfType <BattleUI>(); } battleUI.ToastInteraction(myCell.transform.position, targetCellDamage, 2, "reflect "); bAttackThrough = false; myCell.SetDamage(targetCellDamage); myCell.GetComponent <CellArsenal>().StartHitAfterDelay(mySlot.transform, targetSlot.transform, myCell.GetDamage()); myCell.SetDamage(0); } } return(bAttackThrough); }
bool CheckHitForCell(RaycastHit hit) { bool bHitCell = false; CombatantCell hitCombatCell = hit.transform.GetComponentInChildren <CombatantCell>(); if (hitCombatCell != null) { if (hitCombatCell.GetTeamID() != teamID) { if (myArsenal != null) { myArsenal.AttackColliderHit(hit.transform); SetEnabled(false); bHitCell = true; } } } CharacterCollider hitCharacter = hit.transform.GetComponent <CharacterCollider>(); if (!hitCharacter) { hitCharacter = hit.transform.GetComponentInChildren <CharacterCollider>(); } if (hitCharacter != null) { hitCharacter.TakeHit(damage); myArsenal.AttackColliderHit(hit.transform); SetEnabled(false); bHitCell = true; } return(bHitCell); }
public CombatantCell SpawnCombatCell(CellData cellData, CellSlot parentSlot) { CombatantCell cc = Instantiate(combatCellPrefab, parentSlot.transform); combatCellList.Add(cc); parentSlot.LoadCell(cc, cellData, false); return(cc); }
void RecordMovingCell(CombatantCell cc, CellData cd) { movingCell = cc; if (movingCell != null) { movingCell.LoadCellData(cd); } }
public override void RoundEndAbility(CombatantCell myCell) { base.RoundEndAbility(myCell); myCell.ModifyHealth(healPerRound); if (!battleUI) { battleUI = FindObjectOfType <BattleUI>(); } battleUI.ToastInteraction(myCell.transform.position, healPerRound, 3, "hp +"); }
void Start() { myRectTransform = GetComponent <RectTransform>(); parentRectTransform = transform.parent.GetComponent <RectTransform>(); if (FindObjectOfType <MoveField>() != null) { moveFieldTransform = FindObjectOfType <MoveField>().GetComponent <RectTransform>(); } cameraMain = Camera.main; cellSlot = transform.GetComponentInParent <CellSlot>(); combatCell = GetComponent <CombatantCell>(); }
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); } }
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); } } }
/// HeavyWater 'decays' into regular Water when eliminated public override void OnCellDiedAbility(CombatantCell myCell) { base.OnCellDiedAbility(myCell); myCombatCell = myCell; if (myCombatCell != null) { CellSlot mySlot = myCombatCell.GetSlot(); if (mySlot != null) { mySlot.LoadCell(myCombatCell, waterCellData, false); } } }
public void PlaceCell(CellSlot intoSlot) { if (bEditing && (hotCellData != null)) { int placingSlotIndex = intoSlot.transform.GetSiblingIndex(); /// placed to empty slot... if (((intoSlot.GetCell() == null) || ((intoSlot.GetCell() != null) && (intoSlot.GetCell().GetCellData() == null))) && ((boardValue + hotCellData.cellValue) <= maxBoardValue)) { CombatantCell combatCell = playerBoard.SpawnCombatCell(hotCellData, intoSlot); intoSlot.LoadCell(combatCell, hotCellData, false); if (boardCellDataList.Count > placingSlotIndex) { boardCellDataList[placingSlotIndex] = hotCellData; } else { int difference = (placingSlotIndex - boardCellDataList.Count) + 1; for (int i = 0; i < difference; i++) { boardCellDataList.Add(null); } boardCellDataList[placingSlotIndex] = hotCellData; } } else if (intoSlot.GetCell() != null) { /// or overwrite existing cell CombatantCell existingCell = intoSlot.GetCell(); existingCell.LoadCellData(hotCellData); intoSlot.LoadCell(existingCell, hotCellData, false); if (boardCellDataList.Count > placingSlotIndex) { boardCellDataList[placingSlotIndex] = hotCellData; } else { boardCellDataList.Add(hotCellData); } } hotCellData = null; bEditing = false; UpdateBoardValue(); game.SaveGame(); } }
public void LoadCell(CombatantCell cc, CellData data, bool bEraseCell) { if (cc == null) { if (bEraseCell && (combatCell != null)) { combatCell.LoadCellData(null); } } combatCell = cc; cellData = data; if ((combatCell != null) && (cellData != null)) { combatCell.LoadCellData(cellData); } }
/// Vinegar gains incremental damage after each round public override void RoundEndAbility(CombatantCell myCell) { base.RoundEndAbility(myCell); if (myCell != null) { myCell.ModifyDamage(damageGainPerRound); if (!battleUI) { battleUI = FindObjectOfType <BattleUI>(); } if (battleUI != null) { battleUI.ToastInteraction(myCell.transform.position, damageGainPerRound, 2, "dmg +"); } } }
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(); } }
public void SetBoardTeamID(int value) { if (combatCellList != null) { for (int i = 0; i < combatCellList.Count; i++) { CombatantCell cc = combatCellList[i]; cc.InitCombatantCell(value); } } if (slotList != null) { for (int j = 0; j < slotList.Count; j++) { CellSlot cs = slotList[j]; cs.SetTeamID(value); } } }
/// Soap has 2 60% chances to create a copy when eliminated public override void OnCellDiedAbility(CombatantCell myCell) { base.OnCellDiedAbility(myCell); if (myCell != null) { CellSlot cellSlot = myCell.GetSlot(); if (cellSlot != null) { List <CellSlot> neighborSlots = new List <CellSlot>(); neighborSlots = cellSlot.GetNeighborSlots(); numFragmentsDropped = 0; foreach (CellSlot cs in neighborSlots) { float randomFragmentShot = Random.Range(0f, 1f); if (((cs.GetCell() == null) || ((cs.GetCell() != null) && (cs.GetCell().GetCellData() == null))) && (randomFragmentShot <= fragmentDropRate)) { CombatantBoard board = cs.GetBoard(); board.SpawnCombatCell(this, cs); numFragmentsDropped++; } if (numFragmentsDropped >= potentialFragmentsOnCellDied) { break; } } } myCell.ShowCanvasGroup(false); Destroy(myCell, 0.5f); } }
public virtual void RoundEndAbility(CombatantCell myCell) { }
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); } } }
public virtual void OnCellDiedAbility(CombatantCell myCell) { }