Exemplo n.º 1
0
    public void AddLevel()
    {
        EnemyLevel enemyLevel = ScriptableObject.CreateInstance <EnemyLevel>();

        ScriptableObjects.Add(enemyLevel, this);
        levels.Add(enemyLevel);
    }
Exemplo n.º 2
0
		public static EnemyLevel getEnemyLevel(Character character)
		{

			string locName = (String)At.GetValue(typeof(Character), character, "m_nameLocKey");

			//thanks sinai
			string cleanObjectName = getCleanName(character);

			if (isPlayer(character))
			{
				return EnemyLevel.NORMAL;
			}

			EnemyLevel enemyLevel = EnemyLevel.NORMAL;

			if (isMiniBoss(locName, cleanObjectName))
			{
				enemyLevel = EnemyLevel.MINIBOSS;
			}

			if (isBoss(locName, cleanObjectName))
			{
				enemyLevel = EnemyLevel.BOSS;
			}

			if (isWeakling(locName, cleanObjectName))
			{
				enemyLevel = EnemyLevel.WEAKLING;
			}

			return enemyLevel;
		}
Exemplo n.º 3
0
    public bool Handle(WaveEvent waveEvent)
    {
        bool handled = false;

        switch (waveEvent.type)
        {
        case WaveEvent.Type.SpawnEnemy:
            handled = true;

            if (lanes > waveEvent.lane)
            {
                Lane lane = LaneBy(waveEvent.lane);

                for (int i = 0; lane.objects.Count > i && handled; i++)
                {
                    if (lane.objects[i] is LaneEntity && lane.objects[i].rect.width > lane.objects[i].back - lane.start.x)
                    {
                        handled = false;
                    }
                }

                if (handled)
                {
                    SpawnEnemyEvent spawnEnemyEvent = (waveEvent as SpawnEnemyEvent);
                    EnemyLevel      enemyLevel      = spawnEnemyEvent.enemyDefinition.levels[spawnEnemyEvent.level];
                    lane.Add(new Enemy(spawnEnemyEvent.enemyDefinition, spawnEnemyEvent.level, new EnemySettings(enemyLevel.color, enemyLevel.health, enemyLevel.speed), lane, waveEvent.entryPoint, _container));
                }
            }

            return(handled);

        default:
            return(handled);
        }
    }
Exemplo n.º 4
0
 // initializes the current level and switches to next one
 private void initLevel()
 {
     if (currentlevel == null)
     {
         currentlevel             = enemies[0];
         currentlevel.enemiesLeft = currentlevel.maxEnemies;
     }
 }
Exemplo n.º 5
0
 private void nextLevel()
 {
     //if (enemies[currentlevel.level + 1] != null)
     if (currentlevel.level < enemies.Count - 1)
     {
         currentlevel             = enemies[currentlevel.level + 1];
         currentlevel.enemiesLeft = currentlevel.maxEnemies;
         print("moved to a new level " + currentlevel.level);
     }
 }
Exemplo n.º 6
0
    public GameObject getEnemyWeapon(EnemyType type, EnemyLevel level)
    {
        Dictionary <EnemyLevel, GameObject> weapons = new Dictionary <EnemyLevel, GameObject>();
        GameObject weaponPrefab = null;

        enemyWeaponLevels.TryGetValue(type, out weapons);

        weapons.TryGetValue(level, out weaponPrefab);

        return(weaponPrefab);
    }
Exemplo n.º 7
0
    public List <ItemInfo> GetLootForLevel(EnemyLevel level)
    {
        List <ItemInfo> loot = new List <ItemInfo>();

        foreach (ItemInfo info in LootItems)
        {
            if (info.lootLevel <= level)
            {
                loot.Add(info);
            }
        }

        return(loot);
    }
Exemplo n.º 8
0
	void Awake() {
		// intialize enemy's attribute
		enemyScore = GetComponent<EnemyScore> ();
		enemyAttack = GetComponent<EnemyAttack> ();
		enemyEnergy = GetComponent<EnemyEnergy> ();
		enemyLevel = GetComponent<EnemyLevel> ();

		// other flag status
		facingLeft = true; // enemy start in the scene facing left
		grounded = false;
		doubleJump = false;

		source = GetComponent<AudioSource> ();
	}
Exemplo n.º 9
0
    void Awake()
    {
        // intialize enemy's attribute
        enemyScore  = GetComponent <EnemyScore> ();
        enemyAttack = GetComponent <EnemyAttack> ();
        enemyEnergy = GetComponent <EnemyEnergy> ();
        enemyLevel  = GetComponent <EnemyLevel> ();

        // other flag status
        facingLeft = true;         // enemy start in the scene facing left
        grounded   = false;
        doubleJump = false;

        source = GetComponent <AudioSource> ();
    }
Exemplo n.º 10
0
    public void SetLevel(EnemyLevel level = EnemyLevel.One)
    {
        enemyLevel = level;
        WeaponStats stats = GetComponentInChildren <WeaponStats>();

        switch (enemyLevel)
        {
        case EnemyLevel.One:
            model.sharedMaterial     = QuestManager.instance.gameEnemies.enemyMaterials[0];
            health.startHealth       = 200;
            health.currenthealth     = health.startHealth;
            health.hpSlider.maxValue = health.startHealth;
            stats.damage             = 100;
            break;

        case EnemyLevel.Two:
            model.sharedMaterial     = QuestManager.instance.gameEnemies.enemyMaterials[1];
            health.startHealth       = 300;
            health.currenthealth     = health.startHealth;
            health.hpSlider.maxValue = health.startHealth;
            stats.damage             = 150;
            break;

        case EnemyLevel.Three:
            model.sharedMaterial     = QuestManager.instance.gameEnemies.enemyMaterials[2];
            health.startHealth       = 400;
            health.currenthealth     = health.startHealth;
            health.hpSlider.maxValue = health.startHealth;
            stats.damage             = 200;
            break;

        case EnemyLevel.Four:
            model.sharedMaterial     = QuestManager.instance.gameEnemies.enemyMaterials[3];
            health.startHealth       = 500;
            health.currenthealth     = health.startHealth;
            health.hpSlider.maxValue = health.startHealth;
            stats.damage             = 250;
            break;

        case EnemyLevel.Five:
            model.sharedMaterial     = QuestManager.instance.gameEnemies.enemyMaterials[4];
            health.startHealth       = 600;
            health.currenthealth     = health.startHealth;
            health.hpSlider.maxValue = health.startHealth;
            stats.damage             = 300;
            break;
        }
    }
Exemplo n.º 11
0
    // Start is called before the first frame update
    void Start()
    {
        enemyLevel = EnemyManager.Instance.GetEnemyInfo(Level);

        if (enemyLevel != null)
        {
            if (renderer)
            {
                renderer.material.color = enemyLevel.color;
            }
        }
        else
        {
            Debug.LogWarning("Enemy level info could not be recieved");
        }
    }
Exemplo n.º 12
0
 public void SetColor(EnemyColor color)
 {
     if (this.level == null)
     {
         this.level = new EnemyLevel(color);
     }
     else if (color > EnemyColor.RED)
     {
         color = EnemyColor.RED;
     }
     else
     {
         this.level.Color = color;
     }
     isSpecial = level.Color.Equals(EnemyColor.RED);
 }
Exemplo n.º 13
0
    public void EnemyDestroyed(GameObject enemy)
    {
        totalRemainingEnemyCount--;

        Score += enemy.GetComponent <EnemyController>().GetEnemyPoint();

        EnemyLevel enemyLevel = enemy.GetComponent <EnemyController>().GetEnemyLevel();

        if (!destroyedEnemyCount.ContainsKey(enemyLevel.GetStartColor()))
        {
            destroyedEnemyCount.Add(enemyLevel.GetStartColor(), 0);
        }
        destroyedEnemyCount[enemyLevel.GetStartColor()] = destroyedEnemyCount[enemyLevel.GetStartColor()] + 1;

        if (remainingEnemyCount > 0)
        {
            StartCoroutine(WaitSeconds(1f));
            remainingEnemyCount--;
            UpdateEnemyCountText();
        }

        StartCoroutine(CheckForGameWon(1f));
    }
Exemplo n.º 14
0
    public static void CreateEnemy()
    {
        EnemyLevel enemyLevel = gameState.EnemyLevels.Find(el => el.Level == gameState.currentLevel);

        int prevLevel = 1;

        while (enemyLevel == null)
        {
            enemyLevel = gameState.EnemyLevels.Find(el => el.Level == gameState.currentLevel - prevLevel);
            prevLevel--;

            if (prevLevel <= 0)
            {
                break;
            }
        }

        if (enemyLevel != null)
        {
            List <EnemyPrefab> enemyPrefabs = enemyLevel.EnemyPrefabs;

            List <GameObject> prefabs = new List <GameObject>();

            foreach (EnemyPrefab prefab in enemyPrefabs)
            {
                for (int i = 0; i < prefab.Weight; i++)
                {
                    prefabs.Add(prefab.Prefab);
                }
            }

            int idx = UnityEngine.Random.Range(0, prefabs.Count);

            gameState.currentEnemy = GameObject.Instantiate(prefabs[idx]);
        }
    }
Exemplo n.º 15
0
    private void GenerateDifficulty()
    {
        switch (encounterDifficulty)
        {
        case EncounterDifficulty.Easy:
            //Well shit
            if (GetChance() < 4)
            {
                encounterSize = 3;
                enemyLevel    = EnemyLevel.Higher;
            }    //Somewhat difficult
            else if (GetChance() > 5 && GetChance() < 8)
            {
                encounterSize = 3;
                enemyLevel    = EnemyLevel.Same;
            }    //still difficult, but not a problem
            else if (GetChance() > 8 && GetChance() < 12)
            {
                encounterSize = 2;
                enemyLevel    = EnemyLevel.Higher;
            }
            else if (GetChance() > 12 && GetChance() < 16)
            {
                encounterSize = 2;
                enemyLevel    = EnemyLevel.Same;
            }
            else if (GetChance() > 16)
            {
                encounterSize = 2;
                enemyLevel    = EnemyLevel.Lower;
            }
            break;


        case EncounterDifficulty.Normal:
            //Well shit
            if (GetChance() < 4)
            {
                encounterSize = Random.RandomRange(3, 4);
                enemyLevel    = EnemyLevel.Higher;
            }    //Somewhat difficult
            else if (GetChance() > 5 && GetChance() < 8)
            {
                encounterSize = Random.RandomRange(3, 4);
                enemyLevel    = EnemyLevel.Same;
            }    //still difficult, but not a problem
            else if (GetChance() > 8 && GetChance() < 12)
            {
                encounterSize = Random.Range(2, 3);
                enemyLevel    = EnemyLevel.Same;
            }
            else if (GetChance() > 12 && GetChance() < 16)
            {
                encounterSize = Random.Range(2, 3);
                enemyLevel    = (EnemyLevel)Random.Range(1, 2);
            }
            else if (GetChance() > 16)
            {
                encounterSize = 2;
                enemyLevel    = EnemyLevel.Same;
            }
            break;

        case EncounterDifficulty.Hard:
            //Well shit
            if (GetChance() < 4)
            {
                encounterSize = 4;
                enemyLevel    = EnemyLevel.Higher;
            }    //Somewhat difficult
            else if (GetChance() > 5 && GetChance() < 8)
            {
                encounterSize = Random.RandomRange(3, 4);
                enemyLevel    = (EnemyLevel)Random.Range(1, 2);
            }    //still difficult, but not a problem
            else if (GetChance() > 8 && GetChance() < 12)
            {
                encounterSize = Random.Range(2, 4);
                enemyLevel    = (EnemyLevel)Random.Range(1, 2);
            }
            else if (GetChance() > 12 && GetChance() < 16)
            {
                encounterSize = Random.Range(2, 3);
                enemyLevel    = EnemyLevel.Higher;
            }
            else if (GetChance() > 16)
            {
                encounterSize = 2;
                enemyLevel    = EnemyLevel.Higher;
            }
            break;
        }

//        Debug.Log("You got an opponent pool based on: " + enemyLevel + " with " + encounterSize + " enemies");



        //Instantiate them (Maybe use a pool?)
        //Populate them to the CombatSlots
        //Determine Loot?
    }
Exemplo n.º 16
0
    public void SpawnHorde()
    {
        //Debug.Log(currentLevel);
        switch (currentLevel)
        {
        case EnemyLevel.LEVEL1:
            if (SpacePlayer.score >= (int)EnemyLevel.LEVEL2)
            {
                currentLevel = EnemyLevel.LEVEL2;
                return;
            }
            EnemiesLevel1And2();
            return;

        case EnemyLevel.LEVEL2:
            if (SpacePlayer.score >= (int)EnemyLevel.LEVEL3)
            {
                currentLevel = EnemyLevel.LEVEL3;
                return;
            }
            enemyCount++;
            hordeMultiplier++;
            EnemiesLevel1And2();
            return;

        case EnemyLevel.LEVEL3:
            if (SpacePlayer.score >= (int)EnemyLevel.LEVEL4)
            {
                currentLevel = EnemyLevel.LEVEL4;
                return;
            }
            enemyCount++;
            hordeMultiplier++;
            EnemiesLevel1And2();
            EnemiesLevel3();
            return;

        case EnemyLevel.LEVEL4:
            if (SpacePlayer.score >= (int)EnemyLevel.LEVEL5 && enemiesInArea.Count == 0)
            {
                currentLevel = EnemyLevel.LEVEL5;
                return;
            }
            enemyCount++;
            bigEnemyCount++;
            hordeMultiplier++;
            EnemiesLevel1And2();
            EnemiesLevel4();
            return;

        case EnemyLevel.LEVEL5:
            if (!Boss.activeSelf)
            {
                Boss.SetActive(true);
                BossEncounter();
            }

            return;

        default:
            return;
        }

        //Level 2
        //if(SpacePlayer.score >= 10 && SpacePlayer.score <= 50)
        //{
        //    currentLevel = EnemyLevel.LEVEL2;
        //    enemyCount++;
        //    hordeMultiplier++;
        //}
        ////enemyCount = enemyCount * hordeMultiplier;
        //EnemiesLevel1And2();

        //if(SpacePlayer.score >= 51 && SpacePlayer.score < 100)
        //{
        //    currentLevel = EnemyLevel.LEVEL3;
        //    enemyCount++;
        //    hordeMultiplier++;
        //}

        //if(currentLevel == EnemyLevel.LEVEL3)
        //{
        //    EnemiesLevel3();
        //}
    }
Exemplo n.º 17
0
 public void SetEnemyLevel(EnemyLevel level)
 {
     enemyLevel = level;
 }
Exemplo n.º 18
0
 public void AddToGameScore(EnemyLevel EL)
 {
     GameScore += (int)EL * Step;
     UpdateScore();
 }
Exemplo n.º 19
0
    public void ShowInfo(Dictionary <AbstractEnemy.EnemyColor, int> destroyedEnemyCount, int currentLevel, int currentScore)
    {
        gameObject.SetActive(true);
        gameOverCanvas.SetActive(false);
        infoCanvas.SetActive(true);

        GameObject grayEnemy      = GameObject.Find("GrayEnemyInfo");
        GameObject yellowEnemy    = GameObject.Find("YellowEnemyInfo");
        GameObject greenEnemy     = GameObject.Find("GreenEnemyInfo");
        GameObject redEnemy       = GameObject.Find("RedEnemyInfo");
        GameObject dashes         = GameObject.Find("Dashes");
        GameObject totalText      = GameObject.Find("TotalText");
        GameObject continueButton = GameObject.Find("ContinueButton");

        SetInfoVisible(grayEnemy, false);
        SetInfoVisible(yellowEnemy, false);
        SetInfoVisible(greenEnemy, false);
        SetInfoVisible(redEnemy, false);
        SetInfoVisible(dashes, false);
        SetInfoVisible(totalText, false);
        SetInfoVisible(totalEnemyCountText.gameObject, false);
        SetInfoVisible(continueButton, false);

        int highScore = PlayerPrefs.GetInt("HighScore");

        if (highScore == 0)
        {
            highScoreText.text = "000000";
        }
        else
        {
            highScoreText.text = highScore.ToString();
        }

        currentScoreText.text = currentScore.ToString();
        levelName.text        = "Level " + currentLevel;

        int oldHighScore = PlayerPrefs.GetInt("HighScore");

        if (currentScore > oldHighScore)
        {
            PlayerPrefs.SetInt("HighScore", currentScore);
        }

        int totalEnemyCount = 0;

        foreach (AbstractEnemy.EnemyColor color in (AbstractEnemy.EnemyColor[])Enum.GetValues(typeof(AbstractEnemy.EnemyColor)))
        {
            int score = EnemyLevel.GetScoreByColor(color);
            int count = 0;
            if (destroyedEnemyCount.ContainsKey(color))
            {
                count = destroyedEnemyCount[color];
            }

            string scoreText = (score * count).ToString();
            string countText = count.ToString();
            SetScoreValues(color, scoreText, countText);
            totalEnemyCount += count;
        }

        totalEnemyCountText.text = totalEnemyCount.ToString();

        StartCoroutine(SetInfoVisibleDelayed(1f, grayEnemy, true));
        StartCoroutine(SetInfoVisibleDelayed(2f, yellowEnemy, true));
        StartCoroutine(SetInfoVisibleDelayed(3f, greenEnemy, true));
        StartCoroutine(SetInfoVisibleDelayed(4f, redEnemy, true));
        StartCoroutine(SetInfoVisibleDelayed(5f, dashes, true));
        StartCoroutine(SetInfoVisibleDelayed(6f, totalText, true));
        StartCoroutine(SetInfoVisibleDelayed(6f, totalEnemyCountText.gameObject, true));
        StartCoroutine(SetInfoVisibleDelayed(7f, continueButton, true));
    }
Exemplo n.º 20
0
 private void Start()
 {
     currentLevel = GetComponent <EnemyLevel>();
     currentLevel.InitLevelProperties(this);
 }
Exemplo n.º 21
0
    public void ShowWaveEventButtons()
    {
        HideWaveEventButtons();
        List <List <Button> > waveEventButtons = new List <List <Button> >();

        for (int i = 0; _editor.stage.lanes > i; i++)
        {
            waveEventButtons.Add(new List <Button>());
            Layout layout = new Layout("WaveEvent" + i.ToString() + "Layout", waveEventButtons[i].Count, 1, 0.25f, 0.1f, 1, container, false);
            layout.SetLocalPosition(_editor.stage.LaneBy(i).start + (Vector3.left * layout.width * 0.5f));
            waveEventLayouts.Add(layout);
            Add(layout);
        }

        for (int i = 0; selectedWaveDefinition.waveEvents.Count > i; i++)
        {
            int index     = i;
            int laneIndex = selectedWaveDefinition.waveEvents[index].lane;
            WaveEventDefinition waveEvent = selectedWaveDefinition.waveEvents[index];
            Lane lane = _editor.stage.LaneBy(laneIndex);

            if (waveEventButtons.Count > laneIndex)
            {
                float  width  = 1;
                float  height = 1;
                Color  color  = Color.white;
                string name   = index.ToString();

                switch ((WaveEvent.Type)waveEvent.type)
                {
                case WaveEvent.Type.SpawnEnemy:
                    EnemyDefinition enemyDefinition = Definitions.Enemy((Definitions.Enemies)waveEvent.subType);
                    EnemyLevel      enemyLevel      = enemyDefinition.levels[waveEvent.level];
                    width  = enemyDefinition.width;
                    height = lane.height - enemyDefinition.laneHeightPadding;
                    name   = enemyDefinition.name;
                    color  = enemyLevel.color;
                    break;

                case WaveEvent.Type.SpawnItem:

                    break;
                }

                Button button = new Button(name, width, height, container, "WaveEvent" + index.ToString(),
                                           fontSize: 20,
                                           Enter: (Button butt) => butt.SetColor(Color.green),
                                           Stay: (Button butt) =>
                {
                    if (Input.GetMouseButtonUp(0))
                    {
                        for (int j = 0; waveEventButtons[laneIndex].Count > j; j++)
                        {
                            waveEventButtons[laneIndex][j].Hide();
                        }

                        butt.Select();
                        _selectedWaveEvent = waveEvent;
                        ShowWaveEventEditor(butt, index);
                    }

                    if (Input.GetMouseButtonDown(1))
                    {
                        selectedWaveDefinition.Remove(waveEvent);
                        ShowWaveEventButtons();
                    }
                },
                                           Exit: (Button butt) =>
                {
                    if (_editor.timelineEditor.heldWave == null && heldWaveEvent == null && Input.GetMouseButton(0))
                    {
                        heldWaveEvent = new HeldEvent(butt.rect.position, width, height, color, waveEvent, laneIndex);
                        heldWaveEvent.SetText(name);
                    }

                    butt.SetColor(color);
                },
                                           Close: (Button butt) =>
                {
                    if (Input.GetMouseButtonDown(0) && butt.selected && _waveTypes == null && _enemyLevels == null && _enemyTypes == null && _itemTypes == null && (waveEventEditor == null || !waveEventEditor.containsMouse))
                    {
                        HideWaveEventEditor();
                        butt.Deselect();

                        for (int j = 0; waveEventButtons[selectedWaveDefinition.waveEvents[index].lane].Count > j; j++)
                        {
                            waveEventButtons[selectedWaveDefinition.waveEvents[index].lane][j].Show();
                        }
                    }
                });

                button.SetColor(color);
                waveEventButtons[laneIndex].Add(button);
                waveEventLayouts[laneIndex].Add(button);
                button.SetLocalPosition(new Vector3(waveEvent.entryPoint * lane.width, 1, 0));
            }
        }
    }
Exemplo n.º 22
0
 public override string ToString()
 {
     return(IsCollapsed ? "~" : EnemyLevel.ToString());
 }