void Awake() { if (instance == null) { instance = this; } }
void Awake() { //주인공 게임오브젝트 추출 var player = GameObject.FindGameObjectWithTag("PLAYER"); //주인공의 Tranform 컴포넌트 추출 if (player != null) { playerTr = player.gameObject.GetComponent <Transform>(); } //적 캐릭터의 Tranform 컴포넌트 추출 enemyTr = GetComponent <Transform>(); //Animator 컴포넌트 추출 animator = GetComponent <Animator>(); //이동을 제어하는 MoveAgent 클래스를 추출 moveAgent = GetComponent <MoveAgent>(); //공격을 제어하는 EnemyAttack클래스 추출 enemyAttack = GetComponent <EnemyAttack>(); enemySound = GetComponent <EnemySound>(); //코루틴의 지연시간 생성 ws = new WaitForSeconds(0.3f); //Cycle Offset 값을 불규칙하게 변경 animator.SetFloat(hashOffset, Random.Range(0f, 1f)); animator.SetFloat(hashWalkSpeed, Random.Range(1f, 1.2f)); }
private void Start() { _sound = GetComponent <EnemySound>(); _rb = GetComponent <Rigidbody>(); _agent = GetComponent <NavMeshAgent>(); _material = GetComponentInChildren <MeshRenderer>().material; }
void Start() { player = GameObject.Find("PlayerTank"); waitTime = startWaitTime; waitTurn = startWaitTurn; currentState = EnemyStates.Patrol; muzzle = transform.GetChild(1).gameObject; muzzleFlash = transform.GetChild(3).gameObject; _sounds = GetComponent <EnemySound> (); //muzzleLight = transform.GetChild (2).gameObject; timeBetweenShots = startTimeBetweenShots; foreach (Transform t in moveSpots) { if (t == null) { Debug.Log("The enemy: --" + gameObject.name + "-- is missing one or more movespots"); currentState = EnemyStates.Dead; } } if (enemyType == EnemyTypes.Armored) { fire = transform.GetChild(4).gameObject; } }
// Start is called before the first frame update void Start() { zombie_state = ZombieState.PATROL; patrolling_timer = patrolling_duration; // when the enemy first gets to the player attack right away attack_timer = attack_delay; // memorize the value of chase distance so that we can put it back current_proximity = max_proximity; enemy_sound = GetComponentInChildren <EnemySound>(); }
void DeadCheck() { if (health <= 0) { EnemySound.PlaySound("explosion"); ScoreChanger.points += 10; Destroy(gameObject); } if (transform.position.x <= -5) { Destroy(gameObject); } }
void Start() { sprite = transform.GetChild(0); anim = GetComponent <Animator>(); player = GameObject.FindWithTag("Player").transform; gameManager = FindObjectOfType <GameManager>(); enemySound = GetComponent <EnemySound>(); enemySound.PlaySoundEffect(EnemySound.EffectType.APPEAR); if (abilityAmount == 3) { InvokeRepeating("StartSummoning", summonRepeatRate, summonRepeatRate); } }
private void Start() { _player = GameObject.FindGameObjectWithTag("Player").transform; _playerHealth = _player.GetComponent <PlayerHealth>(); healthBar.SetMaxHealth(health); _rb = GetComponent <Rigidbody2D>(); _sprite = GetComponent <SpriteRenderer>(); _follower = GetComponent <PathFolower>(); _follower.speed = speed; _follower.StartFollow(); _sounds = GetComponent <EnemySound>(); if (_sounds == null) { Debug.LogError("EnemySound.cs is missing on the " + gameObject.name + " gameObject!"); } }
// Start is called before first frame update private void Start() { soundPlayer = GetComponent <EnemySound>(); // Set AudioSource according to enemy type switch (enemyType) { case "small": audioSource = GameObject.Find("SmallEnemySoundSource").GetComponent <AudioSource>(); break; case "medium": audioSource = GameObject.Find("MediumEnemySoundSource").GetComponent <AudioSource>(); break; case "big": audioSource = GameObject.Find("BigEnemySoundSource").GetComponent <AudioSource>(); break; } }
void Awake() { if (check_zombie) { enemy_animation_controller = GetComponent <EnemyAnimationController>(); nav_mesh_agent = GetComponent <NavMeshAgent>(); enemy_controller = GetComponent <EnemyContoller>(); // get enemy audio enemy_sound = GetComponentInChildren <EnemySound>(); } if (check_player) { weapon_controller = GetComponent <WeaponController>(); player_statistics = GetComponent <PlayerStatistics>(); if (PlayerPrefs.GetFloat("playerhealth") > 0) { health_value = PlayerPrefs.GetFloat("playerhealth"); player_statistics.View_Health_Statistics(health_value); } } }
public void PlaySound(string name) { EnemySound s = Array.Find(sounds, EnemySound => EnemySound.name == name); s.source.Play(); }
// Update is called once per frame void Update() { if (placing == trap) { info.text = "Tile Info:" + "Trap\nCost: " + traptile.GetTileCost() + "\nDamage: " + traptile.GetTileDamage() + "\nRogues take Half"; } else if (placing == magic) { info.text = "Tile Info:" + "Magic\nCost: " + magictile.GetTileCost() + "\nDamage: " + magictile.GetTileDamage() + "\nWizards take Half"; } else if (placing == enemy) { info.text = "Tile Info:" + "Enemy\nCost: " + enemytile.GetTileCost() + "\nDamage: " + enemytile.GetTileDamage() + "\nFighters take Half"; } if (GameManager.current == GameManager.GameState.placing) { mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); hit = Physics2D.Raycast(mousePos, Vector2.zero, Mathf.Infinity, paths); tile = Physics2D.Raycast(mousePos, Vector2.zero, Mathf.Infinity, placable); } if (hit) { if (glow == null) { if (deleting) { glow = Instantiate(deleteGlow, hit.collider.transform.position, Quaternion.identity); } else { glow = Instantiate(placeGlow, hit.collider.transform.position, Quaternion.identity); } } else if (glow.transform.position != hit.collider.gameObject.transform.position) { Destroy(glow); if (deleting) { glow = Instantiate(deleteGlow, hit.collider.transform.position, Quaternion.identity); } else { glow = Instantiate(placeGlow, hit.collider.transform.position, Quaternion.identity); } } if (!deleting) { if (Input.GetMouseButton(0) && !placed.Contains(hit.collider.transform.position) && placing != null) { numActions++; if (lastDeleted) { lastDeleted = false; } if (placing == trap) { man.usedMoney += traptile.GetTileCost(); if (TrapSound != null) { TrapSound.Play(); } } else if (placing == magic) { man.usedMoney += magictile.GetTileCost(); if (MagicSound != null) { MagicSound.Play(); } } else if (placing == enemy) { man.usedMoney += enemytile.GetTileCost(); if (EnemySound != null) { EnemySound.Play(); } } actions.Push(Instantiate(placing, hit.collider.transform.position, Quaternion.identity)); placed.Add(hit.collider.transform.position); for (int i = 0; i < undoneCount; i++) { Destroy(undone.Pop()); } undoneCount = 0; actions.TrimExcess(); } } else { if (Input.GetMouseButton(0) && tile) { numActions--; undoneCount++; GameObject holder = tile.collider.gameObject; placed.Remove(hit.collider.transform.position); undone.Push(holder); holder.transform.GetChild(0).GetComponent <SpriteRenderer>().enabled = false; holder.transform.GetChild(1).GetComponent <SpriteRenderer>().enabled = false; holder.GetComponent <BoxCollider2D>().enabled = false; lastDeleted = true; actions.TrimExcess(); SellSound.Play(); if (holder.name == "Trap(Clone)") { man.usedMoney -= traptile.GetTileCost(); } else if (holder.name == "Magic(Clone)") { man.usedMoney -= magictile.GetTileCost(); } else if (holder.name == "Enemy(Clone)") { man.usedMoney -= enemytile.GetTileCost(); } } } } else { if (glow != null) { Destroy(glow); } } }
private void Start() { idleAudioTimer = RandomTimer(); state = ViewState.LookingForPlayer; enemySound = GetComponent <EnemySound>(); }