/// <summary> /// 神兽设置到该格子坐标上 /// </summary> /// <param name="unBeastId"></param> /// <param name="oPos"></param> /// <returns></returns> public bool RoleSetToInitialPos(long unBeastId, CVector3 oPos) { if (!this.m_oMapData.HasMapNode(oPos.m_nX, oPos.m_nY)) { this.logger.Error(string.Format("HasMapNode(oPos) == false:{0}", oPos.ToString())); } if (this.m_oMapData.GetMapNode(oPos.m_nX, oPos.m_nY) == null) { return(false); } //判断这个格子上是否已经有神兽了 if (this.IsPosStandByAnyRole(oPos)) { this.logger.Error(string.Format("IsPosStandByAnyRole(oPos):{0}", oPos.ToString())); return(false); } //如果神兽格子上不存在改神兽,就吧该神兽加到该字典 if (!this.m_oDicRolesPos.ContainsKey(unBeastId)) { this.m_oDicRolesPos.Add(unBeastId, new CVector3(oPos)); this.m_oTablePathNodes[oPos.m_nX][oPos.m_nY].m_bCanWalk = false; this.m_oTablePathNodes[oPos.m_nX][oPos.m_nY].m_BeastID = unBeastId; return(true); } this.logger.Error(string.Format("m_oDicRolesPos.ContainsnIndexX(unHeroId) == false:{0}", unBeastId)); return(false); }
/// <summary> /// 发送神兽请求移动到某个位置 /// </summary> /// <param name="vecTargetPos"></param> public void SendBeastMoveReq(CVector3 vecTargetPos) { CPtcC2MReq_Move msg = new CPtcC2MReq_Move(); msg.beastId = Singleton <BeastRole> .singleton.Id; msg.desPos = vecTargetPos; this.SendMsg(msg); this.m_log.Debug("SendMoveReq:" + vecTargetPos.ToString()); }
public void GetAdjacentNodes(CVector3 oSrc, ref List <CVector3> oFindedNodes) { if (!this.m_oTablePathNodes.ContainsKey(oSrc.m_nX) || !this.m_oTablePathNodes[oSrc.m_nX].ContainsKey(oSrc.m_nY)) { this.logger.Fatal(string.Format("GetAdjacentNodes:oSrc({0}) is not exist:", oSrc.ToString())); return; } PathNode mapNode = this.m_oTablePathNodes[oSrc.m_nX][oSrc.m_nY]; for (int i = 0; i < 6; i++) { PathNode nearNode = mapNode.m_listNextNode[i]; if (nearNode != null && nearNode.m_bCanWalk) { CVector3 cVector = new CVector3(); cVector.m_nX = nearNode.nIndexX; cVector.m_nY = nearNode.nIndexY; cVector.m_nU = nearNode.nIndexU; if (!oFindedNodes.Contains(cVector)) { oFindedNodes.Add(cVector); } } } }