void OnTriggerEnter2D(Collider2D hitInfo) { //Makes editor happy EnemyBasic enemy = null; //Destroyes bullet on collision with anything but player, potions, or enemy detection if (!hitInfo.CompareTag("Player") && !hitInfo.CompareTag("Potions") && !hitInfo.CompareTag("Function")) { Debug.Log(hitInfo.CompareTag("Function")); Destroy(gameObject); } if (hitInfo.CompareTag("Enemy")) { //hitInfo is actually hitting collider of enemy not enemy itself //So we need to get parent of collider where the EnemyBasic script resides if (hitInfo.transform.parent != null) { enemy = hitInfo.transform.parent.GetComponent <EnemyBasic>(); } else { enemy = hitInfo.GetComponent <EnemyBasic>(); } if (enemy != null) { enemy.takeDamage(damage); } } }
public override void Start(RAIN.Core.AI ai) { enemyshoot = ai.WorkingMemory.GetItem <EnemyBasic> ("enemyshoot"); //enemyshoot.canShoot = true; base.Start(ai); }
void AddConcussion() { foreach (GameObject enemy in enemies) { /* * if (enemy.gameObject != null) * if (enemy.GetComponent<Rigidbody2D>() != null) * rbEnemy = enemy.GetComponent<Rigidbody2D>(); * * direction = new Vector2(enemy.transform.position.x - transform.position.x, enemy.transform.position.y - transform.position.y).normalized; * ConcussionBehaviour(direction); */ if (enemy.GetComponent <HealthComponent>() != null) { _healthComponent = enemy.GetComponent <HealthComponent>(); _healthComponent.health -= concussionDamage; } if (enemy.GetComponent <EnemyBasic>() != null) { enemyOnetest = enemy.GetComponent <EnemyBasic>(); enemyOnetest.stun = true; } _addOns.ConcussionAdditionalLifeSteal(); _momentumComponent.AddMomentum(4); //_enemyHopMovement = enemy.GetComponent<EnemyHopMovement>(); } foreach (GameObject proj in eProj) { Destroy(proj); } }
void SpawnBasic(ShipSettings setts, Vector3 initialPos, Vector2 bounds) { GameObject newEnemy = Pool2.GetGameObjectFromPool(); if (newEnemy) { EnemyBasic enemy = newEnemy.GetComponent <EnemyBasic>(); if (!enemy) { enemy = newEnemy.AddComponent <EnemyBasic>(); } BulletSettings bSetts = new BulletSettings(); bSetts.Damage = 10; bSetts.Speed = 5; bSetts.Type = BulletType.LINEAR; setts.Bullet = bullet; setts.BulletParameters = bSetts; setts.HitPoints = 10; setts.MovementSpeed = 10; setts.RateOfFire = 0.5f; enemy.InitializeCurve(initialPos, bounds); enemy.Initialize(setts); } }
public void Move(NavMeshAgent agent, Vector3 playerPos, EnemyBasic enemy, float moveSpeed, float gridLimit) { bool pathSuccefull = false; if (enemy.ArrivedAtDestination() || !agent.hasPath) { do { pathSuccefull = enemy.ChangeDestination(new Vector3(Random.Range(-gridLimit, gridLimit), 0, Random.Range(-gridLimit, gridLimit))); } while (!pathSuccefull); } }
private void CastSpell(int spellID = 0, int MinimumPoints = 50) { EnemyBasic enemyBasicBody = GetComponent <EnemyBasic> (); if (enemyBasicBody.MagicPoints >= MinimumPoints) { enemyBasicBody.MagicPoints -= MinimumPoints; Debug.Log("Has Enough MagicPoint to Cast Spell"); Instantiate(SpellMagicBall); } else { Debug.Log("Donot has enough MagicPoints to Cast!!!!!"); } }
public override ActionResult Execute(RAIN.Core.AI ai) { enemyshoot = ai.Body.GetComponentInChildren <EnemyBasic>(); //enemyshoot.Start (); //enemyshoot.Update (); //enemyshoot.canShoot=true; if (enemyshoot.canShoot == true) { enemyshoot.Shoot(); enemyshoot.canShoot = false; } //yield return new WaitForSeconds(0.4f); return(ActionResult.SUCCESS); }
void OnTriggerEnter2D(Collider2D collider) { int colliderId = collider.GetInstanceID(); if ((collider.gameObject.layer == 8 || collider.gameObject.layer == 10) && !hitList.Contains(colliderId)) { EnemyBasic enemy = collider.gameObject.GetComponent <EnemyBasic>(); enemy.TakeDamage(); var source = GetComponentInParent <AudioSource>(); source.clip = hitSound; source.Play(); enemy.KnockbackEnemy(PlayerManager.instance.Player.transform.position); //only works if has rigidbody hitList.Add(colliderId); } }
// If the Player Enters the Hit Box public void OnTriggerEnter2D(Collider2D collision) { // If the Collision is caused by the Player if (collision.CompareTag("Player")) { // Get the Player Debug.Log("Enemy Hit!"); player = collision.transform.parent.GetComponent <PlayerHealthManager>(); // Storing the Enemy enemy = transform.parent.GetComponent <EnemyBasic>(); // Enemies Damage float damg = enemy.dmg; // Player Takes Damage player.takeDamage(damg); } }
// Use this for initialization void Start() { maxHealth = GetComponent <EnemyBasic>().health; rb = GetComponent <Rigidbody2D>(); sr = GetComponent <SpriteRenderer>(); enemy = GetComponent <EnemyBasic>(); player = PlayerManager.instance.Player; ps = player.GetComponent <PlayerStats>(); state = BossState.Idle; StartCoroutine(SlashTimer()); cam = GameObject.FindGameObjectWithTag("MainCamera"); if (ps.past) { sr.sprite = downPast; } else { sr.sprite = downFuture; } enemy.onDeath += Death; }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag == "Enemy") { EnemyBasic challenger = col.gameObject.GetComponent <EnemyBasic> (); if (playerManager.fastEnough()) { challenger.giveDamage(attack); } } if (col.gameObject.tag == "Stick") { a_rigidbody.isKinematic = true; a_rigidbody.simulated = false; if (!hasIdled) { a_anim.Play("Idle"); a_anim.SetBool("IsCharging", false); a_anim.SetBool("HasFired", false); hasIdled = true; } } }
public void Move(NavMeshAgent agent, Vector3 playerPos, EnemyBasic enemie, float moveSpeed, float gridLimit) { agent.SetDestination(playerPos); //charCtrl.SimpleMove((playerPos-charCtrl.transform.position)*moveSpeed*Time.deltaTime); }
public void CheckPlayerPosition(Vector3 playerPos, Vector3 enemyPos, EnemiesStates states, EnemyBasic enemy, float minDistToAwake, float minDistToChase) { if (Vector3.Distance(playerPos, enemyPos) > minDistToAwake) { enemy.ChangeState(states.asleep); } else if (Vector3.Distance(playerPos, enemyPos) >= minDistToChase) { enemy.ChangeState(states.patrolling); } }
void Update() { RaycastHit2D hit; if (Input.GetButtonDown("Jump") && isGrounded) { //anim.SetBool ("Ground", false); gameObject.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, jumpForce)); } /* * If fire button is pressed, activate meleeAttack game object for X seconds (determined by meleeDuration) * RT is a trigger has value between -1.0f and 1.0f. Snap setting in Input manager gives it value of 0 or 1. * If value is greater than 0, then attack * */ //locks melee to red power //if (GameObject.Find("Player").GetComponent<OrangePowerUp>().powerEquipped == 1) //{ float primaryAttack = Input.GetAxis("primaryAttack"); if (primaryAttack > 0) { meleeAttack.SetActive(true); attackDuration = Time.time + meleeDuration; Debug.DrawRay(meleeRay.transform.position, meleeStrike, Color.green, swordLength); hit = Physics2D.Raycast(meleeRay.transform.position, meleeStrike, swordLength); if (hit != null && hit.collider != null && hit.collider.tag == "Enemy") { enemyBasic = hit.collider.gameObject; enemy = enemyBasic.GetComponent <EnemyBasic>(); enemy.TakeDamage(); } } //} //End of script locked to powerup red if (meleeAttack.activeInHierarchy && Time.time > attackDuration) { meleeAttack.SetActive(false); } if (isDamaged) { damageImage.color = flashColour; AudioSource.PlayClipAtPoint(dmg, transform.position, 3.0f); } else { damageImage.color = Color.Lerp(damageImage.color, Color.clear, flashSpeed * Time.deltaTime); } isDamaged = false; //flip by using right joystick var dir = Mathf.Sign(Input.GetAxis("lookDirection")); if ((Input.GetAxis("lookDirection") > 0.1f && this.transform.localScale.x != 1) || (Input.GetAxis("lookDirection") < -0.1f && this.transform.localScale.x != -1)) { Flip(); } }
public override ActionResult Execute(RAIN.Core.AI ai) { enemyshoot = ai.Body.GetComponentInChildren <EnemyBasic>(); enemyshoot.canShoot = true; return(ActionResult.FAILURE); }
public void Move(NavMeshAgent agent, Vector3 playerPos, EnemyBasic enemie, float moveSpeed, float gridLimit) { }
public float LastEnemySpeed; //ダメージ、フリーズ処理する前の敵の基本スピード /*[CustomEditor(typeof(Zombie1))] * public class Zombie1 : Editor // using UnityEditor; を入れておく * { * bool folding = false; * * public override void OnInspectorGUI() * { * Zombie1 Zn1 = target as Zombie1; * Zn1.DamageTime= EditorGUILayout.FloatField( "被ダメージ硬直時間", Zn1.DamageTime); * Zn1.FreezeTime= EditorGUILayout.FloatField( "フリーズ硬直時間", Zn1.FreezeTime); * } * }*/ // Use this for initialization void Start() { // EnemyBasicスクリプトのデータを最初に呼び出しenemyBasicとする enemyBasic = gameObject.GetComponent <EnemyBasic> (); LastEnemySpeed = enemyBasic.EnemySpeed; }
public void CheckPlayerPosition(Vector3 playerPos, Vector3 enemyPos, EnemiesStates states, EnemyBasic enemy, float minDistToAwake, float minDistToChase) { }