void Start() { // Setting up the references. ai = GetComponent <EnemyAI2>(); anim = GetComponent <Animator>(); //enemyAudio = GetComponent<AudioSource>(); //hitParticles = GetComponentInChildren<ParticleSystem>(); circleCollider = GetComponent <CircleCollider2D>(); loot = GetComponent <LootDrops>(); // Setting the current health when the enemy first spawns. currentHealth = startingHealth; previousHealth = startingHealth; healthbar.SetActive(false); rez = GetComponent <Resurrectable>(); spriteRend = GetComponent <SpriteRenderer>(); if (isStunnable) { stunnable = GetComponent <Stunnable>(); } var prefabs = GameObject.FindGameObjectWithTag("Load").GetComponent <LoadedPrefabs>().prefabs; foreach (var prefab1 in prefabs) { if (prefab1.name == "CritAnim") { critPrefab = prefab1; break; } } CheckOnFire(); CheckFrozen(); }
public void OnCollisionEnter2D(Collision2D collision) { Stunnable stunnable = collision.collider.GetComponentInParent <Stunnable>(); if (stunnable != null && (firstCollision || rigid.velocity.magnitude > stunVelocity)) { stunnable.Stun(stunTime); } firstCollision = false; }
void Start() { ps = GetComponent <ParticleSystem>(); anim = GetComponent <Animator>(); eh = GetComponentInParent <EnemyHealth>(); stunnable = GetComponentInParent <Stunnable>(); ai = GetComponentInParent <EnemyAI2>(); StartCoroutine(StunRune()); }
void OnTriggerStay2D(Collider2D other) { Rigidbody2D r = other.GetComponent <Rigidbody2D>(); if (r != null) { r.AddForce(force * (transform.position - r.transform.position).normalized, ForceMode2D.Force); if (stun) { Stunnable s = r.GetComponent <Stunnable>(); if (s != null) { s.Stun(0.1f); } } } }
void Start() { gHook = GetComponent <GrapplingHook> (); if (gHook == null) { Debug.LogWarning("gHook is Null"); } mPick = GetComponent <Pickaxe>(); respawn = GetComponent <Respawnable>(); stun = GetComponent <Stunnable>(); avatar = GetComponent <Avatar>(); if (avatar == null) { Debug.LogError("Avatar is Null"); } playerAssignCR = StartCoroutine(WaitForPlayerAssign()); }
public void OnTriggerStay2D(Collider2D other) { Rigidbody2D r = other.GetComponentInParent <Rigidbody2D>(); if (r != null && !r.isKinematic) { float dis = Vector2.Distance(transform.position, r.transform.position); if (dis > range) { return; } r.AddForce(transform.right * pushForce * (1f - (dis / range)), ForceMode2D.Force); if (dis < range / 2f) { Stunnable stunnable = r.GetComponent <Stunnable>(); if (stunnable != null) { stunnable.Stun(0.3f); } } } }
// Use this for initialization void Start() { Transform parent = transform.parent; stunControl = parent.GetComponent <Stunnable>(); }