public bool CanPickUpCard(PlayerInfo player, CardInfo card) { int turn = state.GetValue<int>("turn"); bool isPlayersTurn = player.Owner && player.PlayerID == turn; bool ret = isPlayersTurn && (card.state == CardInfo.State.Hand || (card.state == CardInfo.State.Placed && card.stats.type == CardStats.CardType.Unit)) && state.IsAllowed("pickup card"); return ret; }
public void UpdateAll(GameManager game, float delta) { if (selected != null) { selected.GetComponent<Position>().position = game.Inputs.Mouse.Position + offset; if (game.Inputs.Mouse.Left.Released) { Place (game, selected, game.Inputs.Mouse.Position); selected = null; } } else if (selected == null && game.Inputs.Mouse.Left.Pressed) { selected = EntityFinder.GetEntityAt(game.GetEntitiesWith<CardType>(), game.Inputs.Mouse.Position); PlayerInfo playerInfo = new PlayerInfo(); foreach(Entity player in game.GetEntitiesWith<PlayerType>()) { if (player.GetComponent<PlayerType>().info.Owner) { playerInfo = player.GetComponent<PlayerType>().info; break; } } if (selected != null) { if (!game.Rules.CanPickUpCard(playerInfo, selected.GetComponent<CardType>().info)) { selected = null; } else { offset = selected.GetComponent<Position>().position - game.Inputs.Mouse.Position; } } } }