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); }
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; }
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); }
/* * 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); }
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); }
/* * 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); }
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); }
/* * 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; }
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; }
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); }
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; }
public abstract void CardSelected(UiCard selectedCard);
public abstract UiCard GetLeastHigherPriorityAICard(UiCard card);