/** * A normal member to take action of Shooting with Soldier's weapon. * (e.g. Soldier was wrongly placed) */ public void Shoot() { if (bulletCount > 0 && shootingEnabled) { shotParticles.Play(); if (shootSound != null) { shootSound.Play(0); } shotTrajectileAnimator.Play(shotTrajectileAnimator.name); RaycastHit hit; if (Physics.Raycast(shootPoint.transform.position, shootPoint.transform.forward, out hit, 100, layerMask)) { HealthControl healthControl = hit.transform.GetComponent <HealthControl>(); if (healthControl != null) { healthControl.TakeDamage(damage); } } bulletCount--; } if (bulletCount == 0) { grabMechansm.ActionFinished(); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Door") || other.gameObject.CompareTag("Wall") || other.gameObject.CompareTag("Enemy") || other.gameObject.CompareTag("Boss") || other.gameObject.CompareTag("Ball")) { // Destroy bolt on contact. Destroy(gameObject); // If bolt hits an enemy, deal damage to that enemy. HealthControl.dealDamageToEnemy(other.gameObject, attackDamage); if (other.gameObject.GetComponent <Rigidbody>() != null) { // Add a knock back effect to enemies/bosses other.gameObject.GetComponent <Rigidbody>().AddForce(gameObject.transform.forward * knockback); } } // Block an enemy projectile if (other.gameObject.CompareTag("EnemyAttack")) { // Destroy melee attack and enemy's attack Destroy(other.gameObject); Destroy(gameObject); } }
void OnTriggerEnter(Collider other) { Rigidbody thisRigid = GetComponent <Rigidbody>(); if (stuck && other.gameObject.tag.Equals("PlayerAttack")) { stuck = false; thisRigid.velocity = new Vector3(-lastChargeVelocity.x / 4, -lastChargeVelocity.y / 8, -lastChargeVelocity.z / 4); } if (charge) { charge = false; if (other.gameObject.tag.Equals("Player")) { thisRigid.velocity = new Vector3(-lastChargeVelocity.x / 4, -lastChargeVelocity.y / 8, -lastChargeVelocity.z / 4); HealthControl collided = other.GetComponent <HealthControl>(); if (collided) { collided.takeDamage(stats.modifiers.damage); } } else { //Stuck in object thisRigid.velocity = Vector3.zero; stuck = true; } } }
private void Start() { healthscript = GameObject.FindGameObjectWithTag("Player").GetComponent <HealthControl>(); if (OneShotDeath) { damage = healthscript.health; } }
// Start is called before the first frame update void Start() { _controller = GetComponent <CharacterController>(); this.playerHealth = GetComponent <HealthControl>(); this.velocity = new Vector3(0, 0, 0); playerHealth.setMaxHealth(100); }
void Attack(GameObject other) { timer = 0f; if (other != null) { // Deal damage to player HealthControl.dealDamageToPlayer(other, damage); } }
private void SetObjectHealthRPC(NetworkViewID objectOwner, int objectID, float health, float shields) { //Debug.Log("SetObjectHealthRPC received."); GameObject obj = base.GetObject(objectOwner, objectID); HealthControl healthControl = obj.GetComponent <HealthControl>(); healthControl.CurrentHealth = health; healthControl.CurrentShields = shields; }
void Start() { startTime = Time.time; healthControlScript = GameObject.Find("HealthControl").GetComponent <HealthControl> (); if (PlayerPrefs.GetFloat("BestTime") <= 1f) { PlayerPrefs.SetFloat("BestTime", 10000); } }
private void OnSlashHit(HealthControl givenHealh) { if (dashAbility.isDashing) { OriginalStateSet(); } if (givenHealh != null) { swatheEnergy.CurrentEnergy += 1; } }
void OnTriggerEnter(Collider other) { if (modifiers.dot) { if (other.gameObject.tag.Equals("Enemy")) { HealthControl collidedHealth = other.gameObject.GetComponent <HealthControl>(); collidedHealth.applyDot(modifiers.dotTick, modifiers.dotLength); } } }
private void Awake() { healthControl = GetComponent <HealthControl>(); healthControl.onHitDeath += GiveReward; chosenGoldValue = (int)(goldReward.x + Random.Range(0f, goldReward.y)); leftToSpawn = chosenGoldValue; if (giveOnHit) { healthControl.onHitAlive += GivePercent; } }
/// <summary> /// Initializes the server-side objects. /// </summary> private void createServerSideObjects() { Player server = new Player(base.NetworkControl.LocalViewID, Network.player); base.NetworkControl.Players.Add(server.ID, server); base.ObjectTables.AddPlayerTable(server); Debug.Log("Created server player: " + server.ID); Player serverPlayer = base.NetworkControl.ThisPlayer; // Initialize the starting positions of the motherships. Vector3 team1MothershipPos = new Vector3(2000, 0, 0); Vector3 team2MothershipPos = new Vector3(-2000, 0, 0); // Initialize te motherships. GameObject team1Mothership = (GameObject)GameObject.Instantiate( this.MothershipPrefab, team1MothershipPos, Quaternion.identity ); GameObject team2Mothership = (GameObject)GameObject.Instantiate( this.MothershipPrefab, team2MothershipPos, Quaternion.identity ); // Assign teams to the motherships. TeamHelper.PropagateLayer(team1Mothership, (int)Layers.Team1Mothership); TeamHelper.PropagateLayer(team2Mothership, (int)Layers.Team2Mothership); team1Mothership.name = "Team1Mothership"; team2Mothership.name = "Team2Mothership"; // Generate object IDs for the motherships. int team1MothershipID = base.GUIDGenerator.GenerateID(); int team2MothershipID = base.GUIDGenerator.GenerateID(); // Assign some values. ObjectSync team1MSObjSync = team1Mothership.GetComponent <ObjectSync>(); team1MSObjSync.Type = ObjectSyncType.Mothership; team1MSObjSync.AssignID(serverPlayer, team1MothershipID); HealthControl team1MSHealthControl = team1Mothership.GetComponent <HealthControl>(); team1MSHealthControl.DrawHealthInfo = false; ObjectSync team2MSObjSync = team2Mothership.GetComponent <ObjectSync>(); team2MSObjSync.Type = ObjectSyncType.Mothership; team2MSObjSync.AssignID(serverPlayer, team2MothershipID); HealthControl team2MSHealthControl = team2Mothership.GetComponent <HealthControl>(); team2MSHealthControl.DrawHealthInfo = false; base.ObjectTables.AddPlayerObject(serverPlayer, team1MothershipID, team1Mothership); base.ObjectTables.AddPlayerObject(serverPlayer, team2MothershipID, team2Mothership); }
void enemyCollision(GameObject collidedObject) { if (collidedObject.tag.Equals("Player")) { HealthControl collidedHealth = collidedObject.GetComponent <HealthControl>(); collidedHealth.takeDamage(modifiers.damage); if (modifiers.dot) { collidedHealth.applyDot(modifiers.dotTick, modifiers.dotLength); } } }
void OnTriggerEnter(Collider other) { // Check if the bolt come into contact with a door, wall, boss, other enemy or player if (other.gameObject.CompareTag("Door") || other.gameObject.CompareTag("Wall") || (other.gameObject.CompareTag("Enemy") && (enemy != other.gameObject)) || other.gameObject.CompareTag("Boss") || other.gameObject.CompareTag("Player")) { // Destroy bolt on contact. Destroy(gameObject); // If bolt hits a player, deal damage to the player. HealthControl.dealDamageToPlayer(other.gameObject, boltDamage); } }
//On trigger (currently only trigerred by the 2D collider private void OnTriggerEnter2D(Collider2D collision) { Debug.Log(collision.name); HealthControl target = collision.GetComponent <HealthControl>(); if (target != null) { target.TakeDamage(damage); } if (collision.name != "ElectricBullet(Clone)") { Destroy(gameObject); } }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { if (Item.Contain_Item("Key")) { Item.Remove_Item("Key"); Destroy(gameObject); } else { HealthControl healthscript = GameObject.FindGameObjectWithTag("Player").GetComponent <HealthControl>(); healthscript.GetDamage(healthscript.health, false, 1f); } } }
private void KillObjectRPC(NetworkViewID objectOwner, int objectID) { //Debug.Log("KillObjectRPC received."); GameObject obj = base.GetObject(objectOwner, objectID); //if (Network.peerType == NetworkPeerType.Server) //{ // ObjectSync objSync = obj.GetComponent<ObjectSync>(); // if (objSync != null) // objSync.Dispose(); //} HealthControl healthControl = obj.GetComponent <HealthControl>(); healthControl.Die(); }
void OnTriggerStay(Collider other) { if (other.gameObject.tag.Equals("Enemy")) { if (!calcDamage) { timeCount += Time.deltaTime; calcDamage = true; } if (timeCount >= damageCooldown) { HealthControl collidedHealth = other.gameObject.GetComponent <HealthControl>(); collidedHealth.takeDamage(modifiers.damage); timeCount -= Time.deltaTime; } } }
void OnBreathEnded(object sender, ExhalationCompleteEventArgs e) { breathing = false; if (e.BreathQuality >= 4) { canJump = true; } powerBar.fillAmount = e.BreathQuality / 4f; HealthControl.deductLife(); if (HealthControl.lives == 0) { FizzyoFramework.Instance.Recogniser.BreathStarted -= OnBreathStarted; FizzyoFramework.Instance.Recogniser.BreathComplete -= OnBreathEnded; } }
protected virtual void Awake() { entityRB2D = this.GetComponent <Rigidbody2D>(); entityBC2D = this.GetComponent <BoxCollider2D>(); groundMask = (1 << LayerMask.NameToLayer("Ground - Soft")) | (1 << LayerMask.NameToLayer("Ground - Hard")); healthControl = GetComponent <HealthControl>(); healthControl.onHitAlive += HitReactionOnAlive; healthControl.onHitDeath += PhysicsCleanUpOnDeath; knockbackControl = GetComponent <KnockbackControl>(); waitForNotPaused = new WaitUntil(() => !isPaused); currentTerminalVelocity = originalTerminalVelocity; originalState = new StateSetter(this, BaseActionControl, BaseActionUpdate, BaseActionFixedUpdate); SetLivingEntityState(originalState, true); }
// Update is called once per frame void Update() { // When egg drops - If drop below certain distance if (transform.position.y < (mCamera.position.y - 15f)) { if (HealthControl.lives != 0) { HealthControl.deductLife(); AchievementControl.consectJump = 0; if (HealthControl.lives > 0) { SoundControl.playReappearSound(); transform.position = new Vector3(OnCollision.lastCollidedPlatform.position.x, OnCollision.lastCollidedPlatform.position.y + 1.5f, OnCollision.lastCollidedPlatform.position.z); OnCollision.lastCollidedPlatform.gameObject.GetComponent <EdgeCollider2D>().enabled = true; transform.parent = OnCollision.lastCollidedPlatform.gameObject.transform; } } } }
private void Awake() { _healthControl = GetComponent <HealthControl>(); if (_healthControl == null) { Debug.LogError("Health Control script required but not found."); } if (hud == null) { Debug.LogError("Hud canvas could not be loaded"); } _scoreBoard = GameObject.FindObjectOfType <ScoreManager>(); if (_scoreBoard == null) { Debug.LogError("Unable to load score manager script."); } Setup(); HideScreen(_scoreboardScreen, false); }
// Use this for initialization void Start() { // levelCompleteText.text = ""; gameOver = false; paused = false; GameObject healthUIObject = GameObject.FindGameObjectWithTag("HealthUI"); // Locates the healthUIObject if (healthUIObject != null) { healthUI = healthUIObject.GetComponent <HealthControl>(); } else { Debug.Log("Cannot find 'HealthUI' script"); } // Gets pause menu gameobject if (!GetChild(this.gameObject, "PauseMenu", out pauseMenu)) { Debug.Log("Could not find \"PauseMenu\" for " + this.name + " game object"); } // Get TimerText timerText = timerPanel.GetComponent <Text>(); if (timerText == null) { GetChild(timerPanel, "TimerText", out timerPanel, true); timerText = timerPanel.GetComponent <Text>(); } currTime = totalTime; timerActive = true; timer = new Timer(currTime); freezeFlag = freezeFlagGUI.GetComponent <FlagState>(); }
public override void fire(SpellMod modifiers, Transform firePoint, Camera mainCam) { GameObject temp = Instantiate(projectile, mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)) - mainCam.transform.forward.normalized * 10, firePoint.rotation); RaycastHit[] hits; ISpellCollision spellCollision = temp.GetComponent <ISpellCollision>(); temp.GetComponent <Rigidbody>().velocity = mainCam.transform.forward.normalized * 500; hits = Physics.SphereCastAll(mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)), 0.5f, mainCam.transform.forward); Debug.DrawRay(mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)), mainCam.transform.forward); if (hits.Length > 0) { hits = raycastSort(hits, firePoint.position); foreach (RaycastHit hit in hits) { if (hit.collider.tag == "Enemy") { HealthControl collidedHealth = hit.collider.GetComponent <HealthControl>(); collidedHealth.takeDamage(modifiers.damage * modifiers.damagePercent); if (modifiers.dot) { collidedHealth.applyDot(modifiers.dotTick, modifiers.dotLength); } } else if (hit.collider.tag == "EnemyAttack") { Destroy(hit.collider.gameObject); } else if (hit.collider.gameObject.layer == 0) { //modifiers.range = (hit.point - temp.transform.position).magnitude / 250; return; } } spellCollision.setModifiers(modifiers); } }
private void Start() { tyreCount = tyreColRadius.Count; wheelJoint = gameObject.GetComponent <WheelJoint2D>(); wheelMotor = gameObject.GetComponent <WheelJoint2D>().motor; wheelSprite = gameObject.GetComponent <SpriteRenderer>(); wheelCircleCollider = gameObject.GetComponent <CircleCollider2D>(); //wheelBoxCollider = gameObject.GetComponent<BoxCollider2D>(); //wheelBoxCollider.enabled = false; healthControl = FindObjectOfType <HealthControl>(); carcontrol = FindObjectOfType <CarController>(); //hill = GameObject.Find("Map (1)"); slipperyHillCollider = hill.GetComponent <EdgeCollider2D>(); notSlipperyMaterial = (PhysicsMaterial2D)Resources.Load("Materials/HillNotSlippery"); slipperyMaterial = (PhysicsMaterial2D)Resources.Load("Materials/SlipperyHill"); audioControl = FindObjectOfType <AudioControls>(); messageControls = FindObjectOfType <MessageController>(); hasCrashed = false; currentheathDecVal = (float)healthDecStat["tyre_" + (currentTyreNum + 1)]; }
public Collider2D[] PSlashAttack() { currSlashTrans = slashSideTrans; float verticalAxis = Input.GetAxis("Vertical"); if (verticalAxis != 0) { if (verticalAxis > 0) { currSlashTrans = slashUpTrans; } else if (verticalAxis < 0 && !aEntity.IsGrounded) { currSlashTrans = slashDownTrans; } } Instantiate(slashParticles, currSlashTrans.position, Quaternion.identity); Collider2D[] targetsHit = Physics2D.OverlapBoxAll(new Vector2(currSlashTrans.position.x, currSlashTrans.position.y), slashAttackSize, 0f); bool hitAtLeastOne = false; HealthControl healthControl = null; foreach (Collider2D col in targetsHit) { if (col.gameObject.CompareTag("Enemy") || col.gameObject.CompareTag("Hazard")) { healthControl = col.gameObject.GetComponent <HealthControl>(); if (healthControl != null) { Attack slashAttack = new Attack(slashDamage, gameObject, slashKnockback); if (currSlashTrans == slashUpTrans) { slashAttack.knockback.x = 0; } if (currSlashTrans == slashDownTrans) { slashAttack.knockback.x = 0; slashAttack.knockback.y *= -1; } Debug.Log("Hit"); healthControl.DealDamage(slashAttack); } hitAtLeastOne = true; onSlashHit?.Invoke(healthControl); } healthControl = null; } if (hitAtLeastOne) { CameraManager.instance.AddShake(new CameraManager.Shake(1f, 1f, 0.2f)); if (!noFullRecoil) { if (!noRecoil) { DownRecoil(); SideRecoil(); } UpRecoil(); } } slashCooldownCounter = slashCooldownDuration; CanActivate = false; return(targetsHit); }
void Start() { objHealth = GameObject.Find("GameControl").GetComponent <HealthControl> (); rb = GetComponent <Rigidbody> (); }
// Use this for initialization protected override void Start() { base.Start(); this.healthControl = this.GetComponent<HealthControl>(); }
private void Start() { healthscript = GameObject.FindGameObjectWithTag("Player").GetComponent <HealthControl>(); }
void Start() { healthControl = GameObject.Find("HealthControl").GetComponent <HealthControl>(); voice = GameObject.Find("VirusScripti").GetComponent <CreateVirus>(); }
void Start() { objHealth = GameObject.Find("GameControl").GetComponent <HealthControl> (); objSpawn = GameObject.Find("GameControl").GetComponent <SpawnWave> (); }