public LinearRectangleZone(double left, double top, double right, double bottom, ZonePosition startPosition, ZoneDirection direction) : base(left, top, right, bottom) { m_startPosition = startPosition; m_direction = direction; m_stepX = 1; m_stepY = 1; Init(); }
public LinearRectangleZone(double left, double top, double right, double bottom) : base(left, top, right, bottom) { m_startPosition = ZonePosition.TopLeft; m_direction = ZoneDirection.Horizontal; m_stepX = 1; m_stepY = 1; Init(); }
/// <summary> /// The constructor creates a LinearRectangleZone zone. /// </summary> /// <param name="left">The left coordinate of the rectangle defining the region of the zone.</param> /// <param name="top">The top coordinate of the rectangle defining the region of the zone.</param> /// <param name="right">The right coordinate of the rectangle defining the region of the zone.</param> /// <param name="bottom">The bottom coordinate of the rectangle defining the region of the zone.</param> /// <param name="start">The position in the zone to start getting locations - may be any corner /// of the rectangle.</param> /// <param name="direction">The direction to advance first. If ZoneDirection.Horizontal, the locations /// advance horizontally across the zone, moving vertically when wrapping around at the end. If /// ZoneDirection.Vertical, the locations advance vertically up/down the zone, moving horizontally /// when wrapping around at the top/bottom.</param> /// <param name="horizontalStep"></param> /// <param name="verticalStep"></param> public LinearRectangleZone(double left, double top, double right, double bottom, ZonePosition start, ZoneDirection direction, double horizontalStep, double verticalStep) : base(left, top, right, bottom) { m_startPosition = start; m_direction = direction; m_stepX = Math.Abs(horizontalStep); m_stepY = Math.Abs(verticalStep); Init(); }
void MoveZone() { switch (zonePosition) { case ZonePosition.Centre: if (Random.Range(0, 2) == 0) { zone.transform.position = zoneFront.position; // Move the zone to front zonePosition = ZonePosition.Front; } else { zone.transform.position = zoneBack.position; // Move the zone to back zonePosition = ZonePosition.Back; } break; case ZonePosition.Front: if (Random.Range(0, 2) == 0) { zone.transform.position = zoneCentre.position; // Move the zone to centre zonePosition = ZonePosition.Centre; } else { zone.transform.position = zoneBack.position; // Move the zone to back zonePosition = ZonePosition.Back; } break; case ZonePosition.Back: if (Random.Range(0, 2) == 0) { zone.transform.position = zoneFront.position; // Move the zone to front zonePosition = ZonePosition.Front; } else { zone.transform.position = zoneCentre.position; // Move the zone to centre zonePosition = ZonePosition.Centre; } break; default: break; } //if (zonePostitions.Count == 0) // If we have no positions don't move // return; //if (zonePostitions.Count == 1) // If we have 1 position don't move // return; //int newZonePosIndex = Random.Range(0, zonePostitions.Count); //// Make sure we chose a new position //while(newZonePosIndex == currentZonePosIndex) //{ // newZonePosIndex = Random.Range(0, zonePostitions.Count); // Debug.Log(newZonePosIndex); //} //currentZonePosIndex = newZonePosIndex; // Set the current index //zone.transform.position = zonePostitions[currentZonePosIndex].position; // Move the zone to that position }
protected virtual async Task <ZoneInfo> LookingForPublicZone(string publicmapUUID, int publicmapID, ZonePosition pos, RoleEnterZoneRequest req) { //没有统一返回上一次的公共场景. req.roleScenePos = pos; ZoneInfo zone = GetZone(publicmapUUID); if (zone != null && !zone.close) { if (zone.currentRoleCount < zone.map_data.max_players) { return(zone); } } //找当前存在的公共场景. var temp = RPGServerTemplateManager.Instance.GetMapTemplate(publicmapID); if (temp == null) { temp = RPGServerTemplateManager.Instance.GetDefaultMapData(req); req.lastPublicPos = new ZonePosition(); } zone = LookingForExpectServerGroupZone(req.servergroupID, z => { return(z.currentRoleCount < temp.full_players && z.map_data.zone_template_id == temp.id); }, (a, b) => { if (req.roleSessionNode == a.nodeName) { return(-1); } if (req.roleSessionNode == b.nodeName) { return(1); } return(0); }); if (zone != null && !zone.close) { return(zone); } //创建一个公共场景. var rsp = await this.CreateZone(new CreateZoneNodeRequest() { serverGroupID = req.servergroupID, serverID = req.serverID, mapTemplateID = temp.id, reason = "LookingForAreaRequest dispatch", expandData = RPGServerTemplateManager.Instance.GetCreateZoneExpandData(req), roomKey = req.roomKey, expectAreaNode = req.roleSessionNode, }); if (Response.CheckSuccess(rsp)) { return(GetZone(rsp.zoneUUID)); } else { return(null); } }