Beispiel #1
0
    public static void DoEffect(bool AI, card effectcard, int effect_number, List<GameObject> effecttargets)
    {
        if (Stack.Count == 0)

        {
            Player.CanDoStack = false;

            Debug.Log("gonna play audio: ");
            GameObject.FindWithTag("Player").GetComponent<AudioSource>().PlayOneShot(effectcard.sfxAbility0);
            if (effectcard.Type == 2 ) effectcard.StartCoroutine("SpellAfterEffects", AI); //if it's a spell
            else if ( effectcard.Type == 4 ) effectcard.StartCoroutine("SecretAfterEffects", AI); // or a secret
            else Player.SpellInProcess = false; //some ability

        }

        Debug.Log("DoEffect start, effect_number: "+effect_number+", effects on card: "+effectcard.Effects.Count);

        int Param0=0;
        int param0type = effectcard.Effects[effect_number].param0type;

        int effect = effectcard.Effects[effect_number].type;

        if (effectcard.Type == 1 && effectcard.Effects[effect_number].trigger == 1) //if it's a creature's activated ability
            effectcard.Turn ();

        Debug.Log ("gonna do effect type: " + effect);

        if (param0type == 1)	//number of allies
            if (effectcard.ControlledByPlayer) Param0 = Player.player_creatures.Count();
                else Param0 = Enemy.enemy_creatures.Count();

        else if (param0type == 2) //number of allies destroyed this turn
            if (effectcard.ControlledByPlayer) Param0 = Player.AlliesDestroyedThisTurn;
                else Param0 = Enemy.AlliesDestroyedThisTurn;

        else Param0 = effectcard.Effects [effect_number].param0;

        bool EOT = false;
        int BuffDebuffType = 0;
        //int card_index = effectcard.Index;

        Debug.Log ("param0:" + Param0);

        ourtargets = effecttargets;

        switch (effect) { // check the index of the 1st effect and call the appropriate function
        case 0: 	//heal
            Debug.Log ("heal");
            Heal (Param0);
            break;
        case 1:		// damage
            Debug.Log ("damage");
            if (Player.player_creatures.Contains(effectcard) || Enemy.enemy_creatures.Contains(effectcard)) Damage (Param0, effectcard.id_ingame);
            else Damage (Param0, effectcard.id_ingame);
            Debug.Log(" effectcard:"+effectcard.Name + "idingame:" +effectcard.id_ingame);
            break;
        case 2:		//draw card(s)
            Debug.Log ("draw card(s)");
            DrawCard (AI, Param0);
            break;
        case 4: //place a card in your land zone (from deck, graveyard, etc)

            Debug.Log ("place card in land zone");

            PutTargetCardInLandZone(AI);

            break;
        case 5: //place a card in your hand (from deck, graveyard, etc)

            Debug.Log ("place card in hand");

            PutTargetCardInHand(AI);

            break;
        case 6: //fight between two creatures
            Debug.Log ("brawl");
            Brawl();
            break;

        case 8: //untap
            Debug.Log ("untapattackingtarget");
            UntapTarget();
            break;
        case 9: //kill
            Debug.Log ("destroy");
             DestroyCreature();
            break;
        case 10: //debuff.  If the EOT boolean is true, this effect only lasts until end of turn.

            EOT = effectcard.Effects[effect_number].eot;

            Debug.Log ("debuff");
            BuffDebuffType = effectcard.Effects[effect_number].bufftype;
            DoBuff(false, Param0, BuffDebuffType, EOT, effectcard);
            break;

        case 11: //buff

            EOT = effectcard.Effects[effect_number].eot;

            Debug.Log ("buff");
            BuffDebuffType = effectcard.Effects[effect_number].bufftype;
            DoBuff(true, Param0, BuffDebuffType, EOT, effectcard); //we pass effect to let Buff know what type of buff we want
            break;
        case 12: //place creature, param is card index

            Debug.Log ("place creature");
            PlaceCreature(AI, Param0, effectcard);
            break;
        case 13: //place target creature in game under your control

            Debug.Log ("place creature");
            PlaceCreature(AI);
            break;
        case 15: //gain mana

            Debug.Log ("gain mana");
            GainMana(AI, Param0);
            break;
        default:
            Debug.Log ("effect:"+effect);
            Debug.Log ("there's no such effect in DB!");
            break;
        }

        Player.EffectInProcess = false;
    }