public IEnemy MakeSprite(EnemyEnum spriteType, Vector2 location) { return(spriteType switch { EnemyEnum.Wallmaster => new Wallmaster(texture, location, game), EnemyEnum.TealGel => new Gel(texture, location, game, Color.Teal), EnemyEnum.BlueGel => new Gel(texture, location, game, Color.Blue), EnemyEnum.GreenGel => new Gel(texture, location, game, Color.Green), EnemyEnum.GoldGel => new Gel(texture, location, game, Color.Gold), EnemyEnum.LimeGel => new Gel(texture, location, game, Color.Lime), EnemyEnum.BrownGel => new Gel(texture, location, game, Color.Brown), EnemyEnum.GrayGel => new Gel(texture, location, game, Color.Gray), EnemyEnum.WhiteGel => new Gel(texture, location, game, Color.White), EnemyEnum.GreenZol => new Zol(texture, location, Color.Green, game), EnemyEnum.GoldZol => new Zol(texture, location, Color.Gold, game), EnemyEnum.LimeZol => new Zol(texture, location, Color.Lime, game), EnemyEnum.BrownZol => new Zol(texture, location, Color.Brown, game), EnemyEnum.GrayZol => new Zol(texture, location, Color.Gray, game), EnemyEnum.WhiteZol => new Zol(texture, location, Color.White, game), EnemyEnum.Snake => new Snake(texture, location, game), EnemyEnum.RedGoriya => new Goriya(texture, location, Color.Red, game), EnemyEnum.BlueGoriya => new Goriya(texture, location, Color.Blue, game), EnemyEnum.RedKeese => new Keese(texture, location, Color.Red, game), EnemyEnum.BlueKeese => new Keese(texture, location, Color.Blue, game), EnemyEnum.Stalfos => new Stalfos(texture, location, game), EnemyEnum.Trap => new Trap(texture, location, game), EnemyEnum.Trapparatus => new Trapparatus(texture, location, game), EnemyEnum.Owl => new Owl(texture2, location, game), EnemyEnum.FairyEnemy => new FairyEnemy(texture3, location, game), _ => throw new ArgumentException("Invalid sprite! " + spriteType.ToString() + " Sprite factory failed."), });
public GameObject getEnemyPrefabFromType(EnemyEnum type) { switch (type) { case EnemyEnum.PAWN: return(enemyPawnPrefab); case EnemyEnum.KNIGHT: return(enemyKnightPrefab); case EnemyEnum.BISHOP: return(enemyBishopPrefab); case EnemyEnum.ROOK: return(enemyRookPrefab); case EnemyEnum.QUEEN: return(enemyQueenPrefab); case EnemyEnum.KING: return(enemyKingPrefab); default: return(enemyPawnPrefab); } }
// Update is called once per frame void Update() { switch (state) { case EnemyEnum.Attack: Attacking(); break; case EnemyEnum.chase: Chasing(); break; case EnemyEnum.Patrol: Patrolling(); break; case EnemyEnum.spin: Spinning(); break; } if (finish.win == true) { state = EnemyEnum.spin; GetComponent <Renderer>().material.color = new Color(1.0f, 1.0f, 1.0f); } }
private IEnumerator ExplodeOverTime() { for (int i = 0; i < detectedEnemies.Count; i++) { if (detectedEnemies[i] != null) { toDestroy = detectedEnemies[i].GetComponent <BaseEnemy>(); enemyIdentifier = toDestroy.EnemyIdentifier; toDestroy.PolyKill(this); if (enemyIdentifier == EnemyEnum.Coyote) { detectedEnemies[i].AddComponent <BigScalePolyExplosion>(); } else if (enemyIdentifier == EnemyEnum.ChewingGum) { detectedEnemies[i].AddComponent <SmallPolyExplosion>(); } else { detectedEnemies[i].AddComponent <NormalPolyExplosion>(); } yield return(null); } } detectedEnemies.Clear(); }
public static Enemy GetEnemy(EnemyEnum enemyId) { switch (enemyId) { case EnemyEnum.Demon: return new Demon(10,5); case EnemyEnum.Zombie: return new Zombie(15,10); case EnemyEnum.Fallen: return new Fallen(25,15); case EnemyEnum.Ogre: return new Ogre(30,20); case EnemyEnum.Goatman: return new Goatman(35, 25); case EnemyEnum.Skeleton: return new Skeleton(5, 5); case EnemyEnum.Yeti: return new Yeti(40, 25); case EnemyEnum.Brute: return new Brute(45, 20); case EnemyEnum.Fenix: return new Fenix(50, 25); case EnemyEnum.Dragon: return new Dragon(100, 20); default: throw new NotImplementedException(); } }
public Enemy(Point location, EnemyEnum type, double speed, int fireRate) : base(location, ENEMY_WIDTH, ENEMY_HEIGHT, Sprites[(int)type], ENEMY_TAG) { EnemyType = type; Speed = speed; FireRate = fireRate; }
public void CreateWave() { for (int i = 0; i < LevelData.Levels[CurrentLevelIndex].Waves[CurrentWaveIndex].Enemies.Count; i++) { enemyEnum = (EnemyEnum)LevelData.Levels[CurrentLevelIndex].Waves[CurrentWaveIndex].Enemies[i].EnemyId; enemyOffTime = LevelData.Levels[CurrentLevelIndex].Waves[CurrentWaveIndex].Enemies[i].Offtime; speed = LevelData.Levels[CurrentLevelIndex].Waves[CurrentWaveIndex].Enemies[i].Speed; health = LevelData.Levels[CurrentLevelIndex].Waves[CurrentWaveIndex].Enemies[i].Health; monetaryValue = LevelData.Levels[CurrentLevelIndex].Waves[CurrentWaveIndex].Enemies[i].MonetaryValue; GameManager.Instance.SpawnEnemy(enemyEnum, enemyOffTime, speed, health, monetaryValue); } }
void DoSpawn() { int enemyCount = this.CalcSpawnCount(); string s = ""; for (int i = 0; i < enemyCount; i++) { EnemyEnum type = this.CalculateEnemyType(); BoidSpawnManager.Instance.AddToSpawnQueue(type); s += type.ToString() + " "; } Debug.Log(BeatManager.Instance.Intensity + ": " + enemyCount + " " + s); }
static void Main(string[] args) { FriendlyEnum friendlyValue = FriendlyEnum.A; EnemyEnum enemyValue = EnemyEnum.A; // Outputs "true": Console.WriteLine(friendlyValue.In(FriendlyEnum.A, FriendlyEnum.C)); // Outputs "false": Console.WriteLine(friendlyValue.In(FriendlyEnum.B, FriendlyEnum.C)); // Both of these will result in compiler errors, // because EnemyEnum is invading: Console.WriteLine(friendlyValue.In(EnemyEnum.A, EnemyEnum.B)); Console.WriteLine(enemyValue.In(FriendlyEnum.A, FriendlyEnum.B)); }
public IEnemy MakeSprite(EnemyEnum spriteType, Vector2 location) { return(spriteType switch { EnemyEnum.Aquamentus => new Aquamentus(texture, location, game), EnemyEnum.Patra => new Patra(texture, location, game), EnemyEnum.Manhandla => new Manhandla(texture, location, game), EnemyEnum.Gleeok => new Gleeok(texture, location, game), EnemyEnum.Ganon => new Ganon(texture, location, game), EnemyEnum.OrangeGohma => new Gohma(texture, location, Color.Orange, game), EnemyEnum.BlueGohma => new Gohma(texture, location, Color.Blue, game), EnemyEnum.Dodongo => new Dodongo(texture, location, game), EnemyEnum.Digdogger => new Digdogger(texture, location, game), _ => throw new ArgumentException("Invalid sprite! " + spriteType.ToString() + " Sprite factory failed."), });
// Update is called once per frame void Update() { currentCooldown -= Time.deltaTime; if (currentCooldown <= 0 && BoidSpawnManager.Instance.HasSpawns && !spawningEnemy) { currentCooldown = BoidSpawnManager.Instance.SpawnCooldownTime; spawningEnemy = true; enemyToSpawn = BoidSpawnManager.Instance.GetNextSpawn(); BeatManager.Instance.DelayUntilNextBeat(this.SpawnNext); } if (closeSphincter > 0.0f && Time.time > closeSphincter && sphincter != null) { sphincter.Close(); closeSphincter = -1.0f; } }
public void SpawnEnemy(EnemyEnum enemyEnum, float enemyOffTime, float speed, float health, float monetaryValue) { for (int i = 0; i < EnemyPrefabDataList.Count; i++) { if (EnemyPrefabDataList[i].type == enemyEnum) { //GameObject clone = Instantiate(EnemyPrefabDataList[i].prefab); GameObject clone = Instantiate(Resources.Load("Enemies/" + EnemyPrefabDataList[i].prefab.name, typeof(GameObject))) as GameObject; PathFollower pathFollower = clone.GetComponent <PathFollower>(); pathFollower.pathCreator = creator; pathFollower.tower = tower; pathFollower.timer = enemyOffTime; pathFollower.speed = speed; pathFollower.health = health; pathFollower.monetaryValue = monetaryValue; AddEnemyList(clone); if (creatorSecond != null) { GameObject secondPathClone = Instantiate(EnemyPrefabDataList[i].prefab); PathFollower secondPathFollower2 = secondPathClone.GetComponent <PathFollower>(); secondPathFollower2.pathCreator = creatorSecond; secondPathFollower2.tower = tower; secondPathFollower2.timer = enemyOffTime; secondPathFollower2.speed = speed; secondPathFollower2.health = health; secondPathFollower2.monetaryValue = monetaryValue; AddEnemyList(secondPathClone); } if (creatorThird != null) { GameObject thirdPathClone = Instantiate(EnemyPrefabDataList[i].prefab); PathFollower thirdPathFollower3 = thirdPathClone.GetComponent <PathFollower>(); thirdPathFollower3.pathCreator = creatorThird; thirdPathFollower3.tower = tower; thirdPathFollower3.timer = enemyOffTime; thirdPathFollower3.speed = speed; thirdPathFollower3.health = health; thirdPathFollower3.monetaryValue = monetaryValue; AddEnemyList(thirdPathClone); } } } }
/// <summary> /// Spawns an enemy sprite /// </summary> void SpawnEnemy(EnemyEnum enemy) { // Load enemy assets var enemySpriteImagePath = enemy == EnemyEnum.Bat ? "Art/Sprites/Enemies/Bat" : "Art/Sprites/Enemies/Slime"; var enemyCharacterPrefabPath = "Prefabs/Battle/EnemyCharacter"; var enemySprite = Resources.Load <Sprite>(enemySpriteImagePath); var enemyCharacterGameObject = Resources.Load <GameObject>(enemyCharacterPrefabPath); // Grab the container for the battle character var battleCharacterContainer = GameObject.Find("BattleCharacters"); // Spawn the enemy character var enemyCharacter = Instantiate(enemyCharacterGameObject, battleCharacterContainer.transform); enemyCharacter.GetComponent <Image>().sprite = enemySprite; // Move the enemy character a hair to the right enemyCharacter.transform.localPosition = new Vector3(enemyCharacter.transform.localPosition.x + 20f, enemyCharacter.transform.localPosition.y); }
/// <summary> /// Initializes the sprite /// </summary> /// <param name="game">Reference to the game</param> /// <param name="enemy">The type enemy</param> /// <param name="position">The starting position</param> public EnemySprite(XNADash game, EnemyEnum enemy, Vector2 position) { enemyType = enemy; if (enemyType == EnemyEnum.Butterfly) { texture = game.Content.Load <Texture2D>("butterfly"); } else if (enemyType == EnemyEnum.Firefly) { texture = game.Content.Load <Texture2D>("firefly"); } Speed = 500f; MoveUp(); gameInstance = game; Position = position; Destination = position; }
protected EnemyEnum CalculateEnemyType() { int SpawnCount = this.CalcSpawnCount(); float baddieChance = this.BaddieChance(); EnemyEnum enemyType = EnemyEnum.Small; if (baddieChance < 0.33f) { enemyType = EnemyEnum.Small; } else if (baddieChance < 0.66f) { enemyType = EnemyEnum.Medium; } else { enemyType = EnemyEnum.Big; } return(enemyType); }
/// <summary> /// Initialize the battle /// </summary> public void Initialize(EnemyEnum enemy) { // Lets just create a basic character var battleCharacter = new BattleCharacter { Name = "Brian", MaxHp = 100, CurrentHp = 100, MaxMp = 20, CurrentMp = 20, Attack = 10, Defense = 5 }; // Spawn the character's row SpawnCharacterRow(battleCharacter); // Spawn the enemy SpawnEnemy(enemy); isInitialized = true; }
void ChangeToPatrol() { state = EnemyEnum.Patrol; GetComponent <Renderer>().material.color = new Color(0.5f, 0.5f, 0.5f); }
public void AddToSpawnQueue(EnemyEnum enemyType) { spawnQueue.Enqueue(enemyType); }
private void SpawnEnemy(EnemyEnum enemy) { GameObject enemyObject = Instantiate(Resources.Load(enemy.ToString()), spawnPoint, true) as GameObject; enemyObject.transform.position = new Vector3(Random.Range(-spawnBounds.size.x / 2, spawnBounds.size.x / 2), spawnPoint.position.y); }
public static string GetName(this EnemyEnum enemy) => Enum.GetName(enemy.GetType(), enemy);
void ChangeToAttack() { state = EnemyEnum.Attack; GetComponent <Renderer>().material.color = new Color(1.0f, 0.0f, 0.0f); }
void ChangeToChase() { state = EnemyEnum.chase; GetComponent <Renderer>().material.color = new Color(1.0f, 1.0f, 0.0f); }