void Start() { healthSprite = GetComponent<UISprite>(); playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent<DamageController>(); nowHp = playerHealth.health; RefreshSprite(); }
protected void dvDataSource_Updating(object sender, ObjectDataSourceMethodEventArgs e) { Damage d = e.InputParameters["newEntity"] as Damage; int policyItemID = Convert.ToInt32(e.InputParameters["PolicyItemID"]); TextBox tbPolicyNumber = DetailsView1.FindControl("tbPolicyNumber") as TextBox; string policyNumber = tbPolicyNumber.Text; DropDownList ddlInsuranceSubTypes = DetailsView1.FindControl("ddlInsuranceSubTypes") as DropDownList; int insuranceSubTypeID = Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue); DropDownList ddlInsuranceCompanies = DetailsView1.FindControl("ddlInsuranceCompanies") as DropDownList; int insuranceCompanyID = Convert.ToInt32(ddlInsuranceCompanies.SelectedValue); DamageController.ValidateUpdateDamageNumber(d.ID, d.DamageNumber, policyNumber, insuranceSubTypeID, insuranceCompanyID, policyItemID); }
// Start is called before the first frame update void Start() { rigidBody = GetComponent <Rigidbody>(); damageController = this.GetComponent <DamageController>(); targetPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); anim.SetBool("isDying", false); stats = (Stats)GameObject.Find("Stats").GetComponent("Stats"); skillTree = (SkillTree)GameObject.Find("SkillTree").GetComponent("SkillTree"); if (summonedUnit && summoner != null) { summoner.enemiesAlive += summonValor; } }
void OnTriggerEnter2D(Collider2D collider) { AudioSource.PlayClipAtPoint(audio.clip, transform.position); Destroy(gameObject); DamageController damageController = collider.GetComponent <DamageController>(); if (damageController != null) { if (!collider.CompareTag("Ground")) { damageController.Damage(damage); } } }
// Is triggered on collisions private void OnTriggerEnter2D(Collider2D collision) { //Assigns the damagecontroller var to the DamageController.cs attached to the object that collides DamageController damageController = collision.gameObject.GetComponent <DamageController>(); // Added to prevent null reference in certain situations if (!damageController) { return; } //Manages the damage calculations ManageDamage(damageController); }
void OnTriggerEnter2D(Collider2D collider) { DamageController damageController = collider.gameObject.GetComponent <DamageController>(); if (damageController != null) { Destroy(gameObject); damageController.AddHealth(healthBonus); } else { Destroy(gameObject, 10f); } }
public static void FireballCollision(Fireball fireball, Collision other) { if (other.gameObject.CompareTag(fireball.model.ownerTag)) { return; } if (other.gameObject.CompareTag(fireball.model.hitTag)) { DamageController.ApplyDamage(other.gameObject, fireball.model.damage); } Object.Destroy(fireball.gameObject); }
void OnCollisionEnter2D(Collision2D collision) { DamageController damageController = collision.gameObject.GetComponent <DamageController>(); if (damageController != null) { damageController.Damage(collideAttack); } AudioSource.PlayClipAtPoint(audio.clip, transform.position); if (transform.position.y > collision.transform.position.y) { gameObject.GetComponent <DamageController>().Explode(); Destroy(gameObject); } }
public void ManageDamage(DamageController damagecontroller) { // Applies damage to the health of this object health -= damagecontroller.GetDamage(); //Destroys the laser on collision damagecontroller.Hit(); //Destroys the object when the health is <= 0 if (health <= 0) { //Triggers death function TriggerDeath(); } }
private void UpdateState() { DamageController.Regenerate(); VehicleController.UpdateVehicleState(Input); if (State.InVehicle) { return; } Movement.UpdateMovementState(State, Input); Inventory.UpdateWeaponState(Input); Look.UpdateLookState(Input); }
private void Start() { gameCamera = FindObjectOfType <Camera>().transform; objectToPan = transform.Find("Top"); FXShoot = GetComponentInChildren <ParticleSystem>(); textMesh = GetComponentInChildren <TextMesh>(); audioSource = GetComponent <AudioSource>(); fXDestroyer = FindObjectOfType <FXDestroyer>(); if (audioSource != null && SFXShoot != null) { audioSource.clip = SFXShoot; } damageController = GetComponent <DamageController>(); HP = maxHP; }
//Once on StateChange public void ChangeState(GameState newState) { if (GameStateChangedEvent != null) { GameStateChangedEvent(newState); } switch (newState) { case GameState.menu: //TransitionManager.Instance.transitionMode = TransitionManager.TransitionMode.Dissolve; break; case GameState.loading: break; case GameState.inGame: GestureListener gl = FindObjectOfType <GestureListener>(); gl.PlayerDetectedEvent += gl_PlayerDetectedEvent; gl.PlayerLostEvent += gl_PlayerLostEvent; DamageControllerInstance = FindObjectOfType <DamageController>(); ScoreManagerInstance = FindObjectOfType <SaveScore>(); //TransitionManager.Instance.transitionMode = TransitionManager.TransitionMode.Particle; break; case GameState.end: Canvas canvas = FindObjectOfType <Canvas>(); if (canvas != null) { RenderMode pre = canvas.renderMode; if (pre != RenderMode.ScreenSpaceCamera) { canvas.renderMode = RenderMode.ScreenSpaceCamera; canvas.planeDistance = 0.7f; } } break; case GameState.error: FromGameToMainMenu(); break; default: break; } CurrentGameState = newState; Debug.Log("GameState changed to: " + CurrentGameState); }
void LateUpdate() { if (accumulatedDamage >= 0) { int intDamage = (int)accumulatedDamage; string dmg = intDamage.ToString(); /*if(dmgColor == redColor) { * dmg += "!"; * }*/// REMOVED because it looks like 301 when 30! confusing to play-testers Vector3 popupPos = transform.position + new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), 0); DamageController.CreatePopup(dmg, popupPos, dmgColor); currentHealth -= intDamage; } accumulatedDamage = -1; }
// Start is called before the first frame update void Start() { anim.SetBool("isDying", false); stats = (Stats)GameObject.Find("Stats").GetComponent("Stats"); skillTree = (SkillTree)GameObject.Find("SkillTree").GetComponent("SkillTree"); rb = GetComponent <Rigidbody>(); initialPosition = transform.position; minPosition = new Vector3(initialPosition.x - maxMovementRange, initialPosition.y, initialPosition.z); maxPosition = new Vector3(initialPosition.x + maxMovementRange, initialPosition.y, initialPosition.z); damageController = this.GetComponent <DamageController>(); targetPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); InvokeRepeating(nameof(EnableAttack), 0f, 3f); if (summonedUnit && summoner != null) { summoner.enemiesAlive += summonValor; } }
private void ManageDamage(DamageController damagecontroller) { // Applies damage to the health of this object shield -= damagecontroller.GetDamage(); // Updates the health bar UpdateHealthBar(); // Destroys the laser on collision damagecontroller.Hit(); //Destroys the object when the health is <= 0 if (shield <= 0) { PlayerDie(); } }
protected virtual void Dispose(bool b) { RemoveListeners(); _Race = null; VehicleManager = null; goRacer = null; _vehicleController = null; _damCtrl = null; _gps = null; _playerGps = null; _playerRacer = null; _scorer = null; if (PlayerOpposition != null) { PlayerOpposition.Clear(); Opposition.Clear(); } }
public void DamageController_ElementalCalculatorsParseSuccessfully() { // Test Data Dictionary <string, decimal> testDamageData = new Dictionary <string, decimal>() { { "BaseHealth", 100 }, { "Fire", 50 }, { "Ice", 200 } }; // Run the damage effects, and compare the results to those expected. DamageController <DamageUnitTest> testController = new DamageController <DamageUnitTest>(); var numCalc = testController.CalculateDamageTypeEffects(ref testDamageData); // Assert our expectations. Assert.AreEqual(2, numCalc); Assert.AreEqual(100, testDamageData["BaseHealth"]); Assert.AreEqual(150, testDamageData["Fire"]); Assert.AreEqual(50, testDamageData["Ice"]); }
public void Explosion() { Collider2D[] colliders = Physics2D.OverlapCircleAll(GetComponent <Rigidbody2D>().position, explosionCircle.radius * Mathf.Max(explosionCircle.transform.lossyScale.x, explosionCircle.transform.lossyScale.y), explosionMask); for (int i = 0; i < colliders.Length; i++) { Rigidbody2D body = colliders[i].GetComponent <Rigidbody2D>(); if (body != null) { Vector2 direction = body.position - GetComponent <Rigidbody2D>().position; body.AddForce(direction.normalized * explosionPower, ForceMode2D.Impulse); } } Collider2D[] units = Physics2D.OverlapCircleAll(GetComponent <Rigidbody2D>().position, explosionCircle.radius * Mathf.Max(explosionCircle.transform.lossyScale.x, explosionCircle.transform.lossyScale.y), 1 << LayerMask.NameToLayer("Units") | 1 << LayerMask.NameToLayer("Santa")); for (int i = 0; i < units.Length; i++) { LuisController luis = units[i].GetComponent <LuisController>(); if (luis != null) { luis.Stun(); } DamageController santa = units[i].GetComponent <DamageController>(); if (santa != null) { santa.TakeDamage(damage); if (GameScore.gameScore != null) { GameScore.gameScore.CatchItem(GetComponent <ItemController>()); } } else { if (GameScore.gameScore != null) { GameScore.gameScore.CrashItem(GetComponent <ItemController>()); } } } Destroy(gameObject); }
public float TakeDamage(Attack attack) { currentHealth -= attack.damage; damageController = GetComponent <DamageController>(); Vector3 position = new Vector3(transform.position.x, transform.position.y + 1, transform.position.z); if (damageFx != null) { Instantiate(damageFx, position, Quaternion.Euler(new Vector3(-90, 0, 0))); } if (damageController != null) { damageController.enabled = true; } if (currentHealth <= 0) { Dead(); } return(currentHealth); }
// Is triggered on collisions private void OnTriggerEnter2D(Collider2D collision) { //Assigns the damagecontroller var to the DamageController.cs attached to the object that collides DamageController damageController = collision.gameObject.GetComponent <DamageController>(); // Added to prevent null reference in certain situations if (!damageController) { return; } //Checks if the object that collided is a torpedo if (collision.tag == "Torpedo") { //If so this triggers the splash damage and death effects of the torpedo collision.SendMessage("TriggerDeathEffects"); collision.SendMessage("ExplosionDamage"); } //Manages the damage calculations ManageDamage(damageController); }
// Use this for initialization void Start() { resetRespawnTimer = respawnTimer; trans = GetComponent <Transform>(); damageController = gameObject.GetComponent <DamageController> (); enemyAnimation = GetComponentInChildren <EnemyAnimation> (); if (gameObject.tag == "Enemy") { enemyMovement = GetComponent <EnemyMovement> (); spawnPoint = transform; } if (gameObject.tag == "Player") { playerMovement = GetComponent <PlayerMovement> (); } spawnPoint = transform; }
public void DamageController_DeathEventThrowsSuccessfully() { // Test Data List <string> deadEntities = new List <string>(); const string entityName = "Johnny"; // Create the controller, and track the entity's health for a low amount, so we can kill the test entity. DamageController <DamageUnitTest> testController = new DamageController <DamageUnitTest>(); testController.OnEntityDeath += (sender, args) => { deadEntities.Add((args as EntityDeathEventArgs).EntityId); }; testController.DamageManager.BeginTrackingDamage(entityName, 20); DamageUnitTest testDamage = new DamageUnitTest() { BaseHealth = 500 }; testController.ApplyDamage(entityName, testDamage); Assert.AreEqual(1, deadEntities.Count); Assert.AreEqual(entityName, deadEntities[0]); }
void OnTriggerEnter(Collider collider) { // do not collide with own spawner if (collider.gameObject.GetInstanceID() == spawningGameObjectId) { //Debug.Log("Projectile collided with own spawner..."); return; } // prevent friendly fire, i.e. only damage enemies if (collider.gameObject.CompareTag("Enemy")) { //Debug.Log("Projectile collided with enemy!"); DamageController damageController = collider.gameObject.GetComponent <DamageController>(); if (damageController) { damageController.DealDamage(damage); } } Destroy(gameObject); }
public void GetMaxDamageNoExceptions(GameObject hitter) { Vector3 damagePosition = transform.position; float _damage = m_baseArmor + m_currentHealth; float _armorMinusDamage = _damage; if (m_currentArmor > 0) { if (m_currentArmor < _armorMinusDamage) { _armorMinusDamage -= m_currentArmor; m_currentArmor = 0; } else { m_currentArmor -= _armorMinusDamage; _armorMinusDamage = 0; } } m_currentHealth -= _armorMinusDamage; DamageController damageTextController = Instantiate(damageTextObject, damagePosition, Quaternion.Euler(0, 0, 0)).GetComponent <DamageController>(); damageTextController.DamageUpdate(_damage); if (gameObject.tag == "Player") { damageTextController.damageText.color = new Color(1, 69f / 255f, 69f / 255f, 1); damageTextController.transform.localScale += new Vector3(0.2f, 0.2f); } if (m_currentHealth <= 0) { m_currentHealth = 0; isDamageable = false; SendMessage("Death", SendMessageOptions.DontRequireReceiver); } }
void OnTriggerEnter(Collider other) { Collider collider = other.GetComponent <Collider> (); Rigidbody rigidbody; rigidbody = other.gameObject.GetComponent <Rigidbody> (); if (other.tag == "Enemy" || other.tag == "Player") { rigidbody.AddTorque(torqueVec, ForceMode.Impulse); collider.SendMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver); if (other.tag == "Player") { DamageController damageController = playerGO.GetComponent <DamageController>(); if (damageController.health > 0) { SpriteAnimation.spin = true; } } if (other.tag == "Enemy") { DamageController damageController = enemyGO.GetComponent <DamageController>(); if (damageController.health > 0) { //EnemyAnimation.spin = true; } } Destroy(gameObject); } }
// Use this for initialization void Start() { playerObject = GameObject.FindGameObjectWithTag("Player"); damageController = playerObject.GetComponent <DamageController> (); img = GetComponent <Image> (); }
void Start() { damageController = this.GetComponent <DamageController>(); timer = secondsToShowAttackUI; previousHealth = CalculateHealth(); }
public override void Awake() { base.Awake(); _damageController = GetComponent <DamageController>(); _trSkidMarks = GameObject.Find("Skidmarks").transform; SkidAudioSource = GetComponent <AudioSource>(); EngineAudioSource = transform.Find("Sounds/Engine").GetComponent <AudioSource>(); CoughAudioSource = transform.Find("Sounds/Cough").GetComponent <AudioSource>(); ClutchAudioSource = transform.Find("Sounds/ClutchDown").GetComponent <AudioSource>(); EngineAudioSource.mute = true; CoughAudioSource.mute = true; SkidAudioSource.volume = Settings.Instance.SFXVolume; EngineAudioSource.volume = Settings.Instance.SFXVolume; ClutchAudioSource.volume = Settings.Instance.SFXVolume; CoughAudioSource.volume = Settings.Instance.SFXVolume; FLWheel = transform.Find("car/FLWheel").gameObject; FRWheel = transform.Find("car/FRWheel").gameObject; WasRuttingRL = false; WasRuttingRR = false; RutMatrl = (Material)Resources.Load("Prefabs/Materials/WheelRutGrey"); SkidMatrl = (Material)Resources.Load("Prefabs/Materials/SkidMark"); psSprayL = transform.Find("WheelColliders/WCRL/SprayFL").GetComponent <ParticleSystem>(); psSprayR = transform.Find("WheelColliders/WCRR/SprayFR").GetComponent <ParticleSystem>(); psSprayLFwd = transform.Find("WheelColliders/WCRL/SprayFLFwd").GetComponent <ParticleSystem>(); psSprayRFwd = transform.Find("WheelColliders/WCRR/SprayFRFwd").GetComponent <ParticleSystem>(); psDustL = transform.Find("WheelColliders/WCRL/DustFL").GetComponent <ParticleSystem>(); psDustR = transform.Find("WheelColliders/WCRR/DustFR").GetComponent <ParticleSystem>(); peSprayL = psSprayL.emission; peSprayR = psSprayR.emission; pmSprayL = psSprayL.main; pmSprayR = psSprayR.main; try { _fLRimRenderer = transform.Find("car/FLWheel/FLRim").GetComponent <Renderer>(); _fRRimRenderer = transform.Find("car/FRWheel/FRRim").GetComponent <Renderer>(); _rLRimRenderer = transform.Find("car/RLWheel/RLRim").GetComponent <Renderer>(); _rRRimRenderer = transform.Find("car/RRWheel/RRRim").GetComponent <Renderer>(); _fRRimSpinRenderer = transform.Find("car/FRWheel/FRRimSpin").GetComponent <Renderer>(); _rLRimSpinRenderer = transform.Find("car/RLWheel/RLRimSpin").GetComponent <Renderer>(); _fLRimSpinRenderer = transform.Find("car/FLWheel/FLRimSpin").GetComponent <Renderer>(); } catch { _rimSpin = false; } StickyCarBodyPhysicsMaterial = (PhysicMaterial)Resources.Load("PhysicMaterials/StickyCarBodyPhysicsMaterial"); CarBodyPhysicsMaterial = (PhysicMaterial)Resources.Load("PhysicMaterials/CarBodyPhysicsMaterial"); RLWheel = transform.Find("car/RLWheel").gameObject; RRWheel = transform.Find("car/RRWheel").gameObject; RRWheel.transform.localScale = Vector3.one; WCFL = transform.Find("WheelColliders/WCFL").GetComponent <WheelController>(); WCFR = transform.Find("WheelColliders/WCFR").GetComponent <WheelController>(); WCRL = transform.Find("WheelColliders/WCRL").GetComponent <WheelController>(); WCRR = transform.Find("WheelColliders/WCRR").GetComponent <WheelController>(); _rb = GetComponent <Rigidbody>(); _rb.centerOfMass = new Vector3(0, 0.2f, 0.52f); motorForce = 2000f; _maxBrakeForce = 3500f; steerForce = 25f; AntiRollForce = 0f; FCoef = WCRL.fFriction.forceCoefficient; SCoef = WCRL.sideFriction.forceCoefficient; Keyframe[] kfs; kfs = new Keyframe[4] { new Keyframe(0f, 0f, 0f, 0.3f), new Keyframe(0.08f, 0.14f, 2.7f, 2.7f), new Keyframe(0.12f, 0.3f, 3.3f, 3.3f), new Keyframe(0.15f, 0.2f, 0f, 0f) /* * new Keyframe(0f, 0f, 0f, 0.1f), * new Keyframe(0.1f, 0.1f, 2.25f, 2.25f), * new Keyframe(0.17f, 0.27f, 3.3f, 3.3f), * new Keyframe(0.19f, 0.2f, 0f, 0f) */ }; frontFrictTarmac = new AnimationCurve(kfs); kfs = new Keyframe[4] { new Keyframe(0f, 0f, 0.7f, 0.7f), new Keyframe(0.5f, 0.45f, 0.03f, 0.03f), new Keyframe(1f, 0.8f, 0.3f, 0.3f), new Keyframe(1.4f, 0.45f, 0f, 0f) /* * new Keyframe(0f, 0f, 0.7f, 0.7f), * new Keyframe(0.7f, 0.3f, 0.03f, 0.03f), * new Keyframe(1.2f, 0.55f, 0.3f, 0.3f), * new Keyframe(1.7f, 0.45f, 0f, 0f) */ }; rearFrictTarmac = new AnimationCurve(kfs); kfs = new Keyframe[3] { new Keyframe(0f, 0f, 0.7f, 0.7f), new Keyframe(2.25f, 0.5f, 0.3f, 0.3f), new Keyframe(3f, 0.3f, 0f, 0f) }; frontFrictDirtyRoad = new AnimationCurve(kfs); kfs = new Keyframe[4] { new Keyframe(0f, 0f, 0.7f, 0.7f), new Keyframe(1.25f, 0.25f, 0.03f, 0.03f), new Keyframe(2f, 0.35f, 0.3f, 0.3f), new Keyframe(3f, 0.2f, 0f, 0f) }; rearFrictDirtyRoad = new AnimationCurve(kfs); kfs = new Keyframe[3] { new Keyframe(0f, 0f, 0.7f, 0.7f), new Keyframe(2.25f, 0.5f, 0.3f, 0.3f), new Keyframe(3f, 0.3f, 0f, 0f) }; frontFrictDirt = new AnimationCurve(kfs); kfs = new Keyframe[4] { new Keyframe(0f, 0f, 0.7f, 0.7f), new Keyframe(1.25f, 0.25f, 0.03f, 0.03f), new Keyframe(2f, 0.35f, 0.3f, 0.3f), new Keyframe(3f, 0.2f, 0f, 0f) }; rearFrictDirt = new AnimationCurve(kfs); /* * //this is for testing * WCFL.forwardFriction.frictionCurve = frontFrictTarmac; * WCFR.forwardFriction.frictionCurve = frontFrictTarmac; * WCRL.forwardFriction.frictionCurve = rearFrictTarmac; * WCRR.forwardFriction.frictionCurve = rearFrictTarmac; */ }
void OnEnable() { objeto = (DamageController)target; }
// Use this for initialization protected virtual void Start() { curHealth = health; damageController = FindObjectOfType <DamageController>(); }
//by irtsa private void Awake() { ragdoll = GetComponent <RagdollRig>(); damageController = GetComponent <DamageController>(); statusController = GetComponent <StatusController>(); }
// Use this for initialization void Start() { m_characterCtrl = GetComponent<CharacterController>(); m_animator = GetComponent<Animator>(); damageController = GetComponent<DamageController>(); AttackBehaviour ab = m_animator.GetBehaviour<AttackBehaviour>(); //ab.damageController = damageController; target = GameObject.Find("ashe"); navAgent = GetComponent<NavMeshAgent>(); Shader.WarmupAllShaders(); }