//// Public API public void SetEnemyAttributes(Vector3 spawnPoint, EnemyAttributes attributes) { _isActive = true; this.transform.position = spawnPoint; InsertAIAgent(); UnpackEnemyAttributes(attributes); }
public override void Start() { enemyStats = GetComponent <EnemyAttributes> (); master = GetComponent <EnemyAIMaster> (); setProjectile(projectile); started = true; }
//// Private methods void UnpackEnemyAttributes(EnemyAttributes attributes) { _totalLife = _currentLife = attributes.life; _lifeBar.SetUp(_totalLife); _aiAgent.speed = attributes.speed; }
// Use this for initialization void Start() { enemy = GetComponent<EnemyAttributes>(); player = GameObject.FindGameObjectWithTag("Player").transform; state = State.Patrol; patrol = GetComponent<Patrol>(); }
// Use this for initialization void Start() { EA = transform.parent.GetComponent <EnemyAttributes>(); EB = transform.parent.GetComponent <EnemyBehaviour>(); NextAttack = 0; Attacking = false; }
/// <summary> /// Initializes references to ReferenceManager and other managers, list of renderers and /// their materials for HitFlash(), and spawns the spawn particle emitter. /// </summary> protected override void Awake() { base.Awake(); player = reference.shipLookTarget; enemyAttributes = reference.enemyAttributes; waveManager = reference.waveManager; scoringSystem = reference.scoringSystem; objectPoolManager = reference.objectPoolManager; renderers = new List <Renderer>(); materials = new List <Material>(); foreach (Renderer r in gameObject.GetComponentsInChildren <Renderer>()) { if (r.gameObject.CompareTag("Emitter") || r.transform.parent.CompareTag("Emitter")) { continue; } renderers.Add(r); materials.Add(r.material); } }
void Start() { thisWaveEnemyData = Instantiate(enemyData); thisWaveEnemyAttributes = ThisWaveEnemyData.EnemyAttributes; gameplayUiController = GameInstance.Instance.gameplayUiController; }
public GameObject SpawnEnemyAt(Vector3 position, EnemyAttributes attributes) { GameObject enemy = _pool.GetInstance(); enemy.GetComponent <EnemyBehaviour>().SetEnemyAttributes(position, attributes); enemy.GetComponent <Renderer>().material.color = attributes.color; return(enemy); }
// Use this for initialization void Start() { EnemyStats = GetComponent <EnemyAttributes> (); //EnemyMove = GetComponent<EnemyMovement> (); EnemyRigid = GetComponent <Rigidbody2D> (); master = GetComponent <EnemyAIMaster> (); //projSpawner = GetComponent<EnemyProjectileSpawner> (); }
// Use this for initialization void Start() { //Initialise variables EA = GetComponent <EnemyAttributes>(); Player = GameObject.FindGameObjectWithTag("Player"); GC = GameObject.FindGameObjectWithTag("GameController"); target = Player; }
void Awake() { PlayerTransform = GameObject.FindGameObjectWithTag("Player").transform; PlayerHealth = PlayerTransform.GetComponent <PlayerAttributes>(); EnemyMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); EnemyAttributes = GetComponent <EnemyAttributes>(); PlayerDictionary = new Dictionary <GameObject, float>(); }
void OnTriggerEnter2D(Collider2D hitInfo) { EnemyAttributes enemy = hitInfo.GetComponent <EnemyAttributes>(); if (enemy != null) { Destroy(gameObject); FindObjectOfType <GameManager>().EndGame(); } }
private void Awake() { EnemyAttributes = GetComponent <EnemyAttributes>(); EnemyAttributes.SetManager(this); EnemyAudioManager = GetComponentInChildren <EnemyAudioManager>(); EnemyAudioManager.SetManager(this); EnemyMovement = GetComponent <EnemyMovement>(); EnemyMovement.SetManager(this); }
public void dealDamage(EnemyAttributes enemy) { if (!attackCooldown) { GetComponent <Animator>().SetTrigger("punch"); StartCoroutine(activateAttackCooldown()); //Debug.Log("punch"); int damageToDeal = melee; enemy.takeDamage(melee); } }
void OnTriggerEnter2D(Collider2D hitInfo) { EnemyAttributes enemy = hitInfo.GetComponent <EnemyAttributes>(); if (enemy != null) { enemy.TakeDamage(damage); Destroy(gameObject); GameObject bulletEffect = Instantiate(bulletExplosion, transform.position, transform.rotation); Destroy(bulletEffect, 1); } }
public GameObject npc; //for testing void Awake() { // Get gamemanager gameManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>(); inventory = GetComponent <Inventory>(); skills = GetComponent <Skills>(); perkAttributes = GetComponent <PerkAttributes>(); toolbelt = GetComponent <Toolbelt>(); enemyAttributes = GetComponent <EnemyAttributes>(); thirst = 100; hunger = 100; }
void Spawn(int enemyNumber, Vector3 spawn, SpawnTypes mode, EnemyAttributes attributes) { switch (mode) { case SpawnTypes.DelayedIndianLine: _gameManager.StartCoroutine(SpawnDelayedSingleEnemy(spawn, 1, enemyNumber, attributes)); break; case SpawnTypes.LineGroup: SpawnEnemyLineGroup(spawn, enemyNumber, attributes); break; } }
void SpawnEnemyLineGroup(Vector3 initialPosition, int newEnemies, EnemyAttributes attributes) { if (newEnemies > 0) { int poolAvailableElements = _enemySystem.GetAvailableElements(); if (newEnemies > poolAvailableElements) { _enemySystem.EnlargePoolSize(newEnemies - poolAvailableElements); } PositionEnemyLine(initialPosition, newEnemies, attributes); } }
void PositionEnemyLine(Vector3 initialPosition, int enemyNumber, EnemyAttributes attributes) { int enemiesSpawned = 0; Vector3 spawnPoint; Vector3 destiny = _gameManager.Core.transform.position; Vector3 diff = initialPosition - destiny; while (enemiesSpawned < enemyNumber) { float modifier = (enemiesSpawned % 2 == 0 ? -1 : 1) * enemiesSpawned; if (diff.x == 0) { float modHorizontal = diff.z > 0 ? 1 : (diff.z == 0 ? 0 : -1); spawnPoint = new Vector3(initialPosition.x + modifier * modHorizontal, 0, initialPosition.z); } else { if (diff.z == 0) { float modVertical = diff.x > 0 ? 1 : (diff.x == 0 ? 0 : -1); spawnPoint = new Vector3(initialPosition.x, 0, initialPosition.z + modifier * modVertical); } else { if (Mathf.Sign(diff.z) == Mathf.Sign(diff.x)) { spawnPoint = new Vector3((initialPosition.x + modifier), 0, (initialPosition.z + -modifier)); } else { spawnPoint = new Vector3((initialPosition.x + modifier), 0, (initialPosition.z + modifier)); } } } try{ _enemySystem.SpawnEnemyAt(spawnPoint, attributes); enemiesSpawned++; }catch (System.Exception) { CheckAvailablePoolSize(enemyNumber - enemiesSpawned); } } }
// PLAYER public IEnumerator attackEnemy(EnemyAttributes enemy, bool player) { EnemyAttributes playerEnemy = gameManager.getPlayerBehavior().transform.GetComponent <EnemyAttributes>(); Vector3 hitGroundPosition = gameManager.getPlayerBehavior().getHitGround(); //Debug.Log("start attacking"); if (!playerEnemy.getIsAttackingEnemy() && enemy != this) { playerEnemy.setIsAttackigEnemy(true); playerEnemy.lookAtTargetEnemy(enemy); while (playerEnemy.getIsAttackingEnemy()) { if (hitGroundPosition != gameManager.getPlayerBehavior().getHitGround()) { //Debug.Log("not attacking anymore because player clicked elsewhere"); enemy.setMobIndicator(false); enemy.setHealthbar(false); enemy.setAllIndicatorsFallsAndActivate("red"); break; } if (enemy == null) { break; } else { enemy.setHealthbar(true); enemy.setMobIndicator(true); enemy.setAllIndicatorsFallsAndActivate("yellow"); //Debug.Log("attacking enemy running"); } if (!playerEnemy.getAttackCooldown()) { playerEnemy.dealDamage(enemy); } yield return(null); } //Debug.Log("end attacking"); playerEnemy.setIsAttackigEnemy(false); } }
void SpawnEnemy(EnemyAttributes e, Vector3 l) { e.bonus.BonusSetter(); BasicEnemy basicEnemy = _spawner.basicEnemyPool.GetObject(); basicEnemy.UnitDefiner(e.myType); basicEnemy.SetPowerAmount(e.power).SetHealth(e.health).SetCooldown(e.maxCooldown).SetSpawner(_spawner).SetSetinelAmount(e.sentinelAmount).BonusSetter(e.bonus.bonus).SetPointAmount(e.pointAmount).SetLocation(l); basicEnemy.movementOptions.Clear(); basicEnemy.behaviour = e.behaviour.Clone(); basicEnemy.behaviour.TargetSetter(basicEnemy._model.transform.position); if (e.sentinelAmount > 0) { basicEnemy.SentinelSpawn(); } if (e.behaviour.changeMovementWrappers.Length > 0) { basicEnemy.StartCoroutine(basicEnemy.ChangeMovement(e.movementTimeToChange, e.behaviour.changeMovementWrappers)); } }
// THIS ONE IS FOR PLAYER public IEnumerator walkToEnemy(EnemyAttributes enemy) { bool walkingToEnemy = true; EnemyAttributes player = this; Vector3 hitGroundPosition = gameManager.getPlayerBehavior().getHitGround(); while (walkingToEnemy) { enemy.setMobIndicator(true); enemy.setAllIndicatorsFallsAndActivate("yellow"); //Debug.Log("player WALKINMG to enemy"); if (hitGroundPosition != gameManager.getPlayerBehavior().getHitGround()) { //Debug.Log("new walking position"); enemy.setMobIndicator(false); enemy.setAllIndicatorsFallsAndActivate("red"); break; } if (Vector3.Distance(gameManager.getPlayerBehavior().getPlayerPosition(), enemy.getPosition()) < player.getAttackRange()) { //Debug.Log("clsoe enough"); stopMovement(); player.setCurrentTarget(enemy); StartCoroutine(attackEnemy(enemy, true)); break; } else { player.getNavMeshAgent().SetDestination(enemy.getPosition()); } yield return(null); } }
public IEnumerator attackEnemy(EnemyAttributes enemy) { if (!attackingEnemy) { attackingEnemy = true; lookAtTargetEnemy(enemy); while (attackingEnemy) { //Debug.Log("attacking enemy running"); if (Vector3.Distance(this.transform.position, enemy.getPosition()) > attackRange) { //Debug.Log("Lost target, or distance to high to attack"); //enemy.setHealthbar(false); break; } if (enemy == null) { stopMovement(); //Debug.Log("Current target is null"); setHealthbar(false); break; } else { //enemy.setHealthbar(true); } this.dealDamage(enemy); yield return(null); } attackingEnemy = false; } }
public IEnumerator walkToClosestEnemy() { if (!walkingToClosestEnemy) { walkingToClosestEnemy = true; EnemyAttributes enemy = getClosestEnemyInRange(); while (walkingToClosestEnemy) { enemy = getClosestEnemyInRange(); if (enemy == null || !enemiesInRange.Contains(enemy)) { //Debug.Log("No enemy found"); stopMovement(); break; } if (Vector3.Distance(this.getPosition(), enemy.getPosition()) < attackRange) { //Debug.Log("clsoe enough"); setCurrentTarget(enemy); StartCoroutine(attackEnemy(enemy)); break; } else { agent.SetDestination(enemy.getPosition()); } yield return(null); } stopMovement(); walkingToClosestEnemy = false; } }
public void setCurrentTarget(EnemyAttributes enemy) { currentTarget = enemy; }
/// <summary> /// Loads skill attributes from datamined data. /// </summary> // Id has been manually deduced from the datamined data. It's used to connect the attack to datamined information. public void LoadAttributes(int id, EnemyAttributes attributes) { if (attributes == null || attributes.Weapons == null) return; if (attributes.Weapons.Main != null && attributes.Weapons.Main.Skills != null) { foreach (var skill in attributes.Weapons.Main.Skills) { if (skill.id == id) { LoadFromSkillPalette(skill); Weapon = "main"; } } } if (attributes.Weapons.Offhand != null && attributes.Weapons.Offhand.Skills != null) { foreach (var skill in attributes.Weapons.Offhand.Skills) { if (skill.id == id) { LoadFromSkillPalette(skill); Weapon = "off"; } } } if (attributes.Weapons.Underwater != null && attributes.Weapons.Underwater.Skills != null) { foreach (var skill in attributes.Weapons.Underwater.Skills) { if (skill.id == id) { LoadFromSkillPalette(skill); Weapon = "water"; } } } }
public void lookAtTargetEnemy(EnemyAttributes enemy) { transform.LookAt(new Vector3(enemy.transform.position.x, 0, enemy.transform.position.z)); }
/*********************************************************************************************** * LoadAttributes / 2015-10-02 / Wethospu * * * * Loads skill attributes from datamined data. * * * * id: Id of the skill. * * attributes: Attributes for the base enemy. * * * ***********************************************************************************************/ public void LoadAttributes(int id, EnemyAttributes attributes) { if (attributes == null || attributes.Weapons == null) return; if (attributes.Weapons.Main != null && attributes.Weapons.Main.Skills != null) { foreach (var skill in attributes.Weapons.Main.Skills) { if (skill.id == id) { _minimumRange = skill.MinimumRange; _maximumRange = skill.MaxRange; _requiredLevel = skill.LevelRequirement; _internalCooldown = skill.Cooldown; _weapon = "main"; if (skill.Tags != null) _coefficient = skill.Tags.Coefficient; } } } if (attributes.Weapons.Offhand != null && attributes.Weapons.Offhand.Skills != null) { foreach (var skill in attributes.Weapons.Offhand.Skills) { if (skill.id == id) { _minimumRange = skill.MinimumRange; _maximumRange = skill.MaxRange; _requiredLevel = skill.LevelRequirement; _internalCooldown = skill.Cooldown; _weapon = "off"; if (skill.Tags != null) _coefficient = skill.Tags.Coefficient; } } } if (attributes.Weapons.Underwater != null && attributes.Weapons.Underwater.Skills != null) { foreach (var skill in attributes.Weapons.Underwater.Skills) { if (skill.id == id) { _minimumRange = skill.MinimumRange; _maximumRange = skill.MaxRange; _requiredLevel = skill.LevelRequirement; _internalCooldown = skill.Cooldown; _weapon = "water"; if (skill.Tags != null) _coefficient = skill.Tags.Coefficient; } } } }
// Start is called before the first frame update void Start() { player = GameObject.FindGameObjectWithTag("Player"); attributes = this.gameObject.GetComponent <EnemyAttributes>(); playerAttributes = player.GetComponent <PlayerAttributes>(); }
public void addEnemyToEnemyInRange(EnemyAttributes enemy) { enemiesInRange.Add(enemy); }
public void updateHealthbar(EnemyAttributes enemy) { enemy.transform.Find("Healthbar").GetComponent <Healthbar>().updateHealthBar(); }
public void removeEnemyFromEnemyInRange(EnemyAttributes enemy) { enemiesInRange.Remove(enemy); }
// Use this for initialization void Start() { EnemyStats = GetComponent <EnemyAttributes> (); anim = GetComponent <Animator> (); //projSpawner.setProjectile (weaponList[currWeap]); spawnList = new EnemyProjectileSpawner[spawnSeq.Length]; EnemyProjectileSpawner[] allSpawners = GetComponents <EnemyProjectileSpawner> (); for (int i = 0; i < allSpawners.Length; i++) { allSpawners [i].enabled = false; } for (int i = 0; i < spawnList.Length; i++) { for (int x = 0; x < allSpawners.Length; x++) { if (spawnSeq[i].Equals(allSpawners[x].label)) { spawnList [i] = allSpawners [x]; //spawnList [i].enabled = true; //Debug.Log (allSpawners [x].label); break; } } } spawnList [0].enabled = true; moveList = new EnemyMovement[moveSeq.Length]; EnemyMovement[] allMoves = GetComponents <EnemyMovement> (); for (int i = 0; i < allMoves.Length; i++) { allMoves [i].master = this; } for (int i = 0; i < allMoves.Length; i++) { allMoves [i].enabled = false; } for (int i = 0; i < moveList.Length; i++) { for (int x = 0; x < allMoves.Length; x++) { if (moveSeq[i].Equals(allMoves[x].label)) { moveList [i] = allMoves [x]; //moveList [i].enabled = true; //Debug.Log (allMoves [x].label); break; } } } if (GetComponent <SpriteRenderer> ().flipX) { GetComponent <SpriteRenderer> ().flipX = false; moveList [0].xdir = -1; } moveList [0].switchTo(); moveList [0].enabled = true; for (int x = 0; x < allMoves.Length; x++) { if (aggromove.Equals(allMoves[x].label)) { aMove = allMoves [x]; //moveList [i].enabled = true; //Debug.Log (allMoves [x].label); break; } } }
void Start() { enemy = GetComponent<EnemyAttributes>(); fsm = GetComponent<FiniteStateMachine>(); StartCoroutine(SetWayPoints()); //print (tile.transform.position); }