private void Awake() { activeObjects.Clear(); pooling = gameObject.GetComponentInParent <EnemyPooling>(); currentSpawnpoint.y = transform.position.y; spawnState = SPAWNSTATE.WAITING; }
void Start() { gameManager = GameManager.Instance; poolManager = FindObjectOfType <EnemyPooling>(); spawnPosition = gameManager.GetEnemyUnitSpawnPosition(); objAtLeastDelay = minusObjDelayPerCurrentStage * 0f; }
IEnumerator Die() { if (enemyKind == MODE_KIND.Diablo) { // Enemy의를 죽이자 //죽는 애니메이션 시작 animn = 7; Instantiate(explosion, transform.position, Quaternion.identity); //4.5 초후 오브젝트 반환 yield return(new WaitForSeconds(0.5f)); this.gameObject.SetActive(false); Box.transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z); //몬스터가 죽은 자리에서 스폰 StopAllCoroutines(); //객체 반환전 모든 코루틴을 정지 } else { // Enemy의를 죽이자 //죽는 애니메이션 시작 animn = 3; Instantiate(explosion, transform.position, Quaternion.identity); //Enemy에 추가된 모든 Collider를 비활성화(모든 충돌체는 Collider를 상속했음 따라서 다음과 같이 추출 가능) //foreach (Collider coll in gameObject.GetComponentsInChildren<Collider>()) //{ // coll.enabled = false; //} //4.5 초후 오브젝트 반환 yield return(new WaitForSeconds(0.5f)); int aaa = Random.Range(1, 10); if (aaa > 5) { var Mons = ItemPooling.GetItem(); //오브젝트풀링에서 아이템을 빌려온다. //var _Mons = ItemPooling.GetItem2(); Mons.transform.position = new Vector3(transform.position.x, 0.5f, transform.position.z); //몬스터가 죽은 자리에서 스폰 //_Mons.transform.position = new Vector3(transform.position.x, 0.8f, transform.position.z); } StopAllCoroutines(); //객체 반환전 모든 코루틴을 정지 EnemyPooling.ReturnObject(this); //몬스터가 죽으면 자신을 반환 } // 포톤 추가 // 자신과 네트워크상의 모든 아바타를 삭제 //PhotonNetwork.Destroy(gameObject); }
public static int SpawnSkeleton(GameObject spawnPos, int InitNum, float rand) { if (CheckObjectInCamera(spawnPos)) //스폰장소가 카메라화면에 잡히면 { if (InitNum > 0 && maxSkeleton > 0) // { var Mons = EnemyPooling.GetSkeleton(); //오브젝트풀링에서 몬스터를 빌려온다. Mons.GetComponent <NavMeshAgent>().enabled = false; //네비메쉬에이전트 끄고 Mons.transform.position = new Vector3(spawnPos.transform.position.x + Random.Range(-rand, rand), 1, spawnPos.transform.position.z + Random.Range(-rand, rand)); //빌려온 몬스터의 위치를 랜덤배치 Mons.GetComponent <NavMeshAgent>().enabled = true; //재활성화 InitNum--; maxSkeleton--; } } return(InitNum); }
public static int SpawnGargoyle(GameObject spawnPos, int InitNum, float rand) { if (CheckObjectInCamera(spawnPos)) //스폰장소가 카메라화면에 잡히면 { if (InitNum > 0 && maxGargoyle > 0) { var Mons = EnemyPooling.GetGargoyle(); //오브젝트풀링에서 가고일몬스터를 빌려온다. Mons.GetComponent <NavMeshAgent>().enabled = false; Mons.transform.position = new Vector3(spawnPos.transform.position.x + Random.Range(-rand, rand), 1, spawnPos.transform.position.z + Random.Range(-rand, rand)); //빌려온 몬스터의 위치를 랜덤배치 Mons.GetComponent <NavMeshAgent>().enabled = true; InitNum--; maxGargoyle--; } } return(InitNum); }
void Start() { if (instance == null) { instance = this; } base.Initialize(); if (spawnEnemyPoints == null || spawnEnemyPoints.Count == 0) { Debug.LogError("There are no spawn points available!"); } spawnTime = firstSpawnTime; InvokeRepeating("Improve", timeToImprove, timeToImprove); }
void Start() { stageManager = FindObjectOfType <StageManager>(); poolManager = FindObjectOfType <EnemyPooling>(); fusionManager = FindObjectOfType <FusionManager>(); firstHeart = heart; firstAp = ap; firstDp = dp; firstStopByObjectDistance = stopByObjectDistance; _unitOnMiniMap = Instantiate(unitOnMiniMap.gameObject, GameObject.Find("MapSlider").transform); UnitOnMiniMapScript unitOnMiniMapScript = _unitOnMiniMap.GetComponent <UnitOnMiniMapScript>(); unitOnMiniMapScript.targetObject = gameObject; unitOnMiniMapScript.targetUnitTrm = gameObject.transform; SpawnSet(); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } Camera cam = Camera.main; camHeight = 2f * cam.orthographicSize; camWidth = camHeight * cam.aspect; poolScript = poolObject.GetComponent <EnemyPooling>(); playerScript = playerObject.GetComponent <PlayerController>(); menuScript = menuObject.GetComponent <Menu>(); }
private void Awake() { Instance = this; //오브젝트 풀링으로 몬스터들을 관리할 빈게임오브젝트에 이 스크립트를 추가 Initialize(10); }
void Start() { if (instance == null) { instance = this; } base.Initialize(); if (spawnEnemyPoints == null || spawnEnemyPoints.Count == 0) { Debug.LogError("There are no spawn points available!"); } spawnTime = firstSpawnTime; InvokeRepeating("Improve", timeToImprove, timeToImprove); }
private void Start() { pool = GetComponentInParent <EnemyPooling>(); spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent <Spawner>(); timer = lifetime; }