Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        // *When in main menu:
        if (GameManager.ActiveState != GameManager.Gamestate.InGame)
        {
            // Find the card collections in main menu if we haven't cached it yet:
            if (!dtbase)
            {
                dtbase = GameObject.FindObjectOfType <V_CardCollections> ();
            }

            // Load cards in deck:
            if (deckData != null)
            {
                myDeck = new V_Card[deckData [selectedDeck].cards.Length];
                for (int i = 0; i < deckData[selectedDeck].cards.Length; i++)
                {
                    myDeck [i] = dtbase.gameCards [deckData [selectedDeck].cards[i]];
                }
            }
        }
        // *When in game:
        else
        {
            if (!gm)
            {
                gm = FindObjectOfType <V_GameManager> ();
                return;
            }

            // Clamp health:
            health = Mathf.Clamp(health, 0, gm.maxHealth);
        }
    }
Ejemplo n.º 2
0
 public void EndTurn()
 {
     V_GameManager.ChangeTurn(V_GameManager.playerTypes.Us);
     gm = GameObject.FindGameObjectWithTag("GameController");
     gm.GetComponent <V_GameManager> ().curSelected   = null;
     gm.GetComponent <V_GameManager> ().aiCurSelected = null;
 }
Ejemplo n.º 3
0
 public void AIEndTurn()
 {
     V_GameManager.ChangeTurn(V_GameManager.playerTypes.AI);
     gm.GetComponent <V_GameManager> ().curSelected   = null;
     gm.GetComponent <V_GameManager> ().aiCurSelected = null;
     Debug.Log("AI is ending his turn...");
 }
Ejemplo n.º 4
0
    public void SpellActivate()
    {
        Destroy(gameObject, delay);          //oh no... ok I need persistance and a graveyard....
        V_GameManager gm = FindObjectOfType <V_GameManager>();

        if (gm.curSelected == this)
        {
            gm.curSelected = null;
        }
    }
Ejemplo n.º 5
0
 public void DoEffect()
 {
     if (this.gameObject.tag == "PlayerOwned")
     {
         if (extraEffect == cardEffect.AddEnergy)
         {
             if (target == cardTarget.ToOpponent)
             {
                 V_GameManager.EffectAddEnergy(effectValue);
             }
             else
             {
                 V_PlayerHandler.AddEnergy(effectValue);
             }
         }
         if (extraEffect == cardEffect.AddHealth)
         {
             if (target == cardTarget.ToOpponent)
             {
                 V_GameManager.EffectHeal(effectValue);
             }
             else
             {
                 V_PlayerHandler.EffectHeal(effectValue, V_GameManager.shealEffect.gameObject, V_GameManager.avatarZone.transform);
             }
         }
         if (extraEffect == cardEffect.DamagePlayer)
         {
             if (target == cardTarget.ToOpponent)
             {
                 V_GameManager.EffectDamage(effectValue);
             }
             else
             {
                 V_PlayerHandler.EffectDamage(effectValue, V_GameManager.sdamageEffect.gameObject, V_GameManager.avatarZone.transform);
             }
         }
         if (extraEffect == cardEffect.DrawNewCard)
         {
             if (target == cardTarget.ToOpponent)
             {
                 // nothing here yet...
             }
             else
             {
                 V_PlayerHandler player = GameObject.FindGameObjectWithTag("PlayerHandler").GetComponent <V_PlayerHandler> ();
                 player.DrawOneCard();
             }
         }
     }
     if (type == cardType.Spell)
     {
         SpellActivate();
     }
 }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     // References:
     gm   = GameObject.FindObjectOfType <V_GameManager>();
     card = gameObject.GetComponent <V_Card> ();
     if (isInGame)
     {
         curParent = V_GameManager.handZone.transform;
         Brendrr   = V_GameManager.battleZone.GetComponent <Image> ();
         Srendrr   = V_GameManager.spellZone.GetComponent <Image> ();
     }
 }
Ejemplo n.º 7
0
    V_GameManager gm;           // For accessing non-static variables in game manager

    // Use this for initialization
    void Start()
    {
        // DontDestroyOnLoad(gameObject); //its always here

        // }
        //if broken revert to an awake function. MAKE SURE TO CALL!!
        //public void EnterGame(){
        // References:
        p  = FindObjectOfType <V_PlayerHandler>();
        gm = FindObjectOfType <V_GameManager> ();
        // Set the player's starting life and energy:
        V_PlayerHandler.health = startingHealth;
        V_PlayerHandler.energy = startingEnergy;
        V_AI.health            = startingHealth;
        V_AI.energy            = startingEnergy;

        sEnergy = startingEnergy;
        iEnergy = increasingEnergy;
        //need to add handlers for multiple new zones
        battleZone    = battleZoneHandler;
        spellZone     = spellZoneHandler;
        handZone      = handZoneHandler;
        gameArea      = gameAreaHandler;
        graveZone     = graveZoneHandler;
        aiBattleZone  = aiBattleZoneHandler;
        aiSpellZone   = aiSpellZoneHandler;
        aiAvatarZone  = aiAvatarHandler;
        aigraveZone   = aigraveZoneHandler;
        avatarZone    = avatarHandler;
        sdamageEffect = damageEffect;
        shealEffect   = healEffect;

        if (drawCostText != null)
        {
            drawCostText.text = drawCost.ToString();
        }

        // Draw the first hand cards:
        playerTurn    = playerTypes.Player;
        p.gm          = this;
        CardGameState = currentState.draw;
        //this is what we need to use to set the health to the size of the deck. we can disable it for now.
        // V_PlayerHandler.health = p.myDeck.Length;
        //p.StartDraw ();//we can disable this for now. if we have effects that only trigger in starting hand we can readd.
        for (int i = 0; i < startinghand; i++)
        {
            p.DrawOneCard();
        }
    }
Ejemplo n.º 8
0
 public void DoEffectAI()
 {
     if (this.gameObject.tag == "AIOwned")
     {
         if (extraEffect == cardEffect.AddEnergy)
         {
             if (target == cardTarget.ToOpponent)
             {
                 V_PlayerHandler.AddEnergy(effectValue);
             }
             else
             {
                 V_GameManager.EffectAddEnergy(effectValue);
             }
         }
         if (extraEffect == cardEffect.AddHealth)
         {
             if (target == cardTarget.ToOpponent)
             {
                 V_PlayerHandler.EffectHeal(effectValue, V_GameManager.shealEffect.gameObject, V_GameManager.avatarZone.transform);
             }
             else
             {
                 V_GameManager.EffectHeal(effectValue);
             }
         }
         if (extraEffect == cardEffect.DamagePlayer)
         {
             if (target == cardTarget.ToOpponent)
             {
                 V_PlayerHandler.EffectDamage(effectValue, V_GameManager.sdamageEffect.gameObject, V_GameManager.avatarZone.transform);
             }
             else
             {
                 V_GameManager.EffectDamage(effectValue);
             }
         }
     }
     if (type == cardType.Spell)
     {
         SpellActivate();
     }
 }
Ejemplo n.º 9
0
 // This is called when a player hits the "End Turn" button:
 public static void ChangeTurn(playerTypes type)
 {
     if (type == playerTypes.AI)
     {
         if (allowIncreasingEnergy)
         {
             V_PlayerHandler.AddEnergy(iEnergy);
         }
         // Draw 1 free card if Hand Zone is'nt full:
         if (handZone.transform.childCount < 4)
         {
             V_PlayerHandler player = GameObject.FindGameObjectWithTag("PlayerHandler").GetComponent <V_PlayerHandler> ();
             player.DrawOneCard();
         }
         //
         allowIncreasingEnergy = true;
         playerTurn            = playerTypes.Us;
         V_GameManager gm = GameObject.FindGameObjectWithTag("GameController").GetComponent <V_GameManager> ();
         gm.endTurnBTN.SetActive(true);
         gm.DrawBTN.SetActive(true);
         GameObject[] obj = GameObject.FindGameObjectsWithTag("PlayerOwned");
         foreach (GameObject o in obj)
         {
             o.GetComponent <V_CardActions> ().isUsed = false;
         }
     }
     else if (type == playerTypes.Us)
     {
         if (allowIncreasingEnergy)
         {
             V_AI.EffectAddEnergy(iEnergy);
         }
         allowIncreasingEnergy = true;
         playerTurn            = playerTypes.AI;
         GameObject[] obj = GameObject.FindGameObjectsWithTag("AIOwned");
         foreach (GameObject o in obj)
         {
             o.GetComponent <V_CardActions> ().isUsed = false;
         }
     }
     turn++;
 }
Ejemplo n.º 10
0
 public void DoEffect()
 {
     if (this.gameObject.tag == "PlayerOwned")
     {
         //WHY ISN'T THIS A SWITCH CASE??? ///we can do the thing. the thing with child classes.
         if (extraEffect == cardEffect.AddEnergy)
         {
             if (target == cardTarget.ToOpponent)
             {
                 V_GameManager.EffectAddEnergy(effectValue);
             }
             else
             {
                 V_PlayerHandler.AddEnergy(effectValue);
             }
         }
         if (extraEffect == cardEffect.AddHealth)
         {
             if (target == cardTarget.ToOpponent)
             {
                 V_GameManager.EffectHeal(effectValue);
             }
             else
             {
                 V_PlayerHandler.EffectHeal(effectValue, V_GameManager.shealEffect.gameObject, V_GameManager.avatarZone.transform);
             }
         }
         if (extraEffect == cardEffect.DamagePlayer)
         {
             if (target == cardTarget.ToOpponent)
             {
                 V_GameManager.EffectDamage(effectValue);
             }
             else
             {
                 V_PlayerHandler.EffectDamage(effectValue, V_GameManager.sdamageEffect.gameObject, V_GameManager.avatarZone.transform);
             }
         }
         if (extraEffect == cardEffect.DrawXCards)
         {
             if (target == cardTarget.ToOpponent)
             {
                 // nothing here yet...
             }
             else
             {
                 V_PlayerHandler player = FindObjectOfType <V_PlayerHandler> ();
                 //draw x cards
                 for (int i = effectValue; i > 0; i--)
                 {
                     player.DrawOneCard();
                 }
             }
         }
         if (extraEffect == cardEffect.DrawuptoXcards)
         {
             if (target == cardTarget.ToOpponent)
             {
                 // nothing here yet...
             }
             else
             {
                 V_PlayerHandler player = FindObjectOfType <V_PlayerHandler>();
                 //draw up to x cards
                 V_GameManager.effectdraw = effectValue;
             }
         }
         if (extraEffect == cardEffect.LowerAllSpeed)
         {
             //doesn't work :():(:(:(:)(: yet... BUT WHY NOT?????
             GameObject[] obj = GameObject.FindGameObjectsWithTag("AIOwned");
             foreach (GameObject o in obj)
             {
                 if (o.GetComponent <V_Card>().type == cardType.Creature && o.GetComponent <V_Card>().Relentless == false)
                 {
                     o.GetComponent <V_Card>().speed -= effectValue;
                     if (o.GetComponent <V_Card>().speed < 0)
                     {
                         o.GetComponent <V_Card>().speed = 0;
                     }
                     o.GetComponent <V_Card>().cardSpeedHandler.text = o.GetComponent <V_Card>().speed.ToString();
                 }
             }
             GameObject[] objP = GameObject.FindGameObjectsWithTag("PlayerOwned");
             foreach (GameObject o in objP)
             {
                 if (o.GetComponent <V_Card>().type == cardType.Creature && o.GetComponent <V_Card>().Relentless == false)
                 {
                     o.GetComponent <V_Card>().speed -= effectValue;
                     if (o.GetComponent <V_Card>().speed < 0)
                     {
                         o.GetComponent <V_Card>().speed = 0;
                     }
                     o.GetComponent <V_Card>().cardSpeedHandler.text = o.GetComponent <V_Card>().speed.ToString();
                 }
             }
         }
     }
     if (type == cardType.Event)
     {
         SpellActivate();
     }
 }
Ejemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     gm = GameObject.FindObjectOfType <V_GameManager>();
 }