Esempio n. 1
0
    public void UpdateNeighborReferences()
    {
        foreach (PlacementCircle item in m_neighbors)
        {
            item.UpdateCoordinates();
            Vector2 direction = item.m_coordinate - m_coordinate;
            switch (Convert.ToInt32(direction.x))
            {
            case -1:
                switch (Convert.ToInt32(direction.y))
                {
                case -1:
                    m_bottomLeftNeighbor = item;
                    break;

                case 0:
                    m_leftNeighbor = item;
                    break;

                case 1:
                    m_topLeftNeighbor = item;
                    break;
                }
                break;

            case 0:
                switch (Convert.ToInt32(direction.y))
                {
                case -1:
                    m_bottomNeighbor = item;
                    break;

                case 0:
                //throw new Exception();
                case 1:
                    m_topNeighbor = item;
                    break;
                }
                break;

            case 1:
                switch (Convert.ToInt32(direction.y))
                {
                case -1:
                    m_bottomRightNeighbor = item;
                    break;

                case 0:
                    m_rightNeighbor = item;
                    break;

                case 1:
                    m_topRightNeighbor = item;
                    break;
                }
                break;
            }
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 9x 39
    /// square and odd
    ///
    /// 20 second timer
    /// notif for timer has stopped before turn change
    /// save load
    /// menu should pause timer/game
    /// </summary>

    void Update()
    {
        if (m_isPlayingGame)
        {
            if (m_currentTimerDisplay)
            {
                m_currentTimerDisplay.text = m_turnTimer.ToString().Substring(0, (m_turnTimer < 10.0f) ? 1 : 2) + "s";
            }
            PlacementCircle circle = null;
            if (m_turnTimer > 0.0f)
            {
                if (m_currentPlayer.Equals(m_player1) || (m_currentPlayer.Equals(m_player2)))
                {
                    Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        circle = hit.collider.gameObject.GetComponent <PlacementCircle>();
                    }


                    if (Input.GetMouseButtonDown(0) && circle != null)
                    {
                        if (circle.PlacePiece(m_currentPlayer))
                        {
                            SwitchPlayers();
                        }
                    }
                }
                else
                {
                    circle = m_playerAI.SelectionCircle;
                }
            }
            else
            {
                SwitchPlayers();
            }
            m_turnTimer -= Time.deltaTime;
            if (circle)
            {
                if (!FirstTurn && !SecondTurn || !m_currentPlayer.Equals(m_player1))
                {
                    circle.Highlight();
                }
                else if (FirstTurn)
                {
                    if (Convert.ToInt32(circle.m_coordinate.x) == 0 && Convert.ToInt32(circle.m_coordinate.y) == 0)
                    {
                        circle.Highlight();
                    }
                }
                else if (SecondTurn)
                {
                    if (circle.m_coordinate.magnitude >= 2.9f)
                    {
                        circle.Highlight();
                    }
                }
            }
            if (circle != m_highlightedCircle && m_highlightedCircle != null)
            {
                m_highlightedCircle.Hide();
            }
            m_highlightedCircle = circle;
        }
    }