void Fire() { readyTime = Time.time + cooldownSecs; RaycastHit hitInfo; if (!Physics.Raycast(transform.position, transform.forward, out hitInfo, 100, layermask)) { Debug.Log("Plunger Hit Nothing"); return; //nothing hit } EnemyNavigation enemy = hitInfo.transform.GetComponentInParent <EnemyNavigation>(); Rigidbody enemyRigidbody = hitInfo.transform.GetComponentInParent <Rigidbody>(); Health enemyHealth = hitInfo.transform.GetComponentInParent <Health>(); Debug.Log(hitInfo.transform); if (enemy == null || enemyRigidbody == null || enemyHealth == null) { return; //hit a wall, or something } if (!enemyHealth.Damage(damage, teamReference)) { return; //target is invulnerable } Instantiate(impactVFX, hitInfo.point, Quaternion.identity); enemy.DisableNavigation(stunDuration); enemyRigidbody.velocity -= 20 * transform.forward; /* * enemyRigidbody.AddForce(0, 0, upwardForce, ForceMode.VelocityChange); * enemyRigidbody.AddForce(pullForce * (transform.position - enemyRigidbody.position).normalized, ForceMode.VelocityChange); * */ }
private void Awake() { normalState = transform.FindDeepChild("Normal").gameObject; ragdollState = transform.FindDeepChild("Ragdoll").gameObject; m_Navigation = GetComponent <EnemyNavigation>(); m_Agent = GetComponent <NavMeshAgent>(); }
// Use this for initialization void Start() { textyPoo = FindObjectOfType <ManaText>(); mana = GameObject.FindGameObjectWithTag("SceneManager").GetComponent <Mana>(); enemycounter = GameObject.FindGameObjectWithTag("SceneManager").GetComponent <EnemyCounter>(); sm = GameObject.FindGameObjectWithTag("SceneManager").GetComponent <SM_tower_defense>(); nav = GetComponent <EnemyNavigation>(); enemycounter.register(gameObject); }
private void FixedUpdate() { if (!started) { return; } if (wait) { //Debug.Log("Waiting to start spawning"); if (Time.fixedTime - waitingStarted > currentBatch.waitTime) { wait = false; } } else if (enemiesSpawned < currentBatch.enemyCount) { //Debug.Log("Spawning now " + Time.fixedTime); if (Time.fixedTime - lastSpawned > currentBatch.spawnTime) { GameObject enemy = pool.ActivateObject(spawnPoint.position); EnemyNavigation nav = enemy.GetComponent <EnemyNavigation>(); Goblin gob = enemy.GetComponent <Goblin>(); if (nav != null) { nav.SetTarget(baseTower); } if (gob != null) { gob.Initialize(); } lastSpawned = Time.fixedTime; enemiesSpawned++; } } else { currentBatchIndex++; if (wave.batches.Count > currentBatchIndex) { currentBatch = wave.batches[currentBatchIndex]; GameObject prefab = enemyConfig.Enemies.Where(x => x.type == currentBatch.enemyType).First().prefab; pool = ObjectPooler.GetPool(prefab); wait = true; waitingStarted = Time.fixedTime; enemiesSpawned = 0; } else { started = false; } } }
public void spawnParent(Vector2[] navPoints) { GameObject enemyParent = Instantiate(enemy); enemyParent.transform.position = transform.position + spawnLocation; EnemyNavigation en = enemyParent.GetComponent <EnemyNavigation>(); en.speed = 3f; en.navPoints = navPoints; }
public void newMonster() { GameObject monsterInstance = Instantiate(monster, transform.position, Quaternion.identity); monsterInstance.GetComponent <Health>().monsterSpawner = this.gameObject; EnemyNavigation enemyNavigation = monsterInstance.GetComponent <EnemyNavigation>(); enemyNavigation.spawnObject = this.gameObject; enemyNavigation.playerObject = GameObject.FindGameObjectWithTag("Player"); }
public void ReactToHit() { WanderingAI behavior = GetComponent <WanderingAI> (); EnemyNavigation access = GetComponent <EnemyNavigation> (); if (behavior != null) { behavior.SetAlive(false); } StartCoroutine(Die()); }
public void Slow(float time) { EnemyNavigation nav = gameObject.GetComponent <EnemyNavigation>(); if (nav) { nav.Speed *= 0.5f; slowEffectTime = time * effectEffiency; isSlowed = true; } }
// Use this for initialization void Start() { enemy = this.transform.root.gameObject.GetComponent <EnemyEffectMgr>(); nav = this.transform.root.gameObject.GetComponent <EnemyNavigation>(); if (enemy == null) { Debug.Log("Not attached to an enemey"); Destroy(gameObject); } StartCoroutine("effect"); }
public void CreateEnemyPool(GameObject obj, int amount) { State stateReference = State.GetInstance(); for (int i = 0; i < amount; i++) { GameObject clone = Instantiate(obj, Vector3.zero, Quaternion.identity); clone.SetActive(false); EnemyNavigation nav = clone.AddComponent <EnemyNavigation>(); nav.playerTransform = playerTransform; nav.stateReference = stateReference; clone.name = $"Enemy {i + 1}"; enemies.Add(clone); } }
private void Update() { if (slowEffectTime > 0) { slowEffectTime -= Time.deltaTime; } else if (isSlowed) { EnemyNavigation nav = gameObject.GetComponent <EnemyNavigation>(); if (nav) { nav.Speed = nav.Speed; isSlowed = false; } } }
void OnTriggerEnter(Collider col) { EnemyNavigation enemy = col.transform.GetComponentInParent <EnemyNavigation>(); Rigidbody enemyRigidbody = col.transform.GetComponentInParent <Rigidbody>(); Health enemyHealth = col.transform.GetComponentInParent <Health>(); if (enemy == null || enemyRigidbody == null || enemyHealth == null) { return; //hit a wall, or something } if (!enemyHealth.Damage(damage, teamReference)) { return; //target is invulnerable } Instantiate(impactVFX, col.ClosestPointOnBounds(this.transform.position), Quaternion.identity); }
void OnTriggerEnter(Collider other) { EnemyNavigation enemy = other.transform.GetComponentInParent <EnemyNavigation>(); Rigidbody enemyRigidbody = other.transform.GetComponentInParent <Rigidbody>(); Health enemyHealth = other.transform.GetComponentInParent <Health>(); if (enemy == null || enemyRigidbody == null || enemyHealth == null) { return; //hit a wall, or something } if (!enemyHealth.Damage(0, this)) { return; //target is invulnerable } Instantiate(impactVFX, other.transform.position, Quaternion.identity); enemy.DisableNavigation(stunDuration); enemyRigidbody.velocity += 3 * transform.up; Physics.IgnoreCollision(other, coll); }
public void OnInteract() { Callback.FireAndForget(() => { foreach (Collider other in Physics.OverlapSphere(transform.position, radius)) { EnemyNavigation enemy = other.transform.GetComponentInParent <EnemyNavigation>(); Rigidbody enemyRigidbody = other.transform.GetComponentInParent <Rigidbody>(); Health enemyHealth = other.transform.GetComponentInParent <Health>(); if (enemy == null || enemyRigidbody == null || enemyHealth == null) { continue; //hit a wall, or something } if (!enemyHealth.Damage(damage, this)) { continue; //target is invulnerable } Instantiate(impactVFX, other.transform.position, Quaternion.identity); } }, delay, this); }
// This works by measuring the distance to ground with a // raycast then applying a force that decreases as the object // reaches the desired levitation height. // The greater the thrust, the more hover power/height you need; // Vary the parameters below to // get different control effects. For example, reducing the // hover damping will tend to make the object bounce if it // passes over an object underneath. void Start() { // Fairly high drag makes the object easier to control. attackAngle = attackAngle / 2; rb = bike.GetComponent <Rigidbody>(); en = GetComponent <EnemyNavigation>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <bikeBrain>(); sword.SetActive(false); rb.drag = 0.5f; rb.angularDrag = 0.5f; boosting = false; attackCoroutineStarted = false; health = totalHealth; canSeePlayer = false; layerMask = 1 << LayerMask.NameToLayer("Terrain"); engineSoundSource.clip = engineSound; swordHitSource.clip = swordHit; swordSwingSource.clip = swordSwing; explosionSource.clip = explosion; engineSoundSource.Play(); }
public void CreateEnemy(float sleepTime = 0f, UnitType type = UnitType.Standard) { GameObject enemyInstance; if (type == UnitType.Standard) { enemyInstance = enemiesType1.Rent(true); } else { enemyInstance = enemiesType2.Rent(true); } EnemyNavigation nav = enemyInstance.GetComponent <EnemyNavigation>(); if (nav) { nav.SetPath(path); nav.SleepTime += sleepTime; nav.Controller = this; } activeEnemies.Add(enemyInstance); enemyInstance.transform.localPosition = parent.TransformPoint(startPoint); }
public void Start() { game = GameManager.instance; navigation = GetComponent<EnemyNavigation>(); enemyManager = EnemyManager.instance; ragdolls = RagdollManager.instance; GameObject player = GameObject.Find("playerFocus"); GameObject treasureObj = game.treasure.gameObject; GameObject focusPoint = treasureObj.transform.FindChild("treasureFocus").gameObject; treasureTransform = focusPoint.transform; playerTransform = player.transform; enemyTransform = this.transform; // if treasure is on ground and enemy can loot, set first target as treasure if (game.treasure.OnGround() && canLoot){ target = focusTarget.TRESAURE; navigation.target = treasureTransform; } else { target = focusTarget.PLAYER; navigation.target = playerTransform; } }
private void Awake() { EN = GameObject.Find("Enemy").GetComponent <EnemyNavigation>(); oen = GameObject.Find("GlobalControl").GetComponent <OpenvibeEventNotifier>(); em = GameObject.Find("GameManager").GetComponent <ExperimentManager>(); }
// Use this for initialization protected virtual void Start() { health = GetComponent <Health>(); navigation = GetComponent <EnemyNavigation>(); }
void Start() { EnemyManager.instance.OnBuffMain += Buff; AreaEnemySpawner.instance.OnStateChange += Retreat; collisionDetection = GetComponent<CollisionDetection> (); collisionDetection.OnDeath += OnDeath; enemyNavigation = GetComponent<EnemyNavigation> (); InitAttacks (); CheckForDebugMode (); EnemyManager.instance.currentAmount++; //put here instead of enemynavigation to increase as soon as possible UpdateAttacks (level); UpdateStats (); }