Exemplo n.º 1
0
    public void AttackCard(Card attackingCard, Card attackedCard)
    {
        BattleRow attackedCardRow = attackedCard.currentRow;

        attackedCard.OnCardAttacked(attackingCard);
        attackingCard.OnCardAttack();

        if (attackedCard.ShouldBeDestroyed())
        {
            UnitAttackType attackingUnitAttackType = attackingCard.GetUnitInstance().GetUnit().unitAttackType;
            if (attackingUnitAttackType == UnitAttackType.Melee)
            {
                if (attackedCardRow.GetCardsFromCountryOtherThatArgument(attackingCard.Country).Count <= 0)
                {
                    MoveCardToRow(attackingCard, attackedCardRow.RowIndex);
                }
            }

            attackedCard.currentRow.RemoveCardFromRow(attackedCard);

            //Remove card from proper controller (AI or Player)
            if (attackedCard.Country.isPlayerCountry)
            {
                RemovePlayerCard(attackedCard);
            }
            else
            {
                BattleAI.instance.RemoveCard(attackedCard);
            }

            Destroy(attackedCard.gameObject);
        }
    }
Exemplo n.º 2
0
        public void ReceiveHealing(float amount, UnitAttackType attackType, TargetStats targetStats)
        {
            unitInformation.ReceiveHealing(amount, targetStats);

            if (targetStats == TargetStats.health)
            {
                overheadHealthbar.UpdateHealthBar(unitInformation.curhealth, unitInformation.maxHealth);
            }
        }
Exemplo n.º 3
0
    public void SetInfor(int typID)
    {
        Tab_UnitTemplate tUnitTemplate = TableManager.GetUnitTemplateByID(typID)[0];

        mUnitView        = tUnitTemplate.UnitView;
        mUnitAttackRange = tUnitTemplate.UnitAttackRange;
        mUnitMaxHp       = tUnitTemplate.UnitMaxHP;
        mAttackSpaceTime = tUnitTemplate.AttackSpaceTime;
        AttackType       = (UnitAttackType)tUnitTemplate.AttackType;
        mAttack          = tUnitTemplate.Attack;
        mUnitHP          = mUnitMaxHp;
    }
Exemplo n.º 4
0
    public void PrepareShootObject(ref GameObject shootObj, UnitAttackType unitAttackType)
    {
        switch (unitAttackType)
        {
        case UnitAttackType.Melee:
            shootObj.GetComponent <MeshFilter>().sharedMesh = meleeAttackTemplate.GetComponent <MeshFilter>().sharedMesh;
            shootObj.transform.localScale = meleeAttackTemplate.transform.localScale;
            shootObj.GetComponent <AudioSource>().clip = meleeAttackTemplate.GetComponent <AudioSource>().clip;
            break;

        case UnitAttackType.Range:
            shootObj.GetComponent <MeshFilter>().sharedMesh = rangeAttackTemplate.GetComponent <MeshFilter>().sharedMesh;
            shootObj.transform.localScale = rangeAttackTemplate.transform.localScale;
            shootObj.GetComponent <AudioSource>().clip = rangeAttackTemplate.GetComponent <AudioSource>().clip;
            break;

        default:
            break;
        }
    }
Exemplo n.º 5
0
        // so this is the factory pattern. Notice every unit will have an "IAttackBehavior". Read up
        // on interfaces if you're unfamiliar with them. You pass this function/class a simple enum,
        // and it'll return an IAttackBehavior of a certain type, meaning it can react differently
        // to things. So, later, when we do something like unit.AttackBehavior.FindTarget(), we can do
        // that syntactically because all of the classes implement everything in the interface, but they
        // can each do different things. If something has an AttacksBuilding attack behavior, it may just scan
        // for buildings, while the same call on another unit will be a NeverAttacks behavior, which will contain
        // an empty function
        // TODO: implement the attack behaviors below
        public static IAttackBehavior SpawnBehavior(UnitAttackType attackType, Faction faction, float delay = 0, int damage = 0, int range = 0)
        {
            IAttackBehavior attackBehavior;
            switch (attackType)
            {
                case UnitAttackType.StopsToAttack:
                    attackBehavior = new StopsToAttackBehavior(faction, delay, damage, range);
                    break;
                case UnitAttackType.NeverStopsMoving:
                    attackBehavior = new NeverStopsMovingBehavior(faction, delay, damage, range);
                    break;
                case UnitAttackType.NeverAttacks:
                    attackBehavior = new NeverAttacksBehavior();
                    break;
                default:
                    attackBehavior = new NeverAttacksBehavior();
                    break;
            }

            return attackBehavior;
        }
Exemplo n.º 6
0
 public void SetAttackType(UnitAttackType tAttackType)
 {
     AttackType = tAttackType;
 }
Exemplo n.º 7
0
 public virtual void SetHeroCounter(List <int> healthCount, List <int> damageCount, List <int> speedCount, UnitAttackType attackType, string heroName = "")
 {
 }
    public override void SetHeroCounter(List <int> healthCount, List <int> damageCount, List <int> speedCount, UnitAttackType attackType, string heroName = "")
    {
        base.SetHeroCounter(healthCount, damageCount, speedCount, attackType, heroName);

        healthWithGrowth = healthCount;
        damageWithGrowth = damageCount;
        speedWithGrowth  = speedCount;

        attackTypeText.text = attackType.ToString();
        // HEALTH SPEED DAMAGE HERO NAME INFORMATIOn
        healthText.text = healthCount[0] + "/" + healthCount[0] + "<color=green>[" + healthCount[1] + "] </color>";
        damageText.text = damageCount[0] + "<color=green>[" + damageCount[1] + "] </color>";
        speedText.text  = speedCount[0] + "<color=green>[" + speedCount[1] + "] </color>";

        heroNameText.text = heroName;
    }
Exemplo n.º 9
0
 void AttackTarget(UnitAttackType attacktype, int index = 0)
 {
 }
Exemplo n.º 10
0
        public void ReceiveDamage(float amount, UnitAttackType attackType, TargetStats targetStats)
        {
            UpdateCharacterState(CharacterStates.Damage_Received);

            bool blockAttempt = false;

            if (unitInformation.buffList != null && unitInformation.buffList.Count > 0)
            {
                List <BaseBuffInformationData> activateThisBuffs = unitInformation.buffList.FindAll(x => x.buffTrigger == TriggeredBy.ReceivingDamage);

                for (int i = 0; i < activateThisBuffs.Count; i++)
                {
                    switch (activateThisBuffs[i].targetStats)
                    {
                    case TargetStats.health:

                        break;

                    case TargetStats.damage:     // decrease damage increae damage
                        amount += activateThisBuffs[i].effectAmount;
                        break;

                    case TargetStats.speed:

                        break;

                    case TargetStats.range:

                        break;

                    case TargetStats.blockMelee:
                        if (!blockAttempt && attackType == UnitAttackType.MELEE)
                        {
                            blockAttempt = IsBlockAttemptSuccess(activateThisBuffs[i].effectAmount);
                        }
                        break;

                    case TargetStats.blockProjectile:
                        if (!blockAttempt && attackType == UnitAttackType.RANGE)
                        {
                            blockAttempt = IsBlockAttemptSuccess(activateThisBuffs[i].effectAmount);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }

            if (blockAttempt)
            {
                switch (attackType)
                {
                case UnitAttackType.MELEE:
                    mySfx.PlayBlockMelee();
                    break;

                case UnitAttackType.RANGE:
                    mySfx.PlayBlockProjectile();
                    break;

                case UnitAttackType.SPELL:
                    break;

                default:
                    break;
                }

                return;
            }
            switch (attackType)
            {
            case UnitAttackType.MELEE:
                mySfx.PlayReceiveMelee();
                break;

            case UnitAttackType.RANGE:
                mySfx.PlayReceiveProjectile();
                break;

            case UnitAttackType.SPELL:
                break;

            default:
                break;
            }



            amount = Mathf.Abs(amount);
            unitInformation.ReceiveDamage(amount, targetStats);

            if (targetStats == TargetStats.health)
            {
                overheadHealthbar.UpdateHealthBar(unitInformation.curhealth, unitInformation.maxHealth, true);;
            }

            //Debug.Log("[ DAMAGE RECEIVED : " + amount + " RECEIVED BY:"+ unitInformation.unitName + " ]");
            if (!isLeadingHero)
            {
                if (unitInformation.currentState == UnitState.Dead || unitInformation.currentState == UnitState.Injured)
                {
                    UpdateCharacterState(CharacterStates.Injured_State);
                    mySfx.PlayInjuredOrDead();
                }
            }

            if (unitInformation.currentState != UnitState.Healthy)
            {
                if (BattlefieldSpawnManager.GetInstance != null)
                {
                    BattlefieldSpawnManager.GetInstance.RemoveThisUnit(this, unitInformation.currentState);
                }
            }
        }