Пример #1
0
    /// <summary>
    /// This tries to place a domino.  If not legal, a meassage is thrown up.
    /// </summary>
    /// <returns></returns>
    protected bool TryToPlaceDomino()
    {
        bool isLegal = GamePlayManager.Instance.IsLegalMove(ActiveDomino.Controller);

        Debug.Log("Legal move: " + isLegal.ToString());
        if (isLegal)
        {
            GamePlayManager.Instance.PlaceDomino(ActiveDomino.Controller);
            RaiseFXEventsAfterPlacedDomino(ActiveDomino);
            ActiveDomino.MakeInactive();
            ActiveDomino = null;
        }
        else
        {
            // TODO
//            mDisplayStatus.Alpha = 1;
//            mDisplayStatus.AlphaRate = -0.5f;
            InfoText = "Not a legal move.";
            GameEventManager.Instance.RaiseEvent(new GameEvent(
                                                     GameEvent.GameEventType.FAIL_PLACE,
                                                     ActiveDomino,
                                                     GamePlayManager.Instance.Player1Playing ? 0 : 1));
        }

        // then update this
        mTimeStamp = Time.time;
        return(isLegal);
    }
Пример #2
0
    void ComputerMove()
    {
        Debug.Log("Computer move");
        if (!GamePlayManager.Instance.FirstDominoSet)
        {
            Bag            ennemyBag = (GamePlayManager.Instance.Player1Playing) ? mBags[1] : mBags[0];
            List <IDomino> reducecomputerPlayingBag = new List <IDomino>();
            reducecomputerPlayingBag.Add(ActiveDomino);
            ActiveDomino = GamePlayManager.Instance.ComputersPlay(reducecomputerPlayingBag, ennemyBag.GetDominoes()) as Domino;
        }
        else
        {
            Bag ennemyBag          = (GamePlayManager.Instance.Player1Playing) ? mBags[1] : mBags[0];
            Bag computerPlayingBag = (GamePlayManager.Instance.Player1Playing) ? mBags[0] : mBags[1];
            ActiveDomino = GamePlayManager.Instance.ComputersPlay(computerPlayingBag.GetDominoes(), ennemyBag.GetDominoes()) as Domino;
            computerPlayingBag.RemoveDomino(ActiveDomino);
        }


        mTimeStamp = Time.time;

        // updates the graphical position of the domino
        ActiveDomino.UpdateDominoLocation(mBoard.Controller.Size);

        // transfer control of domino to screen
        mDominos.Add(ActiveDomino);

        RaiseFXEventsAfterPlacedDomino(ActiveDomino);
        ActiveDomino.MakeInactive();
        ActiveDomino = null;

        ActivateBagDominoes(GamePlayManager.Instance.Player1Computer ? 0 : 1);
    }
Пример #3
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);
    }
Пример #4
0
    public void Rotate()
    {
        if (mShowingModalDialog)
        {
            return;
        }

        Debug.Log("Rotate");
        if (ActiveDomino != null)
        {
            ActiveDomino.GetComponent <Domino>().MoveClockWise();
        }
    }
Пример #5
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);
        }
    }