void Awake() { DontDestroyOnLoad(this); Inst = this; //添加船体的控制脚本 curPlayShip = transform.Find("PlayerShipGroup").gameObject; curPlayShip.AddComponent <PlayerShip>(); //添加所需模块组件的组件 AudioMgr = gameObject.AddComponent <AudioMgr>(); //调用音效初始化 AudioMgr.Inst(); AudioMgr.PlayAudio(AudioMgr.bgm, AudioMgr._BgmAudioSource_p); EnemyMgr = gameObject.AddComponent <EnemyMgr>(); EnemyMgr.Inst(); EnemyMgr.StartBuild(); AsteridMgr = gameObject.AddComponent <AsteridMgr>(); AsteridMgr.Inst(); AsteridMgr.StrtBuild(); EffectMgr = gameObject.AddComponent <EffectMgr>(); EffectMgr.Inst(); MissilePoolMgr = gameObject.AddComponent <MissilePoolMgr>(); //调用对象池里的生成子弹方法 MissilePoolMgr.Inst(); _MainCancas = transform.Find("Canvas").GetComponent <Canvas>(); _scoreUI = _MainCancas.transform.Find("ScoreUI").gameObject.AddComponent <ScoreUI>(); _scoreUI.Inst(); }
void Awake() { Inst = this; _enemy = gameObject.AddComponent <EnemyMgr>(); _ui = gameObject.AddComponent <UIMgr>(); _shop = gameObject.AddComponent <ShopMgr>(); _npc = gameObject.AddComponent <NPCMgr>(); }
private void Init() { LoadStageData(); CheckLoadRound(); // 고정된 캐릭터 - 추후 캐릭터 선택을 통해 변경되는 코드로 수정필요 characterMgr = characterMgr_obj.GetComponent <CharacterMgr>(); enemyMgr = esMgr_obj.GetComponent <EnemyMgr>(); NextRoundDist = originNextRoundDist; text = stage[curLevel.stage].textObj.GetComponent <TextMeshProUGUI>(); }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } }
public void CalculateDamage(AttackItem attack) { List <EnemyBase> enemies = EnemyMgr.GetEnemies((enemy) => { bool isInRange = Vector3.Distance(transform.position, enemy.transform.position) < attack.Range; bool isDir = false; if (attack.AttackDir == AttackDir.Around) { isDir = true; } else { Vector3 enemyRelativePos = transform.InverseTransformVector(enemy.transform.position); Vector3 meToEnemyVector = enemy.transform.position - transform.position; float factor = Vector3.Dot(meToEnemyVector, transform.forward); if ((attack.AttackDir == AttackDir.Forward && factor > 0) || (attack.AttackDir == AttackDir.Back && factor < 0)) { isDir = true; } else { isDir = false; } } return(isDir && isInRange); }); if (enemies == null || enemies.Count == 0) { return; } for (int i = 0; i < enemies.Count; i++) { enemies[i].GetDamage(attack); } }
private void Awake() { inst = this; }
public void DeleteFromEnemyList(EnemyMgr theEnemy) { enemyList.Remove(theEnemy); CheckEnemyList(); }
//call by enemy script #region Call By Enemy public void RegisterToEnemyList(EnemyMgr theEnemy) { enemyList.Add(theEnemy); }
void Update() { if (m_bDead == true) { return; } if (Input.GetMouseButtonDown(0)) { if (m_PlayerShotGun.m_Animation.isPlaying == false) { // Create a vector at the center of our camera's viewport Vector3 rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f)); // Declare a raycast hit to store information about what our raycast has hit RaycastHit hit; // Check if our raycast has hit anything if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, weaponRange)) { if (hit.transform.tag == "Zombie") { EnemyMgr zomb = hit.collider.GetComponent <EnemyMgr>(); if (zomb.Equals(this)) { zomb.m_fHP -= 50; TAudioMgr.Instance.PlayEffect("zo_hit"); Debug.Log(zomb.m_fHP.ToString()); GameObject obj = TPrefabMgr.Instance("Blood", "Blood", hit.point.x, hit.point.y, hit.point.z); } } if (m_fHP <= 0.0f && m_bDead == false) { //fpc.m_iScore += 10; //Debug.Log(fpc.m_iScore.ToString()); m_bDead = true; TAudioMgr.Instance.PlayEffect("zo_pain"); m_Animation.CrossFade(m_DieAnimation.name); Invoke("DestroyNow", 10.0f); } //int a = 1; //// Set the end position for our laser line //laserLine.SetPosition(1, hit.point); //// Get a reference to a health script attached to the collider we hit //ShootableBox health = hit.collider.GetComponent<ShootableBox>(); //// If there was a health script attached //if (health != null) //{ // // Call the damage function of that script, passing in our gunDamage variable // health.Damage(gunDamage); //} //// Check if the object we hit has a rigidbody attached //if (hit.rigidbody != null) //{ // // Add force to the rigidbody we hit, in the direction from which it was hit // hit.rigidbody.AddForce(-hit.normal * hitForce); //} } } } if ((m_Player != null) && (m_fHP > 0)) { //if (StaticVars.b_isGameOver == false) //{ Vector3 vPos = m_Player.position; vPos.y += 1.0f; Vector3 vRocketDirection = (vPos - transform.position).normalized; // 조준을 시작한 상태가 아니라면 추적, if (Shoot(vRocketDirection)) { Run(); } else { // 웨이포인트로부터 특정 거리 이상 떨어져 있는지 확인 // m_fWaypointDistance 이상 떨어져 있으면 추적이나 공격을 멈추고 // 웨이포인트로 돌아간다. if (m_WayPoint.AwayFromWaypoint(transform, m_fWaypointDistance)) { m_bAiming = false; m_bRun = false; } } if (!m_bAiming) { NormalMove(vRocketDirection); } else { AttackMove(vRocketDirection); } //} //else //{ // m_Animation.CrossFade(m_IdleAnimation.name); //} } }