Esempio n. 1
0
    void Start()
    {
        GameEventManager.Initialize();
        mBags = new List <Bag>(2);

        mBoard = mBoardObject.GetComponent <Board>();
        mBoard.Initialize(kBoardSize);

        // Init shared game data.
        BoardController boardController = mBoard.Controller;

        Debug.Log("board controller " + boardController.ToString());

        DominoGenerator generator = new DominoGenerator(boardController.StartPosition, mDominoObject);

        Debug.Log("board controller" + generator.ToString());
        GamePlayManager.Initialize();
        GamePlayManager.Instance.Init(generator, mBoard.Controller, mDominoObject);

        // init draw bags
        {
            Bag bag = new Bag(kNumSlots, mBoard.Controller.Size, true);

            for (int i = 0; i < kNumSlots; i++)
            {
                Domino d = GamePlayManager.Instance.GetNextDomino();
                d.EnableGraphics(mBoard.Controller.Size);
                bag.AddDomino(d);
            }
            mBags.Add(bag);
        }

        {
            Bag bag = new Bag(kNumSlots, mBoard.Controller.Size, false);

            for (int i = 0; i < kNumSlots; i++)
            {
                Domino d = GamePlayManager.Instance.GetNextDomino();

                d.EnableGraphics(mBoard.Controller.Size);
                d.UpdateDominoLocation(mBoard.Controller.Size);
                bag.AddDomino(d);
            }
            mBags.Add(bag);
        }

        ActiveDomino = GamePlayManager.Instance.GetNextDomino().GetComponent <Domino>();
        if (mActiveDomino != null)
        {
            mActiveDomino.MakeActive();
        }
        mDominos.Add(ActiveDomino);
        ActiveDomino.EnableGraphics(mBoard.Controller.Size);
        ActiveDomino.SetHighlight(HighLightMode.Active);
    }
Esempio n. 2
0
    void HandleDown(Vector2 mousePoint)
    {
        HideHintIfVisible();
        // For debug. Remove.
        //if (mousePoint.x > 300 && mousePoint.y > 200) {
        //	PlaceAnyDomino();
        //	return;
        //}

        // Clicked inside board and there is an active domino.
        if (mBoard.Contains(mousePoint) && (ActiveDomino != null))
        {
            Debug.Log("Inside Board Limits and Active Domino - begin dragging");
            if (ActiveDomino.Contains(mousePoint))
            {
                Debug.Log("Board contains mouse point");
//                mIsDragging = true;
            }
        }
        else if (ActiveDomino == null && GamePlayManager.Instance.Player1Playing && mBags[0].Contains(mousePoint))
        {
            Debug.Log("Inside Bag Limits and Active Domino - begin dragging");
            ActiveDomino = mBags[0].GetSelection(mousePoint);

            mBags[0].RemoveDomino(ActiveDomino);
            mDominos.Add(ActiveDomino);
//            mIsDragging = true;
            ActiveDomino.SetHighlight(HighLightMode.Active);
        }
        else if (ActiveDomino == null && (!GamePlayManager.Instance.Player1Playing) && mBags[1].Contains(mousePoint))
        {
            Debug.Log("Inside Bag Limits and Active Domino - begin dragging");
            ActiveDomino = mBags[1].GetSelection(mousePoint);
            mBags[1].RemoveDomino(ActiveDomino);
            mDominos.Add(ActiveDomino);
//            mIsDragging = true;
            ActiveDomino.SetHighlight(HighLightMode.Active);
        }
    }