private void OnTriggerEnter2D(Collider2D collision)
 {
     if (isActive && collision.CompareTag("Troop"))
     {
         flash = 0;
         TroopMover cont   = collision.GetComponent <TroopMover>();
         int        damage = CalculateDamage(cont.troop);
         health -= damage;
         cont.Destruct();
     }
 }
예제 #2
0
    public void BeginChangeToTroops()
    {
        if (!token.isDisappearing)
        {
            token.isDisappearing = true;
            if (type != TokenType.NORMAL && !wasActivated)
            {
                Activate();
                isMatched = false;
            }

            var troopObj = Instantiate(Settings.main.troops.prefab,
                                       transform.position, Quaternion.identity, transform.parent);
            troop       = troopObj.GetComponent <TroopMover>();
            troop.troop = BattleData.main.heroTeam.maskSets[token.elementId].troop;
            troop.UpdateSprite();

            token.animator.SetTrigger("Reveal");
        }
    }