void Update() { if (_run && !_shieldPanelGO.activeInHierarchy) { BattleCardShell activeShell = GetRandomActivaEnemy(); if (activeShell == null) //No active enemy { EnemiesActionOver(); return; } List <Ability> abilities = activeShell.battleCard.abilities; Dictionary <Ability, int> cdTable = activeShell.battleCard.abilityCDTable; for (int i = abilities.Count - 1; i >= 0; i--) { Ability ability = abilities [i]; if (cdTable [ability] >= ability.cooldown && ability.mana <= activeShell.battleCard.mana) { BattleCardShell targetShell; switch (ability.targetType) { case TargetType.All: { int ran = Random.Range(0, 1); if (ran == 0) { targetShell = GetRandomShell(_battleControl._enemyCardShellSet); } else { targetShell = GetRandomShell(_battleControl._playerCardShellSet); } break; } case TargetType.Friend: { targetShell = GetRandomShell(_battleControl._enemyCardShellSet); break; } case TargetType.Enemy: { targetShell = GetRandomShell(_battleControl._playerCardShellSet); break; } case TargetType.Self: { targetShell = activeShell; break; } default: targetShell = null; break; } if (targetShell != null) { if (ability.targetArea == TargetArea.Area) //If ability is AOE,cast at the middle of enemies; { activeShell.CastAbility(ability, targetShell.shellQueue [0].battleCard); } else { activeShell.CastAbility(ability, targetShell.battleCard); } } } } } }
public void CardClick(BattleCardShell card) { if (_currentActiveAbility == null) { // Debug.Log (1); if (CheckPlayerCardActivity(card)) { { // Debug.Log (2); if (_currentActiveCard == card) { // Debug.Log (3); _currentActiveCard.Hide(); _currentActiveCard = null; } else { // Debug.Log (4); if (_currentActiveCard != null) { _currentActiveCard.Hide(); } _currentActiveCard = card; card.Show(); } } } else { // Debug.Log (5); card.Deny(); } } else { // Debug.Log(6); bool canCast = false; switch (_currentActiveAbility.ability.targetType) { case TargetType.All: { canCast = true; break; } case TargetType.Friend: { if (card.shellType == ShellType.Player) { canCast = true; } break; } case TargetType.Enemy: { // Debug.Log(7); if (card.shellType == ShellType.Enemy) { canCast = true; } break; } case TargetType.Self: { if (card == _currentActiveCard) { canCast = true; } break; } default: break; } if (canCast) { // Debug.Log(8); if (_currentActiveAbility.ability.targetArea == TargetArea.Area) //If ability is AOE,cast at the middle of enemies; { _currentActiveCard.CastAbility(_currentActiveAbility.ability, _enemyCardShellSet [0].battleCard); } else { _currentActiveCard.CastAbility(_currentActiveAbility.ability, card.battleCard); } // _currentActiveAbility.UpdateCDTimer(); _currentActiveAbility = null; _currentActiveCard = null; CheckPlayerCardShellSetActivity(); } else { card.Deny(); } } }