Exemplo n.º 1
0
 void Awake()
 {
     _DotAndHotTable     = new Dictionary <int, DotAndHot> ();
     _debuffAndBuffTable = new Dictionary <int, DebuffAndBuff> ();
     _abilityCDTable     = new Dictionary <Ability, int> ();
     _shell      = GetComponent <BattleCardShell> ();
     _cardEffect = CardEffectedStatic.CardEffected_Normal;
 }
Exemplo n.º 2
0
 public void BackgroundClick()
 {
     if (_currentActiveCard != null)
     {
         _currentActiveCard.Hide();
         _currentActiveCard    = null;
         _currentActiveAbility = null;
     }
 }
Exemplo n.º 3
0
    bool CheckPlayerCardActivity(BattleCardShell cardShell)
    {
//		Debug.Log((cardShell.shellType == ShellType.Enemy) .ToString()+(cardShell.vacant)+( cardShell.hasCast));
        if (cardShell.shellType == ShellType.Enemy || cardShell.vacant || cardShell.hasCast)
        {
            return(false);
        }
        return(cardShell.HasAvailableAbility());
    }
Exemplo n.º 4
0
 public void Drop(BattleCardShell shell)
 {
     if (shell.shellType == ShellType.Enemy)
     {
         if (shell.battleCard.concreteCard.dropRate >= Random.Range(0.001f, 100f))
         {
             _trophyCards.Add(shell.battleCard.concreteCard);
             _trophyAmount.text = _trophyCards.Count.ToString();
             GameObject dropCardIcon = Instantiate(_cardBGIconPrefab, shell.transform.position, Quaternion.identity) as GameObject;
             dropCardIcon.transform.parent     = transform;
             dropCardIcon.transform.localScale = Vector3.one * 0.01f;
             Destroy(dropCardIcon, 2f);
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Loads the player's concrete card into card shells.
 /// </summary>
 void LoadPlayerBattleCard()
 {
     for (int i = 0; i < _playerCardShellSet.Length; i++)
     {
         if (i < _playerCard.Count)
         {
             if (_playerCard [i] != null)
             {
                 BattleCardShell shell = _playerCardShellSet [i];
                 shell.transform.localScale = Vector3.one * 0.6f;
                 shell.LoadCard(_playerCard [i]);
             }
         }
     }
 }
Exemplo n.º 6
0
 void Clear()
 {
     _trophyCards.Clear();
     _enemyCard.Clear();
     _enemyIndex        = 0;
     _currentActiveCard = null;
     foreach (var item in _enemyCardShellSet)
     {
         item.Clear();
         item.gameObject.SetActive(false);
     }
     foreach (var item in _playerCardShellSet)
     {
         item.Clear();
         item.gameObject.SetActive(false);
     }
 }
Exemplo n.º 7
0
    /// <summary>
    /// Gets the random shell from shell set.
    /// </summary>
    /// <returns>The random shell.</returns>
    /// <param name="shellSet">Player set or enemy set.</param>
    BattleCardShell GetRandomShell(BattleCardShell[] shellSet)
    {
        foreach (var item in shellSet)
        {
            if (item.vacant == false)
            {
                _candidateCards.Add(item);
            }
        }
        if (_candidateCards.Count == 0)
        {
            return(null);
        }
        int             index      = Random.Range(0, _candidateCards.Count - 1);
        BattleCardShell returnCard = _candidateCards [index];

        _candidateCards.Clear();
        return(returnCard);
    }
Exemplo n.º 8
0
    BattleCardShell GetRandomActivaEnemy()
    {
        foreach (var item in _battleControl._enemyCardShellSet)
        {
            if (item.vacant == false && item.hasCast == false)
            {
                _candidateCards.Add(item);
            }
        }
        if (_candidateCards.Count == 0)
        {
            return(null);
        }
        int             index      = Random.Range(0, _candidateCards.Count - 1);
        BattleCardShell returnCard = _candidateCards [index];

        _candidateCards.Clear();
        return(returnCard);
    }
Exemplo n.º 9
0
    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);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 10
0
    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();
            }
        }
    }