public void AddTarget( BaseHealth _health ) { #if UNITY_EDITOR if ( Network.peerType == NetworkPeerType.Disconnected ) { this.debugTargetMap.Add( this.currentDebugID, _health ); DebugConsole.Log( "Added target " + this.currentDebugID, _health ); _health.debugTargetID = this.currentDebugID; this.currentDebugID++; } else #endif { NetworkViewID viewID = _health.GetComponent<NetworkView>().viewID; if ( this.targetMap.ContainsKey( viewID ) ) { DebugConsole.Warning( "Target Manager already contains " + viewID + " (" + this.GetTargetWithID( viewID ).gameObject.name+ ")", _health ); return; } DebugConsole.Log( "Adding target " + viewID + " (" + _health.gameObject.name + ") to TargetManager", _health ); this.targetMap.Add( viewID, _health ); } #if UNITY_EDITOR this.debugTargets.Add( _health ); #endif }
public void Start() { m_IslandHealth = gameObject.GetComponent <IslandHealth>(); m_IslandHealth.TakeDamageEvent += UIController.Instance.m_InGameUIController.m_IslandsHealthBarController.ReduceHealth; UIController.Instance.m_InGameUIController.m_IslandsHealthBarController.SetMaxHealth(m_IslandHealth.GetMaxHealth()); m_IslandHealth.OnResetHealth += UIController.Instance.m_InGameUIController.m_IslandsHealthBarController.ResetHealth; }
// Use this for initialization protected override void Awake() { ability = AbilityIDList.getAbility(AbilityID.summonSkeleton); base.Awake(); summonWarrior = Ability.getAbility(AbilityID.summonSkeletonWarrior); summonMage = Ability.getAbility(AbilityID.summonSkeletonMage); summonArcher = Ability.getAbility(AbilityID.summonSkeletonArcher); summonWarlord = Ability.getAbility(AbilityID.summonSkeletonWarlord); summonBrawler = Ability.getAbility(AbilityID.summonSkeletonBrawler); skeletonAbilities.Add(ability); skeletonAbilities.Add(summonWarrior); skeletonAbilities.Add(summonMage); skeletonAbilities.Add(summonArcher); skeletonAbilities.Add(summonWarlord); skeletonAbilities.Add(summonBrawler); summonTracker = Comp <SummonTracker> .GetOrAdd(gameObject); summonTracker.newSummonEvent += onNewSummon; protectionClass = GetComponent <ProtectionClass>(); if (protectionClass) { health = protectionClass.healthClass; } else { health = GetComponent <BaseHealth>(); } mana = GetComponent <BaseMana>(); statBuffs = Comp <StatBuffs> .GetOrAdd(gameObject); }
//When the bullet (which was set as Trigger) enters an object with Collider... void OnTriggerEnter(Collider other) { /* * If the collider the bullet enters is an enemy we destroy it and the bullet as well. * Then, we increment the player's score by 10. */ if (other.tag == "Enemy") { Debug.Log("Enemy"); Destroy(other.gameObject); Destroy(gameObject); PlayerScore.playerScore += 10; } /* * If the collider the bullet enters is a base, then we reduce a point from * the base's "health" and destroy the bullet. */ else if (other.tag == "Base") { GameObject playerBase = other.gameObject; BaseHealth baseHealth = playerBase.GetComponent <BaseHealth> (); baseHealth.health -= 1; Destroy(gameObject); } }
IEnumerator LevelFinished() { int levelFinished = 0; BaseHealth bh = FindObjectOfType <BaseHealth>(); int healthDeduction = bh.startHealth - bh.GetHealth(); int lastSpawnCount = 0; while (healthDeduction + enemiesKilled != totalEnemiesToSpawn && levelFinished != 6) { if (lastSpawnCount != healthDeduction + enemiesKilled) { lastSpawnCount = healthDeduction + enemiesKilled; levelFinished = 0; } else { // Level was not ending on a rare occasion levelFinished++; Debug.Log(levelFinished); } healthDeduction = bh.startHealth - bh.GetHealth(); yield return(new WaitForSeconds(1)); } AudioSource.PlayClipAtPoint(victorySfx, Camera.main.transform.position); for (int i = 5; i > 0; i--) { startDelay.text = "Returning\n to level select \n in " + i + " seconds"; startDelay.fontSize = 32; yield return(new WaitForSeconds(1)); } SceneManager.LoadScene("LevelSelect"); }
public void Start() { m_PlayersHealth = GetComponent <BaseHealth>(); m_PlayersHealth.TakeDamageEvent += UIController.Instance.m_InGameUIController.m_PlayersHealthBarController.ReduceHealth; UIController.Instance.m_InGameUIController.m_PlayersHealthBarController.SetMaxHealth(m_PlayersHealth.GetMaxHealth()); m_PlayersHealth.OnResetHealth += UIController.Instance.m_InGameUIController.m_PlayersHealthBarController.ResetHealth; }
public void onKill(Ability _ability, GameObject target) { if (snakeOnKillChance > 0 && (_ability == ability)) { float rand = Random.Range(0f, 1f); if (rand < snakeOnKillChance) { if (!usingAbility) { usingAbility = GetComponent <UsingAbility>(); } if (usingAbility) { usingAbility.UseAbility(AbilityIDList.getAbility(AbilityID.summonSerpent), target.transform.position, false, false); } } } if (lifeOnKill != 0 && (_ability == ability)) { float rand = Random.Range(0f, 1f); if (rand < lifeOnKill) { if (!baseHealth) { baseHealth = GetComponent <BaseHealth>(); } if (baseHealth) { baseHealth.Heal(lifeOnKill); } } } }
void Awake() { rb = GetComponent <Rigidbody2D>(); col = transform.Find("Colliders").GetComponent <CircleCollider2D>(); stats = GetComponent <StatBlock>(); hp = GetComponent <BaseHealth>(); }
private void shootLaser() { laserLine.enabled = true; laserAudioSource.Play(); //Draw the laser RaycastHit hit; float distance = 0f; if (Physics.Raycast(shootingPoint.position, transform.forward, out hit, 100, wallLayerMask)) { distance = hit.distance; Vector3 endPoint = shootingPoint.localPosition + Vector3.forward * distance; laserLine.SetPosition(0, shootingPoint.localPosition); laserLine.SetPosition(1, endPoint); } //Get and damage colliders; laserTimer -= Time.deltaTime; if (laserTimer < 0) { laserTimer = laserTickRate; RaycastHit[] hits; hits = Physics.RaycastAll(shootingPoint.position, transform.forward, distance, enemyLayerMask); foreach (RaycastHit rayHit in hits) { BaseHealth health = rayHit.collider.GetComponentInParent <BaseHealth>(); if (health != null) { health.TakeDamage(laserDamage); } } } }
private void Start() { resourceController = FindObjectOfType <AMS_ResourceController>(); if (resourceController == null) { Debug.Log("can't find resource controller object"); } //this is just to find the bottom of the object var capColl = gameObject.GetComponent <CapsuleCollider>(); if (capColl != null) { rayOffset = (capColl.height / 2f) * gameObject.transform.localScale.y; } else { rayOffset = 1f; } note = gameObject.GetComponentInChildren <Canvas>().gameObject; if (note == null) { Debug.Log("can't find canvas gameObject"); } baseHealth = FindObjectOfType <BaseHealth>(); if (baseHealth == null) { Debug.Log("basehealth not found in scene"); } }
// Use this for initialization protected override void Awake() { ability = AbilityIDList.getAbility(AbilityID.shieldRush); health = GetComponent <BaseHealth>(); baseStats = GetComponent <BaseStats>(); base.Awake(); }
// Start is called before the first frame update void Start() { currentbase = FindObjectOfType <BaseHealth>(); AMS_ScoreController.rankScores = scoreRanks; AMS_ScoreController.score = 0; AMS_ScoreController.scoreMultiplier = 1; AMS_ScoreController.parTimes = parTimes; timeOnStart = Time.time; baseAlertCurrentTime = 0f; alertCurrentTime = 0f; var playerScript = FindObjectOfType <KE_MainPlayer_Script>(); if (playerScript != null) { var playerObj = playerScript.gameObject; playerHealth = playerObj.GetComponent <AMS_Health_Management>(); if (playerHealth == null) { Debug.Log("player health was not where expected"); } } else { Debug.Log("does not seem to be a player in the level"); } }
private void OnTriggerEnter2D(Collider2D other) { /* swapping if for switch statement, makes code run much faster * if(other.tag == "Player") * { * Destroy(gameObject); * PlayerScore.playerScore -= (int)EnemyController.Columns * 2; * } * else if(other.tag == "Base") * { * GameObject playerBase = other.gameObject; * BaseHealth baseHealth = playerBase.GetComponent<BaseHealth>(); * baseHealth.health -= 1; * Destroy(gameObject); * } */ switch (other.tag) { case "Player": Destroy(gameObject); PlayerScore.playerScore -= (int)EnemyController.Columns * 2; break; case "Base": GameObject playerBase = other.gameObject; BaseHealth baseHealth = playerBase.GetComponent <BaseHealth>(); baseHealth.health -= 1; Destroy(gameObject); break; } }
protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master) { XElement subEle; ele.TryPathTo("BaseHealth", true, out subEle); subEle.Value = BaseHealth.ToString(); ele.TryPathTo("Strength", true, out subEle); subEle.Value = Strength.ToString(); ele.TryPathTo("Perception", true, out subEle); subEle.Value = Perception.ToString(); ele.TryPathTo("Endurance", true, out subEle); subEle.Value = Endurance.ToString(); ele.TryPathTo("Charisma", true, out subEle); subEle.Value = Charisma.ToString(); ele.TryPathTo("Intelligence", true, out subEle); subEle.Value = Intelligence.ToString(); ele.TryPathTo("Agility", true, out subEle); subEle.Value = Agility.ToString(); ele.TryPathTo("Luck", true, out subEle); subEle.Value = Luck.ToString(); }
private void Start() { health = GetComponentInParent <AMS_Health_Management>(); currentCoolDown = 0f; baseHealth = FindObjectOfType <BaseHealth>(); }
// Use this for initialization void Start() { Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius); foreach (Collider otherCollider in colliders) { ExplodingElement explodingElement = otherCollider.gameObject.GetComponent <ExplodingElement>(); if (explodingElement != null) { explodingElement.Explode(transform.position, m_ExplosionRadius, m_ExplosionForce); } BaseHealth <int> health = otherCollider.gameObject.GetComponent <BaseHealth <int> >(); if (health != null) { health.Damage(m_Damage); } } m_Camera = Camera.main.GetComponent <CameraController>(); if (m_Camera != null) { m_Camera.Shake(m_CameraShake); } }
// Use this for initialization protected override void Awake() { ability = AbilityIDList.getAbility(AbilityID.summonWraith); health = GetComponent <BaseHealth>(); mana = GetComponent <BaseMana>(); if (health) { statBuffs = Comp <StatBuffs> .GetOrAdd(gameObject); tracker = Comp <SummonTracker> .GetOrAdd(gameObject); AbilityEventListener listener = Comp <AbilityEventListener> .GetOrAdd(gameObject); listener.onCritEvent += OnCrit; } // get wraith prefabs if (flameWraithPrefab == null) { Ability wraithAbility = Ability.getAbility(AbilityID.summonFlameWraith); if (wraithAbility && wraithAbility.abilityPrefab) { SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>(); if (summon) { flameWraithPrefab = summon.entity; } } wraithAbility = Ability.getAbility(AbilityID.summonPutridWraith); if (wraithAbility && wraithAbility.abilityPrefab) { SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>(); if (summon) { putridWraithPrefab = summon.entity; } } wraithAbility = Ability.getAbility(AbilityID.summonBloodWraith); if (wraithAbility && wraithAbility.abilityPrefab) { SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>(); if (summon) { bloodWraithPrefab = summon.entity; } } } // spirit escape prefab if (spiritEscapePrefab == null) { spiritEscapePrefab = PrefabList.getPrefab("spiritEscape"); } base.Awake(); }
// Use this for initialization void Start() { baseHealth = FindObjectOfType <BaseHealth>(); Pathfinder pathfinder = FindObjectOfType <Pathfinder>(); var path = pathfinder.GetPath(); StartCoroutine(FollowPath(path)); }
// Use to instantiate the class vars and other properties private void init() { // Set vel based on movement type rb2 = GetComponent <Rigidbody2D>(); rb2.gravityScale = 0; health = GetComponent <BaseHealth>(); explode = GetComponent <Explode>(); }
public static void MiniBDamage() { NPC = new NPCSystem(); baseHlth = new BaseHealth(); foreach (var o in NPCSystem.followers) { if (BB_BasicControls.OutpBuilt != 10) { if (GameObject.FindGameObjectsWithTag("House").Length > 0) { num = (BB_BasicControls.houseBuilt / 2); n = Mathf.Round(num); if (o.Status == "House") { if (n > 0) { GameObject house = GameObject.FindWithTag("House"); Destroy(house); destroyedbuilds++; n--; NPCSystem.removeFollower(o.Id); baseHlth.BaseHealthCalc(); } } } if (GameObject.FindGameObjectsWithTag("Outpost").Length > 0) { num1 = (BB_BasicControls.OutpBuilt / 2); n1 = Mathf.Round(num1); if (o.Status == "Outpost") { if (n1 > 0) { GameObject outpost = GameObject.FindWithTag("Outpost"); Destroy(outpost); destroyedbuilds++; n1--; NPCSystem.removeFollower(o.Id); baseHlth.BaseHealthCalc(); } } } tags = arr[Random.Range(0, 1)]; if (o.Status == tags) { if (GameObject.FindGameObjectsWithTag(tags).Length > 0) { GameObject building = GameObject.FindWithTag(tags); Destroy(building); destroyedbuilds++; NPCSystem.removeFollower(o.Id); baseHlth.BaseHealthCalc(); } } } } }
void Start() { body2D = GetComponent <Rigidbody2D>(); renderer2D = GetComponent <SpriteRenderer>(); animator = GetComponent <Animator>(); controller = GetComponent <PlayerSubmarineController>(); health = GetComponent <BaseHealth>(); explode = GetComponent <Explode>(); }
protected virtual void OnTick(BaseHealth target) { if (Lib.HasTagInHierarchy(target.gameObject, "Player")) { return; } target.Damage(1, creator, target.gameObject); }
private void Awake() { m_ShipHealth = GetComponent <BaseHealth>(); m_ShipHealth.TakeDamageEvent += m_HealthBarController.ReduceHealth; m_ShipHealth.TakeDamageEvent += m_EnemyAnimation.DoOnTakeDamageAnimation; m_HealthBarController.SetMaxHealth(m_ShipHealth.GetMaxHealth()); }
void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <PlayerHealth> (); baseObject = GameObject.FindGameObjectWithTag("Base"); baseHealth = baseObject.GetComponent <BaseHealth>(); enemyHealth = GetComponent <EnemyHealth>(); anim = GetComponent <Animator> (); }
void Awake() { Laser = LaserPoint.GetComponent <Light>(); timeBetweenBullets = 1 / MaxFrequence; basehealth = GetComponent <BaseHealth>(); }
int spawnCheckPositionsMaxTries = 50; // Max tries to check for spawn position void Start() { this.GetMinMaxWallsPositions(); playerHealth = GameObject.Find(GlobalVars.playerTankName).GetComponent <PlayerHealth> (); baseHealth = GameObject.Find(GlobalVars.playerBase).GetComponent <BaseHealth> (); // Call the Spawn function after a delay of the spawnTime and then continue to call after the same amount of time. InvokeRepeating("Spawn", spawnTime, spawnTime); }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Base") { GameObject playerBase = other.gameObject; BaseHealth baseHealth = playerBase.GetComponent <BaseHealth>(); baseHealth.health -= 1; Destroy(gameObject); } }
// Use this for initialization protected override void Awake() { ability = AbilityIDList.getAbility(AbilityID.hammerThrow); base.Awake(); mana = GetComponent <BaseMana>(); health = GetComponent <BaseHealth>(); AbilityEventListener ael = AbilityEventListener.GetOrAdd(gameObject); ael.onHitEvent += OnHit; }
// Use this for initialization protected override void Awake() { ability = AbilityIDList.getAbility(AbilityID.volatileReversal); AbilityEventListener ael = AbilityEventListener.GetOrAdd(gameObject); ael.onKillEvent += OnKill; chargeManager = GetComponent <ChargeManager>(); health = GetComponent <BaseHealth>(); base.Awake(); }
void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent<PlayerHealth>(); enemyHealth = GetComponent<EnemyHealth>(); baseObj = GameObject.Find("Base"); model = baseObj.transform.FindChild("baseModel").FindChild("Mesh1"); baseHealth = baseObj.GetComponent<BaseHealth>(); anim = this.GetComponentInChildren<Animator>(); }
void OnTriggerExit2D(Collider2D col) { BaseHealth i = Lib.FindInHierarchy <BaseHealth>(col.gameObject); if (i == null) { return; } inside.Remove(i); }
public void OnTriggerEnter(Collider other) { BaseHealth health = other.GetComponentInParent <BaseHealth> (); if (health != null) { Debug.Log("Killing " + other.gameObject.name); health.KillSelf(); } }
public void InitialiseBaseHealth(Team team, ComputerLane computerLane) { this.team = team; GameObject[] bases = GameObject.FindGameObjectsWithTag(gameObject.tag); foreach (GameObject other in bases) { if(other && other != gameObject) { otherBase = other.GetComponent<BaseHealth>(); } } this.computerLane = computerLane; InitialiseHealth(computerLane); }
void Start() { _bd = GetComponent<BaseHealth>(); }
/// <summary> /// Called when this bullet hits an object that has a target attached /// </summary> /// <param name="_target">_target.</param> public virtual void OnTargetCollision( BaseHealth _health, bool _passingThrough ) { if ( _health.Owner == null || _health.Owner.team != this.source.health.Owner.team ) { _health.DealDamage( this.desc.damage * this.damageScale, true, this.source.health.Owner ); } if ( !_passingThrough ) { BulletManager.instance.DestroyLocalBullet( this ); } }
public bool IsValidTarget( BaseHealth _health, BaseWeaponManager _weaponScript ) { // Ignore dead targets if ( _health == null || _health.currentHealth <= 0.0f || _health.enabled == false || _health.gameObject.activeInHierarchy == false // The target that is doing the search || _health == _weaponScript.health // And those that aren't of the type specfied || ((int)(_health.targetType) & _weaponScript.restrictions.types) == 0 ) { return false; } Vector3 vectorToTarget = _health.transform.position - _weaponScript.transform.position; if ( _weaponScript.restrictions.ignoreBelowHorizon && Vector3.Dot( vectorToTarget, _weaponScript.transform.up ) < 0.0f ) { return false; } // Ignore targets out of range Vector3 v = _health.transform.position - _weaponScript.restrictions.transform.position; float dist = v.magnitude; if ( _weaponScript.restrictions.maxDistance > 0.0f && dist > _weaponScript.restrictions.maxDistance ) { return false; } // Ignore targets not in the team target list if ( _health.Owner == null || ((int)_health.Owner.team & _weaponScript.restrictions.teams ) == 0 ) { return false; } RaycastHit hitInfo; bool hit = Physics.Linecast( _weaponScript.transform.position, _health.transform.position, out hitInfo, this.lineOfSightBlockingLayers ); if ( hit && hitInfo.collider.gameObject != _health.gameObject && hitInfo.collider.gameObject != _weaponScript.gameObject ) { return false; } return true; }
public bool IsMissileTargetting( BaseHealth _health ) { foreach ( KeyValuePair<NetworkViewID, SmartBullet> pair in this.smartBulletMap ) { SeekingBullet seekingBullet = pair.Value as SeekingBullet; if ( seekingBullet == null ) { continue; } if ( seekingBullet.target == _health ) { return true; } } #if UNITY_EDITOR if ( Network.peerType == NetworkPeerType.Disconnected ) { foreach ( KeyValuePair<int, SmartBullet> pair in this.debugSmartBulletMap ) { SeekingBullet seekingBullet = pair.Value as SeekingBullet; if ( seekingBullet == null ) { continue; } if ( seekingBullet.target == _health ) { return true; } } } #endif return false; }
public void RemoveTarget( BaseHealth _target ) { #if UNITY_EDITOR this.debugTargets.Remove( _target ); if ( Network.peerType == NetworkPeerType.Disconnected ) { this.debugTargetMap.Remove( _target.debugTargetID ); } else #endif { this.targetMap.Remove( _target.GetComponent<NetworkView>().viewID ); } }
void Start() { this.GetMinMaxWallsPositions (); playerHealth = GameObject.Find(GlobalVars.playerTankName).GetComponent<PlayerHealth> (); baseHealth = GameObject.Find(GlobalVars.playerBase).GetComponent<BaseHealth> (); // Call the Spawn function after a delay of the spawnTime and then continue to call after the same amount of time. InvokeRepeating ("Spawn", spawnTime, spawnTime); }
void Start() { playerHealth = GameObject.Find(GlobalVars.playerTankName).GetComponent<PlayerHealth> (); baseHealth = GameObject.Find(GlobalVars.playerBase).GetComponent<BaseHealth>(); }
private void AreaOfEffectDamageCheck( BaseHealth _health, Vector3 _position, float _radius, float _damage, bool _friendlyFire, GamePlayer _sourcePlayer ) { if ( _friendlyFire && _sourcePlayer.team == _health.Owner.team ) { return; } float distance = (_health.transform.position - _position ).magnitude; if ( distance < _radius ) { float multiplier = 1.0f - distance / _radius; _health.DealDamage( _damage * multiplier, true, _sourcePlayer ); } }
public Rect GetHealthGUIRect( BaseHealth _health ) { Rect r = new Rect(); if ( _health.guiExtents.Length == 0 ) { Vector3 pos = Camera.main.WorldToScreenPoint( _health.transform.position ); pos.y = Screen.height - pos.y; r.x = pos.x; r.y = pos.y; r.height = r.width = this.minimumBracketScale; } else { r.xMin = r.yMin = float.MaxValue; r.xMax = r.yMax = float.MinValue; foreach ( Transform extent in _health.guiExtents ) { Vector2 pos = Camera.main.WorldToScreenPoint( extent.position ); pos.y = Screen.height - pos.y; r.xMin = Mathf.Min( r.xMin, pos.x ); r.xMax = Mathf.Max( r.xMax, pos.x ); r.yMin = Mathf.Min( r.yMin, pos.y ); r.yMax = Mathf.Max( r.yMax, pos.y ); } if ( r.width < this.minimumBracketScale ) { float centre = r.x + r.width/2; r.x = centre - this.minimumBracketScale/2; r.width = this.minimumBracketScale; } if ( r.height < this.minimumBracketScale ) { float centre = r.y + r.height/2; r.y = centre - this.minimumBracketScale/2; r.height = this.minimumBracketScale; } } return r; }
public void SwitchToNextMissileTargettingMe() { this.currentTarget = BulletManager.instance.GetNextMissileLock( this, 1 ); }
protected override void Update() { base.Update(); if ( this.state != BULLET_STATE.FADING && this.health.currentHealth > 0.0f && this.distanceTravelled >= this.seekingDesc.seekingDelayDistance && this.target != null ) { this.TurnToTarget(); Vector3 vectorToTarget = (target.transform.position - this.transform.position).normalized; float angleToTarget = Vector3.Angle( this.transform.forward, vectorToTarget ); if ( this.seekingDesc.canAngleOut && angleToTarget >= this.seekingDesc.maxDetectionAngle ) { this.target = null; } } this.GetComponent<Rigidbody>().velocity = this.transform.forward * this.seekingDesc.moveSpeed; }