Esempio n. 1
0
        // ------------------- 棋子操作 ------------------------
        // 落子
        public bool TryPlaceChessAt(int campId, int dir, Hex coord)
        {
            CellObjCtrl cctrl = _GridCtrl.GetCellCtrlAt(coord);

            if (cctrl == null)
            {
                return(false);
            }
            if (cctrl.IsBlocked())
            {
                return(false);
            }
            if (cctrl._TgtObj != null)
            {
                return(false);
            }

            cctrl.SetDir(dir);
            _MiroMgr.SetMiroPrefabID(campId);

            _MiroMgr.SpawnAtCellCtrl(cctrl);
            cctrl.SetDir(dir);
            cctrl.PointToCurrentDir();

            //int direction = cctrl.GetDir ();
            return(true);
        }
Esempio n. 2
0
        public void SpawnOne()
        {
            bool        bFind      = false;
            CellObjCtrl emptyCCtrl = null;
            int         count      = 0;

            List <CellObjCtrl> epCtrls =
                _gridCtrl.GetEmptyPlacableCellObjCtrls();

            if (epCtrls.Count == 0)
            {
                return;
            }
            int rid = (int)Random.Range(0, (float)(epCtrls.Count - 0.0001f));

            emptyCCtrl = epCtrls [rid];

            int dir = Mathf.FloorToInt(Random.Range(0.0f, 5.999999f));

            _mgr.SetMiroPrefabID(_campId);
            emptyCCtrl.SetDir(dir);
            _mgr.SpawnAtCellCtrl(emptyCCtrl);
            _Spawned.Invoke();
            print("Spawned!");
        }
Esempio n. 3
0
        private bool SetID(int id)
        {
            MiroV1PlacementMgr mgr = GetComponent <MiroV1PlacementMgr> ();
            int maxCnt             = mgr._MiroPrefabs.Count;

            if (id >= maxCnt)
            {
                return(false);
            }
            mgr.SetMiroPrefabID(id);

            return(true);
        }
Esempio n. 4
0
        public void SpawnOnePair()
        {
            bool bFindEmpty = false;
            int  tryCount   = 0;

            while (!bFindEmpty)
            {
                tryCount++;
                CellObjCtrl ctrlA, ctrlB;

                bFindEmpty = GetCellObjCtrlPair(out ctrlA, out ctrlB);

                if (!bFindEmpty)
                {
                    continue;
                }

                float dirAf = Mathf.Floor(Random.Range(0, 5.999999f));
                int   dirA  = (int)dirAf;
                float dirBf = dirAf + 3.0f;
                dirBf = Mathf.Repeat(dirBf, 6.0f);
                int dirB = (int)dirBf;

                _mgr.SetMiroPrefabID(_campId0);
                ctrlA.SetDir(dirA);
                _mgr.SpawnAtCellCtrl(ctrlA);

                _mgr.SetMiroPrefabID(_campId1);
                ctrlB.SetDir(dirB);
                _mgr.SpawnAtCellCtrl(ctrlB);

                if (tryCount > 200)
                {
                    break;
                }
            }
        }
 public void ChoosePrefab(float id)
 {
     _Mgr.SetMiroPrefabID((int)id);
     _TxtPrefabName.text = _Mgr.GetSelectedMiroPrefabCampName();
 }