Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log("Number of enemies " + Enemy.numAliveEnemies);
        if (GameStateManager.instance.state == GameStateManager.GameState.Gameplay)
        {
            if (!logicPaused)
            {
                if (currentWave < levels[currentLevel].numWavesTillBoss)
                {
                    if (WaveCooldown())
                    {
                        TheWave wave = new TheWave();
                        wave.eTypes           = PickRandomEnemy();
                        wave.spawnAmount      = Random.Range(enemyPatterns[(int)wave.eTypes].minSpawn, enemyPatterns[(int)wave.eTypes].maxSpawn + 1);
                        wave.currentSpawnCool = enemyPatterns[(int)wave.eTypes].spawnRate;
                        waves.Add(wave);
                    }
                    for (int i = 0; i < waves.Count; i++)
                    {
                        if (SpawnRateCoolDown(waves[i]))
                        {
                            Enemy e = EnemyPooling(enemyPatterns[(int)waves[i].eTypes].enemy);

                            int spawnPos = Random.Range(0, enemyPatterns[(int)waves[i].eTypes].spawnLocations.Length);
                            while (spawnPos == prevSpawnPos)
                            {
                                spawnPos = Random.Range(0, enemyPatterns[(int)waves[i].eTypes].spawnLocations.Length);
                            }
                            prevSpawnPos = spawnPos;
                            EnemyPatterns _pat = enemyPatterns[(int)waves[i].eTypes];
                            e.transform.position = _pat.spawnLocations[spawnPos].position;
                            e.OnSpawn();
                            e.gameObject.SetActive(true);
                            waves[i].spawnAmount--;
                            if (waves[i].spawnAmount == 0)
                            {
                                waves.RemoveAt(i);
                                currentWave++;
                                --i;
                            }
                        }
                    }
                }
                else if (!bossSpawned && Enemy.numAliveEnemies == 0)
                {
                    Invoke("SpawnBoss", 3);
                    bossSpawned = true;
                    waves.Clear();
                }

                CircleSwarm();
            }
        }
    }
Ejemplo n.º 2
0
        override protected void Init()
        {
            _dungeonData = FindObjectOfType <DungeonData>();

            #if DEBUG
            if (_dungeonData == null)
            {
                _dungeonData           = new DungeonData();
                _dungeonData.parameter = new DungeonParameter(4500, 4500, 0, 0, 1, 0, 0, 0, "j");
                for (int i = 0; i < _dungeonData.parameter.stocks.Length; i++)
                {
                    _dungeonData.parameter.stocks[i] = 3;
                }
                _dungeonData.SetIsBossBattle(true);
                elementalAffinity = _dungeonData.battleType.ToEnum <Element, BlockType>();
            }
            #endif

            _party = new string[]
            {
                "Amelia",
                "Dhiel",
                "Rizel",
                "Iska"
            };

            _profileType = new Type[]
            {
                typeof(Amelia),
                typeof(Dhiel),
                typeof(Rizel),
                typeof(Iska)
            };

            IsBoss = _dungeonData.isBossBattle;

            InitBattleStates();

            mainPlayer   = FindObjectOfType <MainPlayer>();
            actorList    = new List <GameObject>();
            enemyList    = new List <GameObject> ();
            currentFloor = _dungeonData.parameter.floor;

            _spawner       = FindObjectOfType <ActorSpawner>();
            _attackTracker = FindObjectOfType <AttackTracker>();
            _uiMgr         = FindObjectOfType <UIMgr> ();
            _enemies       = new EnemyPatterns();

            elementalAffinity = _dungeonData.battleType.ToEnum <Element, BlockType>();
        }
Ejemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        EnemyPatterns script = (EnemyPatterns)target;

        label.richText  = true;
        label.alignment = TextAnchor.MiddleLeft;

        title.richText  = true;
        title.alignment = TextAnchor.MiddleCenter;

        value.alignment = TextAnchor.MiddleRight;



        base.OnInspectorGUI();
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);


        switch (script.mode)
        {
            #region TitleModes
        case EnemyPatterns.modifier.circle:
            GUILayout.Label("<b><color=RED>Circle Mode Settings</color></b>", title);
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Space(10);
            break;

        case EnemyPatterns.modifier.player:
            GUILayout.Label("<b><color=RED>Player Mode Settings</color></b>", title);
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Space(10);
            break;

        case EnemyPatterns.modifier.burst:
            GUILayout.Label("<b><color=RED>Burst Mode Settings</color></b>", title);
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Space(10);
            break;

        case EnemyPatterns.modifier.oneTime:
            GUILayout.Label("<b><color=RED>Sigle Shot Mode Settings</color></b>", title);
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            GUILayout.Space(10);
            break;
            #endregion
        }

        #region BaseVariables
        if (script.mode != EnemyPatterns.modifier.player)
        {
            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("<b>Number of Axes   </b>", label);
                script.number = (int)GUILayout.HorizontalSlider(script.number, 1, 75, GUILayout.Width(150));
                int    val1      = (int)script.number;
                string valstring = string.Format("{0:00}", val1);

                GUILayout.Box(valstring, value);
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.BeginHorizontal();
        {
            GUILayout.Label("<b>Bullet Speed           </b>", label);
            script.speed = Mathf.Round(GUILayout.HorizontalSlider(script.speed, 0.0f, 50.0f, GUILayout.Width(150)) * 10f) / 10f;
            int    val1      = (int)script.speed % 100;
            float  val2      = Mathf.Round((script.speed - val1) * 10);
            string valstring = string.Format("{0:00}.{1}", val1, val2);
            GUILayout.Label(valstring, value);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        {
            GUILayout.Label("<b>Bullet Acceleration   </b>", label);
            script.acceleration = Mathf.Round(GUILayout.HorizontalSlider(script.acceleration, 0.0f, 10.0f, GUILayout.Width(150)) * 10f) / 10f;
            int    val1      = (int)script.acceleration % 100;
            float  val2      = Mathf.Round((script.acceleration - val1) * 10);
            string valstring = string.Format("{0:00}.{1}", val1, val2);
            GUILayout.Label(valstring, value);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        {
            GUILayout.Label("<b>Wave mode</b>", label);
            script.waveMode = GUILayout.Toggle(script.waveMode, "");

            GUILayout.Label("<b>Wave Speed</b>", label);
            script.waveSpeed = EditorGUILayout.FloatField(script.waveSpeed);
        }
        GUILayout.EndHorizontal();


        GUILayout.BeginHorizontal();
        {
            GUILayout.Label("<b>Arround mode</b>", label);
            script.arroundMode = GUILayout.Toggle(script.arroundMode, "");
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        {
            GUILayout.Label("<b>Rotation Speed   </b>", label);
            script.rotationSpeed = (int)GUILayout.HorizontalSlider(script.rotationSpeed, -100, 100, GUILayout.Width(150));
            int    val1      = (int)script.rotationSpeed;
            string valstring = string.Format("{0:00}", val1);

            GUILayout.Box(valstring, value);
        }
        GUILayout.EndHorizontal();
        #endregion

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        switch (script.mode)
        {
        case EnemyPatterns.modifier.circle:
            #region CircleMode


            GUILayout.BeginHorizontal(); {
                if (GUILayout.Button("Reset Rotation"))
                {
                    script.rotationSpeed = 0;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("<b>Spawn Time          </b>", label);
                script.spawnTime = Mathf.Round(GUILayout.HorizontalSlider(script.spawnTime, 0.0f, 5.0f, GUILayout.Width(150)) * 10f) / 10f;
                int    val1      = (int)script.spawnTime % 100;
                float  val2      = Mathf.Round((script.spawnTime - val1) * 10);
                string valstring = string.Format("{0:00}.{1}", val1, val2);
                GUILayout.Label(valstring, value);
            }
            GUILayout.EndHorizontal();
            #endregion
            break;

        case EnemyPatterns.modifier.player:
            #region PlayerMode
            GUILayout.BeginHorizontal(); {
                GUILayout.Label("<b><color=RED>Dispersion Angle     </color></b>", label);
                script.dispersionAngle = Mathf.Round(GUILayout.HorizontalSlider(script.dispersionAngle, 0.0f, 3.0f, GUILayout.Width(150)) * 10f) / 10f;
                int    val1      = (int)script.dispersionAngle % 100;
                float  val2      = Mathf.Round((script.dispersionAngle - val1) * 10);
                string valstring = string.Format("{0:00}.{1}", val1, val2);
                GUILayout.Label(valstring, value);
            }
            GUILayout.EndHorizontal();
            #endregion
            break;

        case EnemyPatterns.modifier.burst:
            #region BurstMode
            GUILayout.BeginHorizontal(); {
                GUILayout.Label("<b>Number by Burst     </b>", label);
                script.numberByBurst = (int)GUILayout.HorizontalSlider(script.numberByBurst, 1, 10, GUILayout.Width(150));
                int    val1      = (int)script.numberByBurst;
                string valstring = string.Format("{0:00}", val1);

                GUILayout.Box(valstring, value);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(); {
                GUILayout.Label("<b>Time between bursts </b>", label);
                script.timeBetweenBursts = Mathf.Round(GUILayout.HorizontalSlider(script.timeBetweenBursts, 0.0f, 3.0f, GUILayout.Width(150)) * 10f) / 10f;
                int    val1      = (int)script.timeBetweenBursts % 100;
                float  val2      = Mathf.Round((script.timeBetweenBursts - val1) * 10);
                string valstring = string.Format("{0:00}.{1}", val1, val2);
                GUILayout.Label(valstring, value);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(); {
                GUILayout.Label("<b>Time between bullets</b>", label);
                script.timeBetweenBulletsInBurst = Mathf.Round(GUILayout.HorizontalSlider(script.timeBetweenBulletsInBurst, 0.0f, 3.0f, GUILayout.Width(150)) * 10f) / 10f;
                int    val1      = (int)script.timeBetweenBulletsInBurst % 100;
                float  val2      = Mathf.Round((script.timeBetweenBulletsInBurst - val1) * 10);
                string valstring = string.Format("{0:00}.{1}", val1, val2);
                GUILayout.Label(valstring, value);
            }
            GUILayout.EndHorizontal();
            #endregion
            break;
        }

        serializedObject.Update();
        serializedObject.ApplyModifiedProperties();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(script);
            EditorSceneManager.MarkSceneDirty(script.gameObject.scene);
        }
    }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     patterns = GetComponent <EnemyPatterns>();
 }