public virtual void Fire() { startPoint = cam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0)); Debug.DrawRay(startPoint, cam.transform.forward, Color.red); if (Input.GetMouseButtonDown(0) && Time.time >= lastShot && ammo > 0) { ammo--; anim.SetTrigger("Fire"); lastShot = Time.time + fireRate; RaycastHit hit; if (Physics.Raycast(startPoint, cam.transform.forward, out hit, range)) { Debug.Log("haha"); if (hit.collider.gameObject.layer == enemyLayer) { EnemyAbstract basic = hit.collider.gameObject.GetComponentInParent <EnemyAbstract>(); basic.hit = hit; basic.Damage(damage); } else { if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * 5); } } } } }
public void Spawn(GameObject enemy, Transform spawnPosition) { GameObject enemy1 = Instantiate(enemy, spawnPosition); EnemyAbstract enemyCode = enemy1.GetComponent <EnemyAbstract>(); enemyCode.player = player; enemyCode.level = this; }
public void Spawn(GameObject enemy, Transform spawnPosition) { GameObject enemy1 = Instantiate(enemy, spawnPosition.transform.position, Quaternion.identity); EnemyAbstract enemyCode = enemy1.GetComponent <EnemyAbstract>(); enemyCode.player = player; enemyCode.level = this; Debug.Log("spawned"); }
protected override void HandeleCollide(EnemyAbstract obj, ControllerColliderHit hit) { float trackXCoord = ((track as Track3) != null) ? (track as Track3).CurrentXCoord : controller.transform.position.z; float diff = (trackXCoord - controllerTransform.position.x); TurnDirection direction = diff < 0 ? TurnDirection.Left : TurnDirection.Right; controller.DeadState.TurnDirection = direction; Dead(DeadReason.EnemySide); }
public override int UpdateNode(EnemyAbstract con) { if (con.health <= 25) { return(2); } else { return(0); } }
public override void Fire() { if (Input.GetMouseButton(0) && Time.time >= lastShot && ammo > 0 && !isReloading && !isHolster & !isDraw && !move.sprint) { audioo.Play(); rec.AddRecoil(Random.Range(-1, 2) / 2f, Random.Range(0, 3) / 2f); startPoint = cam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0)); ammo--; muzzleParticles.Emit(Random.Range(2, 4)); anim.SetTrigger("fire"); GameObject bullet1 = Instantiate(bullet, bulletLocation.transform.position, bulletLocation.transform.rotation); bullet1.GetComponent <Rigidbody>().velocity = bullet1.transform.forward * 500; lastShot = Time.time + fireRate; RaycastHit hit; if (Physics.Raycast(startPoint, cam.transform.forward, out hit, range)) { Debug.Log("haha"); if (hit.collider.gameObject.layer == enemyLayer) { if (hit.collider.gameObject.GetComponentInParent <EnemyAbstract>() != null) { EnemyAbstract basic = hit.collider.gameObject.GetComponentInParent <EnemyAbstract>(); basic.hit = hit; basic.Damage(damage); } else { BossGOAP basic = hit.collider.gameObject.GetComponentInParent <BossGOAP>(); basic.Damage(damage); } } else if (hit.collider.gameObject.layer == barrelLayer) { hit.collider.gameObject.GetComponent <Barrel>().StartCoroutine("Explodo"); } else { if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * 5); } } } } }
public override int UpdateNode(EnemyAbstract con) { if (con.health <= 50) { //con.speed = con.injuredSpeed; con.anim.SetFloat("Blend", 1); return(2); } else { return(0); } }
public override int UpdateNode(EnemyAbstract con) { if (con.dead == false) { Debug.Log("Dead"); con.dead = true; con.anim.SetTrigger("Dead"); return(2); } else { return(2); } }
public override int UpdateNode(EnemyAbstract con) { if (Time.time - con.lastAttack >= con.attackRate) { con.lastAttack = Time.time + con.attackRate; int attackType = Random.Range(0, 2); con.anim.SetFloat("AttackBlend", attackType); con.anim.SetTrigger("Attack"); return(2); } else { return(0); } }
public override int UpdateNode(EnemyAbstract con) { if (Vector3.Distance(con.transform.position, con.player.transform.position) >= 2) { Vector3 distance = (con.player.transform.position - con.transform.position).normalized; con.transform.LookAt(new Vector3(con.player.transform.position.x, con.transform.position.y, con.player.transform.position.z)); //distance.y = 0; con.transform.position += distance * con.speed * Time.deltaTime; return(1); } else { return(2); } }
protected virtual void HandeleCollide(EnemyAbstract obj, ControllerColliderHit hit) { obj.DeactivateHelathDecrementers(); if (obj is MiddleEnemy) { obj.Attack(controller, WeaponType.MiddleEnemyWeapon); } else if (obj is BigEnemy) { obj.Attack(controller, WeaponType.BigEnemyWeapon); } else if (obj is ButterflyEnemy) { obj.Attack(controller, WeaponType.ButterflyEnemyWeapon); } }
public override int UpdateNode(EnemyAbstract con) { for (int i = 0; i < nList.Count; i++) { state = nList[i].UpdateNode(con); switch (state) { case 1: return(1); case 2: return(2); } } return(0); }
public virtual void Fire() { Vector3 startPoint = cam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0)); if (Input.GetMouseButtonDown(0) && Time.time >= lastShot && ammo > 0) { ammo--; anim.SetTrigger("Fire"); lastShot = Time.time + fireRate; // GameObject newBull = Instantiate(bullet, firePoint.transform.position, firePoint.transform.rotation); // bulletScript = newBull.GetComponent<BulletScript>(); // bulletScript.damage = damage; RaycastHit hit; if (Physics.Raycast(startPoint, cam.transform.forward, out hit, range)) { if (hit.collider.gameObject.layer == enemyLayer) { Debug.Log("Enemydet"); EnemyAbstract basic = hit.collider.gameObject.GetComponentInParent <EnemyAbstract>(); basic.hit = hit; basic.Damage(damage); } else { if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * 10); } } } // if (Physics.Raycast(startPoint, cam.transform.forward, out hit, range)) // { // Debug.Log("Hitpoint"); // bulletScript.target = hit.point; // bulletScript.hit = hit; // } // else // { // bulletScript.target = startPoint + cam.transform.forward * range; // } } }
void Hit(object hit) { EnemyAbstract hitAsEnemy = (EnemyAbstract)hit; //alternatively EnemyAbstract hitAsEnemy2 = hit as EnemyAbstract; if (hitAsEnemy != null) { hitAsEnemy.Movement(); } IDamagable damageableHit = (IDamagable)hitAsEnemy; if (damageableHit != null) { damageableHit.TakeDamage(); } }
public virtual int UpdateNode(EnemyAbstract con) { return(0); }
public override int UpdateNode(EnemyAbstract con) { con.speed = con.runSpeed; con.anim.SetFloat("Blend", 0); return(2); }
protected override void HandeleCollide(EnemyAbstract obj, ControllerColliderHit hit) { Debug.Log("HandleCollide in AttackState"); }
protected override void HandeleCollide(EnemyAbstract obj, ControllerColliderHit hit) { obj.DeactivateHelathDecrementers(); controller.Attack(obj, WeaponType.Sword); }