private void EndTurn()
    {
        Debug.Log("Before discard! DiscardPile:");
        foreach (GameObject c in BattleHandler.GetInstance().discardPile.GetCards())
        {
            Debug.Log(c.ToString());
        }

        DiscardHand();

        Debug.Log("After discard! DiscardPile:");
        foreach (GameObject c in BattleHandler.GetInstance().discardPile.GetCards())
        {
            Debug.Log(c.ToString());
        }

        EnemyTurn();
        DrawHand(BASE_CARD_DRAW);

        Debug.Log("After Draw! DiscardPile:");
        foreach (GameObject c in BattleHandler.GetInstance().discardPile.GetCards())
        {
            Debug.Log(c.ToString());
        }
    }
 //Parent all cards in a deck to the hand
 public void ParentDeckToHand()
 {
     foreach (GameObject card in this.cards)
     {
         card.transform.SetParent(BattleHandler.GetInstance().handZone.transform);
         card.SetActive(false);
     }
 }
예제 #3
0
 public void OnEndDrag(PointerEventData eventData)
 {
     if (GlobalValues.CurrentScene == GlobalValues.Scene.Battle)
     {
         this.transform.SetParent(BattleHandler.GetInstance().GetHandZone().transform);
         this.transform.SetSiblingIndex(placeholder.transform.GetSiblingIndex());
         Destroy(placeholder);
         GetComponent <CanvasGroup>().blocksRaycasts = true;
     }
 }
예제 #4
0
 public void SetUp(bool isPlayerTeam)
 {
     if (isPlayerTeam)
     {
         this.gameObject.GetComponent <Renderer>().material.mainTexture = BattleHandler.GetInstance().PlayerSpiritSheet;
     }
     else
     {
         this.gameObject.GetComponent <Renderer>().material.mainTexture = BattleHandler.GetInstance().EnemySpiritSheet;
     }
 }
예제 #5
0
    private void Update()
    {
        healthPotionAmountText.text = GameData.healthPotionCount.ToString();
        healthPotionBlocker.gameObject.SetActive(GameData.healthPotionCount <= 0);

        CharacterBattle characterBattle = BattleHandler.GetInstance().GetActiveCharacterBattle();

        specialAmountText.text = characterBattle.GetSpecial().ToString();
        specialAmountText.gameObject.SetActive(characterBattle.GetSpecial() > 0);
        specialBlocker.gameObject.SetActive(characterBattle.GetSpecial() > 0);
    }
    private void Start()
    {
        // Set up Battle Scene
        //BattleHandler.SpawnCharacter(BattleHandler.LanePosition.Middle, true);
        //BattleHandler.SpawnCharacter(BattleHandler.LanePosition.Up, true);
        //BattleHandler.SpawnCharacter(BattleHandler.LanePosition.Down, true);

        /*
         * GameData.EnemyEncounter enemyEncounter = BattleHandler.enemyEncounter;
         * for (int i = 0; i < enemyEncounter.enemyBattleArray.Length; i++) {
         *  GameData.EnemyEncounter.EnemyBattle enemyBattle = enemyEncounter.enemyBattleArray[i];
         *  BattleHandler.SpawnCharacter(enemyBattle, false);
         * }
         */

        BattleHandler.GetInstance().Start(cameraFollow);
    }
    //HandleCardPlayed deactivates the card, so reparenting, turning on raycasts, and cleanup of placeholder must happen here
    public void HandleCardPlayed(GameObject cardObject)
    {
        Card card = cardObject.GetComponent <Card>();

        Card.cardTarget target = card.target;
        if (target == Card.cardTarget.Enemy)
        {
            CURRENT_ENEMY_HEALTH -= card.damage;
        }
        else if (target == Card.cardTarget.Self)
        {
            CURRENT_PLAYER_HEALTH += card.block;
        }
        UpdateHealthBars();

        discardPile.Add(cardObject);
        Destroy(cardObject.GetComponent <Draggable>().GetPlaceholder());
        cardObject.transform.SetParent(BattleHandler.GetInstance().GetHandZone().transform);
        cardObject.GetComponent <CanvasGroup>().blocksRaycasts = true;
        cardObject.SetActive(false);
    }
예제 #8
0
    public void Setup(bool isPlayerTeam)
    {
        this.isPlayerTeam = isPlayerTeam;
        if (isPlayerTeam)
        {
            characterBase.SetAnimsSwordTwoHandedBack();
            characterBase.GetMaterial().mainTexture = BattleHandler.GetInstance().playerSpritesheet;
        }
        else
        {
            characterBase.SetAnimsSwordShield();
            characterBase.GetMaterial().mainTexture = BattleHandler.GetInstance().enemySpritesheet;
        }
        healthSystem = new HealthSystem(100);
        healthBar    = new World_Bar(transform, new Vector3(0, 10), new Vector3(12, 1.7f), Color.grey, Color.red, 1f, 100, new World_Bar.Outline {
            color = Color.black, size = .6f
        });
        healthSystem.OnHealthChanged += HealthSystem_OnHealthChanged;

        PlayAnimIdle();
    }
        public List <GameObject> DrawCards(int toDraw)
        {
            Debug.Log("DrawPile:" + BattleHandler.GetInstance().drawPile.cards.Count + "\nDiscardPile:" + BattleHandler.GetInstance().discardPile.cards.Count + "\nToDraw:" + toDraw);

            //If we can draw enough cards from the draw pile
            if (toDraw <= BattleHandler.GetInstance().drawPile.cards.Count)
            {
                Debug.Log("case 1, draw " + toDraw);

                List <GameObject> ret = new List <GameObject>();
                for (int i = 0; i < toDraw; i++)
                {
                    ret.Add(BattleHandler.GetInstance().drawPile.cards[0]);
                    BattleHandler.GetInstance().drawPile.cards.RemoveAt(0);
                }

                return(ret);
            }

            //If we need to shuffle the discard pile back in
            else if (toDraw <= BattleHandler.GetInstance().drawPile.cards.Count + BattleHandler.GetInstance().discardPile.cards.Count)
            {
                Debug.Log("case 2, draw " + toDraw);

                //draw the entire draw pile
                int partialDraw = BattleHandler.GetInstance().drawPile.cards.Count;
                List <GameObject> partialHand = BattleHandler.GetInstance().drawPile.DrawCards(partialDraw);
                Debug.Log("Partial Hand:");
                foreach (GameObject c in partialHand)
                {
                    Debug.Log(c.ToString());
                }


                //Put the discard back into the draw pile and shuffle
                List <GameObject> addToDraw = BattleHandler.GetInstance().discardPile.cards;
                BattleHandler.GetInstance().drawPile.Add(addToDraw);
                BattleHandler.GetInstance().drawPile.Shuffle();
                //Debug.Log("New Draw Pile:");
                //foreach (GameObject c in BattleHandler.GetInstance().drawPile.cards)
                //    Debug.Log(c.ToString());
                BattleHandler.GetInstance().discardPile.cards = new List <GameObject>();

                //Draw remaining number of cards from the drawpile
                List <GameObject> partialHand2 = BattleHandler.GetInstance().drawPile.DrawCards(toDraw - partialDraw);
                Debug.Log("Partial Hand2:");
                foreach (GameObject c in partialHand2)
                {
                    Debug.Log(c.ToString());
                }

                //Combine both partial Draws
                foreach (GameObject c in partialHand2)
                {
                    partialHand.Add(c);
                }

                Debug.Log("Final Hand:");
                foreach (GameObject c in partialHand)
                {
                    Debug.Log(c.ToString());
                }

                return(partialHand);
            }

            //If we don't have enough cards to draw, we draw all cards in the draw and discard piles
            else
            {
                Debug.Log("case 3, draw " + toDraw);
                //draw the entire draw pile
                int partialDraw = BattleHandler.GetInstance().drawPile.cards.Count;
                List <GameObject> partialHand = BattleHandler.GetInstance().drawPile.DrawCards(partialDraw);
                //draw the entire discard pile
                int partialDraw2 = BattleHandler.GetInstance().discardPile.cards.Count;
                List <GameObject> partialHand2 = BattleHandler.GetInstance().discardPile.DrawCards(partialDraw);
                partialHand.AddRange(partialHand2);
                return(partialHand);
            }
        }
 private void Update()
 {
     BattleHandler.GetInstance().Update();
 }