private void Awake() { anim = GetComponent <Animator>(); ag = GetComponent <NavMeshAgent>(); unit = GetComponent <Unit> (); h = GetComponent <UnitHealth>(); }
public void randomShootAttackHeavy(GameObject prefab, Transform targetPos, UnitHealth target, Transform shootPosition) { int RandomNum = (int)Random.Range(0, heavyRangedAttacks.Length); animator.SetTrigger(heavyRangedAttacks[RandomNum]); StartCoroutine(WaitAndShoot(prefab, targetPos, target, shootPosition, heavyRangedAttackShootPoint[RandomNum])); }
void Awake() { moveRangeCollider = transform.Find("MoveRangeCollider").gameObject.GetComponent<MoveRangeCollider>(); unitHealth = GetComponent<UnitHealth>(); inAttackRange = false; inRangeList = new List<GameObject>(); }
public void CheckAgro() { if (hasTarget) { return; } agroChecks++; Collider[] hitColliders = Physics.OverlapSphere(transform.position, detectDistance, GameManager.instance.unitLayermask); List <Collider> possibleTargets = hitColliders.ToList <Collider>(); possibleTargets.Remove(unitCollider); int random = Random.Range(0, possibleTargets.Count); try { if (possibleTargets[random].tag != this.tag) { UnitHealth _target = possibleTargets[random].GetComponent <UnitHealth>(); ChaseTarget(_target, _target.transform); agroChecks = 0; } else if (agroChecks <= 2) { CheckAgro(); } } catch { return; } }
public void BlockAttack(UnitHealth target) { int RandomNum = (int)Random.Range(0, blockAttackAnims.Length); animator.SetTrigger(blockAttackAnims[RandomNum]); target.TakeDamageWDelayed(unitScript.basicAttackDamage, blockAnimHitTimes[RandomNum]); }
void FireBullet() { Ray ray = new Ray(Muzzle.position, Muzzle.forward); RaycastHit hit; Physics.Raycast(ray, out hit); flashLine.positionCount = 2; flashLine.SetPosition(0, Muzzle.position); flashLine.SetPosition(1, hit.point); flashStay = FlashStayTime; flashLine.enabled = true; if (hit.collider) { UnitHealth hitBody = hit.collider.gameObject.GetComponent <UnitHealth>(); HitCollider hitCollider = hit.collider.gameObject.GetComponent <HitCollider>(); if (!hitBody && hitCollider && hitCollider.ColliderType == HitCollider.Type.Receive) { hitBody = hitCollider.GetOwner(); } if (hitBody) { hitBody.Damage(DamagePerBullet); } } }
void Awake() { moveRangeCollider = transform.Find("MoveRangeCollider").gameObject.GetComponent <MoveRangeCollider>(); unitHealth = GetComponent <UnitHealth>(); inAttackRange = false; inRangeList = new List <GameObject>(); }
private void AttackAction() { if (this.attackee != null) { if (!this.agent.pathPending) { if (this.agent.remainingDistance <= this.agent.stoppingDistance) { if (this.agent.hasPath || this.agent.velocity.sqrMagnitude == 0f) { //Stopped. float distance = Vector3.Distance(this.transform.position, this.attackee.transform.position); if (distance >= 1f) { this.agent.stoppingDistance = 0.9f; this.agent.SetDestination(this.attackee.transform.position); } } } } //Do attack here. UnitHealth health = this.attackee.GetComponent <UnitHealth>(); if (health != null && health.healthPoints > 0) { this.attackee.SendMessage("DoDamage"); } return; } }
public void SetHudElement(UnitController _unitController, UnitHealth _unitHealth) { unit = new UnitInfo(_unitController, _unitHealth); anim = GetComponentInChildren <Animator>(); drawing = FindObjectOfType <Drawing>(); buttonImage = addButton.GetComponent <Image>(); if (_unitController is MeleeUnitController) { shortcutKey.text = "1"; } else if (_unitController is RangedUnitController) { shortcutKey.text = "2"; } else if (_unitController is AoeUnitController) { shortcutKey.text = "3"; } if (_unitController.GetComponentInParent <LeaderSwitch>() != null) { shortcutKey.text = "0"; } typeImage.sprite = _unitController.image; addButton.onClick.AddListener(delegate { AddAgent(unit.unitController.agent); }); }
void Start() { //Get GameController from StaticRef gC = StaticRef.gameControllerRef.GetComponent <GameController> (); //Get Components agent = GetComponent <NavMeshAgent> (); triggerCollider = GetComponent <SphereCollider> (); health = GetComponent <UnitHealth> (); health.unit = this; controller = GetComponent <UnitController> (); controller.unit = this; stateC = GetComponent <UnitStateController> (); if (stateC != null) { stateC.unit = this; } condM = GetComponent <UnitConditionManager> (); condM.unit = this; //Load unit from UnitRef if (preset != null && loadRefValues) { preset.LoadUnitFromRef(this); } controller.InitializeController(); health.InitializeHealth(); }
// Use this for initialization void Start() { rigid = GetComponent <Rigidbody>(); downVel = new Vector3(xVel, yVel, 0); anim = GetComponent <Animator>(); thisSkree = GetComponent <UnitHealth>(); }
void AttackTarget() { targetHealth = currentTarget.GetComponent <UnitHealth>(); //gameObject.transform.LookAt(currentTarget.transform); targetHealth.TakeDamage(damage); }
IEnumerator GiveDamage(UnitHealth unitHealth) { damageGiven = true; unitHealth.TakeDamage(); yield return(new WaitForSeconds(damageRate)); damageGiven = false; }
public void Fire(GameObject prefab, Transform targetPos, UnitHealth target, Transform shootPosition) { GameObject projectile = (GameObject)Instantiate(prefab, shootPosition.position, Quaternion.identity); Projectile projscript = projectile.GetComponent <Projectile>(); projscript.target = target; projscript.targetTrans = targetPos; }
// Use this for initialization void Start () { gunLine = GetComponentInChildren<LineRenderer>(); gunLight = GetComponentInChildren<Light>(); //barrelEnd = transform.FindChild("Turret").FindChild("Gun").FindChild("GunMuzzle"); //turret = transform.FindChild("Turret").gameObject; unitHealth = GetComponent<UnitHealth>(); weapon = GetComponentInChildren<Weapon>(); }
public void HeavyAttack(UnitHealth target) { if (canAttack == false) { return; } unitAnimator.randomAttack2(target); }
private void OnTriggerEnter(Collider other) { UnitHealth targetHealth = other.gameObject.GetComponent <UnitHealth>(); if (targetHealth != null) { DealDamage(targetHealth); } }
private void OnTriggerExit(Collider other) { UnitHealth unit = other.GetComponent <UnitHealth>(); if (unit != null && units.Contains(unit)) { units.Remove(unit); } }
private void OnTriggerEnter(Collider other) { UnitHealth unit = other.GetComponent <UnitHealth>(); if (!triggered && unit != null) { TriggerTrap(); } }
public void UnitHealthSucessfullyInitialize() { int maxHealth = Random.Range(2, 100); GameObject unit = CreateDefaultEnemyWithStats(CreateUnitStats(maxHealth, 1, 1.5f)); UnitHealth unitHealth = unit.GetComponent <UnitHealth>(); Assert.AreEqual(maxHealth, unitHealth.currentHealth); Assert.AreEqual(unitHealth.alive, true); }
private void OnTriggerEnter(Collider other) { UnitHealth unit = other.GetComponent <UnitHealth>(); if (unit != null) { unit.Hit(damage, null); } }
private void OnTriggerStay(Collider collision) { UnitHealth uh = collision.gameObject.GetComponent <UnitHealth>(); if (uh != null) { parent.hitPlayer(uh); } }
private void OnTriggerEnter2D(Collider2D other) { Debug.Log("Collision!"); UnitHealth health = other.gameObject.GetComponent <UnitHealth>(); if (health != null) { health.TakeDamage(_damage); } }
public void Alert(UnitHealth target = null) { alertTimer = AlertTime; if (target) { targetEnemy = target; lastSeenEnemy = target; lastSeenEnemyPos = target.transform.position; } }
private void OnTriggerEnter(Collider other) { UnitHealth unit = other.GetComponent <UnitHealth>(); if (unit != null && !triggered) { spawnParticules.Play(); triggered = true; } }
public void SetUpHud() { UnitController[] controllers = GetComponentsInChildren <UnitController>(); foreach (UnitController controller in controllers) { UnitHealth health = controller.transform.GetComponentInChildren <UnitHealth>(); UnitHudElement currentElement = Instantiate(unitImage, unitPannel.transform).GetComponent <UnitHudElement>(); currentElement.SetHudElement(controller, health); } }
private void dealDamage(GameObject go) { UnitHealth uh = go.GetComponent <UnitHealth>(); if (uh != null) { //Debug.Log (otherPost); uh.TakeDamage(myDamage, knockback, this.transform.position, lateralKnockback); } }
void OnCollisionEnter2D(Collision2D collision) { collision.collider.gameObject.transform.position = new Vector3(respawnPoint.position.x, respawnPoint.position.y); UnitHealth health = collision.collider.GetComponent <UnitHealth>(); if (health) { health.Damage(pitDamage); } }
public void hitPlayer(UnitHealth uh) { if (!hittingPlayerThisFrame) { hittingPlayerThisFrame = true; //Debug.Log("HIT PLAYER"); uh.TakeDamage(1, 0, transform.position, true, false); PlayerRun.slowDown(); } }
public UIHealthBar Create(UnitHealth healthSystem) { UIHealthBar healthBar = Instantiate(healthBarPrefab, transform); healthBar.Setup(this, healthSystem); RegisterHealthBar(healthBar); return(healthBar); }
/// /// The following methods are used to generate and handle the constraint/ability lists. /// /// <summary> /// Called when a unit status is initialized. /// </summary> public void initializeUnitAbilities() { myHealth = GetComponent <UnitHealth>(); UnitAbility[] newAbilities = GetComponents <UnitAbility>(); myAbilities = new UnitAbility[newAbilities.GetLength(0)]; foreach (UnitAbility ability in newAbilities) { myAbilities[ability.getMyAbilityIndex()] = ability; Debug.Log(ability.getMyAbilityIndex()); } }
public ICharacter Construct(ICharacteristicController characteristicController) { CharacteristicController = characteristicController; health = new UnitHealth(this); gameobject = this.gameObject; CharacteristicController.Attributes.UpdateAttribute(AttributeType.Agility, 1); CharacteristicController.Attributes.UpdateAttribute(AttributeType.Strength, 1); CharacteristicController.Attributes.UpdateAttribute(AttributeType.Wisdom, 1); CharacteristicController.Attributes.UpdateAttribute(AttributeType.Endurance, 1); return(this); }
public virtual bool Fire(UnitHealth target) { if (LastShotTime + (60 / fireRate) < Time.time && currentMagazine > 0) { fireSound.Play(); target.health -= damage; LastShotTime = Time.time; currentMagazine -= 1; return true; } else { Reload(); return false; } }
void Awake() { controller = GetComponent<CharacterController> (); unit = GetComponent<UnitHealth> (); }