/// <summary> /// CreateFile2 wrapper. Only available on Windows 8 and above. /// </summary> public static SafeFileHandle CreateFile2( string path, DesiredAccess desiredAccess, ShareMode shareMode, CreationDisposition creationDisposition, FileAttributes fileAttributes = FileAttributes.NONE, FileFlags fileFlags = FileFlags.NONE, SecurityQosFlags securityQosFlags = SecurityQosFlags.NONE) { CREATEFILE2_EXTENDED_PARAMETERS extended = new CREATEFILE2_EXTENDED_PARAMETERS(); extended.dwSize = (uint)Marshal.SizeOf <CREATEFILE2_EXTENDED_PARAMETERS>(); extended.dwFileAttributes = fileAttributes; extended.dwFileFlags = fileFlags; extended.dwSecurityQosFlags = securityQosFlags; unsafe { extended.lpSecurityAttributes = null; } extended.hTemplateFile = IntPtr.Zero; SafeFileHandle handle = Direct.CreateFile2( lpFileName: path, dwDesiredAccess: desiredAccess, dwShareMode: shareMode, dwCreationDisposition: creationDisposition, pCreateExParams: ref extended); if (handle.IsInvalid) { throw ErrorHelper.GetIoExceptionForLastError(); } return(handle); }
/// <summary> /// Checks if the given privilege is enabled. This does not tell you whether or not it /// is possible to get a privilege- most held privileges are not enabled by default. /// </summary> public static bool IsPrivilegeEnabled(SafeTokenHandle token, Privileges privilege) { LUID luid = LookupPrivilegeValue(privilege.ToString()); var luidAttributes = new LUID_AND_ATTRIBUTES { Luid = luid, Attributes = (uint)PrivilegeAttributes.SE_PRIVILEGE_ENABLED }; var set = new PRIVILEGE_SET { Control = PRIVILEGE_SET_ALL_NECESSARY, PrivilegeCount = 1, Privilege = new[] { luidAttributes } }; bool result; if (!Direct.PrivilegeCheck(token, ref set, out result)) { throw ErrorHelper.GetIoExceptionForLastError(privilege.ToString()); } return(result); }
public void should_return_false_given_hasnot_empty_box() { Cabinet cabinet = new Cabinet(0); var directInstance = new Direct(cabinet); Assert.IsFalse(directInstance.HasEmptyBox()); }
/// <summary> /// Free the specified memory on the given heap. /// </summary> /// <param name="heap">If IntPtr.Zero will use the process heap.</param> public static bool HeapFree(IntPtr memory, IntPtr heap) { return(Direct.HeapFree( hHeap: heap == IntPtr.Zero ? ProcessHeap : heap, dwFlags: 0, lpMem: memory)); }
protected override void WriteData(ESPWriter writer) { Direct.WriteBinary(writer); IndirectWorld.WriteBinary(writer); writer.Write(IndirectGridY); writer.Write(IndirectGridX); }
public static void CloseHandle(IntPtr handle) { if (!Direct.CloseHandle(handle)) { throw ErrorHelper.GetIoExceptionForLastError(); } }
public void should_return_true_given_has_empty_box() { Cabinet cabinet = new Cabinet(50); var directInstance = new Direct(cabinet); Assert.IsTrue(directInstance.HasEmptyBox()); }
public static void UnregisterClass(Atom atom, ModuleHandle module) { if (!Direct.UnregisterClass(atom, module)) { throw ErrorHelper.GetIoExceptionForLastError(); } }
public virtual void Move(Direct dir) { if (dir == Direct.Down) { this._CC.Move(new Vector3(0, 0, -_Attribute.MoveSpeed * Time.deltaTime)); } else if (dir == Direct.Up) { this._CC.Move(new Vector3(0, 0, _Attribute.MoveSpeed * Time.deltaTime)); } else if (dir == Direct.Right) { this._CC.Move(new Vector3(_Attribute.MoveSpeed * Time.deltaTime, 0, 0)); this.FaceType = FaceType.Right; } else if (dir == Direct.Left) { this._CC.Move(new Vector3(-_Attribute.MoveSpeed * Time.deltaTime, 0, 0)); this.FaceType = FaceType.Left; } else if (dir == Direct.Jump) { Timer = 0; _JumpSpeed = Main.Instance.JumpSpeed; } else if (dir == Direct.Attack) { this.Attack(); } }
private static void IsFileInfo(ref Proto proto, ref Direct direct, string str) { MatchCollection fileInfo = RegexpsCollection.ForAll[Regexps.FileInfo].Matches(str); foreach (Match m in fileInfo) { String sProto = m.Groups[RegexpsCollection.Groups.FileInfoProto.ToString()].Value; String sDirect = m.Groups[RegexpsCollection.Groups.FileInfoDirect.ToString()].Value; switch (sProto) { case nameof(Proto.SMTP): proto = Proto.SMTP; if (sDirect == " (in)") { direct = Direct.input; } else if (sDirect == " (out)") { direct = Direct.output; } break; case nameof(Proto.IMAP): proto = Proto.IMAP; break; case nameof(Proto.POP): proto = Proto.POP; break; } } }
public static string GetNextNumber(Direct dir) { if (dir.Cell == ".") { return("1"); } if (dir.Cell == "C") { return("1"); } if (dir.Cell == "T") { return("0"); } int number = 0; if (Int32.TryParse(dir.Cell, out number)) { number++; return(number.ToString()); } else { Console.Error.WriteLine(" I DONT KNOW WHAT DO I HAVE TO WRITE"); return("%"); } }
/// <summary> /// Free the given library. /// </summary> public static void FreeLibrary(IntPtr handle) { if (!Direct.FreeLibrary(handle)) { throw ErrorHelper.GetIoExceptionForLastError(); } }
/// <summary> /// Delete the given file. /// </summary> public static void DeleteFile(string path) { if (!Direct.DeleteFileW(path)) { throw ErrorHelper.GetIoExceptionForLastError(path); } }
public VkObjectResult <VkSurfaceCapabilitiesKHR> GetSurfaceCapabilitiesKHR(IVkSurfaceKHR surface) { VkSurfaceCapabilitiesKHR capabilities; var result = Direct.GetPhysicalDeviceSurfaceCapabilitiesKHR(Handle, surface.Handle, &capabilities); return(new VkObjectResult <VkSurfaceCapabilitiesKHR>(result, capabilities)); }
public VkObjectResult <IReadOnlyList <IVkExtensionProperties> > EnumerateDeviceExtensionProperties(string layerName) { var unmanagedSize = layerName.SizeOfMarshalIndirect(); var unmanagedArray = new byte[unmanagedSize]; fixed(byte *unmanagedStart = unmanagedArray) { var unmanaged = unmanagedStart; var pLayerName = layerName.MarshalIndirect(ref unmanaged); int propertyCount; var result = Direct.EnumerateDeviceExtensionProperties(Handle, pLayerName, &propertyCount, null); if (result != VkResult.Success) { return(new VkObjectResult <IReadOnlyList <IVkExtensionProperties> >(result, null)); } var rawArray = new VkExtensionProperties.Raw[propertyCount]; fixed(VkExtensionProperties.Raw *pRawArray = rawArray) result = Direct.EnumerateDeviceExtensionProperties(Handle, pLayerName, &propertyCount, pRawArray); if (result != VkResult.Success) { return(new VkObjectResult <IReadOnlyList <IVkExtensionProperties> >(result, null)); } var properties = rawArray.Select(x => new VkExtensionProperties(&x)).ToArray(); return(new VkObjectResult <IReadOnlyList <IVkExtensionProperties> >(result, properties)); } }
private VkDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR(IVkDisplayModeKHR mode, int planeIndex) { VkDisplayPlaneCapabilitiesKHR result; Direct.GetDisplayPlaneCapabilitiesKHR(Handle, mode.Handle, planeIndex, &result); return(result); }
public void FaceRight() { UpBody.transform.localScale = new Vector3(1f, 1f, 1f); HeadSprite.sprite = characterAttributes.RightHead; BodySprite.sprite = characterAttributes.RightBody; direct = Direct.FaceRight; }
static void AddPointToStartFrom(double startDirectionChangeChance) { maxLength--; if (maxLength <= 0) { return; } var chosenDirection = currentDirection; List <Direct.Direction> directionPossibilities = null; if (MathHelper.RandomChance(chanceToVaryFromDirection)) { directionPossibilities = Direct.FullNeighborsOfWithout(currentDirection); chosenDirection = ListHelper.RandomElementInList(directionPossibilities); } last = PointHelper.PointInDirection(last, chosenDirection); foreach (var p in PointHelper.PointsInDistanceAround(last, 4)) { Map.AddWaterAt(p); } if (MathHelper.RandomChance(startDirectionChangeChance)) { directionPossibilities = Direct.FullNeighborsOfWithout(currentDirection); currentDirection = ListHelper.RandomElementInList(directionPossibilities); startDirectionChangeChance = changeDirectionModifier * -1 * 15; } startDirectionChangeChance += changeDirectionModifier; AddPointToStartFrom(startDirectionChangeChance); }
private void DisposeInternal(IntPtr data) { var unmanaged = (byte *)data; var pAllocator = Allocator.MarshalIndirect(ref unmanaged); Direct.DestroyInstance(Handle, pAllocator); }
public static IEnumerable <string> EnumerateLocalGroups(string server = null) { var groups = new List <string>(); SafeNetApiBufferHandle buffer; uint entriesRead; uint totalEntries; WindowsError result = Direct.NetLocalGroupEnum( servername: server, level: 0, bufptr: out buffer, prefmaxlen: Direct.MAX_PREFERRED_LENGTH, entriesread: out entriesRead, totalentries: out totalEntries, resumehandle: IntPtr.Zero); if (result != WindowsError.NERR_Success) { throw ErrorHelper.GetIoExceptionForError(result, server); } foreach (IntPtr pointer in ReadStructsFromBuffer <IntPtr>(buffer, entriesRead)) { groups.Add(Marshal.PtrToStringUni(pointer)); } return(groups); }
/// <summary> /// Set the given mailslot's read timeout. /// </summary> /// <param name="readTimeout">Timeout for read operations in milliseconds. Set to uint.MaxValue for infinite timeout.</param> public static void SetMailslotTimeout(SafeMailslotHandle mailslotHandle, uint readTimeout) { if (!Direct.SetMailslotInfo(mailslotHandle, readTimeout)) { throw ErrorHelper.GetIoExceptionForLastError(); } }
public static IEnumerable <MemberInfo> EnumerateGroupUsers(string groupName, string server = null) { var members = new List <MemberInfo>(); SafeNetApiBufferHandle buffer; uint entriesRead; uint totalEntries; WindowsError result = Direct.NetLocalGroupGetMembers( servername: server, localgroupname: groupName, level: 1, bufptr: out buffer, prefmaxlen: Direct.MAX_PREFERRED_LENGTH, entriesread: out entriesRead, totalentries: out totalEntries, resumehandle: IntPtr.Zero); if (result != WindowsError.NERR_Success) { throw ErrorHelper.GetIoExceptionForError(result, server); } foreach (Direct.LOCALGROUP_MEMBERS_INFO_1 info in ReadStructsFromBuffer <Direct.LOCALGROUP_MEMBERS_INFO_1>(buffer, entriesRead)) { members.Add(new MemberInfo { Name = Marshal.PtrToStringUni(info.lgrmi1_name), AccountType = (SID_NAME_USE)info.lgrmi1_sidusage }); } return(members); }
/// <summary> /// Opens a thread token. /// </summary> public static SafeTokenHandle OpenThreadToken(TokenRights desiredAccess, bool openAsSelf) { SafeTokenHandle threadToken; if (!Direct.OpenThreadToken(ThreadMethods.Direct.GetCurrentThread(), desiredAccess, openAsSelf, out threadToken)) { WindowsError error = ErrorHelper.GetLastError(); if (error != WindowsError.ERROR_NO_TOKEN) { throw ErrorHelper.GetIoExceptionForError(error, desiredAccess.ToString()); } SafeTokenHandle processToken = OpenProcessToken(TokenRights.TOKEN_DUPLICATE); if (!Direct.DuplicateTokenEx( processToken, TokenRights.TOKEN_IMPERSONATE | TokenRights.TOKEN_QUERY | TokenRights.TOKEN_ADJUST_PRIVILEGES, IntPtr.Zero, SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation, TOKEN_TYPE.TokenImpersonation, ref threadToken)) { throw ErrorHelper.GetIoExceptionForLastError(desiredAccess.ToString()); } } return(threadToken); }
public static void UpdateCamera(float screenPercent, GameObject go, Direct direct) { if (go != null) { Selection.activeGameObject = go; Bounds b = BuildBounds(go); float height = b.extents.y; float h_fov = camera.fieldOfView / 2; float tan_v = Mathf.Tan(h_fov / Mathf.Rad2Deg); float dist = height / (tan_v * screenPercent); Vector3 dir = go.transform.forward; if (direct == Direct.Back) { dir = new Vector3(-dir.x, dir.y, -dir.z); } else if (direct == Direct.Right) { dir = go.transform.right; } else if (direct == Direct.Left) { dir = go.transform.right; dir = new Vector3(-dir.x, dir.y, -dir.z); } Vector3 camera_pos = b.center + dir.normalized * dist; camera.transform.position = camera_pos; camera.transform.LookAt(b.center); } }
/// <summary> /// Flush file buffers. /// </summary> public static void FlushFileBuffers(SafeFileHandle fileHandle) { if (!Direct.FlushFileBuffers(fileHandle)) { throw ErrorHelper.GetIoExceptionForLastError(); } }
/// <summary> /// Gets the formats that are currently available on the clipboard. /// </summary> public unsafe static uint[] GetAvailableClipboardFormats() { uint countOut; uint countIn = 5; uint *array; realloc: { uint *alloc = stackalloc uint[(int)countIn]; array = alloc; if (!Direct.GetUpdatedClipboardFormats(array, countIn, &countOut)) { WindowsError error = ErrorHelper.GetLastError(); switch (error) { case WindowsError.ERROR_INSUFFICIENT_BUFFER: countIn = countOut; goto realloc; default: throw ErrorHelper.GetIoExceptionForError(error); } } } uint[] result = new uint[countOut]; BufferHelper.CopyUintArray(array, result); return(result); }
/// <summary> /// GetEnvironmentStrings split into key value pairs. /// </summary> public static IDictionary <string, string> GetEnvironmentVariables() { var variables = new Dictionary <string, string>(); using (var buffer = Direct.GetEnvironmentStringsW()) { if (buffer.IsInvalid) { return(variables); } foreach (var entry in BufferHelper.SplitNullTerminatedStringList(buffer.DangerousGetHandle())) { // Hidden environment variables start with an equals int separator = entry.IndexOf('=', startIndex: 1); if (separator == -1) { throw new InvalidOperationException("There should never be a string given back from Windows without an equals sign"); } string key = entry.Substring(startIndex: 0, length: separator); string value = entry.Substring(startIndex: separator + 1); variables.Add(key, value); } } return(variables); }
/// <summary> /// This only works for types that aren't built in (e.g. defined in ClipboardFormat). /// </summary> /// <exception cref="ArgumentException">Thrown if passing in a built-in format type.</exception> public static string GetClipboardFormatName(uint format) { return(BufferHelper.CachedInvoke((StringBuffer buffer) => { realloc: int count = Direct.GetClipboardFormatNameW(format, buffer, (int)buffer.CharCapacity); if (count == 0) { WindowsError error = ErrorHelper.GetLastError(); switch (error) { case WindowsError.ERROR_INSUFFICIENT_BUFFER: buffer.EnsureCharCapacity(buffer.CharCapacity + 50); goto realloc; default: throw ErrorHelper.GetIoExceptionForError(error); } } buffer.Length = (uint)count; return buffer.ToString(); })); }
public ValidationResult Validate(OutlookContext context, int id, string email) { Addresses.Clear(); if (CC.Length == 0 && BCC.Length == 0 && Direct.Length == 0) { return(new ValidationResult("Error: No addresses provided!")); } string[] CCs = CC.Split(';'); string[] BCCs = BCC.Split(';'); string[] Directs = Direct.Split(';'); (bool dis1, ValidationResult v1) = CheckExistence(context, id, email, Directs, "Error in direct", 0); if (v1 != ValidationResult.Success) { return(v1); } (bool dis2, ValidationResult v2) = CheckExistence(context, id, email, CCs, "Error in CCs", 1); if (v2 != ValidationResult.Success) { return(v2); } (bool dis3, ValidationResult v3) = CheckExistence(context, id, email, BCCs, "Error in BCCs", 2); if (v3 != ValidationResult.Success) { return(v3); } return(ValidationResult.Success); }
public void FaceRight() { UpBody.transform.localScale=new Vector3(1f,1f,1f); HeadSprite.sprite = characterAttributes.RightHead; BodySprite.sprite = characterAttributes.RightBody; direct=Direct.FaceRight; }
public MoveCommand(Transform player, Leg leg, Direct @operator, int operand) { this._player = player; this._leg = leg; this._operand = operand; this._operator = @operator; }
/// <summary> /// Allocate memory on the given heap. /// </summary> /// <param name="heap">If IntPtr.Zero will use the process heap.</param> /// <exception cref="OverflowException">Thrown if running in 32 bit and byteLength is greater than uint.MaxValue.</exception> public static IntPtr HeapAllocate(ulong byteLength, bool zeroMemory, IntPtr heap) { return(Direct.HeapAlloc( hHeap: heap == IntPtr.Zero ? ProcessHeap : heap, dwFlags: zeroMemory ? Direct.HEAP_ZERO_MEMORY : 0, dwBytes: (UIntPtr)byteLength)); }
/// <summary> /// Sets the file attributes for the given path. /// </summary> public static void SetFileAttributes(string path, FileAttributes attributes) { if (!Direct.SetFileAttributesW(path, attributes)) { throw ErrorHelper.GetIoExceptionForLastError(path); } }
public void should_return_ticket_given_empty_cabinet_when_store() { Bag aBag = new Bag(); Cabinet cabinet = new Cabinet(50); Ticket ticket = new Direct(cabinet).Store(aBag); Assert.IsNotNull(ticket); }
public void should_not_return_bag_given_used_ticket_when_pick() { Bag aBag = new Bag(); Cabinet cabinet = new Cabinet(50); var directInstance = new Direct(cabinet); Ticket ticket = directInstance.Store(aBag); directInstance.Pick(ticket); Assert.IsNull(directInstance.Pick(ticket)); }
public void should_return_bag_given_valid_ticket_when_pick() { Bag aBag = new Bag(); Bag anotherBag = new Bag(); Cabinet cabinet = new Cabinet(50); var directInstance = new Direct(cabinet); Ticket ticket = directInstance.Store(aBag); var resultTicket = directInstance.Pick(ticket); Assert.AreEqual(aBag, resultTicket); Assert.AreNotEqual(anotherBag, resultTicket); }
public Cabinet(int capacity) { _capacity = capacity; direct = new Direct(this); }
public void should_return_null_when_pick_given_cabinet_stroed_ticket() { var robot = new Robot(); var cabinet1 = new Cabinet(2); var cabinet2 = new Cabinet(2); robot.Add(cabinet1); robot.Add(cabinet2); var bag1 = new Bag(); var bag2 = new Bag(); var bag3 = new Bag(); robot.Store(bag1); robot.Store(bag2); var ticket3 = new Direct(cabinet2).Store(bag3); Assert.IsNull(robot.Pick(ticket3)); }
public void Update() { if (_curDirect == Direct.Ready) { foreach (var s in goUp) if (s) { _curDirect = Direct.UpStairs; break; } foreach (var s in goDn) if (s) { _curDirect = Direct.DnStairs; break; } } else if (_curDirect == Direct.UpStairs) { if (goUp[_curFloor]) { if (_remainTime == 0) _remainTime = _parktime; } else { if (_remainTime == 0) _remainTime = _movetime; } if (--_remainTime == 0) // Timer { bool isDelayed = false; foreach (var s in _delayedUpTarget) // Search if delayed exists { if (s == _curFloor) { isDelayed = true; goUp[_curFloor] = true; // Set forcely. Here has not a loop or recursion _delayedUpTarget.Remove(s); break; } } if (!isDelayed) goUp[_curFloor] = false; // if exist, jump over if (_curFloor < _xHi) ++_curFloor; // Do not use '!=' or loop infinity else { _curDirect = Direct.DnStairs; if (_xHi == _xLo) _curDirect = Direct.Ready; } } } else // _curDirect == Direct.DnStairs { if (goDn[_curFloor]) { if (_remainTime == 0) _remainTime = _parktime; } else { if (_remainTime == 0) _remainTime = _movetime; } if (--_remainTime == 0) { bool isDelayed = false; foreach (var s in _delayedDnTarget) { if (s == _curFloor) { isDelayed = true; goDn[_curFloor] = true; _delayedDnTarget.Remove(s); break; } } if (!isDelayed) goDn[_curFloor] = false; if (_curFloor > _xLo) --_curFloor; else { _curDirect = Direct.UpStairs; if (_xHi == _xLo) _curDirect = Direct.Ready; } } } _updateHiLo(); }
protected void _mPlayerControl(Rigidbody2D _rbControlTarget)//玩家八方位移動 { if (_bUp() && !_bRight() && !_bLeft() && !_bDown()) { _enumDirect = Direct.Up; _rbControlTarget.transform.position += Vector3.up * _fMoveSpeed * Time.deltaTime; if (Input.GetKey(KeyCode.X)) { _rbControlTarget.transform.position += Vector3.up * _fMoveSpeed * Time.deltaTime; } } else if (_bUp() && _bRight() && !_bLeft() && !_bDown()) { _enumDirect = Direct.RightUp; _rbControlTarget.transform.position += Vector3.right * _fMoveSpeed * Time.deltaTime; _rbControlTarget.transform.position += Vector3.up * _fMoveSpeed * Time.deltaTime / 2; if (Input.GetKey(KeyCode.X)) { _rbControlTarget.transform.position += Vector3.right * _fMoveSpeed * Time.deltaTime; _rbControlTarget.transform.position += Vector3.up * _fMoveSpeed * Time.deltaTime / 2; } } else if (!_bUp() && _bRight() && !_bLeft() && !_bDown()) { _enumDirect = Direct.Right; _rbControlTarget.transform.position += Vector3.right * _fMoveSpeed * Time.deltaTime; if (Input.GetKey(KeyCode.X)) { _rbControlTarget.transform.position += Vector3.right * _fMoveSpeed * Time.deltaTime; } } else if (!_bUp() && _bRight() && !_bLeft() && _bDown()) { _enumDirect = Direct.RightDown; _rbControlTarget.transform.position += Vector3.right * _fMoveSpeed * Time.deltaTime; _rbControlTarget.transform.position += Vector3.down * _fMoveSpeed * Time.deltaTime / 2; if (Input.GetKey(KeyCode.X)) { _rbControlTarget.transform.position += Vector3.right * _fMoveSpeed * Time.deltaTime; _rbControlTarget.transform.position += Vector3.down * _fMoveSpeed * Time.deltaTime / 2; } } else if (!_bUp() && !_bRight() && !_bLeft() && _bDown()) { _enumDirect = Direct.Down; _rbControlTarget.transform.position += Vector3.down * _fMoveSpeed * Time.deltaTime; if (Input.GetKey(KeyCode.X)) { _rbControlTarget.transform.position += Vector3.down * _fMoveSpeed * Time.deltaTime; } } else if (!_bUp() && !_bRight() && _bLeft() && _bDown()) { _enumDirect = Direct.LeftDown; _rbControlTarget.transform.position += Vector3.left * _fMoveSpeed * Time.deltaTime; _rbControlTarget.transform.position += Vector3.down * _fMoveSpeed * Time.deltaTime / 2; if (Input.GetKey(KeyCode.X)) { _rbControlTarget.transform.position += Vector3.left * _fMoveSpeed * Time.deltaTime; _rbControlTarget.transform.position += Vector3.down * _fMoveSpeed * Time.deltaTime / 2; } } else if (!_bUp() && !_bRight() && _bLeft() && !_bDown()) { _enumDirect = Direct.Left; _rbControlTarget.transform.position += Vector3.left * _fMoveSpeed * Time.deltaTime; if (Input.GetKey(KeyCode.X)) { _rbControlTarget.transform.position += Vector3.left * _fMoveSpeed * Time.deltaTime; } } else if (_bUp() && !_bRight() && _bLeft() && !_bDown()) { _enumDirect = Direct.LeftUp; _rbControlTarget.transform.position += Vector3.left * _fMoveSpeed * Time.deltaTime; _rbControlTarget.transform.position += Vector3.up * _fMoveSpeed * Time.deltaTime / 2; if (Input.GetKey(KeyCode.X)) { _rbControlTarget.transform.position += Vector3.left * _fMoveSpeed * Time.deltaTime; _rbControlTarget.transform.position += Vector3.up * _fMoveSpeed * Time.deltaTime / 2; } } else { _enumPlayerState = PlayerState.Idle; } }
// движения ограниченное границами public void Move(Direct direct) { switch (direct) { case Direct.left: if (px - speed >= 0) px -= speed; else px = 0; break; case Direct.rigt: if (px + speed + sx <= 1000) px += speed; else px = 1000 - sx; break; case Direct.up: if (py - speed >= 0) py -= speed; else py = 0; break; case Direct.down: if (py + speed + sy <= 500) py += speed; else py = 500 - sy; break; case Direct.upleft: if (px - speedd >= 0) px -= speedd; else px = 0; if (py - speedd >= 0) py -= speedd; else py = 0; break; case Direct.uprigt: if (px + speedd + sx <= 1000) px += speedd; else px = 1000 - sx; if (py - speedd >= 0) py -= speedd; else py = 0; break; case Direct.downleft: if (px - speedd >= 0) px -= speedd; else px = 0; if (py + speedd + sy <= 500) py += speedd; else py = 500 - sy; break; case Direct.downrigt: if (px + speedd + sx <= 1000) px += speedd; else px = 1000 - sx; if (py + speedd + sy <= 500) py += speedd; else py = 500 - sy; break; } }
// Движение не ограниченное public void Move1(Direct direct) { switch (direct) { case Direct.left: px -= speed; break; case Direct.rigt: px += speed; break; case Direct.up: py -= speed; break; case Direct.down: py += speed; break; case Direct.upleft: px -= speedd; py -= speedd; break; case Direct.uprigt: px += speedd; py -= speedd; break; case Direct.downleft: px -= speedd; py += speedd; break; case Direct.downrigt: px += speedd; py += speedd; break; } }
//搜索邻近的泡泡(x=行号,y=列号) Slot FindSideBubble(Vector2 seat, Direct dir, bool even) { Vector2 nextSeat = Vector2.zero; if (even) {//偶数行 switch (dir) { case Direct.Left: nextSeat = new Vector2(seat.x, seat.y - 1); break; case Direct.Right: nextSeat = new Vector2(seat.x, seat.y + 1); break; case Direct.LeftUp: nextSeat = new Vector2(seat.x - 1, seat.y - 1); break; case Direct.LeftDown: nextSeat = new Vector2(seat.x + 1, seat.y - 1); break; case Direct.RightUp: nextSeat = new Vector2(seat.x - 1, seat.y); break; case Direct.RightDown: nextSeat = new Vector2(seat.x + 1, seat.y); break; } } else {//奇数行 switch (dir) { case Direct.Left: nextSeat = new Vector2(seat.x, seat.y - 1); break; case Direct.Right: nextSeat = new Vector2(seat.x, seat.y + 1); break; case Direct.LeftUp: nextSeat = new Vector2(seat.x - 1, seat.y); break; case Direct.LeftDown: nextSeat = new Vector2(seat.x + 1, seat.y); break; case Direct.RightUp: nextSeat = new Vector2(seat.x - 1, seat.y + 1); break; case Direct.RightDown: nextSeat = new Vector2(seat.x + 1, seat.y + 1); break; } } return FindBubble(nextSeat); }
private void DajBrojeve(Direct S, ref int a, ref int b) { if (S == Direct.Lijevo) { a = -SIZE; b = 0; } else if (S == Direct.Gore) { a = 0; b = -SIZE; } else if (S == Direct.Desno) { a = SIZE; b = 0; } else if (S == Direct.Dolje) { a = 0; b = SIZE; } }
public void UpravljajZmijom2(Direct Smjer) { DajBrojeve (Smjer, ref X2, ref Y2); }
public void UpravljajZmijom1(Direct Smjer) { DajBrojeve (Smjer, ref X1, ref Y1); }