Пример #1
0
        private UiCard GetLeastHigherPriorityAICard(UiCard selectedCard)
        {
            UiCard [] cards = GetAICards();
            UiCard    LeastHigherPriorityCard = null;

            foreach (UiCard card in cards)
            {
                if (card.pHasChecked)
                {
                    continue;
                }
                if (card.pPriority > selectedCard.pPriority)
                {
                    if (LeastHigherPriorityCard == null)
                    {
                        LeastHigherPriorityCard = card;
                    }
                    else if (LeastHigherPriorityCard.pPriority > card.pPriority)
                    {
                        LeastHigherPriorityCard = card;
                    }
                }
            }
            if (LeastHigherPriorityCard != null)
            {
                LeastHigherPriorityCard.pHasChecked = true;
                LeastHigherPriorityCard.SetSprite(sprites[LeastHigherPriorityCard.pPriority]);
            }
            return(LeastHigherPriorityCard);
        }
Пример #2
0
 public void OnCheck()
 {
     if ((pSelectedCard == null && GetPlayerCards().Length > 1) || (pSelectedCard != null && pSelectedCard.pHasChecked))
     {
         Debug.Log("Please select a card");
         //_WarningText.gameObject.SetActive(true);
         showWarning.Dispatch(true);
         return;
     }
     mCheckCount++;
     if (pSelectedCard == null)
     {
         pSelectedCard = GetMaxPriorityCard(GetPlayerCards());
     }
     pSelectedCard.pHasChecked = true;
     if (GetLeastHigherPriorityAICard(pSelectedCard) != null)
     {
         mAIScore++;
         Debug.Log("Computer Won");
     }
     else
     {
         mPlayerScore++;
         Debug.Log("Pllayer Won");
     }
     UpdateScores();
     if (mCheckCount >= 3 || pCurrentGameMode._IsSingleStep)
     {
         OnSubmitScores();
     }
     pSelectedCard.ResetPosition();
     pSelectedCard = null;
 }
Пример #3
0
 public void CardSelected(UiCard selectedCard)
 {
     UiCard []playerCards = PlayerCards.GetComponentsInChildren<UiCard> ();
     pSelectedCard = selectedCard;
     foreach (UiCard card in playerCards)
         if (card.pPriority != selectedCard.pPriority)
             card.ResetPosition ();
     showWarning.Dispatch (false);
 }
Пример #4
0
        /*
         * This is to get the Max priority card from the give array of Cards
         * */
        private UiCard GetMaxPriorityCard(UiCard [] cards)
        {
            UiCard maxCard = cards [0];

            foreach (UiCard card in cards)
            {
                if (maxCard.pPriority < card.pPriority)
                {
                    maxCard = card;
                }
            }
            return(maxCard);
        }
Пример #5
0
 public void CardSelected(UiCard selectedCard)
 {
     UiCard [] playerCards = PlayerCards.GetComponentsInChildren <UiCard> ();
     pSelectedCard = selectedCard;
     foreach (UiCard card in playerCards)
     {
         if (card.pPriority != selectedCard.pPriority)
         {
             card.ResetPosition();
         }
     }
     showWarning.Dispatch(false);
 }
Пример #6
0
        /*
         * This is to create a Card Object and assigning a Random priority .
         * Here I am assuming that all the sprites in the spritesheet are arranged in Ascending Order.
         * */
        private GameObject CreateObject(Transform parent, bool isAI = false)
        {
            GameObject obj      = (GameObject)Instantiate(UiCardObj, parent.position, Quaternion.identity);
            int        rand     = GetRandomInt();
            UiCard     cardInfo = obj.GetComponent <UiCard>();

            cardInfo.pPriority = rand;
            if (!isAI)
            {
                cardInfo.SetSprite(sprites [rand]);
            }
            cardInfo.IsAI        = isAI;
            obj.transform.parent = parent;
            return(obj);
        }
Пример #7
0
        public void Restart()
        {
            mPlayerScore  = 0;
            mAIScore      = 0;
            mCheckCount   = 0;
            pSelectedCard = null;
            UpdateScores();
            //_WonText.gameObject.SetActive (false);
            //_WarningText.gameObject.SetActive(false);
            showWarning.Dispatch(false);
            showResult.Dispatch(false, "");

            tempList.Clear();
            DeleteAllCards();

            /* For now we have only 2 players.i.e Player and AI Player(Computer/Mobile) , so hard coding for now
             * */
            GenerateCards(pCurrentGameMode._CardsCount, true);
            GenerateCards(pCurrentGameMode._CardsCount, false);
        }
Пример #8
0
 /*
  * This is to get the Max priority card from the give array of Cards
  * */
 private UiCard GetMaxPriorityCard(UiCard []cards)
 {
     UiCard maxCard = cards [0];
     foreach(UiCard card in cards)
     {
         if(maxCard.pPriority < card.pPriority)
             maxCard = card;
     }
     return maxCard;
 }
Пример #9
0
 private UiCard GetLeastHigherPriorityAICard(UiCard selectedCard)
 {
     UiCard [] cards = GetAICards ();
     UiCard LeastHigherPriorityCard = null;
     foreach(UiCard card in cards)
     {
         if(card.pHasChecked)
             continue;
         if(card.pPriority > selectedCard.pPriority)
         {
             if(LeastHigherPriorityCard == null)
                 LeastHigherPriorityCard = card;
             else if(LeastHigherPriorityCard.pPriority > card.pPriority)
                 LeastHigherPriorityCard = card;
         }
     }
     if(LeastHigherPriorityCard != null)
     {
         LeastHigherPriorityCard.pHasChecked = true;
         LeastHigherPriorityCard.SetSprite(sprites[LeastHigherPriorityCard.pPriority]);
     }
     return LeastHigherPriorityCard;
 }
Пример #10
0
        public void Restart()
        {
            mPlayerScore = 0;
            mAIScore = 0;
            mCheckCount = 0;
            pSelectedCard = null;
            UpdateScores ();
            //_WonText.gameObject.SetActive (false);
            //_WarningText.gameObject.SetActive(false);
            showWarning.Dispatch(false );
            showResult.Dispatch (false , "");

            tempList.Clear ();
            DeleteAllCards ();
            /* For now we have only 2 players.i.e Player and AI Player(Computer/Mobile) , so hard coding for now
             * */
            GenerateCards(pCurrentGameMode._CardsCount , true);
            GenerateCards(pCurrentGameMode._CardsCount , false);
        }
Пример #11
0
 public void OnCheck()
 {
     if ((pSelectedCard == null && GetPlayerCards ().Length > 1) || (pSelectedCard != null && pSelectedCard.pHasChecked))
     {
         Debug.Log ("Please select a card");
         //_WarningText.gameObject.SetActive(true);
         showWarning.Dispatch(true);
         return;
     }
     mCheckCount++;
     if(pSelectedCard == null)
         pSelectedCard = GetMaxPriorityCard (GetPlayerCards());
     pSelectedCard.pHasChecked = true;
     if (GetLeastHigherPriorityAICard(pSelectedCard) != null)
     {
         mAIScore ++;
         Debug.Log ("Computer Won");
     }
     else
     {
         mPlayerScore ++;
         Debug.Log ("Pllayer Won");
     }
     UpdateScores ();
     if (mCheckCount >= 3 || pCurrentGameMode._IsSingleStep)
         OnSubmitScores ();
     pSelectedCard.ResetPosition();
     pSelectedCard = null;
 }
Пример #12
0
 public abstract void CardSelected(UiCard selectedCard);
Пример #13
0
 public abstract UiCard GetLeastHigherPriorityAICard(UiCard card);