public void SwitchDummy(Text textButton) { //switch active dummy if (dummyPosition == DummyPosition.straigt) { imageTargetDummy = inclinedDummy; dummyPosition = DummyPosition.inclined; textButton.text = "View : inclined"; if (m_verbose) { Debug.Log("Set dummy to inclined"); } } else { imageTargetDummy = straightDummy; dummyPosition = DummyPosition.straigt; textButton.text = "View : straight"; if (m_verbose) { Debug.Log("Set dummy to straight"); } } //update model position if (currentARObject != null) { currentARObject.transform.SetParent(imageTargetDummy.transform); currentARObject.transform.localPosition = Vector3.zero; currentARObject.transform.rotation = imageTargetDummy.transform.rotation; } }
public void Init(SceneConfigData a_data) { //initialize singleton if (instance != null && instance != this) { Destroy(instance); } instance = this; //set dummy position dummyPosition = a_data.DummyPosition; if (dummyPosition == DummyPosition.straigt) { imageTargetDummy = straightDummy; } else { imageTargetDummy = inclinedDummy; } //setup model list models = new List <AEntity>(); currentSelected = -1; //setup the rest of the class //get first AR Object assigned to Image Target if (imageTargetDummy.transform.childCount == 0) { currentARObject = null; } else { currentARObject = imageTargetDummy.transform.GetChild(0).gameObject.GetComponent <AEntity>(); } //update Object Manager List for (int i = 0; i < a_data.Items.Length; ++i) { AddModel(a_data.Items[i]); } m_verbose = a_data.Verbose; }
// Return the index of the card to play from myHand // TODO: We'll need the auction as well in the future public static int SelectCard(List <Trick> tricks, Trick currentTrick, DummyPosition dummyPosition, List <Card> myHand, List <Card> visibleHand, Strain contractStrain, int contractLevel) { // State of the art AI: play a random legal card! System.Random rnd = new System.Random(); // Look for unplayed cards in suit led. Empty if we're first to lead. List <int> cardsInSuitLed = new List <int>(); if (currentTrick.cards.Count > 0) { for (int i = 0; i < myHand.Count; i++) { Card card = myHand[i]; if (card.suit == currentTrick.cards[0].suit && !card.played) { cardsInSuitLed.Add(i); } } } // If we have cards in the suit led, we need to play one of them. if (cardsInSuitLed.Count > 0) { return(cardsInSuitLed[rnd.Next(cardsInSuitLed.Count)]); } // Otherwise play first legal card for (int i = 0; i < myHand.Count; i++) { if (!myHand[i].played) { return(i); } } Debug.Log("No legal cards found!"); return(0); }
DummyPosition GetDummyPosition(Direction currentPlayer, Direction declarer) { DummyPosition dummy = DummyPosition.ME; switch (currentPlayer) { case Direction.WEST: switch (declarer) { case Direction.WEST: dummy = DummyPosition.PARTNER; break; case Direction.EAST: dummy = DummyPosition.ME; break; case Direction.NORTH: dummy = DummyPosition.RIGHT; break; case Direction.SOUTH: dummy = DummyPosition.LEFT; break; } break; case Direction.NORTH: switch (declarer) { case Direction.WEST: dummy = DummyPosition.LEFT; break; case Direction.EAST: dummy = DummyPosition.RIGHT; break; case Direction.NORTH: dummy = DummyPosition.PARTNER; break; case Direction.SOUTH: dummy = DummyPosition.ME; break; } break; case Direction.EAST: switch (declarer) { case Direction.WEST: dummy = DummyPosition.ME; break; case Direction.EAST: dummy = DummyPosition.PARTNER; break; case Direction.NORTH: dummy = DummyPosition.LEFT; break; case Direction.SOUTH: dummy = DummyPosition.RIGHT; break; } break; case Direction.SOUTH: switch (declarer) { case Direction.WEST: dummy = DummyPosition.RIGHT; break; case Direction.EAST: dummy = DummyPosition.LEFT; break; case Direction.NORTH: dummy = DummyPosition.ME; break; case Direction.SOUTH: dummy = DummyPosition.PARTNER; break; } break; } return(dummy); }