// ------------------- 棋子操作 ------------------------ // 落子 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 MoveInDir(int dir) { /* * if (_TgtObj == null) { * return; * } * * HexCoord hc = GetComponent<HexCoord> (); * Transform tf = hc._Neighbors[dir]; * if (tf == null) { * return; * } * * CellObjCtrl nxtCellObjCtrl = * tf.gameObject.GetComponent<CellObjCtrl> (); * if (nxtCellObjCtrl._TgtObj != null || * nxtCellObjCtrl._bBlocked) { * return; * }*/ bool bCanMove = CanMove(_Dir); if (!bCanMove) { return; } CellObjCtrl nxtCellObjCtrl = CellObjCtrlUtils.GetNbCellObjCtrl(this, 0); LerpMoveTo lerpMoveTo = _TgtObj.GetComponent <LerpMoveTo> (); if (lerpMoveTo == null) { lerpMoveTo = _TgtObj.AddComponent <LerpMoveTo> (); } lerpMoveTo.enabled = true; Transform tf = nxtCellObjCtrl.transform; lerpMoveTo._TgtTF = tf; nxtCellObjCtrl.SetTargetObj(_TgtObj); _TgtObj = null; nxtCellObjCtrl.SetDir(_Dir); nxtCellObjCtrl.PointToCurrentDir(); InvokeTgtObjChanged(); }
public bool TeleportTo(CellObjCtrl otherCtrl, int dir = -1) { if (otherCtrl == null || otherCtrl == this || otherCtrl._TgtObj != null) { return(false); } LerpMoveTo lerpMoveTo = _TgtObj.GetComponent <LerpMoveTo> (); if (lerpMoveTo == null) { lerpMoveTo = _TgtObj.AddComponent <LerpMoveTo> (); } lerpMoveTo.enabled = true; Transform tf = otherCtrl.transform; lerpMoveTo._TgtTF = tf; otherCtrl.SetTargetObj(_TgtObj); _TgtObj = null; if (dir < 0) { otherCtrl.SetDir(_Dir); } else { otherCtrl.SetDir(dir); } otherCtrl.PointToCurrentDir(); InvokeTgtObjChanged(); return(true); }