예제 #1
0
        public override void OnInspectorGUI()
        {
            WaveConfigurator waveConfig = target as WaveConfigurator;
            SerializedObject so         = new SerializedObject(target);

            so.Update();

            SerializedProperty startPointType       = so.FindProperty("startPointType");
            SerializedProperty startPointPickerType = so.FindProperty("startPointPickerType");
            SerializedProperty spawnerType          = so.FindProperty("spawnerType");
            SerializedProperty spawnerPickerType    = so.FindProperty("spawnerPickerType");
            SerializedProperty needSpawnerPicker    = so.FindProperty("needSpawnerPicker");
            SerializedProperty endPointsType        = so.FindProperty("endPointsType");
            SerializedProperty formationType        = so.FindProperty("formationType");

            EditorGUILayout.PropertyField(startPointType, true);
            EditorGUILayout.PropertyField(startPointPickerType, true);

            EditorGUILayout.PropertyField(spawnerType, true);
            needSpawnerPicker.boolValue = false;
            // We only want to show the spawnerPickerType when we have one of these spawners selected.
            if (spawnerType.enumValueIndex == (int)SpawnerEnum.SpawnerType.PerWaveCustom)
            {
                needSpawnerPicker.boolValue = true;
                EditorGUILayout.PropertyField(spawnerPickerType, true);
            }

            EditorGUILayout.PropertyField(endPointsType, true);
            EditorGUILayout.PropertyField(formationType, true);

            // If we do this after the buttons shit hits the fan.
            so.ApplyModifiedProperties();

            Color oldColor = GUI.backgroundColor;

            if (GUILayout.Button("Add components (and destroy old)"))
            {
                waveConfig.AddStartPointComponents();
                waveConfig.AddSpawnerComponents();
                waveConfig.AddEndPointComponents();
                waveConfig.AddFormationComponents();
            }

            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Remove all components"))
            {
                if (EditorUtility.DisplayDialog("Delete components",
                                                "You are about to delete all components other than this (WaveConfigurator), are you sure?",
                                                "Delete",
                                                "Cancel"))
                {
                    waveConfig.RemoveAllComponents();
                }
            }
            GUI.backgroundColor = oldColor;
        }
예제 #2
0
 public void SetEnemyWeapon(WaveConfigurator waveConfigurator)
 {
     this.waveConfigurator = waveConfigurator;
     enemyIsAimer          = waveConfigurator.GetEnemyAimer();
     playerObject          = GameObject.Find("Player").gameObject;
     firingSpeed           = waveConfigurator.GetEnemyFiringSpeed();
     aimingSpeed           = waveConfigurator.GetEnemyAimingSpeed();
     projectileSpeed       = waveConfigurator.GetEnemyProjectileSpeed();
     projectileDamage      = waveConfigurator.GetEnemyProjectileDamage();
     projectilePrefab      = waveConfigurator.GetEnemyProjectilePrefab();
     canfire = firingSpeed;
 }
예제 #3
0
    private IEnumerator SpawnAllEnemiesInWave(WaveConfigurator waveConfigurator)
    {
        var numberOfEnemiesInWave = waveConfigurator.GetNumberOfEnemies();

        for (int i = 0; i < numberOfEnemiesInWave; i++)
        {
            var newEnemy = Instantiate(
                waveConfigurator.GetEnemyPrefab(),
                waveConfigurator.GetWaypoints()[0].transform.position,
                waveConfigurator.GetEnemyPrefab().transform.rotation);
            newEnemy.GetComponent <Enemy>().SetWaveConfig(waveConfigurator);
            yield return(new WaitForSeconds(waveConfigurator.GetTimeBetweenSpawns()));
        }
    }
예제 #4
0
 // When the enemy is spawned, pull all the settings from the WaveConfigurator for the current wave
 public void SetWaveConfig(WaveConfigurator waveConfig)
 {
     this.waveConfigurator = waveConfig;
     waypoints             = waveConfigurator.GetWaypoints();
     transform.position    = waypoints[0].transform.position;
     enemyHealth           = waveConfigurator.GetEnemyHealth();
     collisionDamage       = waveConfigurator.GetEnemyCollisionDamage();
     turningSpeed          = waveConfigurator.GetEnemyTurningSpeed();
     firingSpeed           = waveConfigurator.GetEnemyFiringSpeed();
     enemyIsAimer          = waveConfigurator.GetEnemyAimer();
     aimingSpeed           = waveConfigurator.GetEnemyAimingSpeed();
     projectileSpeed       = waveConfigurator.GetEnemyProjectileSpeed();
     projectileDamage      = waveConfigurator.GetEnemyProjectileDamage();
     projectilePrefab      = waveConfigurator.GetEnemyProjectilePrefab();
     scoreValue            = waveConfigurator.GetEnemyScoreValue();
     playerObject          = GameObject.Find("Player").gameObject;
     gameSession           = GameObject.Find("GameSession").gameObject.GetComponent <GameSession>();
     GetComponentInChildren <EnemyWeapon>().SetEnemyWeapon(waveConfig);
     GetComponent <DamageDealer>().SetDamage(collisionDamage);
 }