private void CreateCurrentCardSetCardsList() { currentCardList = EditorUtils.SetupReorderableList("Cards", currentCardSet.cards, ref currentCard, (rect, x) => { EditorGUI.LabelField(new Rect(rect.x, rect.y, 200, EditorGUIUtility.singleLineHeight), x.name); }, (x) => { currentCard = x; currentCardCost = null; currentCardKeyword = null; currentCardAbility = null; CreateCurrentCardCostsList(); CreateCurrentCardKeywordsList(); CreateCurrentCardAbilitiesList(); }, () => { var menu = new GenericMenu(); foreach (var cardType in gameConfig.cardTypes) { menu.AddItem(new GUIContent(cardType.name), false, CreateCardCallback, cardType); } menu.ShowAsContext(); }, (x) => { currentCard = null; currentCardCost = null; currentCardKeyword = null; currentCardAbility = null; }); }
public CardCollectionEditor(GameConfiguration config) : base(config) { cardSetsList = EditorUtils.SetupReorderableList("Card sets", gameConfig.cardSets, ref currentCardSet, (rect, x) => { EditorGUI.LabelField(new Rect(rect.x, rect.y, 200, EditorGUIUtility.singleLineHeight), x.name); }, (x) => { currentCardSet = x; currentCard = null; currentCardCost = null; currentCardKeyword = null; currentCardAbility = null; CreateCurrentCardSetCardsList(); }, () => { gameConfig.cardSets.Add(new CardSet()); }, (x) => { currentCardSet = null; currentCard = null; currentCardCost = null; currentCardKeyword = null; currentCardAbility = null; }); }
private void CreateCardKeywordCallback(object obj) { var keyword = new RuntimeKeyword(); keyword.keywordId = (int)obj; currentCard.keywords.Add(keyword); }
private void CreateCurrentCardKeywordsList() { currentCardKeywordsList = EditorUtils.SetupReorderableList("Keywords", currentCard.keywords, ref currentCardKeyword, (rect, x) => { var currentKeyword = gameConfig.keywords.Find(k => k.id == x.keywordId); var options = new List <string>(); foreach (var value in currentKeyword.values) { options.Add(value.value); } x.valueId = EditorGUI.Popup(new Rect(rect.x, rect.y, 150, EditorGUIUtility.singleLineHeight), x.valueId, options.ToArray()); }, (x) => { currentCardKeyword = x; }, () => { var menu = new GenericMenu(); for (var i = 0; i < gameConfig.keywords.Count; i++) { menu.AddItem(new GUIContent(gameConfig.keywords[i].name), false, CreateCardKeywordCallback, i); } menu.ShowAsContext(); }, (x) => { currentCardKeyword = null; }); }
public static RuntimeKeyword GetRuntimeKeyword(NetKeyword netKeyword) { var keyword = new RuntimeKeyword(); keyword.keywordId = netKeyword.keywordId; keyword.valueId = netKeyword.valueId; return(keyword); }
public static NetKeyword GetNetKeyword(RuntimeKeyword keyword) { var netKeyword = new NetKeyword(); netKeyword.keywordId = keyword.keywordId; netKeyword.valueId = keyword.valueId; return(netKeyword); }
/// <summary> /// Adds a keyword to this card. /// </summary> /// <param name="keyword">The identifier of the keyword.</param> /// <param name="value">The value of the keyword.</param> public void AddKeyword(int keyword, int value) { var k = keywords.Find(x => x.keywordId == keyword && x.valueId == value); if (k == null) { k = new RuntimeKeyword(); k.keywordId = keyword; k.valueId = value; keywords.Add(k); if (onKeywordAdded != null) { onKeywordAdded(k); } } }
protected virtual void OnRegisterPlayer(NetworkMessage netMsg) { var msg = netMsg.ReadMessage <RegisterPlayerMessage>(); Assert.IsNotNull(msg); // If this player is already registered, ignore this message. var player = server.gameState.players.Find(x => x.netId == msg.netId); if (player != null) { return; } // Create a new player info for the registered player. player = new PlayerInfo(); player.id = server.gameState.players.Count; player.connectionId = netMsg.conn.connectionId; player.netId = msg.netId; player.nickname = msg.name; player.isConnected = true; player.isHuman = msg.isHuman; var gameConfig = GameManager.Instance.config; // Set the player stats based on the generic player definition. foreach (var stat in gameConfig.playerStats) { var statCopy = new Stat(); statCopy.name = stat.name; statCopy.statId = stat.id; statCopy.originalValue = stat.originalValue; statCopy.baseValue = stat.baseValue; statCopy.minValue = stat.minValue; statCopy.maxValue = stat.maxValue; player.stats[stat.id] = statCopy; player.namedStats[stat.name] = statCopy; } // Set the player zones based on the generic zone definitions. var personalZones = gameConfig.gameZones.FindAll(x => x.owner != ZoneOwner.Shared); foreach (var zone in personalZones) { var zoneCopy = new RuntimeZone(); zoneCopy.name = zone.name; zoneCopy.zoneId = zone.id; if (zone.hasMaxSize) { zoneCopy.maxCards = zone.maxSize; } else { zoneCopy.maxCards = int.MaxValue; } player.zones[zone.id] = zoneCopy; player.namedZones[zone.name] = zoneCopy; } foreach (var condition in gameConfig.properties.endGameConditions) { if (condition is PlayerStatEndGameCondition) { var playerStatCondition = condition as PlayerStatEndGameCondition; player.stats[playerStatCondition.statId].onValueChanged += (oldValue, newValue) => { if (playerStatCondition.IsTrue(player)) { server.EndGame(player, playerStatCondition.type); } }; } else if (condition is CardsInZoneEndGameCondition) { var cardsCondition = condition as CardsInZoneEndGameCondition; player.zones[cardsCondition.zoneId].onZoneChanged += value => { if (cardsCondition.IsTrue(player)) { server.EndGame(player, cardsCondition.type); } }; } } // Add the default deck. var deckZoneId = gameConfig.gameZones.Find(x => x.name == "Deck").id; var deck = player.zones[deckZoneId]; foreach (var id in msg.deck) { var card = new RuntimeCard(); card.cardId = id; card.instanceId = player.currentCardInstanceId++; card.ownerPlayer = player; // Copy stats. var libraryCard = gameConfig.GetCard(id); foreach (var stat in libraryCard.stats) { var statCopy = new Stat(); statCopy.statId = stat.statId; statCopy.name = stat.name; statCopy.originalValue = stat.originalValue; statCopy.baseValue = stat.baseValue; statCopy.minValue = stat.minValue; statCopy.maxValue = stat.maxValue; card.stats[stat.statId] = statCopy; card.namedStats[stat.name] = statCopy; } // Copy keywords. foreach (var keyword in libraryCard.keywords) { var keywordCopy = new RuntimeKeyword(); keywordCopy.keywordId = keyword.keywordId; keywordCopy.valueId = keyword.valueId; card.keywords.Add(keywordCopy); } deck.cards.Add(card); } // Add the new player to the server's list of players. server.gameState.players.Add(player); Logger.Log("Player with id " + player.id + " has joined the game."); // When the appropriate number of players is registered, the game can start. if (server.gameState.players.Count == 2) { server.StartGame(); } }