private void Start() { m_LocalBounds = new Bounds(); int count = m_CharacterController2D.Rigidbody2D.GetAttachedColliders(s_ColliderCache); for (int i = 0; i < count; ++i) { m_LocalBounds.Encapsulate(transform.InverseTransformBounds(s_ColliderCache[i].bounds)); } m_Filter = new ContactFilter2D(); m_Filter.layerMask = m_CharacterController2D.groundedLayerMask; m_Filter.useLayerMask = true; m_Filter.useTriggers = false; if (meleeDamager) { meleeDamager.DisableDamage(); m_LocalDamagerPosition = meleeDamager.transform.localPosition; } if (contactDamager) { contactDamager.EnableDamage(); } }
public void EndAttack() { if (meleeDamager != null) { //meleeDamager.gameObject.SetActive(false); meleeDamager.DisableDamage(); } }
public void DisableDamage() { if (contactDamager != null) { contactDamager.DisableDamage(); } }
public void Die(Damager damager, Damageable damageable) { m_RigidBody2D.velocity = Vector2.zero; bodyDamager.DisableDamage(); m_Animator.SetTrigger(m_HashDeathPara); StartCoroutine(DieEffectCoroutine()); }
/// <summary> /// Performs an attack. /// </summary> /// <returns>The current ienumerator step.</returns> IEnumerator AttackTimer() { m_IsAttacking = true; m_ActiveDamager.EnableDamage(); yield return(new WaitForSeconds(m_AttackClip.length)); m_ActiveDamager.DisableDamage(); m_IsAttacking = false; }
public void OnEnemyDie(Damager damager, Damageable damageable) { m_Animator.SetTrigger(m_HashDead); m_Dead = true; meleeDamager.DisableDamage(); contactDamager.DisableDamage(); m_Collider.isTrigger = true; GetComponent <Rigidbody2D>().isKinematic = true; }
private void SpawnConcentratingAttack() { Vector3 spawnPosition = new Vector3(targetToTrack.transform.position.x, targetToTrack.transform.position.y + 0.5f, 0); BulletObject concentratingAttack = m_ConcentratingAttackPool.Pop(spawnPosition); m_CurrentConcentratingAttack = concentratingAttack.bullet.GetComponent <Damager>(); m_CurrentConcentratingAttack.DisableDamage(); }
public void EndMeleeAttack() { if (meleeDamager != null) { meleeDamager.gameObject.SetActive(false); meleeDamager.DisableDamage(); } m_IsAttacking = false; }
/// <summary> /// Performs the attack action. /// </summary> /// <returns>The current ienumerator step.</returns> IEnumerator AttackTimer() { m_IsAttacking = true; m_Damager.EnableDamage(); yield return(new WaitForSeconds(m_AttackClip.length)); m_Damager.DisableDamage(); m_IsAttacking = false; m_BasicEnemy.SetDefaultAction(); OnAttackEvent.Invoke(); }
public void DeActive() { m_SpriteRenderer.sortingOrder = 0; Color color = m_SpriteRenderer.color; color.a = 0.8f; m_SpriteRenderer.color = color; bodyDamager.DisableDamage(); actived = false; }
void Start() { hurtJumpAngle = Mathf.Clamp(hurtJumpAngle, minHurtJumpAngle, maxHurtJumpAngle); tanHurtJumpAngle = Mathf.Tan(Mathf.Deg2Rad * hurtJumpAngle); flickeringWait = new WaitForSeconds(flickeringDuration); meleeDamager.DisableDamage(); if (!Mathf.Approximately(maxHorizontalDeltaDampTime, 0f)) { float maxHorizontalDelta = maxSpeed * cameraHorizontalSpeedOffset + cameraHorizontalFacingOffset; camFollowHorizontalSpeed = maxHorizontalDelta / maxHorizontalDeltaDampTime; } if (!Mathf.Approximately(maxVerticalDeltaDampTime, 0f)) { float maxVerticalDelta = cameraVerticalInputOffset; camFollowVerticalSpeed = maxVerticalDelta / maxVerticalDeltaDampTime; } startingPosition = transform.position; startingFacingLeft = (GetFacing() < 0.0f); }
void Start() { hurtJumpAngle = Mathf.Clamp(hurtJumpAngle, minHurtJumpAngle, maxHurtJumpAngle); tanHurtJumpAngle = Mathf.Tan(Mathf.Deg2Rad * hurtJumpAngle); flickeringWait = new WaitForSeconds(flickeringDuration); meleeDamager.DisableDamage(); shotSpawnGap = 1f / shotsPerSecond; nextShotTime = Time.time; shotSpawnWait = new WaitForSeconds(shotSpawnGap); if (!Mathf.Approximately(maxHorizontalDeltaDampTime, 0f)) { float maxHorizontalDelta = maxSpeed * cameraHorizontalSpeedOffset + cameraHorizontalFacingOffset; camFollowHorizontalSpeed = maxHorizontalDelta / maxHorizontalDeltaDampTime; } if (!Mathf.Approximately(maxVerticalDeltaDampTime, 0f)) { float maxVerticalDelta = cameraVerticalInputOffset; camFollowVerticalSpeed = maxVerticalDelta / maxVerticalDeltaDampTime; } SceneLinkedSMB <PlayerCharacter> .Initialise(animator, this); startingPosition = transform.position; startingFacingLeft = (GetFacing() < 0.0f); wallSlideCooldownTimeRemaining = wallSlideCooldownDuration; wallSlideTimeRemaining = wallSlideTimeoutDuration; DisableWallSlide(); //DisableShield(); // LoseSword(); // DisableRangedAttack(); }
private void OrientToTarget() { if (targetToTrack == null) { return; } if (targetToTrack.position.x < m_ParentTransform.position.x) { transform.localScale = m_OriginalGraphicsLocalScale; leftHeadDamager.EnableDamage(); rightHeadDamager.DisableDamage(); } else { Vector3 reverseScale = m_OriginalGraphicsLocalScale; reverseScale.x *= -1; transform.localScale = reverseScale; leftHeadDamager.DisableDamage(); rightHeadDamager.EnableDamage(); } }
void Attack() { // During attack : nothing if (m_animator.animation.lastAnimationName == m_animationAttack && m_animator.animation.isPlaying == false) { EnableMovements(); if (m_damager != null) { m_damager.DisableDamage(); } } if (Input.GetButtonDown(m_buttonAttackName)) { m_animator.animation.Play(m_animationAttack); DisableMovements(); if (m_damager != null) { m_damager.EnableDamage(); } } }
public void DisableMiddleDamager() { middleDamager.DisableDamage(); }
void Start() { meleeDamager.DisableDamage(); // Turn off melee damager, as it should only be on when using a melee attack. // Hurt jump angle calculations. hurtJumpAngle = Mathf.Clamp(hurtJumpAngle, minHurtJumpAngle, maxHurtJumpAngle); tanHurtJumpAngle = Mathf.Tan(Mathf.Deg2Rad * hurtJumpAngle); // Set up ranged attack variables. shotSpawnGap = 1f / shotsPerSecond; nextShotTime = Time.time; shotSpawnWait = new WaitForSeconds(shotSpawnGap); // Camera follow speed calculations. if (!Mathf.Approximately(maxHorizontalDeltaDampTime, 0f)) { float maxHorizontalDelta = maxSpeed * cameraHorizontalSpeedOffset + cameraHorizontalFacingOffset; camFollowHorizontalSpeed = maxHorizontalDelta / maxHorizontalDeltaDampTime; } if (!Mathf.Approximately(maxVerticalDeltaDampTime, 0f)) { float maxVerticalDelta = cameraVerticalInputOffset; camFollowVerticalSpeed = maxVerticalDelta / maxVerticalDeltaDampTime; } SceneLinkedSMB <PlayerCharacter> .Initialise(animator, this); // Tells state machine to use this script to create and set up each state machine behaviour. flickeringWait = new WaitForSeconds(flickeringDuration); // Set up flicker WaitForSeconds, so it doesn't have to be set up multiple times. startingPosition = transform.position; // Set starting position. startingFacingLeft = (GetFacing() < 0.0f); // Set whether player started facing left or right. // Set available abilities at start. if (!wallSlideOn) { DisableWallSlide(); } else { EnableWallSlide(); } if (!meleeAttackOn) { DisableMeleeAttack(); } else { EnableMeleeAttack(); } if (!rangedAttackOn) { DisableRangedAttack(); } else { EnableRangedAttack(); } }
// Use this for initialization void Start() { bulletPool1 = BulletPool.GetObjectPool(bulletAttack1, 5); bulletPool3 = BulletPool.GetObjectPool(attack3Soldier, 7); vortexGroundEffect = BulletPool.GetObjectPool(spawnSoldierEffect, 7); explodingHash = VFXController.StringToHash("ExplodingHitEffect"); animator = GetComponentInChildren <Animator>(); rigidbody2D = GetComponent <Rigidbody2D>(); spriteRenderer = GetComponentInChildren <SpriteRenderer>(); boxCollider2D = GetComponent <BoxCollider2D>(); AliciaBT.OpenBranch( BT.Sequence().OpenBranch( BT.Wait(3), BT.Call(OrientToTarget), BT.SetBool(animator, "attack1", true), BT.WaitForAnimatorState(animator, "attack1"), BT.SetBool(animator, "attack1", false), BT.Call(Attack1), BT.WaitForAnimatorState(animator, "Idle"), BT.Call(() => Debug.Log("Finish Dash")) ), BT.Sequence().OpenBranch( BT.Wait(2f), BT.Call(OrientToTarget), BT.SetBool(animator, "dash", true), BT.WaitForAnimatorState(animator, "beforeDash"), BT.WaitForAnimatorState(animator, "dash"), BT.Call(MoveToTarget), BT.WaitUntil(MoveCheck), BT.SetBool(animator, "dash", false) ), BT.Sequence().OpenBranch( BT.Call(OrientToTarget), BT.SetBool(animator, "attack2", true), BT.WaitForAnimatorState(animator, "attack2"), BT.SetBool(animator, "attack2", false), BT.Call(Attack2) ), BT.Sequence().OpenBranch( BT.Wait(2f), BT.SetBool(animator, "backward", true), BT.WaitForAnimatorState(animator, "backward"), BT.Call(MoveBackWard), BT.WaitUntil(CheckMoveBackWard), BT.SetBool(animator, "attack3", true), BT.SetBool(animator, "backward", false), BT.WaitForAnimatorState(animator, "attack3"), BT.Call(() => fireShield.Play()), BT.Call(() => shieldDamager.EnableDamage()), BT.Call(PopVortex), BT.Call(SpawnSoldier), BT.Wait(2f), BT.Call(Attack3), BT.WaitUntil(Attack3Check), BT.SetBool(animator, "attack3", false), BT.Call(() => rigidbody2D.position = new Vector2(rigidbody2D.position.x, rigidbody2D.position.y - 0.55f)), BT.Call(() => fireShield.Stop()), BT.Call(() => shieldDamager.DisableDamage()), BT.Call(() => Debug.Log("after attack3")) ) ); }
public void DisableDamager() { attack2Damager.DisableDamage(); Debug.Log("Disabled"); }
public void EndAttacking() { slashAudioPlayer.Stop(); leftDamager.DisableDamage(); rightDamager.DisableDamage(); }
void Update() { if (!_enableMove) { if (!_motor.frozen) { _motor.frozen = true; } return; } else { if (_motor.frozen) { _motor.frozen = false; } } // use last state to restore some ladder specific values if (_motor.motorState != PlatformerMotor2D.MotorState.FreedomState) { // try to restore, sometimes states are a bit messy because change too much in one frame FreedomStateRestore(_motor); } // Jump? // If you want to jump in ladders, leave it here, otherwise move it down if (Input.GetButtonDown(PC2D.Input.JUMP)) { _motor.Jump(); _motor.DisableRestrictedArea(); if (_motor.IsOnLadder()) { _motor.LadderAreaExit(); } } _motor.jumpingHeld = Input.GetButton(PC2D.Input.JUMP); // XY freedom movement if (_motor.motorState == PlatformerMotor2D.MotorState.FreedomState) { _motor.normalizedXMovement = Input.GetAxis(PC2D.Input.HORIZONTAL); _motor.normalizedYMovement = Input.GetAxis(PC2D.Input.VERTICAL); return; // do nothing more } // X axis movement if (Mathf.Abs(Input.GetAxis(PC2D.Input.HORIZONTAL)) > PC2D.Globals.INPUT_THRESHOLD) { _motor.normalizedXMovement = Input.GetAxis(PC2D.Input.HORIZONTAL); } else { _motor.normalizedXMovement = 0; } if (Input.GetAxis(PC2D.Input.VERTICAL) != 0) { bool up_pressed = Input.GetAxis(PC2D.Input.VERTICAL) > 0; if (_motor.IsOnLadder()) { if ( (up_pressed && _motor.ladderZone == PlatformerMotor2D.LadderZone.Top) || (!up_pressed && _motor.ladderZone == PlatformerMotor2D.LadderZone.Bottom) ) { // do nothing! } // if player hit up, while on the top do not enter in freeMode or a nasty short jump occurs else { // example ladder behaviour _motor.FreedomStateEnter(); // enter freedomState to disable gravity _motor.EnableRestrictedArea(); // movements is retricted to a specific sprite bounds // now disable OWP completely in a "trasactional way" FreedomStateSave(_motor); _motor.enableOneWayPlatforms = false; _motor.oneWayPlatformsAreWalls = false; // start XY movement _motor.normalizedXMovement = Input.GetAxis(PC2D.Input.HORIZONTAL); _motor.normalizedYMovement = Input.GetAxis(PC2D.Input.VERTICAL); } } } else if (Input.GetAxis(PC2D.Input.VERTICAL) < -PC2D.Globals.FAST_FALL_THRESHOLD) { _motor.fallFast = false; } if (Input.GetKeyDown(PC2D.Input.START_SLIDE)) { //m_Animator.SetTrigger("slide"); m_Animator.Play("PlayerSlide"); _motor.Dash(); } if (Input.GetKeyDown(PC2D.Input.WAVE_SWORD)) { _motor.Wave(); if (_motor.motorState == PlatformerMotor2D.MotorState.JumpWave) { m_Animator.SetTrigger("jumpWave"); } else { m_Animator.SetTrigger("wave"); } meleeAttack.gameObject.SetActive(true); } if (Input.GetKeyUp(PC2D.Input.WAVE_SWORD)) { meleeAttack.gameObject.SetActive(false); meleeAttack.DisableDamage(); } if (Input.GetKeyDown(PC2D.Input.THROW_DAGGER)) { _motor.Throw(); if (_motor.motorState == PlatformerMotor2D.MotorState.JumpThrow) { m_Animator.SetTrigger("jumpThrow"); } else { m_Animator.SetTrigger("throw"); } } }
public void DisableChopdownDamager() { damager.DisableDamage(); }
private void Awake() { m_Animator = GetComponent <Animator>(); m_RigidBody2D = GetComponent <Rigidbody2D>(); m_Damageable = GetComponent <Damageable>(); m_SpriteRenderer = GetComponent <SpriteRenderer>(); m_Flicker = gameObject.AddComponent <Flicker>(); m_OriginalPosition = transform.position; shortDamager.DisableDamage(); longDamager.DisableDamage(); jumpDamager.DisableDamage(); m_DeathEffectHash = VFXController.StringToHash(deathEffectName); m_HitEffectHash = VFXController.StringToHash(hitEffectName); m_JumpAttackSpellPool = BulletPool.GetObjectPool(jumpAttackSpell, 4); m_DarkMatterPool = BulletPool.GetObjectPool(darkBallSpell, 2); m_SoldierPool = BulletPool.GetObjectPool(miniSoldier, 4); //Behaviour tree m_Ai.OpenBranch( BT.If(() => { return(m_Damageable.CurrentHealth == m_Damageable.startingHealth && m_SoldierCount == 2); }).OpenBranch( //Summon BT.Sequence().OpenBranch( BT.Call(() => TeleportTo(summonTeleportPosition.position)), BT.Wait(4.5f), BT.Call(() => m_SpriteRenderer.flipX = true), BT.Call(() => SetConcetratingEffectLocalPosition(new Vector2(-0.15f, 1.5f))), BT.Call(() => m_Animator.SetTrigger(m_HashSummonPara)), BT.Wait(1f), BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"), BT.WaitUntil(SummonActionEndCheck), BT.Wait(0.5f), BT.Call(() => TeleportToRandom()), BT.Wait(5f) ) ), BT.If(() => { return(m_Damageable.CurrentHealth <= m_Damageable.startingHealth * 2 / 3 && m_SoldierCount == 3); }).OpenBranch( //Summon BT.Sequence().OpenBranch( BT.Call(() => TeleportTo(summonTeleportPosition.position)), BT.Wait(4.5f), BT.Call(() => m_SpriteRenderer.flipX = true), BT.Call(() => SetConcetratingEffectLocalPosition(new Vector2(-0.15f, 1.5f))), BT.Call(() => m_Animator.SetTrigger(m_HashSummonPara)), BT.Wait(1f), BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"), BT.WaitUntil(SummonActionEndCheck), BT.Wait(0.5f), BT.Call(() => TeleportToRandom()), BT.Wait(5f) ) ), BT.If(() => { return(m_Damageable.CurrentHealth <= m_Damageable.startingHealth / 3 && m_SoldierCount == 4); }).OpenBranch( //Summon BT.Sequence().OpenBranch( BT.Call(() => TeleportTo(summonTeleportPosition.position)), BT.Wait(4.5f), BT.Call(() => m_SpriteRenderer.flipX = true), BT.Call(() => SetConcetratingEffectLocalPosition(new Vector2(-0.15f, 1.5f))), BT.Call(() => m_Animator.SetTrigger(m_HashSummonPara)), BT.Wait(1f), BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"), BT.WaitUntil(SummonActionEndCheck), BT.Wait(0.5f), BT.Call(() => TeleportToRandom()), BT.Wait(5f) ) ), BT.RandomSequence(new int[] { 3, 2, 2, 2 }, 1).OpenBranch( //Walk BT.Sequence().OpenBranch( BT.Call(OrientToTarget), BT.Call(() => m_Animator.SetBool(m_HashWalkPara, true)), BT.Call(() => SetHorizontalSpeed(1f)), BT.Wait(2.5f), BT.Call(() => SetHorizontalSpeed(0)), BT.Call(() => m_Animator.SetBool(m_HashWalkPara, false)), BT.Wait(0.5f) ), ////Teleport //BT.Sequence().OpenBranch( // BT.Call(() => TeleportToRandom()), // BT.Wait(4.5f) //), //Top to bottom Attack BT.Sequence().OpenBranch( BT.Call(() => SetConcetratingEffectLocalPosition(new Vector2(-1.3f, 1f))), BT.Call(() => m_Animator.SetTrigger(m_HashTopToDowmAttackPara)), BT.Wait(0.5f), BT.Call(OrientToTarget), BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"), BT.Wait(1f) ), //Combo Attack BT.If(() => { return((targetToTrack.position - transform.position).sqrMagnitude < 4f); }).OpenBranch( BT.Sequence().OpenBranch( BT.Call(() => m_Animator.SetTrigger(m_HashTopAttackPara)), BT.Wait(0.5f), BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"), BT.Call(OrientToTarget), BT.Call(() => m_Animator.SetTrigger(m_HashBottomAttackPara)), BT.Wait(0.5f), BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"), BT.Call(OrientToTarget), BT.Call(() => m_Animator.SetTrigger(m_HashTopAttackPara)), BT.Wait(0.5f), BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"), BT.Wait(1f) ) ), //JumpAttack BT.Sequence().OpenBranch( BT.Call(() => SetConcetratingEffectLocalPosition(new Vector2(-0.85f, -0.75f))), BT.Call(() => m_Animator.SetTrigger(m_HashJumpAttackPara)), BT.Call(OrientToTarget), BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"), BT.Wait(1f) ) ), BT.Call(OrientToTarget), BT.Wait(1f) ); }
public void EndAttack() { attackDamager.DisableDamage(); }
public void DisableLowestDamager() { lowestDamager.DisableDamage(); }
/// <summary> /// End the attack itself (not the animation) /// </summary> protected void EndMeleeAttack() { _isUsing = false; onMeleeAttackDone.Invoke(); _damager.DisableDamage(); }
public void DisableHighestDamager() { highestDamager.DisableDamage(); }