// ------------------- 棋子操作 ------------------------ // 落子 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); }
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!"); }
private void Sow() { _NewConfirmCtrl = null; if (_bControlDragRotator) { TurnDragRotatorForCellObjCtrl(_cctrl, true); } _mgr.SpawnAtCellCtrl(_cctrl); _Sow.Invoke(_cctrl); }
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; } } }