public void Run() { mRigid.constraints = RigidbodyConstraints.None; // mAnim.mState = AnimState.FLYING; // after a certain amount of time, switch states back to combat // before that, let us handle collisions again. float timePassed = Time.time - mTimeStartedFlying; // If they have been flying for > 4 seconds, then just kill them. if (timePassed > 4f) { mEntity.TakeDamage(100000000000f); Debug.Log("Killed because flying too long"); return; } if (timePassed > 0.05f) { mRigid.detectCollisions = true; } if (timePassed > mEntity.GetBase().mTimeFly) { mEntity.mStateChange = STATE.COMBAT; } // make them tumble in the air. mModelFollower.rotateSpeed = 100000000000f; Vector3 rot = transform.rotation.eulerAngles; rot.x += mRotSpeed.Value.x; rot.y += mRotSpeed.Value.y; rot.z += mRotSpeed.Value.z; transform.rotation = Quaternion.Euler(rot); }
private void OnTriggerEnter(Collider other) { // Also want it destroying the lanky shield if it hits him if (hasBeenThrown) { EnemyForceField forceField = UT_FindComponent.FindComponent <EnemyForceField>(other.gameObject); if (forceField != null) { forceField.TakeDamage(10000f); DestroyObject(); return; } } if ((other.GetComponent <DestroyObjectOnCollision>() != null && other.GetComponent <ThrowableObject>() == null) && hasBeenThrown) { DestroyObject(); return; } AI_Controller npc = UT_FindComponent.FindComponent <AI_Controller>(other.gameObject); if (npc != null && hasBeenThrown) { npc.TakeDamage(properties.damage); addScore.Raise(pointsForEnemyKill); DestroyObject(); } }
public virtual void GetHitByMelee() { AUD_Manager.PostEvent("EN_Hit_ST", gameObject); // here we check if we have a shield, and just return it if true. if (GetComponentInChildren <EnemyForceField>() != null) { return; } Instantiate(hitParticles, transform.position, transform.rotation); owner.TakeDamage(50f); if (owner.GetHealth() > 0f && GetComponent <AI_FlyLogic>() != null) { owner.mStateChange = STATE.FLYING; // now add a force slightly up and away from the player. Vector3 dirFromPlayer = transform.position - owner.mPlayerTrans.Value.position; dirFromPlayer.y = 0f; // need a small percentage in the y dir though. float strength = Vector3.Magnitude(dirFromPlayer); dirFromPlayer.y = strength * 0.3f; dirFromPlayer = Vector3.Normalize(dirFromPlayer); // dirFromPlayer.y+=0.3f; // gotta make them fly up. GetComponent <Rigidbody>().AddForce(dirFromPlayer * mMeleeForce.Value); GetComponent <AI_FlyLogic>().mTimeStartedFlying = Time.time; // we also gotta "cheat" a little bit by pushing them up a little bit, to ensure no early collisions with the ground. Vector3 newPos = transform.position; newPos.y += 0.5f; transform.position = newPos; AUD_Manager.PostEvent("PC_MeleeImpact_ST_LP", gameObject); } }
private void OnCollisionEnter(Collision other) { if (mEntity.mState == STATE.FLYING) { // Only collisions with the floor matter. Debug.Log("Collision while falling with: " + other.gameObject); if (other.gameObject.tag == "Ground") { AUD_Manager.DynamicDialogueFromData(mHitsGround, gameObject); mEntity.TakeDamage(20f); mEntity.mStateChange = STATE.COMBAT; } } }
// //Collision Goes Under Here // /// <summary> /// Number of Hits before being knocked to the ground /// </summary> private void OnTriggerEnter2D(Collider2D collision) { var other = collision.gameObject.tag; if (other == "LauncherAttack" && !inAir) { //Adjust enemy settings aiRef.FacePlayer(); aiHitRef.GravitySetting(juggleGravity); aiHitRef.KnockUp(launcherForce); // aiHitRef.FreezeTimeOnHit(freezeTimer); aiControlRef.HitStunned(true); //Adjust player settings playerHitRef.GravitySetting(juggleGravity); playerHitRef.KnockUp(launcherForce); playerAnimRef.SetBool("heavyAttacking", false); playerAnimRef.SetBool("heavyAttacking2", false); playerAnimRef.SetBool("isLaunching", false); aerialTimer = 0; } if (other == "LightAttack" && !inAir) { //Adjust enemy settings aiRef.FacePlayer(); aiHitRef.KnockBack(knockBackForce); aiControlRef.HitStunned(true); aiControlRef.TakeDamage(launcher); //Adjust Player settings // playerHitRef.KnockBack(knockBackForce); } if (other == "HeavyAttack" && !inAir) { //adjust enemy settings aiRef.FacePlayer(); aiHitRef.KnockBack(knockBackForce); aiControlRef.HitStunned(true); aiControlRef.TakeDamage(swordHit); //Adjust Player settings // playerHitRef.KnockBack(knockBackForce); } //When in the Air if (other == "LightAttack" && inAir) { aerialTimer = 0; ++aerialHitCounter; //Move the enemy aiRef.FacePlayer(); aiHitRef.KnockUp(airHitForce); //Apply Hitstun aiControlRef.HitStunned(true); //Move the player playerHitRef.KnockUp(airHitForce); } if (other == "HeavyAttack" && inAir) { aerialTimer = 0; ++aerialHitCounter; //Move the enemy aiRef.FacePlayer(); aiHitRef.KnockUp(airHitForce); //Apply hitstun aiControlRef.HitStunned(true); //Move the player playerHitRef.KnockUp(airHitForce); } }
private void OnTriggerEnter(Collider other) { // Deal with the two deflectors BulletDeflector deflector = other.GetComponent <BulletDeflector>(); if (deflector != null) { return; } // Deal with player damage IDamageable damageableObject = other.GetComponentInParent <IDamageable>(); if (damageableObject != null) { if (other.GetComponentInParent <PlayerHealth>() && bullet.bouncedByPlayer == false && effectiveDeflectorActive.Value == false) { damageableObject.TakeDamage(bullet.damage); AUD_Manager.SetSwitch("ImpactObject", "Character", gameObject); AUD_Manager.SetSwitch("ImpactType", "Kinetic", gameObject); AUD_Manager.PostEvent("WP_ProjImpact_ST", gameObject); bullet.DestroyBullet(); return; } // SimpleEnemy se = other.GetComponent<SimpleEnemy>(); // if (se != null && bullet.bouncedByPlayer == true) { // se.TakeDamage(bullet.damage); // bullet.DestroyBullet(); // return; // } EnemyForceField forceField = other.GetComponent <EnemyForceField>(); if (forceField != null && bullet.bouncedByPlayer) { damageableObject.TakeDamage(bullet.damage); bullet.DestroyBullet(); return; } } // Deal with killing the enemy AI_Controller enemyController = other.GetComponentInParent <AI_Controller>(); if (enemyController != null && bullet.bouncedByPlayer) { enemyController.TakeDamage(bullet.damage); bullet.DestroyBullet(); return; } // Handle Turret as well. AI_Turret turController = other.GetComponentInChildren <AI_Turret>(); if (turController != null && bullet.bouncedByPlayer) { turController.TakeDamage(bullet.damage); bullet.DestroyBullet(); } // Deal with any object if (other.GetComponent <DestroyObjectOnCollision>() != null) { ThrowableObject throwableObj = other.GetComponent <ThrowableObject>(); if (throwableObj != null && bullet.bouncedPerfectly) { throwableObj.DestroyObject(); return; } AUD_Manager.SetSwitch("ImpactObject", "Environment", gameObject); AUD_Manager.SetSwitch("ImpactType", "Energy", gameObject); AUD_Manager.PostEvent("WP_ProjImpact_ST", gameObject); bullet.DestroyBullet(); } }