コード例 #1
0
        public static List <CardMethod> SelectCardMethods()
        {
            var myList = new List <CardMethod>();

            var conn  = DatabaseConnection.GetExEventDatabaseConnection();
            var query = "SELECT method_name FROM award_method";
            var cmd   = new SqlCommand(query, conn);

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();

                if (!reader.HasRows)
                {
                    throw new ApplicationException("No methods found!");
                }
                while (reader.Read())
                {
                    var item = new CardMethod();

                    item.methodName = reader.GetString(0);
                    myList.Add(item);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            return(myList);
        }
コード例 #2
0
 //dictates how the unleash should be its targetted mode
 public CardMethod FinalizeLinks()
 {
     foreach (GameObject cardPrefab in cardPrefabList)
     {
         if (cardPrefab.GetComponent <Display>().card.cardMethod == CardMethod.Targetted)
         {
             //returns targetted
             linkMethod = CardMethod.Targetted;
             return(linkMethod);
         }
         else
         {
             linkMethod = CardMethod.Dropped;
         }
     }
     //returns dropped
     return(linkMethod);
 }
コード例 #3
0
    public void Update()
    {
        PointRay      = Input.mousePosition;
        ray           = Camera.main.ScreenPointToRay(PointRay);
        pointedObject = Physics2D.GetRayIntersection(ray);
        //pointedTarget = Physics2D.GetRayIntersection(ray);
        //pointedTarget = Physics2D.GetRayIntersection(ray);

        if (Input.GetMouseButtonDown(2))
        {
            Debug.Log($"GameObject is {pointedObject.collider.gameObject.name}");
        }


        //For Choosing Cards to play
        if (state == CombatState.PlayerTurn)
        {
            //Test for drawing cards///////////////////////
            //if (Input.GetMouseButtonDown(2))
            //{
            //    state = CombatState.DrawPahase;
            //    deckManager.DrawCards(Draw);
            //    DeckUpdater();
            //    playerHand.StateChanger(state);
            //    state = CombatState.PlayerTurn;
            //    playerHand.StateChanger(state);
            //}
            ////////////////////////////////////


            //clicking cards during player phase
            //load delegate function effect of card
            if (Input.GetMouseButtonDown(0))
            {
                if (pointedObject.collider != null && pointedObject.collider.gameObject.tag == "Card")
                {
                    activeCard = pointedObject.collider.gameObject;
                    Card activeCardCard = activeCard.GetComponent <Display>().card;

                    //makes the dropzone move up so that becomes the target for drop cards
                    //for thedropfield moving up approach targetting system
                    //if (activeCardCard.cardMethod == CardMethod.Dropped)
                    //{
                    //    Vector3 dropFieldShift = dropField.transform.localPosition;
                    //    dropField.transform.localPosition = new Vector3(dropFieldShift.x, dropFieldShift.y, -1);
                    //}

                    //checks the scriptable attached in Display if cost can be accomodated by Energy
                    //if (activeCardCard.energyCost <= Energy)
                    if (activeCardCard.energyCost <= playerFunctions.currEnergy)
                    {
                        state = CombatState.ActiveCard;
                        //activeCard.GetComponent<DragNDrop>().StateChanger(state); /////////////////////
                        playerHand.StateChanger(state);
                    }
                    //else if(activeCard.gameObject.GetComponent<Display>().card.energyCost > Energy)
                    else if (activeCard.gameObject.GetComponent <Display>().card.energyCost > playerFunctions.currEnergy)
                    {
                        Debug.Log("Not enough Energy");
                    }

                    else if (pointedObject.collider != null && pointedObject.collider.gameObject.tag == "Card")
                    {
                        Debug.Log($"GameObject is {pointedObject.collider.gameObject.name}");
                    }
                }
            }


            //Entering Creative Mode
            else if (Input.GetKeyDown(KeyCode.C))
            {
                state = CombatState.CreativeMode;

                creativeUI.SetActive(true);
            }
        }

        else if (state == CombatState.ActiveCard)
        {
            EffectLoader activeEffectLoader = activeCard.GetComponent <EffectLoader>();
            Card         activeCardCard     = activeCard.GetComponent <Display>().card;

            ////////////



            //Right-click is back function
            if (Input.GetMouseButtonDown(1))
            {
                state = CombatState.PlayerTurn;
                //activeCard.GetComponent<DragNDrop>().StateChanger(state); ///////////////////////////
                playerHand.StateChanger(state);
                playerHand.ResetOriginal();

                //for thedropfield moving up approach targetting system
                //if (activeCardCard.cardMethod == CardMethod.Dropped)
                //{
                //    //returns dropfield to back after activate of card
                //    dropField.transform.localPosition = originalDropFieldPosition;
                //}
            }

            //pass targetted object
            if (Input.GetMouseButtonDown(0))
            {
                GameObject targetObject = pointedObject.collider.gameObject;

                if (targetObject.tag == "Enemy" && activeCardCard.cardMethod == CardMethod.Targetted)
                {
                    //activeEffectLoader.EffectLoaderActivate(targetObject, player); ---- This is to be used if single jigsaws ccan be activated without creative mode
                    activeEffectLoader.ActivateCardEffect(targetObject, player);

                    //Energy = Energy - activeCard.gameObject.GetComponent<Display>().card.energyCost;
                    EnergyUpdater(-activeCard.gameObject.GetComponent <Display>().card.energyCost);
                    //calls discard method and puts active card in discard pile
                    DiscardFromHand();
                    activeCard.transform.SetAsLastSibling();
                    //retuns to player turn phase
                    state = CombatState.PlayerTurn;
                    //activeCard.GetComponent<DragNDrop>().StateChanger(state);////////////////////
                    playerHand.StateChanger(state);
                    DeckUpdater();

                    //////just for testing unli attacks///
                    //state = CombatState.PlayerTurn;
                    //activeDragNDrop.StateChanger(state);
                    /////////////////////////////////////
                }
                //layer 13 is Playing Field
                //if its utility or offense dropped
                else if (targetObject.layer == 13 && activeCardCard.cardMethod == CardMethod.Dropped && activeCardCard.cardType != CardType.Ability)
                {
                    //activeEffectLoader.EffectLoaderActivate(targetObject, player); ---- to be used if single jigsaw effect is to be able to activate without creative mode
                    activeEffectLoader.ActivateCardEffect(targetObject, player);

                    //Energy = Energy - activeCard.gameObject.GetComponent<Display>().card.energyCost;
                    EnergyUpdater(-activeCard.gameObject.GetComponent <Display>().card.energyCost);
                    //calls discard method and puts active card in discard pile
                    DiscardFromHand();
                    activeCard.transform.SetAsLastSibling();
                    //retuns to player turn phase
                    state = CombatState.PlayerTurn;
                    //activeCard.GetComponent<DragNDrop>().StateChanger(state);////////////////////
                    playerHand.StateChanger(state);
                    DeckUpdater();

                    //for thedropfield moving up approach targetting system
                    ////returns dropfield to back after activate of card
                    //dropField.transform.localPosition = originalDropFieldPosition;
                }
                //if card is ablity, target object will always be player
                else if (targetObject.layer == 13 && activeCardCard.cardMethod == CardMethod.Dropped && activeCardCard.cardType == CardType.Ability)
                {
                    //player as taget then pass player as actor
                    activeEffectLoader.EffectLoaderActivate(player, player);
                    //Energy = Energy - activeCard.gameObject.GetComponent<Display>().card.energyCost;
                    EnergyUpdater(-activeCard.gameObject.GetComponent <Display>().card.energyCost);
                    //calls discard method and puts active card in discard pile
                    DiscardFromHand();
                    activeCard.transform.SetAsLastSibling();
                    //retuns to player turn phase
                    state = CombatState.PlayerTurn;
                    //activeCard.GetComponent<DragNDrop>().StateChanger(state);////////////////////
                    playerHand.StateChanger(state);
                    DeckUpdater();
                }
                else
                {
                    Debug.Log("no target here");
                }
            }
        }


        else if (state == CombatState.CreativeMode)
        {
            //for choosing cards to go in creative mode
            if (Input.GetMouseButtonDown(0))
            {
                if (pointedObject.collider != null && pointedObject.collider.gameObject.tag == "Card")
                {
                    activeCard = pointedObject.collider.gameObject;
                    Card activeCardCard = activeCard.GetComponent <Display>().card;

                    //checks the scriptable attached in Display if cost can be accomodated by Energy
                    //checks if current chosen card's input link matches the output of the previous card
                    if (activeCardCard.energyCost <= playerFunctions.currEnergy && // activeCardCard.energyCost <= playerFunctions.currEnergy
                        creativeManager.CheckLinkEligibility(activeCardCard) &&
                        activeCardCard.jigsawEffect != null &&  //jigsawEffect
                        creativeManager.creativityCost < player.GetComponent <PlayerFunctions>().currCreativity)
                    {
                        //transfers the card in creative mode then disables the prefab
                        //Energy -= activeCardCard.energyCost;
                        EnergyUpdater(-activeCardCard.energyCost);

                        creativeManager.ChooseForCreative(activeCardCard);
                        creativeList.Add(activeCard);
                        //cardDictionary.Add(activeCard.transform.GetSiblingIndex(), activeCard);
                        activeCard.SetActive(false);
                    }
                    //else if (activeCardCard.energyCost > playerFunctions.currEnergy)
                    else if (activeCardCard.energyCost > playerFunctions.currEnergy)
                    {
                        creativeManager.MessagePrompt("Insufficient Energy");
                    }
                    else if (!creativeManager.CheckLinkEligibility(activeCardCard))
                    {
                        creativeManager.MessagePrompt("Jigsaw Links Doesn't Match");
                    }
                    else if (activeCardCard.jigsawEffect == null) //jigsawEffect
                    {
                        creativeManager.MessagePrompt("Card Has No Jigsaw");
                    }
                    else if (creativeManager.creativityCost >= player.GetComponent <PlayerFunctions>().currCreativity)
                    {
                        creativeManager.MessagePrompt("Insufficient Creativity");
                    }
                }
            }
            //for executing the link
            else if (Input.GetKeyDown(KeyCode.Space))
            {
                //prevents single cards for using creative mode
                if (creativeList.Count <= 1)
                {
                    Debug.Log("got here");
                    creativeManager.MessagePrompt("No Card Selected");
                }
                else
                {
                    //activate like execute button
                    ExecuteUnleashButton();
                }
            }

            //Right-click is back function
            else if (Input.GetMouseButtonDown(1))
            {
                //returns dropfield to back after activate of card
                if (creativeList.Count > 0)
                {
                    int tempIndex = creativeManager.ReturnFromCreative();
                    //adds back energy when backing out
                    //Energy += creativeList[tempIndex].GetComponent<Display>().card.energyCost;
                    EnergyUpdater(creativeList[tempIndex].GetComponent <Display>().card.energyCost);

                    creativeList[tempIndex].SetActive(true);
                    creativeList.Remove(creativeList[tempIndex]);
                    //removes scale increase on all cards
                    playerHand.ResetOriginal();
                }
            }

            //completely backs out from creative mode
            else if (Input.GetKeyDown(KeyCode.C))
            {
                foreach (GameObject card in creativeList)
                {
                    int tempIndex = creativeManager.ReturnFromCreative();
                    //Energy += creativeList[tempIndex].GetComponent<Display>().card.energyCost;
                    EnergyUpdater(creativeList[tempIndex].GetComponent <Display>().card.energyCost);
                    creativeList[tempIndex].SetActive(true);
                }
                creativeList.Clear();
                //removes scale increase on all cards
                playerHand.ResetOriginal();
                state = CombatState.PlayerTurn;
                creativeUI.SetActive(false);
            }
        }

        //when picking target for unleasing creativity
        else if (state == CombatState.UnleashCreativity)
        {
            //lift click in targetting during unleash
            if (Input.GetMouseButtonDown(0))
            {
                GameObject targetObject = pointedObject.collider.gameObject;
                //this method takes the cardMethod of linked cards
                //if there is a targetted card, the linked are all targetted, it is dropped if there are no targetted cards
                CardMethod linkMethod = creativeManager.FinalizeLinks();
                //if targetted, click will work one specific enemy units only
                if (pointedObject.collider != null && linkMethod == CardMethod.Targetted && targetObject.tag == "Enemy")
                {
                    //access player stats and reduces their creativity meter
                    player.GetComponent <PlayerFunctions>().AlterPlayerCreativity(-creativeManager.creativityCost);
                    //initiates link effects in CreativeManager
                    //returns the cost for crativity
                    creativeManager.UnleashCreativity(targetObject, player);
                }
                //if dropped, click will wor on anything
                else if (pointedObject.collider != null && linkMethod == CardMethod.Dropped && targetObject.layer == 13)
                {
                    //access player stats and reduces their creativity meter
                    player.GetComponent <PlayerFunctions>().AlterPlayerCreativity(-creativeManager.creativityCost);
                    //initiates link effects in CreativeManager
                    //returns the cost for crativity
                    creativeManager.UnleashCreativity(targetObject, player);
                }
                //removes scale increase on all cards
                playerHand.ResetOriginal();
                //Discards cards used in creative mode
                foreach (GameObject linkedCard in creativeList)
                {
                    activeCard = linkedCard;
                    //calls discard method and puts active card in discard pile
                    DiscardFromHand();
                }
                //clearing CardObjects
                creativeList.Clear();
                state = CombatState.PlayerTurn;
                creativeUnleash.SetActive(false);
                //playerHand.StateChanger(state); -- not yet sure
                DeckUpdater();
            }
            //back button, goes back to last state of creativity panel and re-enables it
            else if (Input.GetMouseButtonDown(1))
            {
                state = CombatState.CreativeMode;
                creativeUI.SetActive(true);
                creativeUnleash.SetActive(false);
            }
        }

        //just for testing enemy phases/////
        //else if(state == CombatState.EnemyTurn)
        //{
        //    if(Input.GetKeyDown(KeyCode.Backspace))
        //    {
        //        state = CombatState.PlayerTurn;
        //        Energy = defaultEnergy;
        //        EnergyUpdater();
        //    }
        //}
        ///////////////////////////////
    }