public Enemy(Texture2D i, int vX, int hitP, Rectangle r, int t) { img = i; velocityX = vX; hitpoints = hitP; rect = r; velocityY = 0; switch (t) { case 1: type = enemyType.chi; color = Color.LightBlue; break; case 2: type = enemyType.earth; color = Color.Gray; break; case 3: type = enemyType.fire; color = Color.OrangeRed; break; case 4: type = enemyType.water; color = Color.DarkBlue; break; } }
void makeEnemy(enemyType x) { // instantiate prefab // dump all the stats in int mapPhase = this.GetComponent <StateController>().mapPhase; if (mapPhase == 3) { NewenemyObject = Instantiate(enemyPrefab, new Vector2(bossX, bossY), Quaternion.identity); NewenemyObject.GetComponent <EnemyStats>().bottomX = bossX; NewenemyObject.GetComponent <EnemyStats>().bottomY = bossY; } else { NewenemyObject = Instantiate(enemyPrefab, new Vector2(bottomX, bottomY), Quaternion.identity); NewenemyObject.GetComponent <EnemyStats>().bottomX = bottomX; NewenemyObject.GetComponent <EnemyStats>().bottomY = bottomY; } NewenemyObject.GetComponent <EnemyStats>().stat = x.stat; NewenemyObject.GetComponent <EnemyStats>().modifier = x.modifier; NewenemyObject.GetComponent <EnemyStats>().expPoints = x.expPoints; NewenemyObject.GetComponent <EnemyStats>().expPointsHalf = x.expPointsHalf; NewenemyObject.GetComponent <EnemyStats>().enemySprite = x.enemySprite; }
public void childColorMatch() { snakeHead = GameObject.Find("Snake_Head " + GameObject.Find("EnemySpawner").GetComponent <enemySpawning>().id).GetComponent <basicEnemyScript>(); if (snakeHead == null) { Destroy(gameObject); } if (snakeHead.enemyCurrent == basicEnemyScript.enemyType.Red) { enemyCurrent = enemyType.Red; gameObject.renderer.material.color = Color.red; gameObject.tag = "Red"; } if (snakeHead.enemyCurrent == basicEnemyScript.enemyType.Blue) { enemyCurrent = enemyType.Blue; gameObject.renderer.material.color = Color.blue; gameObject.tag = "Blue"; } if (snakeHead.enemyCurrent == basicEnemyScript.enemyType.Green) { enemyCurrent = enemyType.Green; gameObject.renderer.material.color = Color.green; gameObject.tag = "Green"; } }
// Use this for initialization void Start() { isBulletFired = false; randomNumber = Random.Range(0, 3); gameObject.name = "Snake_Head " + GameObject.Find("EnemySpawner").GetComponent <enemySpawning>().id; id = GameObject.Find("EnemySpawner").GetComponent <enemySpawning>().id; gameObject.renderer.material.color = enemyColors[randomNumber]; if (randomNumber == 0) { gameObject.tag = "Red"; enemyCurrent = enemyType.Red; } if (randomNumber == 1) { gameObject.tag = "Blue"; enemyCurrent = enemyType.Blue; } if (randomNumber == 2) { gameObject.tag = "Green"; enemyCurrent = enemyType.Green; } }
public void setType(int i) { switch (i) { case 1: type = enemyType.chi; color = Color.LightBlue; break; case 2: type = enemyType.earth; color = Color.Gray; break; case 3: type = enemyType.fire; color = Color.OrangeRed; break; case 4: type = enemyType.water; color = Color.DarkBlue; break; case 5: type = enemyType.boss; color = Color.White; break; } }
public Enemy(Texture2D i, int vX, int hitP, Rectangle r) { img = i; velocityX = vX; color = Color.LightBlue; hitpoints = hitP; rect = r; velocityY = 0; type = enemyType.chi; }
// Start is called before the first frame update void Start() { if (currEnemy == 0) { enemy = enemyType.seal; health = enemyHealth[0]; } else { enemy = enemyType.orca; health = enemyHealth[1]; } }
public void selectEnemy() { // check if in phase 1 or 2 mapPhase = this.GetComponent <StateController>().mapPhase; // take element from list at random, remove fromt list (?) if (mapPhase == 1) { // take from easy enemy list // take in order from beginning if (enemyArrayEasy.Count == 0) { // change map phase using function in statecontroller! //transform.parent.gameObject.GetComponent<StateController>().changeLevel(2); // call make enemy again? //selectEnemy(); Debug.Log("ran out of enemies! something is wrong"); } else { newEnemy = enemyArrayEasy[0]; enemyArrayEasy.RemoveAt(0); makeEnemy(newEnemy); } } else if (mapPhase == 2) { //take from hard enemy list randomIndex = Random.Range(0, enemyArray.Count); newEnemy = enemyArray[randomIndex]; enemyArray.RemoveAt(randomIndex); makeEnemy(newEnemy); } else { // generate boss i guess newEnemy = bossArray[0]; bossArray.RemoveAt(0); makeEnemy(newEnemy); } // update stats GameObject.Find("gameController").GetComponent <UpdateStatUI>().updateEnemy(); }
/// <summary> /// Generates a randomized enemy. /// </summary> public Enemy() { Random rng = new Random(); //Generate health this.Health = rng.Next(15, 50); //Generate elemental type. Random number between 0 and the length of the enum. this.Element = (ElementalType)rng.Next(0, Enum.GetNames(typeof(ElementalType)).Length); //Beast or humanoid? enemyType randomType = (enemyType)rng.Next(0, 2); string[] randomNouns; string noun = string.Empty; switch (randomType) { case enemyType.beast: //Generate noun. randomNouns = ("cheetah wolf bird cougar hedgehog aardvark skunk muskrat rat bear " + "ermine ocelot jaguar beaver leopard").Split(' '); noun = randomNouns[rng.Next(0, randomNouns.Length)]; //Generate weapon. this.EnemyWeapon = new Weapon(WeaponType.claw); break; case enemyType.humanoid: //Generate noun. randomNouns = ("knight demon gorilla fighter ninja horror skeleton zombie vampire shadowknight " + "shaman goblin orc monster").Split(' '); noun = randomNouns[rng.Next(0, randomNouns.Length)]; //Generate weapon. this.EnemyWeapon = new Weapon(); break; } string[] randomAdjs = ("Dark Evil Menacing Angry Hellish Furious Glowing Ghostly Ghastly Accursed Fallen " + "Giant Huge Corrupted Enslaved Terrifying Barbed Spiked Infested Strange Odd Gross").Split(' '); string adj = randomAdjs[rng.Next(0, randomAdjs.Length)]; //Finish name. this.Name = adj + " " + this.Element.ToString().ToLower() + " " + noun; }
// Update is called once per frame void Update() { enemySpawn = GameObject.Find("EnemySpawner").GetComponent <enemySpawning>(); largeEnemyMovement[] largeEnemyMovements = GameObject.FindObjectsOfType <largeEnemyMovement>() as largeEnemyMovement[]; foreach (largeEnemyMovement t in largeEnemyMovements) { if (t.gameObject.name.Equals("Large_Enemy " + GameObject.Find("EnemySpawner").GetComponent <enemySpawning>().largeId) && enemySpawn.randomLargeSpawner == 7) { transform.Translate(Vector3.left * shipSpeed * Time.deltaTime); } else if (t.gameObject.name.Equals("Large_Enemy " + GameObject.Find("EnemySpawner").GetComponent <enemySpawning>().largeId) && enemySpawn.randomLargeSpawner == 12) { transform.Translate(Vector3.right * shipSpeed * Time.deltaTime); } } //color tagging if (randomNumber == 0) { enemyCurrent = enemyType.Red; gameObject.tag = "Red"; } if (randomNumber == 1) { enemyCurrent = enemyType.Blue; gameObject.tag = "Blue"; } if (randomNumber == 2) { enemyCurrent = enemyType.Green; gameObject.tag = "Green"; } // self-destruction Travelled += 0.01f; if (Travelled >= LifeTime) { StartCoroutine(FlyUpwards()); } }
public void pushBackItem(GameObject _go) { if (_go == null) { return; } enemyType temp = _go.GetComponent <ATKandDamage>().type; if (cacheControllerDic.ContainsKey(temp)) { cacheControllerDic[temp].pushBackItem(_go); } else { Debug.LogError("不存在该Go对象对象池"); } }
public void changeType(int newType) { switch (newType) { case 0: type = enemyType.BEAR; transform.position = new Vector3(transform.position.x, Random.Range(-4.5f, 4.5f), transform.position.z); health = 2; gameObject.GetComponent <Animator>().SetBool("isBear", true); break; case 1: type = enemyType.COYOTE; transform.position = new Vector3(transform.position.x, Random.Range(-4.5f, 4.5f), transform.position.z); health = 1; gameObject.GetComponent <Animator>().SetBool("isBear", false); break; } }
public Enemy(int xLoc, int yLoc, int eWidth, int eHeight, enemyType t) { last_x = x = xLoc; last_y = y = yLoc; width = eWidth; height = eHeight; last_dir = dir = PlayerDir.UP; cur_target = null; col_tok = null; //creates the lowest level of enemy if (t == enemyType.GRUNT) { eType = t; attack = 2; speed = 2; max_health = health = 10; } //creates the second level of enemy else if (t == enemyType.BEETLE) { eType = t; attack = 5; speed = 2; max_health = health = 10; } //creates toughest level of enemy else if (t == enemyType.BERSERKER) { eType = t; attack = 5; speed = 3; max_health = health = 15; } else if (t == enemyType.TROOPER) { eType = t; attack = 5; speed = 2; max_health = health = 20; } }
public Enemy(int xLoc, int yLoc, int eWidth, int eHeight, enemyType t) { last_x = x = xLoc; last_y = y = yLoc; width = eWidth; height = eHeight; last_dir = dir = PlayerDir.UP; cur_target = null; col_tok = null; //creates the lowest level of enemy if (t == enemyType.GRUNT) { eType = t; attack = 2; speed = 2; max_health = health = 10; } //creates the second level of enemy else if (t == enemyType.BEETLE) { eType = t; attack = 5; speed = 2; max_health = health = 10; } //creates toughest level of enemy else if (t == enemyType.BERSERKER) { eType = t; attack = 5; speed = 3; max_health = health = 15; } else if (t == enemyType.TROOPER) { eType = t; attack = 5; speed = 2; max_health = health = 20; } }
// Update is called once per frame void Update() { if (randomNumber == 0) { enemyCurrent = enemyType.Red; gameObject.tag = "Red"; } if (randomNumber == 1) { enemyCurrent = enemyType.Blue; gameObject.tag = "Blue"; } if (randomNumber == 2) { enemyCurrent = enemyType.Green; gameObject.tag = "Green"; } }
public GameObject popItem(enemyType _type) { if (cacheControllerDic.ContainsKey(_type)) { return(cacheControllerDic[_type].popItem()); } else { for (int i = 0; i < enemyItemList.Count; i++) { if (enemyItemList[i]._type == _type) { EnemyCache cache = new EnemyCache(enemyItemList[i]._go, enemyItemList[i]._go); cache.init(2, 10); cacheControllerDic.Add(_type, cache); return(cache.popItem()); } } Debug.LogError("找不到此类型的Go"); return(null); } }
void SpawnEnemy(enemyType e) { int nextSpawn = lastSpawn; while (nextSpawn == lastSpawn) { nextSpawn = Random.Range(0, spawnPositions.Length); } if (e == enemyType.Shotgun) { Instantiate(shotgunEnemy, spawnPositions[nextSpawn].transform.position, transform.rotation, transform); // Instantiate(shotgunEnemy, spawnPositions[nextSpawn],shotgunEnemy.transform.LookAt(spawnPositions[nextSpawn])); } else { Instantiate(basicEnemy, spawnPositions[nextSpawn].transform.position, transform.rotation, transform); } currentEnemies++; }
public void setEnemyType(enemyType newType) { eEnemyType = newType; }
public void load(TileLayer _objects_layer) { objects_layer = _objects_layer; for (int w = 0; w < objects_layer.getWidth(); ++w) { for (int h = 0; h < objects_layer.getHeight(); ++h) { Tile t = objects_layer.getTile(w, h); if (t.getTexture() == -1) { continue; } if (obj_hash[t.getTexture()] == objectType.SPAWN) { if (t.getTexture() == PLAYER_SPAWN) { game_state.local_player.setX((w * TileEngine.TILE_SIZE) + (TileEngine.TILE_SIZE / 2) - game_state.local_player.getWidth() / 2); ///2+game_state.local_player.getWidth()); game_state.local_player.setY((h * TileEngine.TILE_SIZE) + (TileEngine.TILE_SIZE / 2) - game_state.local_player.getHeight()); ///2+game_state.local_player.getHeight()); } else { int width = 0; int height = 0; enemyType type = enemyType.BEETLE; switch (t.getTexture()) { case 78: //Beetle width = 30; height = 30; type = enemyType.BEETLE; break; case 72: //grunt width = 32; height = 36; type = enemyType.GRUNT; break; case 73: //Berserker width = 32; height = 36; type = enemyType.BERSERKER; break; case 77: //Trooper width = 32; height = 36; type = enemyType.TROOPER; break; default: continue; } Enemy monster = new Enemy((w * TileEngine.TILE_SIZE) + 16 - (width / 2), (h * TileEngine.TILE_SIZE) + 16 - (height / 2), width, height, type); game_state.monster_engine.AddMonster(monster); } t.setTexture(-1); } } } }
// Update is called once per frame void Update () { time+=Time.deltaTime; switch (statetype) { case enemyType.enemy: if (time > enemytime) { factoryOK=true; time=0; } if (factoryOK) { Instantiate (enemytype[Random.Range(0,enemytype.Length)], new Vector3(Random.Range(-1.9f,1.9f),4.5f,0), Quaternion.identity); factoryOK=false; } break; case enemyType.GZenemy: if (time > enemytime) { factoryOK=true; time=0; } if (factoryOK) { Instantiate (enemytype[Random.Range(0,enemytype.Length)]); factoryOK=false; } break; case enemyType.ATenemy: if (time > 4f) { factoryOK=true; time=0; } if (factoryOK) { Instantiate (ATenemytype[Random.Range(0,ATenemytype.Length)], new Vector3(Random.Range(-1.9f,1.9f),4.5f,0), Quaternion.identity); factoryOK=false; mounthave++; Plane_Gameclass.ATenemymount++; if(mounthave==ATmount) { ATlevelmount--; if(ATlevelmount<0) { statetype=enemyType.Bossenemy; } else { statetype=enemyType.Nothing; } } } break; case enemyType.Bossenemy: if (time > 4f) { factoryOK=true; time=0; } if (Plane_Gameclass.ATenemymount==0&&ATlevelmount<0) { GameObject.FindObjectOfType<initMain_level>().audio.clip=bossvioce; GameObject.FindObjectOfType<initMain_level>().audio.Play(); chuxianboss(); statetype=enemyType.Nothing; } break; case enemyType.Nothing: if(ATlevelmount>=0&&Plane_Gameclass.ATenemymount==0) { mounthave=0; statetype=enemyType.ATenemy; } break; } }
public void Set(enemyType t, int depth) { this.type = t; switch (type) { case enemyType.Mantis: this.animator.SetTrigger("Mantis"); this.strength = 5 + ((int)(depth / 2)); this.range = 1; this.health = 8 + depth; break; case enemyType.Falcon: this.animator.SetTrigger("Falcon"); this.strength = 10 + depth; this.range = 1; this.health = 12 + (depth * 2); break; case enemyType.Snake: this.animator.SetTrigger("Snake"); this.strength = 7 + ((int)(depth / 2)); this.range = 1; this.health = 10 + depth; break; case enemyType.BlueHeron: this.animator.SetTrigger("BlueHeron"); this.strength = 10 + depth; this.range = 1; this.health = 14 + (depth * 2); break; case enemyType.Spider: this.animator.SetTrigger("Spider"); this.strength = 9 + ((int)(depth / 2)); this.range = 1; this.health = 12 + depth; break; case enemyType.Salamander: this.animator.SetTrigger("Salamander"); this.strength = 10 + depth; this.range = 1; this.health = 16 + (depth * 2); break; case enemyType.Bear: this.animator.SetTrigger("Bear"); this.strength = 20; this.range = 1; this.health = 200; break; default: this.animator.SetTrigger("Mantis"); this.strength = 1; this.range = 1; this.health = 1; break; } }
// Update is called once per frame void Update() { time += Time.deltaTime; switch (statetype) { case enemyType.enemy: if (time > enemytime) { factoryOK = true; time = 0; } if (factoryOK) { Instantiate(enemytype[Random.Range(0, enemytype.Length)], new Vector3(Random.Range(-1.9f, 1.9f), 4.5f, 0), Quaternion.identity); factoryOK = false; } break; case enemyType.GZenemy: if (time > enemytime) { factoryOK = true; time = 0; } if (factoryOK) { Instantiate(enemytype[Random.Range(0, enemytype.Length)]); factoryOK = false; } break; case enemyType.ATenemy: if (time > 4f) { factoryOK = true; time = 0; } if (factoryOK) { Instantiate(ATenemytype[Random.Range(0, ATenemytype.Length)], new Vector3(Random.Range(-1.9f, 1.9f), 4.5f, 0), Quaternion.identity); factoryOK = false; mounthave++; Plane_Gameclass.ATenemymount++; if (mounthave == ATmount) { ATlevelmount--; if (ATlevelmount < 0) { statetype = enemyType.Bossenemy; } else { statetype = enemyType.Nothing; } } } break; case enemyType.Bossenemy: if (time > 4f) { factoryOK = true; time = 0; } if (Plane_Gameclass.ATenemymount == 0 && ATlevelmount < 0) { GameObject.FindObjectOfType <initMain_level>().audio.clip = bossvioce; GameObject.FindObjectOfType <initMain_level>().audio.Play(); chuxianboss(); statetype = enemyType.Nothing; } break; case enemyType.Nothing: if (ATlevelmount >= 0 && Plane_Gameclass.ATenemymount == 0) { mounthave = 0; statetype = enemyType.ATenemy; } break; } }