void Awake() { rb2d = GetComponent<Rigidbody2D>(); rb2d.gravityScale = 0; movement = GetComponent<EnemyMovement>(); StartCoroutine(ChangeInput()); }
void Awake() { playerAudio = GetComponent<AudioSource>(); anim = GetComponent<Animator>(); enemyMovement = GetComponent<EnemyMovement>(); isKuollut = Animator.StringToHash("isKuollut"); }
void Start() { enemyMovement = GetComponent<EnemyMovement> (); target = GameObject.FindGameObjectWithTag("Player").transform; anim = GetComponent <Animator> (); enemyHiss = GetComponent<AudioSource> (); }
void OnTriggerStay2D(Collider2D other) { if (timer <= 0.1f && other.GetComponent<EnemyMovement> ()) { eM = other.GetComponent<EnemyMovement>(); eM.slowed = false; } }
//private Rigidbody enemyRB; void Awake() { anim = GetComponent<Animator>(); enemyMovement = GetComponent<EnemyMovement>(); CurrentHealth = MaxHealth; //enemyRB = GetComponent<Rigidbody>(); }
void Start() { GameObject knight = transform.parent.Find("Knight").gameObject; _patrol = knight.GetComponent<EnemyMovement>(); _chase = knight.GetComponent<KnightChase>(); _patrol.enabled = true; _chase.enabled = false; }
public override void Awake() { base.Awake(); enemyMovement = GetComponent<EnemyMovement>(); gameController = GameObject.FindGameObjectWithTag(Tags.gameController); enemiesCounter = gameController.GetComponent<EnemiesCounter>(); }
void Awake() { player = GameObject.Find("Player"); playerHealth = player.GetComponent <PlayerHealth>(); enemyHealth = GetComponent<EnemyHealth>(); enemyMovement = GetComponent<EnemyMovement>(); anim = GetComponent <Animator>(); }
void Awake() { _tags = FindObjectOfType<Tags>(); _currencyManager = FindObjectOfType<CurrencyManager>(); _scoreManager = FindObjectOfType<ScoreManager>(); _enemyMovement = FindObjectOfType<EnemyMovement>(); _anim = GetComponent<Animator>(); }
void OnTriggerEnter2D(Collider2D other) { if (other.tag != "Player" && other.tag != "Collectibles" && other.tag != "LethalHazard" && other.tag != "Platform") { otherRB = other.GetComponent<Rigidbody2D> (); Debug.Log ("not here"); if (other.tag == "Destructable Platform") { Debug.Log ("here"); other.GetComponent<PlatformHealthManager> ().takeDamage (abilityDamage); } if (other.tag == "Enemy" && attTimer <= 0) { timer = 0.1f; other.GetComponent<EnemyHealthManager> ().takeDamage (abilityDamage); } if (other.tag == "Boss" && attTimer <= 0) { timer = 0.1f; if (sasuke != null) { sasuke.takeDamage(abilityDamage); } else { return; } } if (other.tag == "Boss") { other.GetComponent<BossHealthManager> ().takeDamage (abilityDamage); } if (other.tag == "Destroyable") { DestroyObject(other.gameObject); } if(other.GetComponent<EnemyMovement>()) { eMScrp = other.GetComponent<EnemyMovement>(); eMScrp.GetStun(stunTime); } if( other.GetComponent<EnemyAttack>()) { eAScrp = other.GetComponent<EnemyAttack>(); eAScrp.GetStun(stunTime); } if (other.transform.position.x < transform.position.x) { otherRB.velocity = new Vector2 (-10, 2); } else { otherRB.velocity = new Vector2 (10, 2); } } }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Arbiter Minions * -Uses Pathfinding * -Moves freely through the body saves for the * -When the mother attacks, it should head towards the player * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ private void ArbiterMinionAwake() { em = GetComponent<EnemyMovement>(); if (pathfinding) { pr = GetComponent<PathRequester>(); pr.active = true; } nextWaypoint = em.chasee; }
protected override void Awake() { base.Awake(); model = transform.GetChild(0); //color = AssignColor(); enemyActions = GetComponent<EnemyActions>(); enemyMovement = GetComponent<EnemyMovement>(); levelManager = FindObjectOfType<LevelManager>(); }
void Start() { // Load GameObjects spawner = GameObject.Find("Spawner"); // Load Scripts wave = spawner.gameObject.GetComponent<WaveSysteem>(); enemyN = enemy.gameObject.GetComponent<EnemyMovement> (); enemyD = dream.gameObject.GetComponent<EnemyMovement> (); }
// Use this for initialization void Awake() { //anim = GetComponent<Animator>(); //to use with bullets // //boxCollider2D = GetComponent<BoxCollider2D>(); enemyMovement = GetComponent<EnemyMovement>(); enemyAttack = GetComponentInChildren<EnemyAttack>(); currentHealth = startingHealth; }
void Start() { move = GetComponent<EnemyMovement> (); aoePrefab = (GameObject)Resources.Load("AreaDamage"); animator = gameObject.GetComponentInChildren<Animator>(); if (actionDamage == 0) { actionDamage = 5; } //actionDamage = 5; aoeLifetime = 1.7f; }
// public bool enemyLvlling; // bool enemyLvlUp; // GameObject enemy = enemy1 && enemy2; void Awake() { experience = gameObject.GetComponent <Experience> (); enemyMovement = enemy1.GetComponent <EnemyMovement> (); // enemyShooting = enemy2.GetComponent <EnemyShooting> (); enemyHealth = enemy1.GetComponent <EnemyHealth> (); enemy2Health = enemy2.GetComponent <EnemyHealth> (); // enemyLvlUp = false; enemyHealth.startingHealth = 40; enemy2Health.startingHealth = 50; enemyMovement.speed = 4; }
private void Awake() { m_Instance = this; m_LevelData.Sincronise(); float x = (-Screen.width + TILE_SIZE) / PIXEL_PER_UNIT / 2.0f; float y = (Screen.height - TILE_SIZE) / PIXEL_PER_UNIT / 2.0f; Vector2 initialPos = new Vector2(x, y); /* * int width = (int)(Screen.width / TILE_SIZE); * int height = (int)(Screen.height / TILE_SIZE); */ Vector2 offset = new Vector2(TILE_SIZE / PIXEL_PER_UNIT, -TILE_SIZE / PIXEL_PER_UNIT); Vector2 spawnPos = initialPos + offset; PlayerMovement player = Instantiate(m_PlayerPrefab, spawnPos, Quaternion.identity); player.Setup(1, 1); player.m_LifeText = m_LifeText; player.m_RangeText = m_RangeText; for (int i = 0; i < m_LevelData.GetWidth(); ++i) { for (int j = 0; j < m_LevelData.GetHeight(); ++j) { offset = new Vector2(TILE_SIZE * i / PIXEL_PER_UNIT, -TILE_SIZE * j / PIXEL_PER_UNIT); spawnPos = initialPos + offset; CreateTile(m_LevelData.Tiles[i][j], spawnPos); if (m_LevelData.Tiles[i][j] == ETileType.Trap) { EnemyMovement ennemy = Instantiate(m_EnemyPrefab, spawnPos, Quaternion.identity); ennemy.Setup(j, i); if (LevelManager.Instance != null) { LevelManager.Instance.m_Enemy.Add(ennemy); } } else if (m_LevelData.Tiles[i][j] == ETileType.Floor) { int rand = (int)Random.Range(0, 3); if (rand == 0) { Instantiate(m_TokenList[(int)Random.Range(0, m_TokenList.Length)], spawnPos, Quaternion.identity); } } } } }
void Awake() { // Set up the references. player = GameObject.FindGameObjectWithTag("Player").transform; animator = GetComponent <Animator>(); //playerHealth = player.GetComponent<PlayerHealth>(); //enemyHealth = GetComponent<EnemyHealth>(); nav = GetComponent <NavMeshAgent>(); enemy = GetComponent <EnemyMovement>(); isDead = false; }
void SummonEnemy(EnemyMovement e) { Addressables.InstantiateAsync(e.EnemyReference).Completed += op => { var enemys = op.Result.GetComponentsInChildren <IEnemy>(); foreach (IEnemy enemy in enemys) { enemy.Initialize(e); enemy.lockOn = l; } }; }
void Awake() { damage = 10.0f; attackRadius = 0.2f; canAttack = true; nextAttackTime = 0; enemyAttackTime = 0; rb = gameObject.GetComponent <Rigidbody2D>(); animation_manager = gameObject.GetComponent <AnimationManager>(); enemyStat = gameObject.GetComponent <EnemyStat>(); enemyMovement = gameObject.GetComponent <EnemyMovement>(); }
void OnTriggerEnter2D(Collider2D other) { if (timeBetweenAttacks <= 0 && (other.tag == "Enemy" || other.tag == "Boss")) { timeBetweenAttacks = 0.2f; Debug.Log("time reseted"); if (other.name != "Player" || other.tag != "Collectibles" || other.tag != "LethalHazard" || other.tag != "Platform") { if (other.GetComponent<Rigidbody2D> () == null) { return; } else { otherRB = other.GetComponent<Rigidbody2D> (); } if (other.tag == "Boss") { if (sasuke != null) { timer = 0; sasuke.takeDamage (1); } else { return; } } if (other.tag == "Destructable Platform") { other.GetComponent<PlatformHealthManager> ().takeDamage (abilityDamage); } if (other.tag == "MysteryBox") { other.GetComponent<MysteryBoxHealthManager> ().takeDamage (abilityDamage); } if (other.tag == "Enemy") { Debug.Log("damage deal"); other.GetComponent<EnemyHealthManager> ().takeDamage (abilityDamage); } if (other.tag == "MiniBoss") { other.GetComponent<BossHealthManager> ().takeDamage (abilityDamage); } if (other.GetComponent<EnemyMovement> ()) { eMScrp = other.GetComponent<EnemyMovement> (); eMScrp.GetStun (stunTime); } if (other.GetComponent<EnemyAttack> ()) { eAScrp = other.GetComponent<EnemyAttack> (); eAScrp.GetStun (stunTime); } if (other.transform.position.x < player.transform.position.x) { otherRB.velocity = new Vector2 (-5, 2); } else { otherRB.velocity = new Vector2 (5, 2); } } } //Cleanup //Destroy(gameObject); }
IEnumerator SpawnEnemies(EnemyMovement enemyPrefabCopy) { while (true) { GetComponent <AudioSource>().PlayOneShot(enemySpawnSound); enemyCount++; enemyCountText.text = enemyCount.ToString(); var newEnemy = Instantiate(enemyPrefabCopy, gameObject.transform.position, Quaternion.identity); newEnemy.transform.parent = parentEnemy; yield return(new WaitForSeconds(secondsBetweenSpawn)); } }
private void OnTriggerEnter2D(Collider2D other) { EnemyMovement enemy = other.GetComponent <EnemyMovement>(); if (enemies.Contains(other.gameObject) || enemy == null) { return; } enemies.Add(other.gameObject); CheckLock(); }
void Damage(Transform enemy) { EnemyMovement e = enemy.GetComponent <EnemyMovement>(); if (e != null) { e.DamageTaken(damage); } else { return; } }
void Start() { //movements m_transform = gameObject.transform; m_movement = new EnemyMovement(this, m_waypoints); //attacks m_bullet = Resources.Load("bullet") as GameObject; Vector3 bulletOffset = new Vector3(0, 0, 0); m_attack = new ActionBehavior(this, m_bullet, fireRate, damage, m_projectileDirection, "Player", bulletOffset); m_attack.setBulletSpeed(0.1f); }
private void CreateEnemy() { var currentEnemy = Instantiate(_prefabsEnemy[Random.Range(0, _prefabsEnemy.Length)], _pointSpawnPosition[Random.Range(1, _pointSpawnPosition.Length)].position, Quaternion.identity, transform.GetChild(0)); EnemyMovement enemyMovement = currentEnemy.GetComponent <EnemyMovement>(); if (currentEnemy.GetComponent <ShootEnemy>()) { currentEnemy.GetComponent <ShootEnemy>().Init(_arenaManager); } enemyMovement.Init(_playerPosition, _arenaManager); enemyMovement.Death += ExcludeEnemyFromList; _currentLivingEnemies.Add(currentEnemy); }
// Use this for initialization void Start() { rend = GetComponent <Renderer> (); enemyMovement = transform.parent.GetComponent <EnemyMovement> (); playerGO = GameObject.FindGameObjectWithTag("Player"); spriteAnimation = playerGO.GetComponent <SpriteAnimation> (); if (spriteAnimation != null) { spinTimer = spriteAnimation.spinTimer; resetSpinTimer = spinTimer; } }
void Start() { player = Player.instance; if (whoIsControlling == WhoIsControlling.EnemyControl) { enemy = transform.root; enemySight = enemy.Find("Sight"); enemySightScript = enemySight.GetComponent <EnemySight>(); enemyMovementScript = enemy.GetComponent <EnemyMovement>(); } }
void Awake() { enemyMovement = GetComponent <EnemyMovement>(); thisRigidbody2D = GetComponent <Rigidbody2D>(); damageObject = GetComponent <DamageObject>(); spawnHealth = GetComponent <SpawnHealth>(); spawnForceField = GetComponent <SpawnForceField>(); damageTimeout = 0.4f; blobState = State.Roaming; startPosition = transform.position; thisEnemy = gameObject; }
// Use this for initialization void Start() { //Get the level. If it is a tutorial level, set the level to 1 string levelNameStart = SceneManager.GetActiveScene().name.Remove(1, SceneManager.GetActiveScene().name.Length - 1); Level = levelNameStart != "T" ? int.Parse(SceneManager.GetActiveScene().name.Remove(0, 5)) : 1; //Change the BaseDamage and BaseHealth to use the current level. BaseDamage += (Level); BaseHealth += (Level * 2); StartingHealth = BaseHealth; _xpWorth = 100 + (Level * 10); enemyMovementStorage = GetComponent <EnemyMovement>(); }
void SpawnEnemy() { enemy = (GameObject)Instantiate(enemyPrefab, transform.position, transform.rotation); enemyMovement = enemy.GetComponent<EnemyMovement>(); enemyMovement.spawnPosistion = transform.position; enemyMovement.moveTimePeriod = moveTimePeriod; enemyMovement.moveUpAndDown = moveUpAndDown; enemyMovement.spawnFacingScrooge = spawnFacingScrooge; enemyMovement.enemyType = enemyType; enemyMovement.Spawn(); }
IEnumerator WalkBackATinyBit() { EnemyMovement.FaceTarget(transform, targetDistance.Target); float startTime = Time.realtimeSinceStartup; while (Time.realtimeSinceStartup < startTime + 24f / 30f) { physic.MoveForward(-0.1f); yield return(new WaitForEndOfFrame()); } walkBackCooldown.Start(); }
IEnumerator SpawnEnemy() { while (true) // loop forever { AddScore(); GetComponent <AudioSource>().PlayOneShot(spawnedEnemySFX); EnemyMovement newEnemy = Instantiate(enemyPrefab, transform.position, Quaternion.identity); newEnemy.transform.parent = transform; newEnemy.GetComponent <EnemyDamage>().deathFXParentTransform = deathFXParentTransform; newEnemy.GetComponent <EnemyMovement>().deathFXParentTransform = deathFXParentTransform; yield return(new WaitForSeconds(secondsBetweenSpawning)); } }
void Awake() { _playerHealth.GetComponent <PlayerHealth>(); _enemyAttackAnimation.GetComponent <EnemyAttackAnimation>(); _enemyMovement = GetComponent <EnemyMovement>(); _enemybattleMechanics = GetComponent <EnemyBattleMechanics>(); _spiritBar = GetComponent <SpiritBar>(); CurrentHealth = MaxHealth; IsDead = false; CanSpecial = false; Source = GetComponent <AudioSource>(); }
private void Awake() { characterScript = GetComponent <CharacterAnimation>(); audioSource = GetComponent <AudioSource>(); if (gameObject.CompareTag(Tags.ENEMY_TAG)) { enemyMovement = GetComponentInParent <EnemyMovement>(); } //burada ShakeCamera() scriptine erişmek için cameranın tagini kullanarak camerayı bulduk, //sonra cameradan da bileşenlerine erişerek ShakeCamera scriptine ulaştık. shakeCamera = GameObject.FindWithTag(Tags.MAIN_CAMERA_TAG).GetComponent <ShakeCamera>(); }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("thief")) { EnemyMovement thief = other.GetComponent <EnemyMovement>(); if (thief.m_HasTreassure) { thief.m_TargetTransform = m_Treassure; thief.m_HasTreassure = false; m_MatchManager.m_score++; } } }
void Start() { player = GameObject.FindGameObjectWithTag("Player"); if (isRanged) { meleeAttackRadius = 10f; } moveScript = GetComponent <EnemyMovement>(); animator = GetComponent <Animator>(); }
public IEnumerator EndTurn() { if (isTurnInProgress && OnEndTurn != null) { yield return(StartCoroutine(WaitForFrames(minimumTurnFrames - turnFrameCounter))); isTurnInProgress = false; turnFrameCounter = 0; OnEndTurn(); print("------END------"); EnemyMovement.Stop(); } }
void Start() { //abilities.Add(new Teleport(anim, 0)); abilities.Add(new EnergyShot(anim, 0)); enemyInfo = new EnemyInformation(this.gameObject.name); movement = new EnemyMovement(enemyInfo, this.gameObject); ai = new AI(enemyInfo, this.gameObject, abilities, movement); enemyInfo.CurrentHealth = enemyInfo.MaxHealth; movement.MovementEnabled = true; }
/// <summary> /// 発射 /// 塔的攻击处理 /// </summary> /// <param name="target">敵</param> void Attack(EnemyMovement target) { //生成子弹 Projectile instance = Instantiate(projectilePrefab, projectileSpawnPoint.transform.position, Quaternion.identity); instance.target = target; //定义目标 instance.range = Range; //攻击范围 instance.power = (int)(instance.power * PowerMultiplier); //子弹威力 currentReloadTime = ReloadRate; //重置攻击时间 Destroy(instance.gameObject, 5); //5秒删除对象 //Debug.Log("Reload Time: " + reloadTime); }
void Awake() { _playerHealth.GetComponent<PlayerHealth>(); _enemyAttackAnimation.GetComponent<EnemyAttackAnimation>(); _enemyMovement = GetComponent<EnemyMovement>(); _enemybattleMechanics = GetComponent<EnemyBattleMechanics>(); _spiritBar = GetComponent<SpiritBar>(); CurrentHealth = MaxHealth; IsDead = false; CanSpecial = false; Source = GetComponent<AudioSource>(); }
void Awake() { Assert.IsNotNull(template); spriteRenderer = this.GetComponent <SpriteRenderer>(); spriteRenderer.sprite = template.sprite; mvt = this.GetComponent <EnemyMovement>(); // atk = template.Atk; // hpDisplay.UpdateHpDisplay(currentHealth); text = GetComponentInChildren <TextMeshPro>(); Debug.Log("awake called"); }
private static EnemyMovement InitComponents(GameObject instance, Unit unit) { EnemyController enemyController = instance.GetComponent <EnemyController>(); EnemyMovement enemyMovement = instance.GetComponent <EnemyMovement>(); EnemyHealth enemyHealth = instance.GetComponent <EnemyHealth>(); UnitView unitView = instance.GetComponent <UnitView>(); enemyController.Init(unit); enemyMovement.Init(unit); enemyHealth.Init(unit); unitView.Init(unit); return(enemyMovement); }
void Awake() { animationScript = GetComponent <CharacterAnimation>(); audioSource = GetComponent <AudioSource>(); if (gameObject.CompareTag(Tags.ENEMY_TAG)) { enemy_Movement = GetComponentInParent <EnemyMovement>(); } shakeCamera = GameObject.FindWithTag(Tags.MAIN_CAMERA_TAG).GetComponent <ShakeCamera>(); }
public void InitializeAttack() { _nearestPlayerCollider = new Collider2D[3]; _cooldownTimer = 0; _hasToCharge = false; _enemyMovement = GetComponent <EnemyMovement>(); _objectPooler = ObjectPoolerManager.instance; state = State.Moving; playerPosition = _enemyMovement.FindNearestPlayer(); _playerHealth = GetNearestPlayerHealth(playerPosition); Timing.RunCoroutine(AttackSignal().CancelWith(gameObject)); Timing.RunCoroutine(ChargeSignal().CancelWith(gameObject)); }
void Retarget() { Collider[] otherEnemies = Physics.OverlapSphere(transform.position, range); foreach (var col in otherEnemies) { EnemyMovement other = col.GetComponent <EnemyMovement>(); if (other != null) { target = other; break; } } }
private IEnumerator AttackGrenadeTask() { TaskRunning = true; EnemyMovement.FaceTarget(transform, Target); lastGrenadeTime = Time.time; GetComponent <AttackTarget>().Execute("Player"); while (GetComponent <AttackTarget>().attacking) { yield return(new WaitForEndOfFrame()); } TaskRunning = false; }
private void Awake() { _senses = this.GetComponent <EnemySenses>(); _chars = this.GetComponent <EntityCharacteristics>(); _movementController = this.GetComponent <EnemyMovement>(); _chars.SetMaxHealth(100); _chars.SetMaxStamina(100); _chars.ChangeHealth(100); _chars.ChangeStamina(100); UpdateHealthInUI(); }
void Start() { enemyMovement = GetComponent<EnemyMovement>(); enemyHealth = GetComponent<EnemyHealth>(); anim = GetComponent<Animator>(); Scrooge = GameObject.FindGameObjectWithTag("Player").transform; timer = jumpTimer; direction = Scrooge.position.x - transform.position.x; if (direction > 0) direction = 1; else if (direction < 0) direction = -1; }
void Start() { if (GetComponent<EnemyMovement> ()) { if (GetComponent<EnemyAnimation> () != null) { enemyAnimation = FindObjectOfType<EnemyAnimation> (); enemyDefeatedAnimDuration = enemyAnimation.enemyDefeatedAnimDuration; } else { enemyAnimation = null; } //Auto Hook if (GetComponent<EnemyHealthManager> ()) { enemyHealthManager = GetComponent<EnemyHealthManager> (); } //else { // enemyHealthManager = GetComponentInChildren<EnemyHealthManager> (); //} // Adding "In Chidren" fixes errors, but generates whorst ones. Its probably necesary though. enemyAttack = GetComponent<EnemyAttack> (); enemyMovement = GetComponent<EnemyMovement> (); enemyAnimator = GetComponent<Animator> (); //Initial Save startingPosition = gameObject.transform.position; startingHP = enemyHealthManager.enemyHP; } else { if (GetComponentInChildren<EnemyAnimation> () != null) { enemyAnimation = FindObjectOfType<EnemyAnimation> (); enemyDefeatedAnimDuration = enemyAnimation.enemyDefeatedAnimDuration; } else { enemyAnimation = null; } //Auto Hook if (GetComponentInChildren<EnemyHealthManager> ()) { enemyHealthManager = GetComponentInChildren<EnemyHealthManager> (); } //else { // enemyHealthManager = GetComponentInChildren<EnemyHealthManager> (); //} // Adding "In Chidren" fixes errors, but generates whorst ones. Its probably necesary though. enemyAttack = GetComponentInChildren<EnemyAttack> (); enemyMovement = GetComponentInChildren<EnemyMovement> (); enemyAnimator = GetComponentInChildren<Animator> (); //Initial Save startingPosition = gameObject.transform.position; startingHP = enemyHealthManager.enemyHP; } }
// Init void Awake() { input = GetComponent<EnemyMovement>(); if (startRight) { // Move right input.moveLeft = false; input.moveRight = true; } else { // Move left input.moveLeft = true; input.moveRight = false; } }
void OnTriggerEnter2D(Collider2D other) { //if (other.name != "Player" || other.tag != "Collectibles" || other.tag != "LethalHazard" || other.tag != "Platform") if(other.GetComponent<Rigidbody2D> () || other.tag == "Obstacle") { otherRB = other.GetComponent<Rigidbody2D> (); if (other.tag == "Boss" && attTimer <=0) { attTimer = 0.1f; sasuke.takeDamage (abilityDamage); } if (other.tag == "Enemy" && attTimer <=0) { attTimer = 0.1f; other.GetComponent<EnemyHealthManager> ().takeDamage (abilityDamage); } if (other.tag == "Obstacle") { //Debug.Log("IS GETTING CALLED"); DestroyObject(other.gameObject); } if(other.GetComponent<EnemyMovement>()) { eMScrp = other.GetComponent<EnemyMovement>(); eMScrp.GetStun(stunTime); } if( other.GetComponent<EnemyAttack>()) { eAScrp = other.GetComponent<EnemyAttack>(); eAScrp.GetStun(stunTime); } if(other.tag != "Obstacle"){ if (other.transform.position.x < transform.position.x) { otherRB.velocity = new Vector2 (-18, 2); } else { otherRB.velocity = new Vector2 (18, 2); } } } }
// Use this for initialization void Start() { health = gameObject.GetComponent<Health> (); health.enabled = false; if (weapon) { weapon = Instantiate (weapon, new Vector3 (this.transform.position.x, this.transform.position.y, 0), this.transform.rotation) as Weapon; weapon.transform.SetParent (this.transform); weapon.enabled = false; } rbody = this.GetComponent<Rigidbody2D> (); movement = this.GetComponent<EnemyMovement> (); movement.enabled = false; boundingstimeout = this.GetComponent<BoundingsTimeout2D> (); boundingstimeout.enabled = false; spriterenderer = this.GetComponent<SpriteRenderer> (); }
// Init void Awake() { input = GetComponent<EnemyMovement>(); }
private void UpdateEnemyGrid(float delta) { // Make sure that there is at least one enemy to update. if (enemies.Count == 0) return; timeSinceEnemyMove += delta; // Enemies should move once every ENEMY_MOVE_INTERVAL seconds. if (timeSinceEnemyMove > ENEMY_MOVE_INTERVAL) { // enemy[0] should exist if enemies.Count != 0 (per if statement above). int moveX = enemies[0].Texture.Width + ENEMY_PADDING; int moveY = enemies[0].Texture.Height + ENEMY_PADDING; if (nextEnemyMovement == EnemyMovement.Down) { // Move enemies on the y axis. foreach (var enemy in enemies) enemy.Position.Y += moveY; // Check if the grid has reached the left side of the screen. if (GetLeftMostEnemy().Position.X < Math.Abs(moveX * 2)) nextEnemyMovement = EnemyMovement.Right; // Check if the grid has reached the right side of the screen. if (GetRightMostEnemy().Position.X > WINDOW_WIDTH - Math.Abs(moveX * 2)) nextEnemyMovement = EnemyMovement.Left; } else { // Flip the positive (right) movement if required. if (nextEnemyMovement == EnemyMovement.Left) moveX *= -1; // Move enemies on the x axis. foreach (var enemy in enemies) enemy.Position.X += moveX; // Check if the grid has reached the left or right side of the screen. if (GetLeftMostEnemy().Position.X < Math.Abs(moveX*2) || GetRightMostEnemy().Position.X > WINDOW_WIDTH - Math.Abs(moveX*2)) { nextEnemyMovement = EnemyMovement.Down; } } timeSinceEnemyMove = 0; } // 1% chance of enemy laser fire. if (rand.Next(100) < 1) { // Randomly select an enemy and take their position on the X axis. int selectedColumn = (int)enemies[rand.Next(enemies.Count)].Position.X; // Get the bottom-most enemy in that column. Sprite selectedEnemy = GetBottomMostEnemyInColumn(selectedColumn); // Create a laser. enemyLasers.Add(new Sprite(laserTexture, selectedEnemy.Position)); } }
private void ResetLevel() { playerLasers.Clear(); enemyLasers.Clear(); superEnemy.Position = new Vector2(-40, 20); superEnemy.Alive = false; enemies.Clear(); nextEnemyMovement = EnemyMovement.Right; var enemyTexture = Content.Load<Texture2D>("textures/enemy"); var offset = new Vector2(50, 50); for (int y = 0; y < 5; y++) { for (int x = 0; x < 10; x++) { var enemyPosition = offset + new Vector2( x * (enemyTexture.Width + ENEMY_PADDING), y * (enemyTexture.Height + ENEMY_PADDING)); var enemy = new Sprite(enemyTexture, enemyPosition); enemy.Color = Color.LimeGreen; enemies.Add(enemy); } } }
//private List<Vector3> enemyPositions; void Awake() { _instance = this; //enemyPositions = new List<Vector3>(); }
public EnemyController(EnemyMovement enemyMovement, Spawner spawner, HealthBar healthbar) { EnemyMovement = enemyMovement; Spawner = spawner; HealthBar = healthbar; }
void Awake() { _tags = FindObjectOfType<Tags>(); _enemyMovement = FindObjectOfType<EnemyMovement>(); }
private void BodyguardAwake() { em = GetComponent<EnemyMovement>(); masterMacrophage = em.chasee.GetComponent<EnemyMovement>(); }