/// <summary> /// 生成横向pingpong敌人 /// </summary> /// <param name="count"></param> private void SpawnHorizontalPingpongEnemy() { var pos = GetStartPosition(true); for (int i = 0; i < pos.Length; i++) { enemyBehavior = new EnemyBehavior(); enemyBehavior.pingpongBehavior = PingpongBehavior.Horizontal; var entity = entityFactoryService.CreateEnemy(UidUtils.Uid, pos[i], EnemyType.PingpongBehavior, enemyBehavior, speed); pingPongEnemyList.Add(entity); } }
/// <summary> /// 随机生成敌人 /// </summary> /// <param name="count"></param> private void SpawnRandomEnemy(int count) { while (count > 0) { //不在主角身上生成敌人 防止立即碰到 Vector2 pos = Vector2.zero; do { pos = GetRandomPosition(); } while (pos == contexts.game.globalHero.value.position.value); enemyBehavior.normalBehavior = NormalBehavior.Chase; entityFactoryService.CreateEnemy(UidUtils.Uid, pos, EnemyType.NormalBehavior, enemyBehavior); count--; } }