コード例 #1
0
    private BoardSection GetClosestBoardSection()
    {
        Vector3 cameraPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2 cardPosition   = new Vector2(cameraPosition.x, cameraPosition.y);

        RaycastHit2D[] hit            = Physics2D.RaycastAll(cardPosition, Vector2.zero, 0.0f, 1 << LayerMask.NameToLayer("Board"));
        BoardSection   closestSection = null;
        float          distance       = float.MaxValue;

        for (int i = 0; i < hit.Length; i++)
        {
            if (hit[i].collider != null)
            {
                BoardSection section = hit[i].transform.GetComponent <BoardSection>();
                if (!section)
                {
                    return(null);
                }
                float sectionDistance = Vector2.Distance(transform.position, hit[i].transform.position);
                if (sectionDistance < distance)
                {
                    closestSection = section;
                    distance       = sectionDistance;
                }
            }
        }
        return(closestSection);
    }
コード例 #2
0
ファイル: Deck.cs プロジェクト: AngieGE/Solitaire
 public Card(int v, House h, string cn, BoardSection bs, Sprite ci, Color c)
 {
     value         = v;
     house         = h;
     cardImageName = cn;
     boardSection  = bs;
     cardImage     = ci;
     color         = c;
 }
コード例 #3
0
 private void ChangeBoardSection(BoardSection section)
 {
     if (section == currentSection)
     {
         return;
     }
     HighlightBoard(section);
     currentSection = section;
 }
コード例 #4
0
ファイル: CardBehaviour.cs プロジェクト: AngieGE/Solitaire
    public void OnEndDrag(PointerEventData eventData)
    {
        if (!_IsDraggable)
        {
            return;
        }
        //TODO If i moved more than one card remove collider from intermdiate card
        //TODO Add collider to the last card
        transform.position = new Vector3(transform.position.x, transform.position.y, AuxiliaryZIndex);
        GameObject otherCardCollider = _MyMagnet.GetComponent <Magnet>().GetOtherCardCollider();

        if (otherCardCollider != null)
        {
            //get the board section in order to call the metod that checks if the movement is valid

            BoardSection bs = _MyMagnet.GetComponent <Magnet>().GetBoardSection();
            GameObject   otherCardPileManager = null;
            otherCardPileManager = _MyMagnet.GetComponent <Magnet>().GetOtherCardPileManager();

            bool validMovement = false;
            if (otherCardPileManager != null)
            {
                switch (bs)
                {
                case BoardSection.Foundation:
                    otherCardPileManager.GetComponent <FoundationBehaviour>().SetCardToPlace(card);
                    validMovement = otherCardPileManager.GetComponent <FoundationBehaviour>().CheckValidMovement();
                    break;

                case BoardSection.OpenCell:
                    validMovement = otherCardPileManager.GetComponent <OpenCellBehaviour>().CheckValidMovement();
                    break;

                case BoardSection.Tableau:
                    validMovement = otherCardPileManager.GetComponent <TableauBehaviour>().CheckValidMovement();
                    break;

                default:
                    break;
                }
            }
            if (validMovement)
            {
                ChangeCardOfPile(otherCardPileManager);
            }
            else
            {
                ResetPosition();
            }
        }
        else   // the player dropped the card on an empty space. didnt put the card on top of any other card.
        //return the card back to its original pile
        {
            ResetPosition();
        }
    }
コード例 #5
0
    private void Update()
    {
        if (state != CardState.CARD_IN_HAND)
        {
            return;
        }
        BoardSection newSection = GetClosestBoardSection();

        ChangeBoardSection(newSection);
    }
コード例 #6
0
ファイル: Main_Menu.xaml.cs プロジェクト: butler1233/CardsApp
        private async void RefreshBoard()
        {
            //Refresh the board
            BoardSection.Clear();
            BoardSection.Add(new ViewCell()
            {
                View = common.Common.GetLoadingGridView("Loading The Board™")
            });
            Settings.Players = await BasicRequest <List <Player> >("Players/List", "POST");

            var boardStatus = await BasicRequest <Dictionary <string, decimal> >("Status/All", "POST");

            Settings.Players.Sort((x, y) => y.CurrentMargin.CompareTo(x.CurrentMargin));
            BoardSection.Clear();
            foreach (Player Play in Settings.Players)
            {
                var LabelColor = Color.Red;
                if (Play.Active)
                {
                    LabelColor = Color.White;
                }
                var Cell = new EntryCell()
                {
                    IsEnabled = false, Text = boardStatus[Play.Name].ToString("F2"), Label = Play.Name, LabelColor = LabelColor
                };
                BoardSection.Add(Cell);
            }

            //refresh the games
            CurrentGames.Clear();
            CurrentGames.Add(new ViewCell()
            {
                View = common.Common.GetLoadingGridView("Loading Current Games")
            });
            var Games = await BasicRequest <List <GameInfo> >("GamesPlayed/Unfinished", "POST");

            CurrentGameEntries = new Dictionary <TextCell, GameInfo>();
            Games.Sort((x, y) => y.GameUniqueId.CompareTo(x.GameUniqueId));
            CurrentGames.Clear();
            foreach (GameInfo game in Games)
            {
                var playernames = new List <string>();
                foreach (Player player in game.Players)
                {
                    playernames.Add(player.Name);
                }
                var Cell = new TextCell()
                {
                    Text = game.GameType.Name + " - £" + game.Entry.ToString("F2"), Detail = $"ID: {game.GameUniqueId} Players: {string.Join(", ",playernames)}"
                };
                Cell.Tapped += CurrentGamePress;
                CurrentGameEntries.Add(Cell, game);
                CurrentGames.Add(Cell);
            }
        }
コード例 #7
0
 private void HighlightBoard(BoardSection section)
 {
     if (section == null)
     {
         if (currentSection != null)
         {
             //currentSection.GetComponent<Outline>().enabled = false;
             return;
         }
     }
     if (section != null)
     {
         //section.GetComponent<Outline>().enabled = true;
     }
     if (currentSection != null)
     {
         //currentSection.GetComponent<Outline>().enabled = false;
     }
 }
コード例 #8
0
    public void read_in_board_sections()
    {
        StreamReader reader = new StreamReader(Application.dataPath + "/Standard Assets/Resources/board_tiles.csv");
        int k = 0;
        BoardSection board_section = new BoardSection();
        try
        {
            do
            {
                if(k == 5){
                    game_board_sections.Add (board_section);
                    board_section = new BoardSection();
                    k = 0;
                }
                else{
                    string[] section_row = reader.ReadLine().Split (',');

                    for (int i = 0;i<section_row.Length;i++){
                        Tile new_tile = new Tile();
                        new_tile.Terrain_type = section_row[i];
                        board_section.Tiles[k,i] = new_tile;
                    }
                    k++;
                }
            }
            while(reader.Peek () != -1);
        }

        catch
        {
            Debug.Log ("File is Empty");
        }
        finally
        {
            game_board_sections[1].render_board_section(Vector3.zero);
            reader.Close ();
        }
    }
コード例 #9
0
    private BoardSection[] hexMap; //Unconnected sections of the board

    #endregion Fields

    #region Constructors

    public Board(BoardSection[] inMap)
    {
        hexMap = inMap;
    }
コード例 #10
0
 public BoardSection CreateSection(int sectionNum, PlanetSystem[][] sectionArrays, int[] columnArray)
 {
     BoardSection section = new BoardSection (sectionNum, sectionArrays, columnArray, calculateNextOrigin (), HexPrefab, hexSize);
     return section;
 }
コード例 #11
0
    public void PrepareGalaxySetup()
    {
        int[] center = determineCenter();

        BoardSection[] boardSections = new BoardSection[1];
        int ringCount;
        BoardType boardType;
        if (gameManager.PlayerCount <= 3) {
            //1 & 2 aren't valid player numbers, so we assume 3 in those cases (for quicker solo testing)
            boardType = BoardType.ThreePlayer;
        } else {
            boardType = BoardType.Hexagon;
        }
        if (gameManager.PlayerCount < 7) {
            ringCount = 3;
        } else {
            ringCount = 4;
        }

        float rotation = determineBoardRotation();
        Color emptyColor = gameManager.UIMgr.MapSetupUI.Empty;
        boardSections[0] = new BoardSection(0, ringCount, boardType, calculateNextOrigin (), center, HexPrefab, hexSize, rotation, emptyColor);

        GameBoard = new Board(boardSections);
        setHomeSystems();
        GameBoard.SetSystem(GetSystem("Mecatol Rex"), 0, center[0], center[1]);

        repositionBoard(rotation);

        if (gameManager.NetworkMgr.IsMasterClient()) {
            DealSystems(gameManager.PlayerCount);
        }
    }