/// <summary> /// OnSourceLost /// </summary> public void OnSourceLost(SourceStateEventData eventData) { RemoveSourceIdFromHandMap(eventData.SourceId); UpdateStateMachine(); eventData.Use(); //移动棋子 QiziScript qiziScrip = HostTransform.GetComponent <QiziScript>(); PointData start = new PointData(qiziScrip.x, qiziScrip.y, qiziScrip.z); ChessManager.GetInstant().CheckAndMove(start, HostTransform.position); }
//移动棋子 public void MoveQizi(MoveData move) { GameObject game = QiziMap.GetGameObject(move.start.x.ToString() + move.start.y.ToString()); if (game == null) { return; } QiziScript qiziobj = game.GetComponent <QiziScript>(); float he = 0.0f; if (qiziobj.current == Constant.RED) { if (move.end.y < 5) { he = heffset; game.transform.localPosition = new Vector3((move.end.x - 4) * xoffset, yoffset, he + (4 - move.end.y) * zoffset); } else { game.transform.localPosition = new Vector3((move.end.x - 4) * xoffset, yoffset, he + (5 - move.end.y) * zoffset); } } else { if (move.end.y > 4) { he = heffset; game.transform.localPosition = new Vector3((move.end.x - 4) * xoffset, yoffset, -he + (5 - move.end.y) * zoffset); } else { game.transform.localPosition = new Vector3((move.end.x - 4) * xoffset, yoffset, he + (4 - move.end.y) * zoffset); } } QiziMap.ReplaceGameObject(move.start.x.ToString() + move.start.y.ToString(), move.end.x.ToString() + move.end.y.ToString(), game); qiziobj.x = move.end.x; qiziobj.y = move.end.y; qiziobj.z = move.end.z; }