void OnSceneClean(GameMessage msg) { FlagsHelper.Unset(ref currentState, GameState.started); FlagsHelper.Unset(ref currentState, GameState.ended); FlagsHelper.Unset(ref currentState, GameState.arenaAnimating); FlagsHelper.Unset(ref currentState, GameState.firstOut); }
public void RemoveStatus(BallStatus newStatus, Material toRemove) { FlagsHelper.Unset <BallStatus>(ref status, newStatus); if (toRemove != null && matQueue.Remove(toRemove)) { CheckStatus(); } }
public void RemoveStatus(BallStatus newStatus, Material toRemove) { FlagsHelper.Unset <BallStatus>(ref status, newStatus); if (toRemove != null && matQueue.Remove(toRemove)) { CheckStatus(); } AttachedBall.RemoveStatusAllAttachedBalls(transform, newStatus, toRemove); }
private void HandleLimbActivationChange(bool isActive, Limb limb) { if (isActive) { FlagsHelper.Set(ref active, limb); } else { FlagsHelper.Unset(ref active, limb); } }
/// <summary> /// Sets a bit flag to a file attribute. /// </summary> /// <param name="user"></param> /// <param name="attrib"></param> /// <param name="value"></param> public void SetWin32Attribute(FileAttributes attrib, bool value) { if (value) { Win32FileAttribute = (int)FlagsHelper.Set(((FileAttributes)Win32FileAttribute), attrib); } else { Win32FileAttribute = (int)FlagsHelper.Unset(((FileAttributes)Win32FileAttribute), attrib); } }
//Removes a Layer that this object could collide with public void RemoveFromCollisions(string layerName) { FlagsHelper.Unset(ref collisionLayerMask, 1 << LayerMask.NameToLayer(layerName)); FlagsHelper.Unset(ref collisionLayerMaskDown, 1 << LayerMask.NameToLayer(layerName)); //Handle Terrain and PassThroughBottom at the same time for ease of use if (layerName == "Terrain") { FlagsHelper.Unset(ref collisionLayerMaskDown, 1 << LayerMask.NameToLayer("PassThroughBottom")); } }
public void UpdateState(State state, bool value) { var states = State; if (value) { FlagsHelper.Set(ref states, state); } else { FlagsHelper.Unset(ref states, state); } State = states; }
/// <summary> /// Sets a bit flag to a file attribute. /// </summary> /// <param name="user"></param> /// <param name="attrib"></param> /// <param name="value"></param> public void SetWin32Attribute(Principal user, FileAttributes attrib, bool value) { using (var context = new OnlineFilesEntities()) if (!(context.FileSecurities.Where(d => d.fk_FileId == pk_FileId).ToList().Any(x => user.UserProfile.mySecurityGroups.Contains(x.SecurityObjectId) && x.canWrite))) { throw new SecurityException("Not Authorized."); } if (value) { Win32FileAttribute = (int)FlagsHelper.Set(((FileAttributes)Win32FileAttribute), attrib); } else { Win32FileAttribute = (int)FlagsHelper.Unset(((FileAttributes)Win32FileAttribute), attrib); } }
public void UpdateState(State state, bool value) { var states = State; if (value) { FlagsHelper.Set(ref states, state); } else { FlagsHelper.Unset(ref states, state); } State = states; //DebugLog.DebugWrite($"State of player {NetId} is now : {Environment.NewLine}" + // $"{DebugLog.GenerateTable(Enum.GetNames(typeof(State)).ToList(), FlagsHelper.FlagsToListSet(State))}"); }
public static void BitMaskField <T>(ref T enumValue) where T : System.Enum { Dictionary <int, bool> toggleBools = new Dictionary <int, bool>(); int possiableInt = System.Enum.GetValues(typeof(T)).Cast <int>().Max(); foreach (T item in System.Enum.GetValues(typeof(T))) { int intValue = System.Convert.ToInt32(item); if (intValue == 0 || intValue == possiableInt) { toggleBools.Add(intValue, object.Equals(enumValue, item)); continue; } toggleBools.Add(intValue, FlagsHelper.IsSet(enumValue, item)); } using (var horizon = new EditorGUILayout.HorizontalScope()) { foreach (T item in System.Enum.GetValues(typeof(T))) { int intValue = System.Convert.ToInt32(item); using (var check = new EditorGUI.ChangeCheckScope()) { toggleBools[intValue] = GUILayout.Toggle(toggleBools[intValue], item.ToString(), toggleStyle); if (check.changed) { if (intValue == 0 || intValue == possiableInt) { if (toggleBools[intValue]) { enumValue = item; } continue; } if (toggleBools[intValue]) { FlagsHelper.Set(ref enumValue, item); } else { FlagsHelper.Unset(ref enumValue, item); } } } } } }
protected Piece(Point2D positionPoint2D, Color color, string letter, string name, bool moveRepeat) { Name = name; _flags = moveRepeat ? PieceEnum.InPlay | PieceEnum.MoveRepeat : PieceEnum.InPlay; Letter = letter; _positionPoint2D = positionPoint2D; Color = color; if (positionPoint2D.X % 2 == positionPoint2D.Y % 2) { FlagsHelper.Set(ref _flags, PieceEnum.LightColor); } else { FlagsHelper.Unset(ref _flags, PieceEnum.LightColor); } }
private void HandleCrouch() { if (!input.held.crouch) { var check = entity.CheckProximity(entity.LocalScale.y, Direction2D.UP); if (!check.Above) { var newBounds = entity.PriorTransform.localScale; var crouchPosition = entity.Position; crouchPosition.y += newBounds.y; entity.SetLocalScale(newBounds); entity.SetPosition(crouchPosition); FlagsHelper.Unset(ref state, State.CROUCH); } else { Debug.Log("detected something above"); } } }
void OnResetGame(GameMessage msg) { FlagsHelper.Unset(ref currentState, GameState.ended); FlagsHelper.Unset(ref currentState, GameState.started); }
void OnArenaAnimated(GameMessage msg) { // Set a bit at position to 0. FlagsHelper.Unset(ref currentState, GameState.arenaAnimating); }
public IEnumerator OnChangePageRunner(bool show, Transform parent, ViewElementTransform rectTransformData, float TweenTime, float delayIn, bool ignoreTransition, bool reshowIfSamePage) { if (lifeCyclesObjects != null) { foreach (var item in lifeCyclesObjects.ToArray()) { try { item.OnChangePage(show); } catch (Exception ex) { ViewSystemLog.LogError(ex.ToString(), this); } } } if (show) { if (parent == null) { ViewSystemLog.LogError($"{gameObject.name} does not set the parent for next viewpage.", this); goto END; //throw new NullReferenceException(gameObject.name + " does not set the parent for next viewpage."); } //停掉正在播放的 Leave 動畫 if (leaveCoroutine != null) { // viewController.StopCoroutine(OnLeaveCoroutine); } //還在池子裡,應該先 OnShow //或是正在離開,都要重播 OnShow if (IsShowed == false || OnLeaveWorking) { rectTransform.SetParent(parent, true); if (rectTransformData == null || !string.IsNullOrEmpty(rectTransformData.parentPath)) { rectTransform.anchoredPosition3D = Vector3.zero; rectTransform.localScale = Vector3.one; } else { ApplyRectTransform(rectTransformData); } float time = 0; while (time < delayIn) { time += GlobalTimer.deltaTime; yield return(null); } OnShow(); goto END; } //已經在場上的 else { //如果目前的 parent 跟目標的 parent 是同一個人 那就什麼事都不錯 if ((rectTransformData == null || !string.IsNullOrEmpty(rectTransformData.parentPath)) && parent.GetInstanceID() == rectTransform.parent.GetInstanceID()) { //ViewSystemLog.LogWarning("Due to already set the same parent with target parent, ignore " + name); if (reshowIfSamePage) { OnShow(); } goto END; } //其他的情況下用 Tween 過去 if (TweenTime >= 0) { rectTransform.SetParent(parent, true); if (rectTransformData == null || !string.IsNullOrEmpty(rectTransformData.parentPath)) { var marginFixer = GetComponent <ViewMarginFixer>(); viewController.StartMicroCoroutine(EaseUtility.To( rectTransform.anchoredPosition3D, Vector3.zero, TweenTime, EaseStyle.QuadEaseOut, (v) => { rectTransform.anchoredPosition3D = v; }, () => { if (marginFixer) { marginFixer.ApplyModifyValue(); } } )); viewController.StartMicroCoroutine(EaseUtility.To( rectTransform.localScale, Vector3.one, TweenTime, EaseStyle.QuadEaseOut, (v) => { rectTransform.localScale = v; } )); } else { rectTransform.SetParent(parent, true); var flag = rectTransformData.rectTransformFlag; FlagsHelper.Unset(ref flag, RectTransformFlag.AnchoredPosition); FlagsHelper.Unset(ref flag, RectTransformFlag.LocalScale); ApplyRectTransform(rectTransformData, flag); viewController.StartMicroCoroutine(EaseUtility.To( rectTransform.anchoredPosition3D, rectTransformData.rectTransformData.anchoredPosition, TweenTime, EaseStyle.QuadEaseOut, (v) => { rectTransform.anchoredPosition3D = v; }, () => { } )); viewController.StartMicroCoroutine(EaseUtility.To( rectTransform.localScale, rectTransformData.rectTransformData.localScale, TweenTime, EaseStyle.QuadEaseOut, (v) => { rectTransform.localScale = v; }, () => { } )); } goto END; } //TweenTime 設定為 <0 的情況下,代表要完整 OnLeave 在 OnShow else { float time = 0; while (time < delayIn) { time += GlobalTimer.deltaTime; yield return(null); } OnLeave(ignoreTransition: ignoreTransition); while (OnLeaveWorking == true) { yield return(null); } ViewSystemLog.LogWarning("Try to ReShow ", this); rectTransform.SetParent(parent, true); if (rectTransformData == null || !string.IsNullOrEmpty(rectTransformData.parentPath)) { rectTransform.anchoredPosition3D = Vector3.zero; rectTransform.localScale = Vector3.one; } else { ApplyRectTransform(rectTransformData); } time = 0; while (time < delayIn) { time += GlobalTimer.deltaTime; yield return(null); } OnShow(); goto END; } } } else { OnLeave(ignoreTransition: ignoreTransition); goto END; } END: changePageCoroutine = null; yield break; }
//Disables this object from colliding with one-way platforms public void DisableOneWayPlatforms() { FlagsHelper.Unset(ref collisionLayerMaskDown, 1 << LayerMask.NameToLayer("PassThroughBottom")); }
private void HandleGrounded() { var movement = input.held.direction.Vector; var resolvedVelocity = entity.velocity; FlagsHelper.Unset(ref state, State.JUMP); wallJumpImpactDirection.Clear(); // Horizontal movement. resolvedVelocity.x = movement.x * data.velocityHorizontalGroundMax; if (!FlagsHelper.IsSet(state, State.CROUCH)) { if (input.held.crouch) { var newBounds = entity.LocalScale; var crouchPosition = entity.Position; newBounds.x *= data.boundsMultiplierCrouchX; newBounds.y *= data.boundsMultiplierCrouchY; crouchPosition.y -= entity.LocalScale.y; var sizeOffset = CoreUtilities.GetWorldSpaceSize(newBounds, entity.collider as BoxCollider2D, 0.5f).x; var checkDistance = newBounds.x; var hitLeft = entity.Check(Constants.Directions.LEFT, checkDistance); var hitRight = entity.Check(Constants.Directions.RIGHT, checkDistance); if (hitLeft) { crouchPosition.x = hitLeft.point.x + sizeOffset; } if (hitRight) { crouchPosition.x = hitRight.point.x - sizeOffset; } entity.SetLocalScale(newBounds); entity.SetPosition(crouchPosition); FlagsHelper.Set(ref state, State.CROUCH); } } if (!input.held.jump) { additiveJumpFrameCount = 0; jumpCount = 0; } // Jump if (input.pressed.jump) { if (jumpCount < data.jumpCountMax) { resolvedVelocity.y = data.velocityJumpImpulse; jumpCount++; } } entity.SetVelocity(resolvedVelocity); }
void OnSceneLoaded(GameMessage msg) { // Set a bit at position to 0. FlagsHelper.Unset(ref currentState, GameState.gameReloaded); }