示例#1
0
    private void SpawnEnemies()
    {
        chaserGroups.ForEach(group =>
        {
            group.enemyStartPositions.ForEach(position =>
            {
                GameObject enemyInstance           = Instantiate(chaserPrefabs[Random.Range(0, chaserPrefabs.Count)], position, Quaternion.identity);
                Vector3 originalScale              = enemyInstance.transform.localScale;
                enemyInstance.transform.localScale = new Vector3(
                    originalScale.x * Random.Range(randomWidthMultiplierRange.x, randomWidthMultiplierRange.y),
                    originalScale.y * Random.Range(randomHeightMultiplierRange.x, randomHeightMultiplierRange.y),
                    originalScale.z * Random.Range(randomWidthMultiplierRange.x, randomWidthMultiplierRange.y));

                PureChaser chaser      = Utils.GetRequiredComponent <PureChaser>(enemyInstance);
                chaser.targetTransform = GameManager.Instance.GetPlayerTransform();
                chaser.SetSpeed(group.chaseSpeed);
                chaser.startChaseRadius           = group.startChaseRadius;
                chaser.enemy.OnCollideWithPlayer += RestartAfterCutscene;

                NPCBark npcBark = Utils.GetRequiredComponent <NPCBark>(enemyInstance);
                NPCInteractable npcInteractable = Utils.GetRequiredComponent <NPCInteractable>(enemyInstance);
                npcInteractable.enabled         = false;

                spawnedEnemies.Add(new SpawnedEnemy(enemyInstance, chaser, group, npcBark, npcInteractable));
            });
        });
    }
示例#2
0
 public SpawnedEnemy(GameObject gameObject, PureChaser pureChaser, TutorialChaserGroup chaserGroup, NPCBark npcBark, NPCInteractable npcInteractable)
 {
     this.gameObject      = gameObject;
     this.pureChaser      = pureChaser;
     this.chaserGroup     = chaserGroup;
     this.npcBark         = npcBark;
     this.npcInteractable = npcInteractable;
 }