public void RefreshPositionAnimation() { var gameLogic = CustomServices.GameLogic; this.destinationPosition = gameLogic.CalculateCandyPostion(this.attributes.Coordinate); this.animationState = AnimationStates.Moving; }
void CheckIfGrounded() { Debug.Log(m_CapsuleCollider2D.bounds.size); RaycastHit2D[] hits; hits = Physics2D.CapsuleCastAll(new Vector2(transform.position.x, transform.position.y) + m_CapsuleCollider2D.offset, m_CapsuleCollider2D.bounds.size * 0.95f, CapsuleDirection2D.Vertical, 0f, Vector2.down, 1 / 16f, LayerMask.GetMask("Ground")); if (hits.Length >= 1) { foreach (RaycastHit2D hit in hits) { if (Vector2.Angle(transform.up, hit.normal) < 45f) { m_IsGrounded = true; // Tocamos el suelo después de falling if (m_AnimationState == AnimationStates.FALLING) { // TRANSICION A RUNNING DESDE LANDING SwitchState(AnimationStates.LANDING); } break; } } } else { m_IsGrounded = false; m_AnimationState = AnimationStates.FALLING; m_PlayerAnimator.SetInteger("AnimationState", 8); } }
protected override void Update(TimeSpan gameTime) { var timeFactor = (float)gameTime.TotalSeconds; if (this.animationState == AnimationStates.Moving) { this.transform2D.LocalPosition = Vector2.SmoothStep(this.transform2D.LocalPosition, this.destinationPosition, timeFactor * SmoothSpeed); if (this.destinationPosition == this.transform2D.LocalPosition) { this.animationState = AnimationStates.None; } } else if (this.animationState == AnimationStates.Appear) { this.transform2D.LocalScale = Vector2.SmoothStep(this.transform2D.LocalScale, this.destinationScale, timeFactor * SmoothSpeed); if (this.destinationScale == this.transform2D.LocalScale) { this.animationState = AnimationStates.None; } } else if (this.animationState == AnimationStates.Disappear) { if (this.explisionAnimation2D.State == AnimationState.Stopped) { this.animationState = AnimationStates.None; } } }
public void Update(GameTime gameTime) { ElapsedTime += gameTime.ElapsedGameTime.TotalSeconds; switch (AnimationState) { case AnimationStates.Visible: if (ElapsedTime >= VisibleTimeInSeconds) { ElapsedTime -= VisibleTimeInSeconds; AnimationState = AnimationStates.FadeOut; Map.ExecuteFollowingScripts(Owner, 0); } break; case AnimationStates.FadeOut: if (ElapsedTime >= FadeOutSeconds) { ElapsedTime -= FadeOutSeconds; AnimationState = AnimationStates.Visible; IsFinished = true; } break; } }
private void ResetAnimationParameters() { this.phaseTimer = 0f; this.pauseBetweenFullAnimationCycleTimer = -1f; this.state = AnimationStates <T> .TIMEOUT; this.currentDirection = 1; }
void AlternateMovePC() { if (isGrounded) { if (Mathf.Abs(moveDirection.x) != 0 || Mathf.Abs(moveDirection.z) != 0) // if there's some input { moveDirection *= baseSpeed * speed; } else { pcAnimationState = AnimationStates.Idle; } } else { if (Mathf.Abs(moveDirection.x) != 0 || Mathf.Abs(moveDirection.z) != 0) // if there's some input { moveDirection *= airBaseSpeed * speed; } } ApplyJump(); ApplyGravity(); ApplyMovementModifiers(); cc.Move(moveDirection * Time.deltaTime); moveDirection = Vector3.zero; if (cc.velocity == Vector3.zero) { wasStopped = true; } }
public ScrollingTextOverlay(Texture2D sprText, string NextLevelPath = null) { this.sprText = sprText; this.NextLevelPath = NextLevelPath; AnimationState = AnimationStates.MovingIn; IsFinished = false; }
public void PlayAnimation(AnimationStates stateAnimation) { switch (stateAnimation) { case AnimationStates.IDLE: { StopAnimations(); animator.SetBool("inIdle", true); } break; case AnimationStates.WALKING: { StopAnimations(); animator.SetBool("inWalk", true); } break; case AnimationStates.RUNNING: { StopAnimations(); animator.SetBool("inRun", true); } break; } void StopAnimations() { animator.SetBool("inWalk", false); animator.SetBool("inRun", false); animator.SetBool("inIdle", false); } }
/// <summary> /// Manages currentState and updates the player's animator component. /// </summary> void AnimationUpdate() { Animator thisAnimator = GetComponent <Animator>(); if (this.GetComponent <Rigidbody>().velocity.magnitude > 0.2F && isTouchingGround) { currentState = AnimationStates.walking; } else if (this.GetComponent <Rigidbody>().velocity.magnitude <= 0.2F && isTouchingGround) { currentState = AnimationStates.idle; } switch (currentState) { case AnimationStates.idle: thisAnimator.SetBool("Idle", true); thisAnimator.SetBool("Walking", false); thisAnimator.SetBool("Jumping", false); break; case AnimationStates.walking: thisAnimator.SetBool("Idle", false); thisAnimator.SetBool("Walking", true); thisAnimator.SetBool("Jumping", false); break; case AnimationStates.jumping: thisAnimator.SetBool("Idle", false); thisAnimator.SetBool("Walking", false); thisAnimator.SetBool("Jumping", true); break; } }
public void TakeEnemy() { if (Skillinfo != null) { SingleSkill ss = Skillinfo as SingleSkill; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); bool isCollider = Physics.Raycast(ray, out hitInfo); if (isCollider) { if (hitInfo.collider.tag == Tags.enemy) { if (Vector3.Distance(transform.position, hitInfo.transform.position) < ss.SkillDis) { PlayerStatusManager.Instance.CutMP(Skillinfo.SkillMP); agent.SetDestination(transform.position); PlayerState = AnimationStates.SkillAttack; PlayAnim(ss.AnimName, ss.AnimTime, () => { PlayerState = AnimationStates.Attack; }); isEnemy = true; transform.LookAt(hitInfo.transform); GameObject effect = Resources.Load <GameObject>(ss.EffectPath); GameObject.Instantiate(effect, hitInfo.transform.position, Quaternion.identity); hitInfo.collider.SendMessage("GetAttack", ss.SkillDamage); } } } } isLockTarget = false; Skillinfo = null; MouseCursorManager.Instance.SetMouseCorsor(MouseCursorTypes.Normal); }
public Player(Vector2 _vector, double _damage, Texture2D texture, double _collisionRadius, double _HitPoints) : base(_vector, _damage, texture, _collisionRadius) { hitPoints = _HitPoints; going = new AnimatedSprite(texture, 3, 2); states = AnimationStates.Standing; }
void Start() { HUDmount = FindObjectOfType <HUDScoreSetter>().transform.Find("HUD_" + name[PlayerNumber] + "/ItemInfoMountPoint").gameObject; navPoints = new List <HUDPointer>(); GameObject g = Instantiate(FindObjectOfType <CommonPunch>().gameObject); _currentItem = g.GetComponent <Item>(); GameObject g2 = Instantiate(g); defaultWeapon = g2.GetComponent <Item>(); //NoFriction = Resources.Load<PhysicMaterial>("Assets/Class Prototype/Physics Materials/NoFriction.physicMaterial"); _collider = transform.Find("Collision/Foot Collider").gameObject.GetComponent <SphereCollider>(); _controllerStatus = new ControlStruct(); _rigidbody = this.GetComponent <Rigidbody>(); if (attackPoint == null) { attackPoint = this.transform; } AnimState = new AnimationStates(anim); audio = FindObjectOfType <AudioManager>(); }
private void GetAttack(int hp) { if (EnemyState == AnimationStates.Death) { return; } emenyState = AnimationStates.Attack; transform.LookAt(player); if (UnityEngine.Random.Range(1, 11) / (double)10 <= enemyInfo.MissPrecent) { enemyShow.ShowAttackMsg("Miss", Color.green); } else { PlayAnim("TakeDamage1"); enemyInfo.Hp -= hp; enemyShow.ShowAttackMsg(" - " + hp, Color.red); } if (enemyInfo.Hp <= 0) { PlayAnim("Death"); EnemyState = AnimationStates.Death; PlayerStatusManager.Instance.AddExp(enemyInfo.Exp); GameObject go = GameObject.Instantiate(Death_Pre, transform.position, transform.rotation); go.GetComponent <EnemyDeath>().Death(enemyInfo.EnemyType); Destroy(this.gameObject); } }
void PlayAnim(AnimationStates state) { switch (state) { case AnimationStates.EnterWRR: cameraAnimator.Play("StartWallrunRight"); break; case AnimationStates.EnterWRL: cameraAnimator.Play("StartWallrunLeft"); break; case AnimationStates.WRR: cameraAnimator.Play("WallrunRight"); break; case AnimationStates.WRL: cameraAnimator.Play("WallRunLeft"); break; case AnimationStates.ExitWRR: cameraAnimator.Play("ExitWallrunRight"); break; case AnimationStates.ExitWRL: cameraAnimator.Play("ExitWallrunLeft"); break; } }
/// <summary> /// The awake function is used to apply values to variables. /// </summary> protected void Awake() { render = GetComponent <SpriteRenderer> (); lookDir = LookingDirection.Down; curAnimState = AnimationStates.Idle; LastPressedDirection = new List <LookingDirection> (); }
public void TryToCelebrate(bool postGame) { if (postGame) // end of game { if (quixelState == AnimationStates.idle || quixelState == AnimationStates.resting) { quixelAnimator.SetTrigger(triggerCelebrate); quixelState = AnimationStates.celebrating; return; } return; } else { if (quixelState == AnimationStates.idle) { quixelAnimator.SetTrigger(triggerCelebrate); quixelState = AnimationStates.celebrating; StartCoroutine(CelebrationCountdown()); return; } return; } }
string RulesInterface.action() { string animationToPlay = ""; float randomValue = Random.value; if (randomValue < 0.6) { string[] possibleAttacks = AnimationStates.GetGroundAttacks(); int randomAttack = Random.Range(0, possibleAttacks.Length - 1); animationToPlay = possibleAttacks[randomAttack]; } else if (randomValue > 0.6 && randomValue < 0.8) { animationToPlay = AnimationStates.WALK_BACKWARDS; } else if (randomValue > 0.8 && randomValue < 0.9) { animationToPlay = AnimationStates.JUMPING_BACKWARDS; } else { animationToPlay = AnimationStates.JUMPING_UP; } return(animationToPlay); }
// Update is called once per frame void Update() { if (animState == AnimationStates.on) { // animate movement var stepToMove = Time.deltaTime * movementSpeed; this.transform.localPosition = Vector3.MoveTowards(transform.localPosition, AnimationTargetPosition, stepToMove); // animate rotation var stepToRotate = Time.deltaTime * rotationSpeed; this.transform.localRotation = Quaternion.RotateTowards(transform.localRotation, AnimationTargetRotation, stepToRotate); // animate scale var stepToScale = Time.deltaTime * scaleSpeed; this.transform.localScale = Vector3.MoveTowards(transform.localScale, AnimationTargetScale, stepToScale); // turn animation off when it reaches the target if (this.transform.localRotation == AnimationTargetRotation && this.transform.localPosition == AnimationTargetPosition && this.transform.localScale == AnimationTargetScale) { animState = AnimationStates.off; } } }
public void MulTakeEnemy() { if (Skillinfo != null) { MultiSkill ss = Skillinfo as MultiSkill; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); bool isCollider = Physics.Raycast(ray, out hitInfo); if (isCollider) { if (hitInfo.collider.tag == Tags.ground) { if (Vector3.Distance(transform.position, hitInfo.point) < ss.SkillDis) { PlayerStatusManager.Instance.CutMP(Skillinfo.SkillMP); Vector3 vector3 = new Vector3(hitInfo.point.x, hitInfo.point.y + 1, hitInfo.point.z); GameObject effect = Resources.Load <GameObject>(Skillinfo.EffectPath); effect = Instantiate(effect, vector3, hitInfo.transform.rotation); effect.GetComponent <MulSkillEffect>().Init(Skillinfo); transform.LookAt(hitInfo.point); PlayerState = AnimationStates.SkillAttack; PlayAnim(ss.AnimName, ss.AnimTime, () => { PlayerState = AnimationStates.Attack; }); } } } } isLockPosition = false; Skillinfo = null; MouseCursorManager.Instance.SetMouseCorsor(MouseCursorTypes.Normal); }
public void OnSelect(Globals.SelectionType SelectionMode) { // todo: does this need to be conditioned to only happen when not dragging? // !this.gameObject.transform.parent.parent.gameObject.GetComponent<HandDraggable>().IsDraggingEnabled if (ImEditable()) { // disable parent's hand draggable this.gameObject.transform.parent.parent.gameObject.GetComponent <HandDraggable>().enabled = false; Globals.Instance.SelectedBlock = this.gameObject; Globals.Instance.SelectionMode = SelectionMode; // move the block up off the matrix plane AnimationTargetPosition = new Vector3( this.transform.localPosition.x, this.transform.localPosition.y + 4 * Globals.BlockSpacing, this.transform.localPosition.z); AnimationTargetScale = new Vector3( originalLocalScale.x * Globals.selectedBlockScale, originalLocalScale.y * Globals.selectedBlockScale, originalLocalScale.z * Globals.selectedBlockScale); animState = AnimationStates.on; movementSpeed = 2f; // show selection highlight around the block Globals.Instance.SelectionHighlight.SendMessage("OnSelect"); // play sound effect this.GetComponents <AudioSource>()[0].Play(); } }
void rotateRelative(Vector3 relativeAmount) { animState = AnimationStates.off; // rotate the cube around the world x, y and z axes // amount to rotate is based on the relative amount vector against the original rotation of the block // x,y,z navitagion is scaled to rotations by NavigationToRotationFactor // x,y,z navigation is constrained to 1 axis this.transform.rotation = navStart_block_rotation; if (Mathf.Abs(relativeAmount.y) > 0) { this.transform.Rotate( navStart_axes_transform.right, relativeAmount.y * Globals.NavigationToRotationFactor, Space.World); } if (Mathf.Abs(relativeAmount.x) > 0) { this.transform.Rotate( navStart_axes_transform.up, relativeAmount.x * Globals.NavigationToRotationFactor, Space.World); } if (Mathf.Abs(relativeAmount.z) > 0) { this.transform.Rotate( navStart_axes_transform.forward, -relativeAmount.z * Globals.NavigationToRotationFactor, Space.World); } }
// // handlers for user input // public void OnFocusEnter() { // set stabilization plane to 0,0 of parent Transform gridPlane = this.transform.parent; UnityEngine.VR.WSA.HolographicSettings.SetFocusPointForFrame(gridPlane.position, gridPlane.up); if (!Globals.CurrentlyNavigating && Globals.Instance.SelectedBlock == null && IsNotSelectedBySomeoneElse() && ImEditable()) { // show selection highlight around the block Globals.Instance.SelectionHighlight.SendMessage("OnFocus", this.gameObject); Globals.Instance.FocusedObject = this.gameObject; // move the block up off the matrix plane AnimationTargetPosition = new Vector3( this.transform.localPosition.x, originalLocalPosition.y + 0.2f * Globals.BlockSpacing, this.transform.localPosition.z); movementSpeed = 2f; animState = AnimationStates.on; } }
protected override void DefaultValues() { base.DefaultValues(); this.currentAnimationState = AnimationStates.Idle; this.HitType = ARMobileHitType.ExistingPlane; }
public void PlayAnimation(AnimationStates states) { switch (states) { case AnimationStates.IDLE: { StopAnimations(); animator.SetBool("inIdle", true); } break; case AnimationStates.RUN: { StopAnimations(); animator.SetBool("inRun", true); } break; case AnimationStates.WALK: { StopAnimations(); animator.SetBool("inWalk", true); } break; case AnimationStates.SIDE_WALK: { StopAnimations(); animator.SetBool("inSideWalk", true); } break; } }
string RulesInterface.action() { string[] possibleAttacks = AnimationStates.GetAirAttacks(); int randomAttack = Random.Range(0, possibleAttacks.Length - 1); return(possibleAttacks[randomAttack]); }
public AnimationDrivenLocomotion( AnimationTree animationTree, Skeleton skeleton, AnimationStates states, Blender2D blender, TimeScale timeScale, string idleState, string moveState, KinematicBody target, Physics3DSettings physicsSettings, ITimeSource timeSource, bool active, ILoggerFactory loggerFactory) : base(target, physicsSettings, timeSource, active, loggerFactory) { Ensure.That(animationTree, nameof(animationTree)).IsNotNull(); Ensure.That(skeleton, nameof(skeleton)).IsNotNull(); Ensure.That(states, nameof(states)).IsNotNull(); Ensure.That(blender, nameof(blender)).IsNotNull(); Ensure.That(timeScale, nameof(timeScale)).IsNotNull(); Ensure.That(idleState, nameof(idleState)).IsNotNullOrEmpty(); Ensure.That(moveState, nameof(moveState)).IsNotNullOrEmpty(); AnimationTree = animationTree; Skeleton = skeleton; States = states; Blender = blender; TimeScale = timeScale; IdleState = idleState; MoveState = moveState; }
private void MoveToNextAnimationState() { switch (SpikeState) { case AnimationStates.Stage1: SpikeState = AnimationStates.Stage2; break; case AnimationStates.Stage2: SpikeState = AnimationStates.Stage3; break; case AnimationStates.Stage3: SpikeState = AnimationStates.Stage4; break; case AnimationStates.Stage4: SpikeState = AnimationStates.Stage1; break; default: SpikeState = AnimationStates.Stage1; break; } }
private void ExecuteAction() { if ((Array.IndexOf(AnimationStates.GetAttacks(), characterAction) >= 0)) { characterActions.PerformAttack(characterAction); } else if (characterAction == AnimationStates.WALK_BACKWARDS) { characterActions.Block(); characterActions.Walk(rigidBody, animator, AnimationStates.WALK_BACKWARDS); } else if (characterAction == AnimationStates.WALK_FORWARDS) { characterActions.Walk(rigidBody, animator, AnimationStates.WALK_FORWARDS); } else if (characterAction == AnimationStates.STANDING && !currentCharacter.GetIsJumping()) { animator.SetFloat("Horizontal", 0); currentCharacter.EndAnimation(AnimationStates.STANDING); } else if (characterAction == AnimationStates.JUMPING_BACKWARDS) { switch (currentCharacter.GetIsFlipped()) { case true: characterActions.Jump(rigidBody, "JumpingRight"); break; case false: characterActions.Jump(rigidBody, "JumpingLeft"); break; } } else if (characterAction == AnimationStates.JUMPING_FORWARDS) { switch (currentCharacter.GetIsFlipped()) { case true: characterActions.Jump(rigidBody, "JumpingLeft"); break; case false: characterActions.Jump(rigidBody, "JumpingRight"); break; } } else if (characterAction == AnimationStates.JUMPING_UP) { characterActions.Jump(rigidBody, "JumpingUp"); } else if (characterAction == AnimationStates.BLOCKING_JUMPING || characterAction == AnimationStates.BLOCKING_CROUCHING) { characterActions.Block(); characterActions.Invoke("StopBlocking", 5); //// Stops blocking after x seconds } ///// Swap characters if (characterAction == "SwapCharacter2") { characterAssist.Swap("Assist1", false); } else if (characterAction == "SwapCharacter3") { characterAssist.Swap("Assist2", false); } }
public int DoDamage() { if (Array.IndexOf(AnimationStates.GetAttacks(), animationStatus) >= 0) { return(character.GetAttackOutput(animationStatus)); } return(0); }
private IEnumerator HintCountdown() { yield return(new WaitForSeconds(1)); ShootHintProjectile(); quixelState = AnimationStates.idle; yield break; }
public SelectAnimation(int duration, Vector2 position, Texture2D texture) { this.texture = texture; //assume square frames in a single row nofFrames = texture.Width / texture.Height; int ribLength = texture.Height; sourceRects = new List<Rectangle>(); for (int i = nofFrames - 1; i >= 0; i--) sourceRects.Add(new Rectangle(i * ribLength, 0, ribLength, texture.Height)); frameTime = duration / nofFrames; origin = new Vector2(ribLength / 2, texture.Height / 2); this.position = position; animationState = AnimationStates.Ready; }
public virtual void Update(GameTime gameTime) { if (animationState == AnimationStates.Active) { elapsed += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (elapsed > frameTime) { currentFrame++; elapsed = 0; } if (currentFrame == nofFrames) { animationState = AnimationStates.Done; } } }
public void ResetAnimation() { frameNo = 0; timer = 0; finished = false; state = AnimationStates.FORWARD; }
public void AnimateOut() { switch (AnimationState) { case AnimationStates.Hiding: case AnimationStates.Hidden: break; case AnimationStates.Showing: AnimationStoryboard.Stop(); goto default; default: AnimationState = AnimationStates.Hiding; Animate(GetCurrentRects(), GetTargetRectsForHide()); break; } }
public void AnimateIn() { switch (AnimationState) { case AnimationStates.Shown: case AnimationStates.Showing: break; case AnimationStates.Hiding: AnimationStoryboard.Stop(); goto default; case AnimationStates.Hidden: default: SetBackgroundToMatchWallpaper(); AnimationState = AnimationStates.Showing; Animate(GetCurrentRects(), GetTargetRectsForShow()); break; } }
private void OnAnimationComplete(object sender, EventArgs e) { if (AnimationState == AnimationStates.Hiding) { AnimationState = AnimationStates.Hidden; } else { AnimationState = AnimationStates.Shown; foreach (ThumbnailBorder thumb in ThumbnailCanvas.Children) { thumb.ShowDecorations(); } } AnimationComplete(this, new EventArgs()); }
private void startAnimationOpen() { if (this.animationState == AnimationStates.Opening) return; this.animationState = AnimationStates.Opening; this.setAlignmentsForAnimation(); this.mainGrid.Width = 0; this.EditView.Width = this.ActualWidth; this.mainGrid.IsEnabled = true; this.startAnimation(0, this.ActualWidth, this.stopAnimationOpen); }
private void stopAnimationClose() { this.animationToken = null; this.animationState = AnimationStates.Closing; this.mainGrid.BeginAnimation(WidthProperty, null); this.mainGrid.Width = 0; this.Hide(); }
private void startAnimationClose() { if (this.animationState == AnimationStates.Closing) return; this.animationState = AnimationStates.Closing; this.setAlignmentsForAnimation(); this.EditView.Width = this.ActualWidth; this.mainGrid.IsEnabled = false; this.startAnimation(this.ActualWidth, 0, this.stopAnimationClose); }
private void stopAnimationOpen() { this.animationToken = null; this.animationState = AnimationStates.Opening; this.mainGrid.BeginAnimation(WidthProperty, null); this.mainGrid.Width = double.NaN; this.EditView.Width = double.NaN; this.mainGrid.HorizontalAlignment = HorizontalAlignment.Stretch; this.EditView.HorizontalAlignment = HorizontalAlignment.Stretch; this.mainGrid.IsEnabled = true; }