/// <summary> /// Initializes a new instance of the <see cref="Card"/> class. /// </summary> /// <param name="resGeometry">The key of the GeometryResource.</param> /// <param name="cardPair">The pair this card belongs to.</param> public Card(NamedOrGenericKey resGeometry, CardPairLogic cardPair) : base(resGeometry) { this.Pair = cardPair; }
/// <summary> /// Builds up the given screen on the given SceneManipulator. /// </summary> /// <param name="manipulator">The manipulator.</param> /// <param name="currentScreen">The screen to be build.</param> private void BuildScreen(SceneManipulator manipulator, ScreenData currentScreen) { int tilesX = m_currentLevel.Tilemap.TilesX; int tilesY = m_currentLevel.Tilemap.TilesY; float tileDistX = Constants.TILE_DISTANCE_X; float tileDistY = -Constants.TILE_DISTANCE_Y; Vector3 midPoint = new Vector3((tilesX - 1) * tileDistX / 2f, 0f, ((tilesY - 1) * tileDistY / 2f)); foreach (CardPairData actPairData in currentScreen.MemoryPairs) { CardPairLogic actCardPair = new CardPairLogic(actPairData); // Define all resources needed for a card for this pair var resTitleMaterial = manipulator.AddSimpleColoredMaterial(actPairData.TitleFile); var resGeometry1 = manipulator.AddGeometry(new CardObjectType() { FrontMaterial = resTitleMaterial, BackMaterial = m_resBackgroundMaterial1 }); var resGeometry2 = manipulator.AddGeometry(new CardObjectType() { FrontMaterial = resTitleMaterial, BackMaterial = m_resBackgroundMaterial2 }); // Create both cards for this pair Card cardA = new Card(resGeometry1, actCardPair); Card cardB = new Card(resGeometry2, actCardPair); Tuple<int, int> slotA = SearchFreeCardSlot(m_currentLevel, m_cardMapOnScreen); m_cardMapOnScreen[slotA.Item1, slotA.Item2] = cardA; Tuple<int, int> slotB = SearchFreeCardSlot(m_currentLevel, m_cardMapOnScreen); m_cardMapOnScreen[slotB.Item1, slotB.Item2] = cardB; // Add both cards to the scene cardA.Position = new Vector3(slotA.Item1 * tileDistX, 0f, slotA.Item2 * tileDistY) - midPoint; cardA.AccentuationFactor = 1f; cardB.Position = new Vector3(slotB.Item1 * tileDistX, 0f, slotB.Item2 * tileDistY) - midPoint; cardB.AccentuationFactor = 1f; manipulator.Add(cardA); manipulator.Add(cardB); // Assigns the cards to the pair object actCardPair.Cards = new Card[] { cardA, cardB }; manipulator.Add(actCardPair); m_cardPairsOnScreen.Add(actCardPair); } }