void setListeners() { for (int i = 0; i < player.actionSelection.getSize(); i++) { int copy = i; Button HUD_clickable_Card = GameObject.Find("HUDSelectedAction" + (copy)).GetComponent <Button>(); HUD_clickable_Card.onClick.AddListener(delegate { ActionCard currentActionCard = player.actionSelection.getActionCard(copy); if (currentActionCard is WeaponActionCard) { switch (currentActionCard.type) { case "gravityMine": player.addWeapon("gravityMine"); break; case "laser": player.addWeapon("laser"); break; case "rocket": player.addWeapon("rocket"); break; } } player.AddMainFuel(currentActionCard.fuelCost); player.actionSelection.removeActionCardwithIndex(copy); player.CardCounterChange(-1); EventManager.TriggerEvent("Player_Card_Selection_Changed"); EventManager.TriggerEvent("Player_Main_Fuel_Has_Changed"); EventManager.TriggerEvent("Player_Add_Fuel_Has_Changed"); }); } }
// void DrawTextures(Rect[] rects) // { // // } public void Init(ActionCard actionCard) { this.actionCard = actionCard; SetupIcon(); label.text = actionCard.data.cardName; }
public async Task <ActionResult> PartActionCardContent() { //消息类型 var msgtype = MsgTypeEnum.actionCard.ToString(); //actionCard内容 var actionCard = new ActionCard { Text = "![screenshot](https://gw.alipayobjects.com/zos/skylark-tools/public/files/84111bbeba74743d2771ed4f062d1f25.png) " + "### 乔布斯 20 年前想打造的苹果咖啡厅 " + "Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划", Title = "乔布斯 20 年前想打造一间苹果咖啡厅,而它正是 Apple Store 的前身", HideAvatar = "0", BtnOrientation = "0", Btns = new List <BtnInfo>() { new BtnInfo() { Title = "内容不错", ActionUrl = "https://www.dingtalk.com/" }, new BtnInfo() { Title = "不感兴趣", ActionUrl = "https://www.dingtalk.com/" } } }; var response = await SendDingTalkMessage(new { msgtype, actionCard }); return(Ok(response)); }
public bool BuildMarvel(ActionCard card) { // the card is turned into a building // ... return(false); }
public static async Task UseActionCard <T>(Game game, T useActionCard, ActionCard card, Func <Game, T, Task> effect) where T : PlayerAction.FreeUse { Player player = game.GetPlayer(useActionCard.PlayerId); await player.DropActionCard(game, useActionCard.Source); //由于行动牌可能是由多张牌转换过来的,要根据source处理 UsingInfo usingInfo = new UsingInfo() { Card = card, Info = $"{player.Hero.Name}使用了{card.Name}", }; //结算前把牌放入结算区 foreach (var cardId in useActionCard.Source) { var c = game.GetCard(cardId); game.AddUsingCard(c); usingInfo.Source.Add(c); } game.AddUsingInfo(usingInfo); await effect(game, useActionCard); foreach (var cardId in useActionCard.Source) { var c = game.GetCard(cardId) as ActionCard; game.RemoveUsingCard(c); //结算完毕进入弃牌堆 game.UsedActionDeck.Add(c); } }
public void Pay(ActionCard card) { if (card.cost[ResourceType.Money] > 0) { this.Money -= card.cost[ResourceType.Money]; } }
public void SetCardsForNextTurn(List <Card> scannedCards) { // Debug.Log("Game manager recieving scanned cards"); foreach (Card c in scannedCards) { // Debug.Log("GameManager recieving card : " + c); if (c is ItemCard) { currentItemCard = (ItemCard)c; // Debug.Log("GameManager recieving item card"); } else if (c is ScenarioCard) { currentScenarioCard = (ScenarioCard)c; // Debug.Log("GameManager recieving scenario card"); } if (c is ActionCard) { ActionCard tmpCard = (ActionCard)c; // Debug.Log("GameManager recieving action card : " + tmpCard.CharacterId); currentActionCards[tmpCard.CharacterId] = tmpCard; } } }
public static void Register(Game game) { //注册一个事件用于阻塞 game.EventSystem.Register(EventEnum.AfterPlayrSizeChange, -1, args => { flag = null; foreach (var player in game.Players) { ActionCard card = player.ActionCards.Find(c => c.configID == game.Database.getID(typeof(AT_N005))); if (card != null) { afterPlayerSizeChange(card, args); } } return(Task.CompletedTask); }); game.EventSystem.Register(EventEnum.AfterPlayrSizeChange, 100, args => { if (flag != null) { return(flag.Task); } else { return(Task.CompletedTask); } }); }
public void ReplaceAThing() { thing.SetToNothing(); board.thingInfoArea.text = "Replace a Thing"; List <ActionCard> playerCards = player.hand.GetAllCards(); if (playerCards.Count == 0) { return; } ActionCard card = playerCards[Random.Range(0, playerCards.Count)]; playerCards.Remove(card); MoveCard(card.gameObject, "Graveyard", 3, 0.5f); GameObject cardObj = Instantiate(board.actionCardPrefab, board.deck.transform); Data_ActionCard cardData = DeckManager.instance.DealActionCard(); ActionCard actionCard = cardObj.GetComponent <ActionCard>(); actionCard.SetData(cardData); cardObj.SetActive(false); actionCard.interactable = true; MoveCard(cardObj, "PlayerHand", 2, 0.5f); Debug.Log("Player has " + enemy.hand.GetCardCount() + " cards"); player.hand.AddCard(actionCard); }
public static void Register(Game game) { //注册一个事件用于阻塞 game.EventSystem.Register(EventEnum.changeEventDirection, -1, (args) => { flag = null; foreach (var player in game.Players) { ActionCard card = player.ActionCards.Find(c => c.configID == game.Database.getID(typeof(AT_N020))); if (card != null) { effect(card, args); } } return(Task.CompletedTask); }); game.EventSystem.Register(EventEnum.changeEventDirection, 100, (x) => { if (flag != null) { return(flag.Task); } else { return(Task.CompletedTask); } }); }
public override async Task DoEffect(Game game, FreeUse useWay) { ActionCard source = game.GetCard(useWay.Source[0]) as ActionCard; Player player = game.GetPlayer(useWay.PlayerId); Player target = game.GetPlayer(useWay.PlayersId[0]); await target.ChangeSize(game, -1, source, player); Player now = target; while (true) { ChooseSomeCardResponse chooseSomeCardResponse = (ChooseSomeCardResponse)await game.WaitAnswer(new ChooseSomeCardRequest() { Count = 1, PlayerId = now.Id, TimeOut = game.RequestTime, EnoughOnly = false }); if (chooseSomeCardResponse.Cards.Count == 0) { break; } else { Player nowTarget = now == player ? target : player; await now.discard(game, chooseSomeCardResponse.Cards); await nowTarget.ChangeSize(game, -1, source, now); now = nowTarget; } } }
public bool Discard(ActionCard card) { hand.Extract(card); Money += 3; manager.discards[card.data.age - 1].Add(card); return(true); }
public override bool isValidTarget(Game game, FreeUse useWay, ActionCard card, out string invalidInfo) { if (_changeTarget != null) { return(_changeTarget.isValidTarget(game, useWay, card, out invalidInfo)); } return(base.isValidTarget(game, useWay, card, out invalidInfo)); }
override public void Add(ActionCard card) { base.Add(card); card.transform.parent = this.transform; card.transform.localPosition = new Vector3((cards.Count - 4) * 5, 0, 0); card.transform.localRotation = Quaternion.identity; card.Visible = true; }
public AirliftViewModel(IContext<BaseActionCard> selectedActionCardContext, ActionCardManager actionCardManager) { this.selectedActionCardContext = selectedActionCardContext; this.actionCardManager = actionCardManager; actionCard = selectedActionCardContext.Context as ActionCard<AirliftItem>; if (actionCard == null) this.selectedActionCardContext.Context = null; }
public HomeController(ILogger <HomeController> logger, INGrokHostedService ngrok, IWebHostEnvironment env, ActionCard email) { _logger = logger; _ngrok = ngrok; _env = env; _email = email; }
static Task effect(ActionCard card, object[] args) { Game game = args[0] as Game; //这里不能用异步阻塞,直接返回任务完成 doeffect(card, args, game).NoWait(); return(Task.CompletedTask); }
public GovernmentGrantViewModel(IContext<BaseActionCard>selectedActionCardContext, ActionCardManager actionCardManager) { this.selectedActionCardContext = selectedActionCardContext; this.actionCardManager = actionCardManager; actionCard = selectedActionCardContext.Context as ActionCard<GovernmentGrantItem>; if (actionCard == null) this.selectedActionCardContext.Context = null; }
/// <summary> /// Wywołuje wszystkie akcje przypisane do karty /// </summary> /// <param name="caller"></param> public void CallActions(Player caller) { foreach (ActionString actionString in actionStrings) { ActionCard action = ActionCard.Create(actionString); action.Call(caller); } }
public static SpacecraftAction ParseCard(ActionCard card) { //Debug.Log(card.type); if (card.type.Equals("forward") || card.type.Equals("backward")) { SpacecraftAction.Direction direction = SpacecraftAction.Direction.None; switch (card.type) { case "forward": direction = SpacecraftAction.Direction.Forwards; break; case "backward": direction = SpacecraftAction.Direction.Backwards; break; } float force = card.forceOrVelocity; float duration = card.duration; float fuelCost = card.fuelCost; return(new SpacecraftBoost(direction, fuelCost, force, duration)); } else if (card.type.Contains("rotate")) { SpacecraftAction.Direction direction = SpacecraftAction.Direction.None; switch (card.type) { case "rotateLeft": direction = SpacecraftAction.Direction.Left; break; case "rotateRight": direction = SpacecraftAction.Direction.Right; break; } float velocity = card.forceOrVelocity; float duration = card.duration; float fuelCost = 1; return(new SpacecraftRotation(direction, fuelCost, velocity, duration)); } else if (card.type.Equals("gravityMine")) { return(new SpacecraftWeaponAction(SpacecraftWeaponAction.WeaponType.GravityMine, card.fuelCost)); } else if (card.type.Equals("laser")) { return(new SpacecraftWeaponAction(SpacecraftWeaponAction.WeaponType.Laser, card.fuelCost)); } else if (card.type.Equals("rocket")) { return(new SpacecraftWeaponAction(SpacecraftWeaponAction.WeaponType.Rocket, card.fuelCost)); } else if (card.type.Equals("none")) { return(new SpacecraftRotation(SpacecraftRotation.Direction.Forwards, 0, 0, 2)); } return(null); }
public override async Task DoEffect(Game game, FreeUse useWay) { ActionCard source = game.GetCard(useWay.Source[0]) as ActionCard; Player player = game.GetPlayer(useWay.PlayerId); Player target = game.GetPlayer(useWay.PlayersId[0]); await player.ChangeSize(game, -1, source, player); await target.ChangeSize(game, -2, source, player); }
public GovernmentGrantManager(ActionCard<GovernmentGrantItem> card, IEnumerable<Node> nodes, ResearchStationCounter researchStationCounter) { this.nodes = nodes; this.card = card; this.researchStationCounter = researchStationCounter; this.researchStationCounter.ResearchStationConstructed += ResearchStationChanged; Update(); }
/// <summary> /// Loads all card data from a large string containing the info in CSV format. /// </summary> /// <param name="csv">The string containing card info in CSV format</param> public void LoadCSVText(string csv) { Debug.Log("Loading CSV Text..."); // Parses CSV into a format where each line is separated and split further into a list of cells List <List <string> > parsedCsv = ParseCSV(csv); foreach (List <string> line in parsedCsv) { Card thisCard; if (line[1].ToLower() == "action") { // this is an Action Card thisCard = new ActionCard(); MasterActionDeck.Add((ActionCard)thisCard); } else if (line[1].ToLower() == "event") { // this is an Event Card thisCard = new EventCard(); if (int.Parse(line[10]) == 1) { // this is a super positive event card PositiveEventCards.Add((EventCard)thisCard); } else if (int.Parse(line[11]) == 1) { // this is a super negative event card SuperNegativeEventCards.Add(line[12], (EventCard)thisCard); } else { // this is just a normal event card MasterEventDeck.Add((EventCard)thisCard); } } else { // We don't recognize this card's type Debug.LogError("Unknown card type " + line[1]); continue; } // Add basic card info from the corresponding slots in the CSV line int.TryParse(line[0], out thisCard.cardNumber); thisCard.cardName = line[3]; thisCard.cardDesc = line[5]; int.TryParse(line[6], out thisCard.costCarbon); int.TryParse(line[7], out thisCard.costMoney); int.TryParse(line[8], out thisCard.hope); int.TryParse(line[9], out thisCard.momentum); // Load card image from the corresponding file path for that image // e.g., "ActionCards/2-Choose Public Transport" thisCard.cardImage = Resources.Load <Sprite>( (line[1].ToLower() == "action" ? "ActionCards" : "EventCards") + "/" + thisCard.cardNumber.ToString() + "-" + thisCard.cardName); } Debug.Log("Done loading CSV!"); // Cards are all loaded and ready to go; time to pass this off to the GameManager GameManager.Instance.SetupGame(); }
internal override void OnEnterHand(Game game, Player player) { base.OnEnterHand(game, player); if (game.UsedActionDeck.Count > 0) { _changeTarget = game.UsedActionDeck[game.UsedActionDeck.Count - 1];//变形成已经在弃牌堆的最后一张牌 } game.EventSystem.Register(EventEnum.AfterAddCard, game.GetSeat(player), afterAddCard); game.EventSystem.Register(EventEnum.AfterRemoveCard, game.GetSeat(player), afterRemoveCard); }
public void ActionCardCallsInternalActionWithPlayer() { var player = new Player("Fake"); var action = new FakeAction(); var card = new ActionCard(action); card.Play(player); Assert.IsTrue(action.WasCalledWith(player)); }
public override Task DoEffect(Game game, FreeUse useWay) { ActionCard source = game.GetCard(useWay.Source[0]) as ActionCard; source.setProp("onTurnStart", new CardCallback(source, onTurnStart)); source.setProp("player", game.GetPlayer(useWay.PlayerId)); game.EventSystem.Register(EventEnum.TurnStart, game.GetSeat(game.GetPlayer(useWay.PlayerId)), source.getProp <CardCallback>("onTurnStart").call); Debug.Log(source + "注册延迟效果"); return(Task.CompletedTask); }
private void DestroyConnection(ActionCard actionCard, RouteCard connectionToDestroy) { _client.SendMessage(new DestroyMessage { CardId = actionCard.Id, Coordinates = connectionToDestroy.Coordinates, SenderId = CurrentPlayer.Id, RoleType = CurrentPlayer.Role.Role }); }
private void Expore(ActionCard actionCard, GoldCard cardToOpen) { _client.SendMessage(new ExploreMessage { CardId = actionCard.Id, Coordinates = cardToOpen.Coordinates, SenderId = CurrentPlayer.Id, RoleType = CurrentPlayer.Role.Role }); }
private void UseKey(ActionCard actionCard, RouteCard routeCard) { _client.SendMessage(new KeyMessage { CardId = actionCard.Id, Coordinates = routeCard.Coordinates, SenderId = CurrentPlayer.Id, RoleType = CurrentPlayer.Role.Role }); }
/// <summary> /// Checks if the played card will work given whatever hope and momentum constraints are placed by the event card. /// </summary> /// <param name="playedCard"></param> public bool ValidCard(ActionCard playedCard) { // Make sure card played is valid given momentum constraints if (Momentum > 0 && playedCard.momentum <= 0) { Debug.Log("Card played must have momentum during a momentum run."); return(false); } return(true); }
private static void ComputeCardScore(ActionCard card) { var attack = card.Attackers.Sum(x => x.Skills.Attack); var defence = card.Defenders.Sum(x => x.Skills.Defence); var captainAttack = card.Attackers.FirstOrDefault(x => x.IsCaptain); if (captainAttack != null) { if (new[] { SpecialSkill.EAffected.Self, SpecialSkill.EAffected.OwnTeam }.Contains(captainAttack.SpecialSkill.Affected)) { if (captainAttack.SpecialSkill.Skill == ESkill.Attack) { attack += captainAttack.SpecialSkill.Value; } else if (captainAttack.SpecialSkill.Skill == ESkill.Penalty && card.PlayerLimit == (int)ActionCard.EActionCardType.Penalty) { attack += captainAttack.SpecialSkill.Value; } } else if (captainAttack.SpecialSkill.Skill == ESkill.Defence) { //weaken opponent's defence defence += captainAttack.SpecialSkill.Value; } } var captainDefence = card.Defenders.FirstOrDefault(x => x.IsCaptain); if (captainDefence != null) { if (new[] { SpecialSkill.EAffected.Self, SpecialSkill.EAffected.OwnTeam }.Contains(captainDefence.SpecialSkill.Affected)) { if (captainDefence.SpecialSkill.Skill == ESkill.Defence) { defence += captainDefence.SpecialSkill.Value; } } else if (captainDefence.SpecialSkill.Skill == ESkill.Attack) { //weaken opponent's attack attack += captainDefence.SpecialSkill.Value; } else if (captainDefence.SpecialSkill.Skill == ESkill.Penalty && card.PlayerLimit == (int)ActionCard.EActionCardType.Penalty) { //weaken opponent's penalty attack += captainDefence.SpecialSkill.Value; } } card.Score = new Score(attack, defence); }
public bool Resolve(ActionCard card) { Debug.Log("No resolution done for now"); if (card && card.data && card.data.production.Length > 0 && card.data.production[0] != null && card.data.production[0].contentAsList[ResourceType.Money] > 0) { Money += card.data.production[0].contentAsList[ResourceType.Money]; return(true); } return(false); }
// Update is called once per frame void Update() { RaycastHit hit; Ray ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { Transform objectHit = hit.transform; hovered = objectHit.gameObject.GetComponent <ActionCard>(); if (hovered != null) { if (Input.GetMouseButtonDown(0)) { if (!city.hand.Contains(hovered)) { Debug.LogWarning("This is not your hand"); } else { if (option == 0) { if (TryPlay(hovered)) { Debug.Log("you can play this card"); manager.EndTurn(); } } else if (option == 1) { Debug.Log("Marvel"); if (city.BuildMarvel(hovered)) { manager.EndTurn(); } } if (option == 2) { Debug.Log("Discarding"); city.Discard(hovered); manager.EndTurn(); } } } } } else { hovered = null; } }
public AirliftManager(ActionCard<AirliftItem> card, IEnumerable<Node> nodes, IEnumerable<Player> players) { this.nodes = nodes; this.players = players; this.card = card; foreach (Player player in this.players) { player.Moved += Moved; } Update(); }
private ActionCard readAction(string dataType, string dataText, string fileName, StreamReader reader) { if (dataText == "<{>") { ActionCard action = new ActionCard(); string line = reader.ReadLine().Trim (); do { string[] lineParts; //Split category name from data lineParts = line.Split(":".ToCharArray(), 2); //Remove any extra whitespace from parts & set descriptive variables string newDataType = gameManager.LanguageMgr.StringToDataType(lineParts[0].Trim ()); string newDataText = lineParts[1].Trim (); if (newDataType == "Name") { action.Name = readTextLine(newDataType, newDataText, fileName); } else if (newDataType == "Quantity") { action.Quantity = readIntLine(newDataType, newDataText, fileName); } else if (newDataType == "Expansion") { action.Expansion = gameManager.LanguageMgr.StringToExpansion(readTextLine(newDataType, newDataText, fileName)); } else if (newDataType == "Flavor Text") { action.FlavorText = readTextLine (newDataType, newDataText, fileName); } else if (newDataType == "Rule Text A") { action.RulesText = readTextBlock(newDataType, newDataText, fileName, reader); } else if (newDataType == "Play Text") { action.PlayText = readTextLine(newDataType, newDataText, fileName); } else if (newDataType == "Rule Text B") { action.DiscardText = readTextBlock(newDataType, newDataText, fileName, reader); } else if (newDataType == "ID") { action.Id = readTextLine (newDataType, newDataText, fileName); } line = reader.ReadLine().Trim (); } while (line != "<}>"); // End of outermost block if (action.Id == default(string)) { action.Id = action.Name; } return action; } else { throw new System.Exception(string.Format("Error reading file {0}:: got \"{1}\" should be <{>", fileName, dataText)); } }
public void addActiveActionCard(ActionCard newActionCard) { activeActionCards.Add(newActionCard); }
void activeActionCardHasBeenCompleted(ActionCard card) { card.targetPosition = card.targetPosition + new Vector2(2*ACTION_CARD_SIZE, 0); activeActionCards.Remove(card); }