public override void Attack(PlayerAttack attack, BattleCombatant target) { currentAttack = attack; currentAttackTarget = target; if (attack.Name == "Fried Chicken Smoothie") { anim.Play("Jumping"); playSound(healSound); currentAttackTarget.Heal(); } else if (attack.Name == "All-Purpose Slice") { initialPosition = transform.position; AnimationInProgress = true; currentAnimation = AnimationSequence.JumpForward; attackAnimationState = AttackAnimationState.NeedsToStart; } else if (attack.Name == "Sales Pitch") { initialPosition = transform.position; AnimationInProgress = true; currentAnimation = AnimationSequence.SalesPitch; attackAnimationState = AttackAnimationState.NeedsToStart; } }
private void animLaserFire() { switch(attackAnimationState) { case AttackAnimationState.NeedsToStart: LaserFire.Play(); playSound(LaserFireSound); attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: LaserFire.transform.Rotate (new Vector3(0, 0, 10) * Time.deltaTime); if(LaserFire.transform.rotation.eulerAngles.z > 9 && LaserFire.transform.rotation.eulerAngles.z < 10) { LaserFire.Stop(); LaserFire.Clear(); LaserFire.transform.localRotation = initialLaserRot; currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; //EVERYONE DIES HAHAHAHAHAHAH targets.ForEach(t => t.Damage(AttackPower)); AnimationInProgress = false; } break; } }
public override void AutoAttack(List <BattleCombatant> targetList) { if (currentChargeCount == chargesRequred) { // do crazy attack targets = targetList; AnimationInProgress = true; currentAnimation = AnimationSequence.LaserCharge; attackAnimationState = AttackAnimationState.NeedsToStart; currentChargeCount = 0; } else { currentChargeCount++; // do a simple attack target = getWeakestTarget(targetList); AnimationInProgress = true; currentAnimation = AnimationSequence.LameBounce; attackAnimationState = AttackAnimationState.NeedsToStart; startTimer(); } }
private void animReturningFromSlamming() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: rigidbody2D.gravityScale = 1; GetComponent <BoxCollider2D>().enabled = true; attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: if (rigidbody2D.velocity.magnitude < 0.01f) { anim.SetTrigger("Finished"); originalBasketball.transform.localPosition = originalBasketballLocalPos; originalBasketball.renderer.enabled = true; attackAnimationState = AttackAnimationState.Complete; } break; case AttackAnimationState.Complete: currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; break; } }
public override void AutoAttack(List <BattleCombatant> targetList) { //select the player with the lowest HP as the target // allows you to call autoattack without a target // this is so we can trigger the orphanrush animation outside of the battle if (targetList != null) { target = targetList.OrderByDescending(t => t.HitPoints).First(); } //if our HP is low, use the SUPER ORPHAN RUSH attack if (HitPoints / (float)MaxHitPoints < 0.2f) { orphanRushParticles.emissionRate = 15; poweredUp = true; } else { orphanRushParticles.emissionRate = 5; poweredUp = false; } AnimationInProgress = true; attackAnimationState = AttackAnimationState.NeedsToStart; startTimer(); }
// Update is called once per frame public override void Update() { base.Update(); switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: if (timerIsGreaterThan(0.5f)) { GetComponent <Animator>().SetBool("IsAttacking", true); attackAnimationState = AttackAnimationState.InProgress; playSound(gunshotSound); target.Damage(AttackPower); startTimer(); } break; case AttackAnimationState.InProgress: if (timerIsGreaterThan(0.5f)) { GetComponent <Animator>().SetBool("IsAttacking", false); stopTimer(); attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; } break; } }
// Update is called once per frame public override void Update () { base.Update(); switch(attackAnimationState) { case AttackAnimationState.NeedsToStart: if(timerIsGreaterThan(0.5f)) { GetComponent<Animator>().SetBool("IsAttacking", true); attackAnimationState = AttackAnimationState.InProgress; playSound(gunshotSound); target.Damage(AttackPower); startTimer(); } break; case AttackAnimationState.InProgress: if(timerIsGreaterThan(0.5f)) { GetComponent<Animator>().SetBool("IsAttacking", false); stopTimer(); attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; } break; } }
private void animLaserFire() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: LaserFire.Play(); playSound(LaserFireSound); attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: LaserFire.transform.Rotate(new Vector3(0, 0, 10) * Time.deltaTime); if (LaserFire.transform.rotation.eulerAngles.z > 9 && LaserFire.transform.rotation.eulerAngles.z < 10) { LaserFire.Stop(); LaserFire.Clear(); LaserFire.transform.localRotation = initialLaserRot; currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; //EVERYONE DIES HAHAHAHAHAHAH targets.ForEach(t => t.Damage(AttackPower)); AnimationInProgress = false; } break; } }
private void animLaserFire() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: LaserFire.enableEmission = true; playSound(LaserFireSound); attackAnimationState = AttackAnimationState.InProgress; startTimer(); break; case AttackAnimationState.InProgress: if (timerIsGreaterThan(2.5f)) { LaserFire.enableEmission = false; currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; targets.ForEach(t => t.Damage(t.MaxHitPoints - 1)); AnimationInProgress = false; } break; } }
private void UpdateAttackAnimation() { if (attackAnimationState == AttackAnimationState.GOING_BACKWARDS) { backwardsVector2Lerper.Update(); transform.GetChild(0).localPosition = backwardsVector2Lerper.CurrentValue; if (backwardsVector2Lerper.Reached) { attackAnimationState = AttackAnimationState.GOING_FORWARD; forwardVector2Lerper = new Vector2Lerper(transform.GetChild(0).localPosition, target.transform.position - transform.position, 0.05f); forwardVector2Lerper.SetValues(transform.GetChild(0).localPosition, target.transform.position - transform.position, true); } } else { forwardVector2Lerper.Update(); transform.GetChild(0).localPosition = forwardVector2Lerper.CurrentValue; if (forwardVector2Lerper.Reached) { attackAnimationState = AttackAnimationState.NOT_PLAYING; DamageCallback(); AudioController.instance.PlayPunchSound(); //The amount of time we want the footman to be on the enemy Invoke("ResetAttackPosition", 0.3f); } } }
public override void AutoAttack (List<BattleCombatant> targetList) { //select the player with the lowest HP as the target target = getRandomTarget (targetList); AnimationInProgress = true; attackAnimationState = AttackAnimationState.NeedsToStart; startTimer(); }
public override void AutoAttack(List <BattleCombatant> targetList) { //select the player with the lowest HP as the target target = getRandomTarget(targetList); AnimationInProgress = true; attackAnimationState = AttackAnimationState.NeedsToStart; startTimer(); }
public override void PlayAttackAnimation() { animator.enabled = false; attackAnimationState = AttackAnimationState.GOING_BACKWARDS; backwardsVector2Lerper = new Vector2Lerper(new Vector2(0f, 0f), -GetAttackingDirection() / 8, 0.3f); backwardsVector2Lerper.SetValues(new Vector2(0f, 0f), -GetAttackingDirection() / 8, true); }
// Update is called once per frame public override void Update () { base.Update(); // FF loses his shield when powered up if(!poweredUp) { // FF is shielded so long as the orphan is awake isShielded = !orphanShield.isSleeping; } else { isShielded = false; } switch(attackAnimationState) { case AttackAnimationState.NeedsToStart: GetComponent<Animator>().SetTrigger("FistPump"); if(timerIsGreaterThan(0.5f)) { orphanRushParticles.time = 0; orphanRushParticles.Play(); attackAnimationState = AttackAnimationState.InProgress; playSound(OrphanRushSound); orphanRushParticles = Instantiate(OrphanRushPrefab) as ParticleSystem; orphanRushParticles.transform.parent = transform; orphanRushParticles.transform.localPosition = new Vector3(2.0f, 0, 0); startTimer(); } break; case AttackAnimationState.InProgress: if(timerIsGreaterThan(1.4f)) { if(target != null) { if(poweredUp == true) { // don't kill him on the first attack if(isFirstPoweredUpAttack) { target.Damage(target.HitPoints - 2); isFirstPoweredUpAttack = false; } else { target.Damage(52); } } else { target.Damage(23); } } stopTimer(); attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; } break; } }
private void Update() { #region 处理远端玩家动画的同步 if (_attackAnimationState == AttackAnimationState.Execute) { remoteRoleAnimator.SetTrigger("toAttack"); _attackAnimationState = AttackAnimationState.StandBy; } #endregion }
private void animPrepareToSlam() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: Vector2 launchForce = new Vector2(0f, 300f); originalBasketball.localPosition = new Vector2(0.18f, 0.21f); GetComponent <BoxCollider2D>().enabled = false; rigidbody2D.AddForce(launchForce); anim.SetTrigger("Dunking"); attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: if (rigidbody2D.velocity.magnitude < 0.8) { anim.SetTrigger("Slamming"); rigidbody2D.gravityScale = 0; originalBasketball.renderer.enabled = false; attacksketball.position = transform.position + new Vector3(0.18f, 0.21f, 0.0f); basketballVelocity = currentAttackTarget.transform.position - attacksketball.position; basketballVelocity *= 2; attacksketball.renderer.enabled = true; playSound(throwSound); attackAnimationState = AttackAnimationState.Complete; } break; case AttackAnimationState.Complete: attacksketball.position = attacksketball.position + basketballVelocity * Time.fixedDeltaTime; if (attacksketball.position.x > (currentAttackTarget.transform.position.x - 0.1)) { attacksketball.renderer.enabled = false; currentAttackTarget.Damage(currentAttack.Power); playSound(hitSound); currentAnimation = AnimationSequence.ReturningFromSlamming; attackAnimationState = AttackAnimationState.NeedsToStart; } break; } }
private void animLameBounce() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: if (timerIsGreaterThan(1.0f)) { initialPosition = transform.position; lameBounceVelocity = (transform.position - Vector3.right / 2) - transform.position; lameBounceVelocity *= 3; playSound(hitSound); target.Damage(1); startTimer(); attackAnimationState = AttackAnimationState.InProgress; } break; case AttackAnimationState.InProgress: transform.position = transform.position + lameBounceVelocity * Time.fixedDeltaTime; if (timerIsGreaterThan(0.1f)) { attackAnimationState = AttackAnimationState.Complete; startTimer(); } break; case AttackAnimationState.Complete: transform.position = initialPosition; if (timerIsGreaterThan(0.5f)) { currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; } break; } }
private void Awake() { IdleAnimationState = new IdleAnimationState(this); JumpAnimationState = new JumpAnimationState(); AttackAnimationState = new AttackAnimationState(); BlockAnimationState = new BlockAnimationState(); EvadeAnimationState = new EvadeAnimationState(); HitAnimationState = new HitAnimationState(); DieAnimationState = new DieAnimationState(); DanceAnimationState = new DanceAnimationState(); InteractAnimationState = new InteractAnimationState(); MovementBlendTree = new MovementBlendTree(this); SetupAnimations(); mainAnimationState = IdleAnimationState; }
protected override void Update() { if (attackAnimationState != AttackAnimationState.NOT_PLAYING) { if (target) { UpdateAttackAnimation(); } else { ResetAttackPosition(); attackAnimationState = AttackAnimationState.NOT_PLAYING; } } base.Update(); }
public override void Attack(PlayerAttack attack, BattleCombatant target) { currentAttack = attack; currentAttackTarget = target; if (attack.Name == "Slam Dunk") { AnimationInProgress = true; currentAnimation = AnimationSequence.PreparingToSlam; attackAnimationState = AttackAnimationState.NeedsToStart; } else if (attack.Name == "Gatorade\u2122 Sports Drink") { playSound(healSound); currentAttackTarget.Heal(); } }
private void animFlyTowardsTarget() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: initialPosition = transform.position; GetComponent <JamesGasBehavior>().EnableFlightMode(); attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: rigidbody2D.AddForce(new Vector2(0, 400) * Time.fixedDeltaTime); if (transform.position.y > 0.1f) { playSound(GasBlastSound); attackAnimationState = AttackAnimationState.Complete; } break; case AttackAnimationState.Complete: rigidbody2D.AddForce(currentAttackTarget.transform.position - transform.position * 250 * Time.fixedDeltaTime); if (transform.rotation.eulerAngles.z < 170 && transform.rotation.eulerAngles.z > 163) { currentAttackTarget.Damage(currentAttack.Power); currentAnimation = AnimationSequence.FlyingBack; attackAnimationState = AttackAnimationState.NeedsToStart; } break; } }
public override void AutoAttack(List <BattleCombatant> targetList) { if (currentChargeCount == chargesRequred) { targets = targetList; AnimationInProgress = true; currentAnimation = AnimationSequence.LaserCharge; attackAnimationState = AttackAnimationState.NeedsToStart; currentChargeCount = 0; } else { currentChargeCount++; } StaffGlow.gravityModifier = Mathf.Lerp(-0.001f, -0.02f, currentChargeCount / (float)chargesRequred); }
public override void Attack(PlayerAttack attack, BattleCombatant target) { currentAttack = attack; currentAttackTarget = target; if (attack.Name == "Gas Blast") { initialPosition = transform.position; AnimationInProgress = true; currentAnimation = AnimationSequence.FlyingTowardsTarget; attackAnimationState = AttackAnimationState.NeedsToStart; } else if (attack.Name == "Can of Beans") { playSound(HealSound); currentAttackTarget.Heal(); } }
private void animJumpForward() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: Vector2 launchVelocity = new Vector2(7f, 0f); setDragEnabled(false); //calculate the needed initial vertical speed to reach the target float dist = currentAttackTarget.transform.position.x - transform.position.x - 0.3f; float time = dist / launchVelocity.x; launchVelocity.y = Mathf.Abs(Physics2D.gravity.y) / 2 * time; // cheap hack to hit floating bosses if (currentAttackTarget.transform.position.y > transform.position.y + 0.2) { launchVelocity.y += 4f; } rigidbody2D.velocity = launchVelocity; attackAnimationState = AttackAnimationState.InProgress; GetComponent <Animator> ().SetBool("IsAttacking", true); break; case AttackAnimationState.InProgress: if (transform.position.x > currentAttackTarget.transform.position.x - 1f) { playSound(knifeSlash); currentAttackTarget.Damage(currentAttack.Power); attackAnimationState = AttackAnimationState.Complete; } break; case AttackAnimationState.Complete: if (rigidbody2D.velocity == Vector2.zero) { currentAnimation = AnimationSequence.JumpBackward; attackAnimationState = AttackAnimationState.NeedsToStart; } break; } }
private void animLaserCharge() { switch(attackAnimationState) { case AttackAnimationState.NeedsToStart: LaserCharge.Play(); attackAnimationState = AttackAnimationState.InProgress; playSound(LaserChargeSound); break; case AttackAnimationState.InProgress: if(LaserCharge.time >= 2.5) { currentAnimation = AnimationSequence.LaserFire; attackAnimationState = AttackAnimationState.NeedsToStart; LaserFire.Stop(); } break; } }
private void animSalesPitch() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: GetComponent <Animator>().SetFloat("Speed", 10); GetComponent <ConstantVelocity>().enabled = true; GetComponent <ConstantVelocity>().velocity = Vector2.right * 3; attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: if (transform.position.x > currentAttackTarget.transform.position.x - 0.5f) { GetComponent <ConstantVelocity>().enabled = false; GetComponent <Animator>().SetFloat("Speed", 0); attackAnimationState = AttackAnimationState.Complete; salesPitchParticles.transform.position = transform.position; salesPitchParticles.time = 0; salesPitchParticles.Play(); startTimer(); } break; case AttackAnimationState.Complete: if (timerIsGreaterThan(1.0f)) { currentAnimation = AnimationSequence.JumpBackward; attackAnimationState = AttackAnimationState.NeedsToStart; currentAttackTarget.PutToSleep(currentAttack.Power); } break; } }
private void animFlyTowardsTarget () { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: initialPosition = transform.position; GetComponent<JamesGasBehavior>().EnableFlightMode(); attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: rigidbody2D.AddForce(new Vector2(0, 400) * Time.fixedDeltaTime); if(transform.position.y > 0.1f) { playSound(GasBlastSound); attackAnimationState = AttackAnimationState.Complete; } break; case AttackAnimationState.Complete: rigidbody2D.AddForce(currentAttackTarget.transform.position - transform.position * 250 * Time.fixedDeltaTime); if(transform.rotation.eulerAngles.z < 170 && transform.rotation.eulerAngles.z > 163) { currentAttackTarget.Damage(currentAttack.Power); currentAnimation = AnimationSequence.FlyingBack; attackAnimationState = AttackAnimationState.NeedsToStart; } break; } }
private void animJumpBackward() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: Vector2 launchVelocity = new Vector2(-7f, 0f); setDragEnabled(false); //calculate the needed initial vertical speed to reach the initial position float dist = initialPosition.x - transform.position.x; float time = dist / launchVelocity.x; launchVelocity.y = Mathf.Abs(Physics2D.gravity.y) / 2 * time; rigidbody2D.velocity = launchVelocity; attackAnimationState = AttackAnimationState.InProgress; GetComponent <Animator>().SetBool("IsAttacking", false); break; case AttackAnimationState.InProgress: if (transform.position.x < initialPosition.x + 0.2f) { rigidbody2D.velocity = Vector2.zero; currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; // reset X position to inital value transform.position = new Vector3(initialPosition.x, transform.position.y, initialPosition.z); // reset drag to initial value setDragEnabled(true); } break; } }
private void animFlyingBack() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: rigidbody2D.AddForce(new Vector2(-400, 100) * Time.deltaTime); if (transform.position.x < initialPosition.x + 0.1f) { attackAnimationState = AttackAnimationState.InProgress; } break; case AttackAnimationState.InProgress: GetComponent <JamesGasBehavior>().DisableFlightMode(); rigidbody2D.velocity = Vector2.zero; attackAnimationState = AttackAnimationState.Complete; break; case AttackAnimationState.Complete: if (transform.position.y < initialPosition.y + 0.2) { currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; transform.position = new Vector3(initialPosition.x, transform.position.y, transform.position.z); } break; } }
private void animLaserCharge() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: LaserCharge.Play(); attackAnimationState = AttackAnimationState.InProgress; playSound(LaserChargeSound); break; case AttackAnimationState.InProgress: if (LaserCharge.time >= 3.0) { currentAnimation = AnimationSequence.LaserFire; attackAnimationState = AttackAnimationState.NeedsToStart; LaserCharge.Stop(); } break; } }
public override void Update(GameTime gameTime) { base.Update(gameTime); // Attack animation if (AnimationState == AttackAnimationState.Starting) { if (RenderingPosition == RenderingPosition.Ally) Position = new Vector2(Position.X + 3, Position.Y); else Position = new Vector2(Position.X - 3, Position.Y); FrameCounter++; if (FrameCounter == FramesToApex) AnimationState = AttackAnimationState.Ending; } else if (AnimationState == AttackAnimationState.Ending) { if (RenderingPosition == RenderingPosition.Ally) Position = new Vector2(Position.X - 3, Position.Y); else Position = new Vector2(Position.X + 3, Position.Y); FrameCounter--; if (FrameCounter == 0) AnimationState = AttackAnimationState.Ended; } // Hit animation if (Hit) { if (FrameCounter == 0) HitInvisible = !HitInvisible; FrameCounter++; if (FrameCounter == FlickerInterval) { FrameCounter = 0; FlickerCounter++; } if (FlickerCounter == FlickerDuration) { FlickerCounter = 0; Hit = false; HitInvisible = false; } } }
private void animJumpForward () { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: Vector2 launchVelocity = new Vector2 (7f, 0f); setDragEnabled(false); //calculate the needed initial vertical speed to reach the target float dist = currentAttackTarget.transform.position.x - transform.position.x - 0.3f; float time = dist / launchVelocity.x; launchVelocity.y = Mathf.Abs (Physics2D.gravity.y) / 2 * time; // cheap hack to hit floating bosses if(currentAttackTarget.transform.position.y > transform.position.y + 0.2) { launchVelocity.y += 4f; } rigidbody2D.velocity = launchVelocity; attackAnimationState = AttackAnimationState.InProgress; GetComponent<Animator> ().SetBool ("IsAttacking", true); break; case AttackAnimationState.InProgress: if (transform.position.x > currentAttackTarget.transform.position.x - 1f) { playSound (knifeSlash); currentAttackTarget.Damage (currentAttack.Power); attackAnimationState = AttackAnimationState.Complete; } break; case AttackAnimationState.Complete: if (rigidbody2D.velocity == Vector2.zero) { currentAnimation = AnimationSequence.JumpBackward; attackAnimationState = AttackAnimationState.NeedsToStart; } break; } }
// Update is called once per frame public override void Update() { base.Update(); // FF loses his shield when powered up if (!poweredUp) { // FF is shielded so long as the orphan is awake isShielded = !orphanShield.isSleeping; } else { isShielded = false; } switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: GetComponent <Animator>().SetTrigger("FistPump"); if (timerIsGreaterThan(0.5f)) { orphanRushParticles.time = 0; orphanRushParticles.Play(); attackAnimationState = AttackAnimationState.InProgress; playSound(OrphanRushSound); orphanRushParticles = Instantiate(OrphanRushPrefab) as ParticleSystem; orphanRushParticles.transform.parent = transform; orphanRushParticles.transform.localPosition = new Vector3(2.0f, 0, 0); startTimer(); } break; case AttackAnimationState.InProgress: if (timerIsGreaterThan(1.4f)) { if (target != null) { if (poweredUp == true) { // don't kill him on the first attack if (isFirstPoweredUpAttack) { target.Damage(target.HitPoints - 2); isFirstPoweredUpAttack = false; } else { target.Damage(52); } } else { target.Damage(23); } } stopTimer(); attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; } break; } }
private void animJumpBackward() { switch(attackAnimationState) { case AttackAnimationState.NeedsToStart: Vector2 launchVelocity = new Vector2(-7f, 0f); setDragEnabled(false); //calculate the needed initial vertical speed to reach the initial position float dist = initialPosition.x - transform.position.x; float time = dist / launchVelocity.x; launchVelocity.y = Mathf.Abs(Physics2D.gravity.y) / 2 * time; rigidbody2D.velocity = launchVelocity; attackAnimationState = AttackAnimationState.InProgress; GetComponent<Animator>().SetBool("IsAttacking", false); break; case AttackAnimationState.InProgress: if(transform.position.x < initialPosition.x + 0.2f) { rigidbody2D.velocity = Vector2.zero; currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; // reset X position to inital value transform.position = new Vector3(initialPosition.x, transform.position.y, initialPosition.z); // reset drag to initial value setDragEnabled(true); } break; } }
private void animPrepareToSlam () { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: Vector2 launchForce = new Vector2 (0f, 300f); originalBasketball.localPosition = new Vector2(0.18f, 0.21f); GetComponent<BoxCollider2D>().enabled = false; rigidbody2D.AddForce(launchForce); anim.SetTrigger ("Dunking"); attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: if (rigidbody2D.velocity.magnitude < 0.8) { anim.SetTrigger ("Slamming"); rigidbody2D.gravityScale = 0; originalBasketball.renderer.enabled = false; attacksketball.position = transform.position + new Vector3(0.18f, 0.21f, 0.0f); basketballVelocity = currentAttackTarget.transform.position - attacksketball.position; basketballVelocity *= 2; attacksketball.renderer.enabled = true; playSound(throwSound); attackAnimationState = AttackAnimationState.Complete; } break; case AttackAnimationState.Complete: attacksketball.position = attacksketball.position + basketballVelocity * Time.fixedDeltaTime; if(attacksketball.position.x > (currentAttackTarget.transform.position.x - 0.1) ) { attacksketball.renderer.enabled = false; currentAttackTarget.Damage(currentAttack.Power); playSound(hitSound); currentAnimation = AnimationSequence.ReturningFromSlamming; attackAnimationState = AttackAnimationState.NeedsToStart; } break; } }
public override void Attack(PlayerAttack attack, BattleCombatant target) { currentAttack = attack; currentAttackTarget = target; if(attack.Name == "Slam Dunk") { AnimationInProgress = true; currentAnimation = AnimationSequence.PreparingToSlam; attackAnimationState = AttackAnimationState.NeedsToStart; } else if(attack.Name == "Gatorade\u2122 Sports Drink") { playSound(healSound); currentAttackTarget.Heal(); } }
private void animReturningFromSlamming () { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: rigidbody2D.gravityScale = 1; GetComponent<BoxCollider2D>().enabled = true; attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: if(rigidbody2D.velocity.magnitude < 0.01f) { anim.SetTrigger("Finished"); originalBasketball.transform.localPosition = originalBasketballLocalPos; originalBasketball.renderer.enabled = true; attackAnimationState = AttackAnimationState.Complete; } break; case AttackAnimationState.Complete: currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; break; } }
/// <summary> /// 处理同步动作响应 /// </summary> /// <param name="data"></param> public override void OnResponse(string data) { _attackAnimationState = AttackAnimationState.Execute; }
public override void Attack(PlayerAttack attack, BattleCombatant target) { currentAttack = attack; currentAttackTarget = target; if(attack.Name == "Fried Chicken Smoothie") { anim.Play("Jumping"); playSound(healSound); currentAttackTarget.Heal(); } else if(attack.Name == "All-Purpose Slice") { initialPosition = transform.position; AnimationInProgress = true; currentAnimation = AnimationSequence.JumpForward; attackAnimationState = AttackAnimationState.NeedsToStart; } else if(attack.Name == "Sales Pitch") { initialPosition = transform.position; AnimationInProgress = true; currentAnimation = AnimationSequence.SalesPitch; attackAnimationState = AttackAnimationState.NeedsToStart; } }
private void animSalesPitch() { switch(attackAnimationState) { case AttackAnimationState.NeedsToStart: GetComponent<Animator>().SetFloat("Speed", 10); GetComponent<ConstantVelocity>().enabled = true; GetComponent<ConstantVelocity>().velocity = Vector2.right * 3; attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: if(transform.position.x > currentAttackTarget.transform.position.x - 0.5f) { GetComponent<ConstantVelocity>().enabled = false; GetComponent<Animator>().SetFloat("Speed", 0); attackAnimationState = AttackAnimationState.Complete; salesPitchParticles.transform.position = transform.position; salesPitchParticles.time = 0; salesPitchParticles.Play(); startTimer(); } break; case AttackAnimationState.Complete: if (timerIsGreaterThan(1.0f)) { currentAnimation = AnimationSequence.JumpBackward; attackAnimationState = AttackAnimationState.NeedsToStart; currentAttackTarget.PutToSleep (currentAttack.Power); } break; } }
public override void AutoAttack (List<BattleCombatant> targetList) { //select the player with the lowest HP as the target // allows you to call autoattack without a target // this is so we can trigger the orphanrush animation outside of the battle if(targetList != null) { target = targetList.OrderByDescending(t => t.HitPoints).First(); } //if our HP is low, use the SUPER ORPHAN RUSH attack if(HitPoints / (float)MaxHitPoints < 0.2f) { orphanRushParticles.emissionRate = 15; poweredUp = true; } else { orphanRushParticles.emissionRate = 5; poweredUp = false; } AnimationInProgress = true; attackAnimationState = AttackAnimationState.NeedsToStart; startTimer(); }
private void animLameBounce() { switch(attackAnimationState) { case AttackAnimationState.NeedsToStart: if(timerIsGreaterThan(1.0f)) { initialPosition = transform.position; lameBounceVelocity = (transform.position - Vector3.right/2) - transform.position; lameBounceVelocity *= 3; playSound(hitSound); target.Damage(1); startTimer(); attackAnimationState = AttackAnimationState.InProgress; } break; case AttackAnimationState.InProgress: transform.position = transform.position + lameBounceVelocity * Time.fixedDeltaTime; if(timerIsGreaterThan(0.1f)) { attackAnimationState = AttackAnimationState.Complete; startTimer(); } break; case AttackAnimationState.Complete: transform.position = initialPosition; if(timerIsGreaterThan(0.5f)) { currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; } break; } }
public override void AutoAttack (List<BattleCombatant> targetList) { if(currentChargeCount == chargesRequred) { // do crazy attack targets = targetList; AnimationInProgress = true; currentAnimation = AnimationSequence.LaserCharge; attackAnimationState = AttackAnimationState.NeedsToStart; currentChargeCount = 0; } else { currentChargeCount++; // do a simple attack target = getWeakestTarget(targetList); AnimationInProgress = true; currentAnimation = AnimationSequence.LameBounce; attackAnimationState = AttackAnimationState.NeedsToStart; startTimer(); } }
public override void AutoAttack (List<BattleCombatant> targetList) { if(currentChargeCount == chargesRequred) { targets = targetList; AnimationInProgress = true; currentAnimation = AnimationSequence.LaserCharge; attackAnimationState = AttackAnimationState.NeedsToStart; currentChargeCount = 0; } else { currentChargeCount++; } StaffGlow.gravityModifier = Mathf.Lerp (-0.001f, -0.02f, currentChargeCount / (float)chargesRequred); }
private void animLaserFire() { switch(attackAnimationState) { case AttackAnimationState.NeedsToStart: LaserFire.enableEmission = true; playSound(LaserFireSound); attackAnimationState = AttackAnimationState.InProgress; startTimer(); break; case AttackAnimationState.InProgress: if(timerIsGreaterThan(2.5f)) { LaserFire.enableEmission = false; currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; targets.ForEach(t => t.Damage(t.MaxHitPoints - 1)); AnimationInProgress = false; } break; } }
private void animFlyingBack () { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: rigidbody2D.AddForce(new Vector2(-400, 100) * Time.deltaTime); if(transform.position.x < initialPosition.x + 0.1f) { attackAnimationState = AttackAnimationState.InProgress; } break; case AttackAnimationState.InProgress: GetComponent<JamesGasBehavior>().DisableFlightMode(); rigidbody2D.velocity = Vector2.zero; attackAnimationState = AttackAnimationState.Complete; break; case AttackAnimationState.Complete: if(transform.position.y < initialPosition.y + 0.2) { currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; AnimationInProgress = false; transform.position = new Vector3(initialPosition.x, transform.position.y, transform.position.z); } break; } }
public override void Attack(PlayerAttack attack, BattleCombatant target) { currentAttack = attack; currentAttackTarget = target; if(attack.Name == "Gas Blast") { initialPosition = transform.position; AnimationInProgress = true; currentAnimation = AnimationSequence.FlyingTowardsTarget; attackAnimationState = AttackAnimationState.NeedsToStart; } else if(attack.Name == "Can of Beans") { playSound(HealSound); currentAttackTarget.Heal(); } }