private static IEnumerator CoSpawnEnemy(Model.EnemyPlayer enemy, Vector2 pos) { var enemyPlayer = EnemyFactory.Create(enemy, pos); enemyPlayer.StartRun(); yield return(new WaitForSeconds(UnityEngine.Random.Range(0.0f, 0.2f))); }
public static EnemyPlayer Create(Model.EnemyPlayer spawnCharacter, Vector2 position) { var objectPool = Game.instance.Stage.objectPool; var enemy = objectPool.Get <Character.EnemyPlayer>(position); if (!enemy) { throw new NotFoundComponentException <Character.EnemyPlayer>(); } var player = Game.instance.Stage.GetPlayer(); enemy.Set(spawnCharacter, player, true); // y좌표값에 따른 정렬 처리 var sortingGroup = enemy.GetComponent <SortingGroup>(); if (!sortingGroup) { throw new NotFoundComponentException <SortingGroup>(); } sortingGroup.sortingOrder = (int)(position.y * 10) * -1; return(enemy); }
public IEnumerator CoSetData(Model.EnemyPlayer enemyPlayer, Vector3 offset) { yield return(StartCoroutine(CoSpawnEnemy(enemyPlayer, offset))); }