private void Init() { RatAnimator = GetComponent <RatAnimator>(); ratStateMachine.Init(this); idling = new Idle(); walking = new Walk(); jumping = new Jump(); climbing = new Climb(); jumpingOff = new JumpOff(); idling.Init(this, ratStateMachine); walking.Init(this, ratStateMachine); jumping.Init(this, ratStateMachine); climbing.Init(this, ratStateMachine); jumpingOff.Init(this, ratStateMachine); ratStateMachine.AddState(idle, idling); ratStateMachine.AddState(walk, walking); ratStateMachine.AddState(jump, jumping); ratStateMachine.AddState(climb, climbing); ratStateMachine.AddState(jumpOff, jumpingOff); ratStateMachine.ChangeState(idle); //update helpers rotationUpdater.Add(UpdateRotation); }
private void NextClimbButton_Clicked(object sender, EventArgs e) { Climb climb = new Climb() { SessionID = DateTime.Today.Date, CentreName = CentreEntry.Text, AreaInCentre = ClimbAreaEntry.Text, ClimbGrade = ClimbGradeEntry.Text, ClimbAttempts = Convert.ToInt32(ClimbAttemptsEntry.Text) }; using (SQLiteConnection conn = new SQLiteConnection(App.filePath)) { conn.CreateTable <Climb>(); conn.Insert(climb); } i = 0; iGrade = -1; jGrade = 1; iClimbs++; ClimbsSessionEntry.Text = iClimbs.ToString(); ClimbAttemptsEntry.Text = i.ToString(); SubtractAttemptButton.IsEnabled = false; ClimbGradeEntry.Text = $"VB - V{jGrade.ToString()}"; SubtractGradeButton.IsEnabled = false; AddGradeButton.IsEnabled = true; ClimbAreaEntry.Text = null; }
public void NoClimbSpeed_NoRacialBonus() { // Arrange var mockClimb = new Mock <IMovement>(); //mockClimb.Setup(c => c.BaseSpeed).Returns(null); // Redundant - the default behavior is to return null var strength = Mock.Of <IAbilityScore>(); var mockAbilityScores = new Mock <IAbilityScoreSection>(); mockAbilityScores.Setup(abs => abs.Strength) .Returns(strength); var mockSpeeds = new Mock <IMovementSection>(); mockSpeeds.Setup(ms => ms.Climb) .Returns(mockClimb.Object); var mockCharacter = new Mock <ICharacter>(); mockCharacter.Setup(c => c.AbilityScores) .Returns(mockAbilityScores.Object); mockCharacter.Setup(c => c.MovementModes) .Returns(mockSpeeds.Object); Climb climb = new Climb(mockCharacter.Object); // Act var total = climb.RacialBonuses.GetTotal(); // Assert Assert.AreEqual(0, total); Assert.IsTrue(climb.ArmorCheckPenaltyApplies); }
private void SetupNextState(Climb nextClimb) { _animator.speed = 1; switch (nextClimb) { case Climb.Up: _animator.SetTrigger("climbUp"); break; case Climb.Flip: _animator.SetTrigger("flipUp"); break; case Climb.Mantle: _animator.SetTrigger("mantle"); break; case Climb.Down: _animator.SetTrigger("transitionDown"); break; case Climb.AcrossRight: case Climb.AcrossLeft: case Climb.Jump: _animator.SetTrigger("transitionAcross"); break; case Climb.None: case Climb.Hang: _animator.SetTrigger("stopClimbing"); break; } }
public string SaveMediaAsClimbAvatar(Climb obj, Media media, ImageCropOpts cropOptions) { if (obj == null || media == null || media.Type != MediaType.Image) { throw new ArgumentException("SaveMediaAsClimbAvatar invalid arguments"); } if (media.ObjectMedias.Where(om => om.OnOjectID == obj.ID).Count() == 0) { throw new ArgumentException("Media does not belong to climb"); } var mediaImageUrl = string.Format("{0}/media/{1}", Stgs.ImgsRt, media.Content); string newImgUrl = string.Empty; using (Stream stream = new ImageDownloader().DownloadImageAsStream(mediaImageUrl)) { var meta = SaveClimbAvatarAuthorization(obj, stream, cropOptions); Climb original = obj.GetSimpleTypeClimbClone(); newImgUrl = SaveAvatar240Thumb(stream, obj.Avatar, obj.NameUrlPart, ImageManager.ClimbPath, fileName => { obj.Avatar = fileName; climbRepo.Update(obj); }, cropOptions, Path.GetFileName(media.ThumbUrl())); //-- No change occurs to the mods profile because the image has to be verified by other users SaveModActionAndUpdateModProfile(ModActionType.ClimbSetAvatar, original, obj, meta, (m, actionID) => m.SetAvatarChanged(actionID), null, "set climb img {0}", obj.Name); } return(newImgUrl); }
public bool TryHangingInput(out Climb nextClimb) { DirectionFacing direction = AddNextClimbs(); nextClimb = Climb.Down; if (_climbHandler.NextClimbs.Any()) { Climb switchedClimb = _climbHandler.SwitchClimbingState(direction, _climbHandler.CurrentClimbingState.PivotCollider != null && _climbHandler.CurrentClimbingState.IsUpright == false); if (switchedClimb == Climb.None) { return(false); } if (_climbHandler.CurrentClimbingState.PivotCollider == null || switchedClimb == Climb.Down) { MovementState.UnsetPivot(); nextClimb = Climb.None; } else { nextClimb = switchedClimb; } return(true); } else { return(false); } }
private void SetClimbPageViewData(Climb climb) { var location = geoSvc.GetLocationByID(climb.LocationID); ViewBag.Current = location; SetPlaceContextToViewData(location); ViewBag.RecentSends = new VisitsService().GetClimbsRecentSuccessfulLoggedClimbs(climb.ID, 10).ToList(); var allClimbsAtLocation = geoSvc.GetClimbsOfLocation(climb.LocationID).ToList(); ViewBag.OtherClimbs = allClimbsAtLocation.Where(c => c.ID != climb.ID).ToList(); ViewBag.OtherClimbsInSection = allClimbsAtLocation.Where(c => c.SectionID == climb.SectionID).ToList(); //-- ClimbTypeID == ClimbTypeID ViewBag.OtherClimbsSimilar = allClimbsAtLocation.Where(c => c.GradeCfNormalize > (climb.GradeCfNormalize - 15) && c.GradeCfNormalize < (climb.GradeCfNormalize + 15)).ToList(); var meta = geoSvc.GetObjectModMetaOrSystemCreate(location); ViewBag.ModMeta = meta; ViewBag.Posts = new List <PostRendered>(); //Todo fix ViewBag.MediaList = medSvc.GetObjectsTopMedia(climb.ID, 10); ViewBag.LatestOpinions = new ContentService().GetLatestOpinionsOnObject(climb.ID, 20).ToList(); ViewBag.PageQR = string.Format("http://c/{0}", climb.ID.ToString("N")); }
/// <summary> /// Save the image used to represent the climb in thumbnails and on the main page. Also saves the image to the climbs media stream /// </summary> /// <param name="obj"></param> /// <param name="stream"></param> /// <param name="cropOptions"></param> /// <returns></returns> public Media SaveClimbAvatar(Climb obj, Stream stream, ImageCropOpts cropOptions) { ObjectModMeta meta = null; //-- We don't need to set ModProfile on thread, or retrieve object mod-meta for indoor climbs if (obj.Type == CfType.ClimbOutdoor) { meta = SaveClimbAvatarAuthorization(obj, stream, cropOptions); } var original = obj.GetSimpleTypeClimbClone(); //-- Also save the image to the climbs's media real //-- If the climb is indoor we don't save indoor climb avatar as var media = new MediaService().CreateImageMedia(new Media() { FeedVisible = (obj.Type != CfType.ClimbIndoor), Title = "Climbing pic of " + obj.Name, ContentType = "image/jpg" }, obj.ID, stream); SaveAvatar240Thumb(stream, obj.Avatar, obj.NameUrlPart, ImageManager.ClimbPath, fileName => { obj.Avatar = fileName; climbRepo.Update(obj); }, cropOptions, media.Content); //-- We don't want to save mod trail if it's indoor (the setters working, kinda boring!) if (obj.Type == CfType.ClimbOutdoor) { //-- No change occurs to the mods profile because the image has to be verified by other users SaveModActionAndUpdateModProfile(ModActionType.ClimbSetAvatar, original, obj, meta, (m, actionID) => m.SetAvatarChanged(actionID), null, "set climb img {0}", obj.Name); } return(media); }
/// <summary> /// /// </summary> /// <remarks>Called by the parent methods CreateClimbIndoor & CreateClimbOutdoor</remarks> private void DeleteClimb(Climb obj) { climbRepo.Delete(obj.ID); //-- Remove from the cache AppLookups.RemoveCacheIndexEntry(obj.ID); }
public async Task <ActionResult <Climb> > PostClimb([FromBody] Climb climb) { _context.Climbs.Add(climb); await _context.SaveChangesAsync(); return(CreatedAtAction("GetClimb", new { id = climb.Id }, climb)); }
public async Task <IActionResult> PutClimb(int id, Climb climb) { if (id != climb.Id) { return(BadRequest()); } _context.Entry(climb).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClimbExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void SwitchClimbingState(bool ignoreUp) { _ignoreMovement = false; Climb nextClimb = PlayerMotor.SwitchClimbingState(ignoreUp); SetupNextState(nextClimb); _shouldFlip = true; }
// Use this for initialization void Start() { PlayerState = State.OnGround; pms = GetComponent <PlayerMovementSmooth>(); climb = GetComponent <Climb>(); lame = GetComponent <LadderMovement>(); gc = GetComponentInChildren <GroundCheck>(); }
private void Awake() { xAxisClamp = 0.0f; initialXPos = transform.position.x; initialYPos = transform.position.y; climbScript = player.GetComponent <Climb>(); t = player.GetComponent <Transform>(); }
public async Task <ActionResult <Climb> > PostClimb([FromBody] Climb climb) { await _climbContext.Climbs.AddAsync(climb); await _climbContext.SaveChangesAsync(); return(CreatedAtAction(nameof(PostClimb), new { id = climb.ClimbId }, climb)); }
//This trigger starts the climb action void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { Climb climbScript = other.gameObject.GetComponent <Climb>(); climbScript.StartClimbing(startNode); } }
private ClimbingState GetClimbingState(Climb climb, Collider2D col, bool shouldHang = false) { if (CurrentClimbingState.PivotCollider != null) { _anim.SetBool(PlayerAnimBool.OnCorner, CurrentClimbingState.IsUpright); } return(ClimbingState.GetClimbingState(climb, col, _motor.Collider, shouldHang)); }
public IActionResult Put(int id, Climb climb) { if (id != climb.Id) { return(BadRequest()); } _climbRepository.Update(climb); return(NoContent()); }
void OnTriggerEnter(Collider other) { //This trigger ends the climb action if (other.gameObject.CompareTag("Player")) { Climb climbScript = other.gameObject.GetComponent <Climb>(); climbScript.EndClimbing(); } }
void Start() { controller = GetComponent <CharacterController>(); armsAnim = GetComponent <ArmsAnimatorBehabior>(); climbScript = GetComponent <Climb>(); pl = playerCam.GetComponent <PlayerLook>(); //BORRAR? Cursor.lockState = CursorLockMode.Locked; Crouch(); }
void Start() { PL = GameObject.FindGameObjectWithTag("Player"); rb = GetComponent <Rigidbody>(); animator = GetComponent <Animator>(); rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; playercharacter = PL.GetComponent <CapsuleCollider>(); climbScript = this.GetComponent <Climb>(); climbT = climbScript.targetObj; }
//public ClimbListItemDto(Guid id, string name, string name2, string avatar, string grade, double? rating, int ratingCount) //{ // ID = id.ToString("N"); // Name = name; // Name2 = name; // Grade = grade; // Avatar = avatar; // Rating = rating; // RatingCount = ratingCount; //} public ClimbListItemDto(Climb c) { ID = c.ID.ToString("N"); Name = c.Name; if (c.Type == Entities.Enum.CfType.ClimbIndoor) { Alt = DtoHelper.GetPGAltName(c as ClimbIndoor); } Grade = c.GradeLocal; Avatar = c.Avatar; Rating = c.Rating; RatingCount = c.RatingCount; }
protected void Awake() { climb = GetComponent <Climb>(); health = GetComponent <Health>(); movement = GetComponent <Movement>(); animationFlip = gameObject.AddComponent <AnimationFlip>(); climb.CustomCharacterController = this; }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <param name="originalImageUrl"></param> /// <param name="cropOptions"></param> /// <returns></returns> public ObjectModMeta SaveClimbAvatarAuthorization(Climb obj, Stream stream, ImageCropOpts cropOptions) { var meta = SetModDetailsOnPrincipalAndStopModIfNegativeReputationAndReturnObjectModMeta(obj); if (meta.VerifiedAvatar > 1 && !currentUser.IsInRole("ModAdmin,ModSenior")) { throw new AccessViolationException("SaveAreaProfileImage: Only Senior Moderators can change avatar images that have already been verified by other users"); } return meta; }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <param name="originalImageUrl"></param> /// <param name="cropOptions"></param> /// <returns></returns> public ObjectModMeta SaveClimbAvatarAuthorization(Climb obj, Stream stream, ImageCropOpts cropOptions) { var meta = SetModDetailsOnPrincipalAndStopModIfNegativeReputationAndReturnObjectModMeta(obj); if (meta.VerifiedAvatar > 1 && !currentUser.IsInRole("ModAdmin,ModSenior")) { throw new AccessViolationException("SaveAreaProfileImage: Only Senior Moderators can change avatar images that have already been verified by other users"); } return(meta); }
public static ClimbingState GetClimbingState(Climb climb, Collider2D climbCollider, Collider2D playerCollider, bool shouldHang = false) { if (climb == Climb.None) { return(new ClimbingState()); } float climbingSpeed = 1; float animSpeed = 1; DirectionFacing direction = GetClimbingSide(climbCollider); Climb transitionClimb = Climb.None; switch (climb) { case Climb.Up: case Climb.Flip: Hanging(direction); transitionClimb = Climb.Down; climbingSpeed = ConstantVariables.MoveToEdgeSpeed; animSpeed = GetAnimationSpeed(playerCollider, climbCollider, climbingSpeed); break; case Climb.Mantle: Mantle(direction); transitionClimb = Climb.Up; climbingSpeed = ConstantVariables.AcrossSpeed; animSpeed = GetAnimationSpeed(playerCollider, climbCollider, climbingSpeed); break; case Climb.Down: OffEdge(direction); transitionClimb = Climb.Down; break; case Climb.AcrossLeft: case Climb.AcrossRight: if (shouldHang) { Hanging(direction); transitionClimb = Climb.Down; } else { OffEdge(direction); transitionClimb = Climb.Up; } climbingSpeed = 0.2f; animSpeed = GetAnimationSpeed(playerCollider, climbCollider, climbingSpeed); break; } return(new ClimbingState(transitionClimb, climbCollider, climbingSpeed, animSpeed, _target, _player, direction)); }
public Climb SwitchClimbingState(bool ignoreUp = false) { var direction = DirectionFacing.None; if (_climbHandler.CurrentClimbingState.Climb != Climb.Jump && _climbHandler.CurrentClimbingState.Climb != Climb.None) { direction = AddNextClimbs(ignoreUp); } Climb nextClimb = _climbHandler.SwitchClimbingState(direction); return(nextClimb); }
public ClimbingState(Climb climb, Collider2D col, float movementSpeed, float animationSpeed, ColliderPoint pivot, ColliderPoint player, DirectionFacing climbSide) { Climb = climb; PivotCollider = col; MovementSpeed = movementSpeed; AnimationSpeed = animationSpeed; PivotPosition = pivot; PlayerPosition = player; ClimbSide = climbSide; IsUpright = col.IsUpright(); IsCorner = col.IsCorner(); CanClimbDown = col.CanClimbDown(); }
// Use this for initialization void Start() { PlayerState = State.OnGround; jump = GetComponent <Jump>(); pms = GetComponent <PlayerMovementSmooth>(); climb = GetComponent <Climb>(); lame = GetComponent <LadderMovement>(); whip = GetComponentInChildren <Whip>(); gc = GetComponentInChildren <GroundCheck>(); playerCollider = GetComponent <BoxCollider2D>(); }
public SearchEngineEntryPlace(Climb climb) { //-- Searchable fields this.Key = climb.IDstring; this.Description = climb.Description; this.Name = climb.Name; this.NameShort = climb.Name; this.SearchSupportString = climb.Name; //-- Result / display fields this.CountryID = climb.CountryID; this.TypeID = (byte)climb.Type; this.Title = climb.Name; this.Excerpt = climb.Name; this.Url = climb.SlugUrl; }
private void FixupClimb(Climb previousValue) { if (previousValue != null && previousValue.ClimbTags.Contains(this)) { previousValue.ClimbTags.Remove(this); } if (Climb != null) { if (!Climb.ClimbTags.Contains(this)) { Climb.ClimbTags.Add(this); } if (ClimbID != Climb.ID) { ClimbID = Climb.ID; } } }
public override void OnStateEnter() { _input = stateMachine.GetComponent <InputReader>(); _stats = stateMachine.GetComponent <StatHolder>().held; _motor = stateMachine.GetComponent <Motor>(); _grounded = stateMachine.GetComponent <Grounded>(); _edgeDetect = stateMachine.GetComponent <EdgeDetect>(); _edgeDetect.enabled = true; _climb = stateMachine.GetComponent <Climb>(); toggle = false; _crouch = stateMachine.GetComponent <Crouch>(); _falldmg = stateMachine.GetComponent <FallDamage>(); #region change motor vals _motor.speed = _stats.airSpeed; _motor.accelRate = _stats.airAccelRate; _motor.sprintHorizontalInputReductionMult = 1f; #endregion }
/// <summary> /// /// </summary> /// <returns></returns> private ObjectModMeta DeleteClimbOutdoorAuthorization(Climb obj) { var meta = SetModDetailsOnPrincipalAndStopModIfNegativeReputationAndReturnObjectModMeta(obj); var contentRank = meta.CQR; if (contentRank > 7 && !currentUser.IsInRole("ModAdmin")) { throw new AccessViolationException("DeleteArea: Only Admin Moderators can delete climbs with CQR higher than 7"); } else if (contentRank > 1 && !currentUser.IsInRole("ModAdmin,ModSenior")) { throw new AccessViolationException("DeleteArea: Only Senior Moderators can delete climbs with CQR higher than 1"); } else if (!currentUser.IsInRole("ModAdmin,ModSenior,ModCommunity")) { throw new AccessViolationException("DeleteArea: You must be Moderator to delete climbs"); } return meta; }
/// <summary> /// /// </summary> /// <param name="original"></param> /// <param name="updated"></param> /// <param name="categories"></param> /// <returns></returns> ObjectModMeta UpdateClimbAuthorization(Climb original, Climb updated, List<int> categories) { var meta = SetModDetailsOnPrincipalAndStopModIfNegativeReputationAndReturnObjectModMeta(original); if ((original.ID != updated.ID) || (original.CountryID != updated.CountryID)) { throw new ArgumentException(string.Format("Original climb {0}[{1}][{2}] is not the same climb as updated climb {3}[{4}][{5}]", original.Name, original.CountryID, original.ID, updated.Name, updated.CountryID, updated.ID)); } if ((original.Name != updated.Name) && meta.HasBeenVerified) { if (meta.HasBeenVerified && !currentUser.IsInRole("ModAdmin,ModSenior")) { throw new AccessViolationException("UpdateArea[" + original.ID + "]: Only Senior Moderators can change the name of an climb that has already been verified."); } } if ((original.NameUrlPart != updated.NameUrlPart) && meta.HasBeenVerified) { if (meta.HasBeenVerified && !currentUser.IsInRole("ModAdmin,ModSenior")) { throw new AccessViolationException("UpdateArea[" + original.ID + "]: Only Senior Moderators can change the url part for a climb that has already been verified."); } } if ((original.Description != updated.Description) && meta.HasBeenVerified && meta.CQR > 6) { if (!currentUser.IsInRole("ModAdmin,ModSenior")) { throw new AccessViolationException("UpdateArea[" + original.ID + "]: Only Senior Moderators can change the description of a climb that has been verified and has a high CQR."); } } return meta; }
/// <summary> /// No fancy authorization logic, just create the mod profile it it's the users first time & check they're not a bad egg (negative rep) /// </summary> /// <param name="obj"></param> /// <param name="categories"></param> void CreateClimbAuthorization(Climb obj, List<int> categories) { SetModDetailsOnPrincipalAndStopModIfNegativeReputationAndReturnObjectModMeta(obj); }
private void SetClimbPageViewData(Climb climb) { var location = geoSvc.GetLocationByID(climb.LocationID); ViewBag.Current = location; SetPlaceContextToViewData(location); ViewBag.RecentSends = new VisitsService().GetClimbsRecentSuccessfulLoggedClimbs(climb.ID, 10).ToList(); var allClimbsAtLocation = geoSvc.GetClimbsOfLocation(climb.LocationID).ToList(); ViewBag.OtherClimbs = allClimbsAtLocation.Where(c => c.ID != climb.ID).ToList(); ViewBag.OtherClimbsInSection = allClimbsAtLocation.Where(c=>c.SectionID == climb.SectionID).ToList(); //-- ClimbTypeID == ClimbTypeID ViewBag.OtherClimbsSimilar = allClimbsAtLocation.Where(c => c.GradeCfNormalize > (climb.GradeCfNormalize - 15) && c.GradeCfNormalize < (climb.GradeCfNormalize + 15) ).ToList(); var meta = geoSvc.GetObjectModMetaOrSystemCreate(location); ViewBag.ModMeta = meta; ViewBag.Posts = new List<PostRendered>(); //Todo fix ViewBag.MediaList = medSvc.GetObjectsTopMedia(climb.ID, 10); ViewBag.LatestOpinions = new ContentService().GetLatestOpinionsOnObject(climb.ID, 20).ToList(); ViewBag.PageQR = string.Format("http://c/{0}", climb.ID.ToString("N")); }