public void onSpawn() { enemyManager = GameObject.FindGameObjectWithTag("EnemyManager").GetComponent <EnemyDifficulty> (); gameState = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameState> (); AILevel = enemyManager.setNewEnemyDifficulty(); GetComponent <State> ().health = AILevel; setBehaviour(); }
private Enemy SpawnEnemy(EnemyDifficulty difficulty, Vector3 pos) { var path = _enemiesPrefabPrefix + _spawnData.enemiesDictionary[difficulty].GetRandomPrefab().name; //Debug.Log("Difficulty = " + difficulty + " ::: Enemy Prefab Path = " + path); return(PhotonNetwork.Instantiate(path, pos, Quaternion.identity) .GetComponent <Enemy>()); }
public static EnemyDifficulty GetEnemyDifficulty(List <TR2Entity> enemies) { if (enemies.Count == 0) { return(EnemyDifficulty.VeryEasy); } ISet <TR2Entities> enemyEntities = new HashSet <TR2Entities>(); enemies.ForEach(e => enemyEntities.Add((TR2Entities)e.TypeID)); int weight = 0; foreach (TR2Entities enemyEntity in enemyEntities) { EnemyDifficulty enemyDifficulty = EnemyDifficulty.Medium; foreach (EnemyDifficulty difficulty in _enemyDifficulties.Keys) { if (_enemyDifficulties[difficulty].Contains(enemyEntity)) { enemyDifficulty = difficulty; break; } } weight += (int)enemyDifficulty; } // What's the average? double average = (double)weight / enemyEntities.Count; weight = Convert.ToInt32(Math.Round(average, 0, MidpointRounding.AwayFromZero)); List <EnemyDifficulty> allDifficulties = new List <EnemyDifficulty>(Enum.GetValues(typeof(EnemyDifficulty)).Cast <EnemyDifficulty>()); if (weight > 0) { weight--; } if (weight >= allDifficulties.Count) { weight = allDifficulties.Count - 1; } return(allDifficulties[weight]); }
public void FillDeck(EnemyDifficulty difficulty) { ShowCardIndicators(); switch (difficulty) { case EnemyDifficulty.Beginner: // set up the cards to be played // for beginner battle there will be 5 copies of each 1-9 card Card[] addCardsBgn = new Card[45]; for (int i = 0; i < additionCardsPrefabs.Length; i++) { ArrayFuncs.FillArray(addCardsBgn, additionCardsPrefabs[i], (i * 5), 5); } // move the cards to the deck deckCards.InsertRange(0, addCardsBgn); break; case EnemyDifficulty.Intermediate: // set up the cards to be played // for intermediate battle there will be 16 copies of each 1-9 card Card[] addCardsInt = new Card[144]; for (int i = 0; i < additionCardsPrefabs.Length; i++) { ArrayFuncs.FillArray(addCardsInt, additionCardsPrefabs[i], (i * 16), 16); } // intermediate battle will include 8 wild cards *** wild cards are assumed to be single card type *** Card[] wildCardInt = new Card[8]; for (int j = 0; j < wildCardsPrefabs.Length; j++) { ArrayFuncs.FillArray(wildCardInt, wildCardsPrefabs[j], 0, 8); } // move the cards to the deck deckCards.InsertRange(0, addCardsInt); deckCards.InsertRange(addCardsInt.Length, wildCardInt); break; case EnemyDifficulty.Expert: // currently expert is same as intermediate mode goto case EnemyDifficulty.Intermediate; } }
//called to spawn a object from the pool public void SpawnFromPool(EnemyDifficulty diff, Vector3 position, Quaternion rotation) { Debug.Log("this got here"); if (pools == null) { Debug.Log("[ObjectPooler] There is no enemies in the pool"); return; } foreach (Pool p in pools) { if (p.enemyDiff == diff) { optionalEnemies.Add(p); } } if (optionalEnemies != null) { int toSpawn = UnityEngine.Random.Range(0, optionalEnemies.Count); GameObject objectToSpawn = Instantiate(optionalEnemies[toSpawn].prefab, position, Quaternion.identity); objectToSpawn.transform.position = position; objectToSpawn.transform.rotation = rotation; IPooledObject pooledObj = objectToSpawn.GetComponent <IPooledObject>(); if (pooledObj != null) { pooledObj.OnObjectSpawn(); } optionalEnemies.Clear(); } return; }
/// <summary> /// Sets the enemy stats based on the difficulty /// </summary> /// <param name="difficulty"></param> /// <exception cref="NotImplementedException"></exception> public void InitCovidStats(Difficulty difficulty) { switch (difficulty) { case Difficulty.Easy: health = 1; enemyDifficulty = EnemyDifficulty.Easy; break; case Difficulty.Medium: health = 2; enemyDifficulty = EnemyDifficulty.Medium; break; case Difficulty.Hard: health = 3; enemyDifficulty = EnemyDifficulty.Hard; break; default: throw new NotImplementedException("Not implemented"); } }
/// <summary> /// Initializes the current and maximum health of player, as well as the amount of damage he'll take per hit /// </summary> /// <param name="difficulty">The difficulty level associated with the current playthrough. /// This is used to populate the maximum health and the amount of damage taken per hit.</param> public void InitializeHealth(EnemyDifficulty difficulty) { _curHealth = _maxHealth = difficulty.InitialHealth; _decreaseFactor = difficulty.DamageToPlayerPerHit; }
/// <summary> /// Object use to control a character's health /// </summary> /// <param name="difficulty">The difficulty level associated with the current playthrough. /// This is used to populate the maximum health and the amount of damage taken per hit.</param> public Health(EnemyDifficulty difficulty) { InitializeHealth(difficulty); }
// Start is called before the first frame update void Start() { currentPhase = new Start(this, playerStats, nPCData, playerHand, nPCHand); difficulty = nPCData.difficulty; }
private void RandomizeORPistol() { //Is there something in the unarmed level pistol location? if (_unarmedLevelPistolIndex != -1) { List <TR2Entities> ReplacementWeapons = TR2EntityUtilities.GetListOfGunTypes(); ReplacementWeapons.Add(TR2Entities.Pistols_S_P); TR2Entities Weap = ReplacementWeapons[_generator.Next(0, ReplacementWeapons.Count)]; if (_levelInstance.Is(LevelNames.CHICKEN)) { // Grenade Launcher and Harpoon cannot trigger the bells in Ice Palace while (Weap.Equals(TR2Entities.GrenadeLauncher_S_P) || Weap.Equals(TR2Entities.Harpoon_S_P)) { Weap = ReplacementWeapons[_generator.Next(0, ReplacementWeapons.Count)]; } } TR2Entity unarmedLevelWeapons = _levelInstance.Data.Entities[_unarmedLevelPistolIndex]; uint ammoToGive = 0; bool addPistols = false; uint smallMediToGive = 0; uint largeMediToGive = 0; if (_startingAmmoToGive.ContainsKey(Weap)) { ammoToGive = _startingAmmoToGive[Weap]; if (PerformEnemyWeighting) { // Create a score based on each type of enemy in this level and increase the ammo count based on this EnemyDifficulty difficulty = EnemyUtilities.GetEnemyDifficulty(_levelInstance.GetEnemyEntities()); ammoToGive *= (uint)difficulty; // Depending on how difficult the enemy combination is, allocate some extra helpers. addPistols = difficulty > EnemyDifficulty.Easy; if (difficulty == EnemyDifficulty.Medium || difficulty == EnemyDifficulty.Hard) { smallMediToGive++; } if (difficulty > EnemyDifficulty.Medium) { largeMediToGive++; } if (difficulty == EnemyDifficulty.VeryHard) { largeMediToGive++; } } else if (_levelInstance.Is(LevelNames.LAIR)) { ammoToGive *= 6; } } //#68 - Provide some additional ammo for a weapon if not pistols if (Weap != TR2Entities.Pistols_S_P) { AddORAmmo(GetWeaponAmmo(Weap), ammoToGive, unarmedLevelWeapons); } unarmedLevelWeapons.TypeID = (short)Weap; if (Weap != TR2Entities.Pistols_S_P) { // If we haven't decided to add the pistols (i.e. for enemy difficulty) // add a 1/3 chance of getting them anyway. #149 If the harpoon is being // given, the pistols will be included. if (addPistols || Weap == TR2Entities.Harpoon_S_P || _generator.Next(0, 3) == 0) { CopyEntity(unarmedLevelWeapons, TR2Entities.Pistols_S_P); } } for (int i = 0; i < smallMediToGive; i++) { CopyEntity(unarmedLevelWeapons, TR2Entities.SmallMed_S_P); } for (int i = 0; i < largeMediToGive; i++) { CopyEntity(unarmedLevelWeapons, TR2Entities.LargeMed_S_P); } } }
void Start() { readScore(); enemy = GameObject.FindGameObjectWithTag("EnemyManager").GetComponent <EnemyDifficulty> (); highScore = 0; }
//設定難度 protected virtual void SetStageDifficulty(Difficulty difficulty) { //轉型 _nowdifficulty = (EnemyDifficulty)difficulty; }
IEnumerator SpawnOutposts() { //Delay for IDs and spawns to settle yield return(new WaitForSeconds(2.0f)); for (int i = 0; i < aiTCs.Count; i++) { //Pick a difficilty EnemyDifficulty difficulty = (EnemyDifficulty)UnityEngine.Random.Range((int)EnemyDifficulty.EASY, (int)EnemyDifficulty.HARD + 1); Debug.Log($"Creating an outpost with difficulty set to {difficulty}"); //CWs if (difficulty >= EnemyDifficulty.MED) { StartCoroutine(SpawnOutpostBuidling(aiTCs[i], minerCW)); } if (difficulty >= EnemyDifficulty.HARD) { StartCoroutine(SpawnOutpostBuidling(aiTCs[i], fighterCW)); } //Turrets int turretSpawnAmount = 0; switch (difficulty) { case EnemyDifficulty.EASY: { turretSpawnAmount = UnityEngine.Random.Range(0, 3); break; } case EnemyDifficulty.MED: { turretSpawnAmount = UnityEngine.Random.Range(2, 4); break; } case EnemyDifficulty.HARD: { turretSpawnAmount = UnityEngine.Random.Range(4, 7); break; } default: { break; } } for (int f = 0; f < turretSpawnAmount; f++) { StartCoroutine(SpawnOutpostBuidling(aiTCs[i], turret)); } //Starting Resource float multipler = 1.0f; if (difficulty >= EnemyDifficulty.MED) { multipler = 1.5f; } else if (difficulty >= EnemyDifficulty.HARD) { multipler = 2.0f; } for (int a = 0; a < banks.Count; a++) { if (banks[a].ID == aiTCs[i].GetComponent <AIBehaviour>().playerID) { banks[a].resourceCount *= multipler; } } } yield return(null); }