public void doStuffEnemy(EnemyShip theEnemy) { theEnemy.displayEnemyShip(); theEnemy.FollowHeroShip(); theEnemy.EnemyShipShoots(); Console.ReadKey(); }
public EnemyShip makeEnemyShip(string newShipType) { EnemyShip newShip = null; if (newShipType.Equals("U", StringComparison.Ordinal)) { return(new UFOEnemyShip()); } else { if (newShipType.Equals("R", StringComparison.Ordinal)) { return(new RocketEnemyShip()); } else { if (newShipType.Equals("B", StringComparison.Ordinal)) { return(new BigUFOEnemyShip()); } else { return(null); } } } }
public void AppendEnemy(EnemyShip e) { e.Weapon.BulletAdder = EnemyBulletAdder; e.Weapon.RecycledBulletAdder = EnemyRecycledBulletAdder; e.onDeath += () => toRemoveEnemies.Add(e); enemyShips.Add(e); }
public EnemyShip MakeEnemyShip(EnemyShipEnum shipType) { EnemyShip shipChosen = null; switch (shipType) { case EnemyShipEnum.UFOEnemyShip: shipChosen = new UFOEnemyShip(); break; case EnemyShipEnum.RocketEnemyShip: shipChosen = new RocketEnemyShip(); break; case EnemyShipEnum.BigUFOEnemyShip: shipChosen = new BigUFOEnemyShip(); break; default: shipChosen = null; break; } return(shipChosen); }
public BumbleBeesLogic(Dictionary <Sprites, Texture2D> sprites) { pixel = sprites[Sprites.Pixel]; pnts = new List <Point>(); CreateCurve(); ship = new EnemyShip(sprites[Sprites.Pixel], pnts, new Vector2(800, 0)); }
private IEnumerator BossBehavior(EnemyShip enemy) { // this behavior will first move downwards to the center of the screen // and then it will follow the player enemy.Move(0, 2); // we intentionally ignore the MaxSpeed by applying a factor of 2 while (!enemy.IsDestroyed && enemy.Position.Y < -100) { yield return(null); } enemy.Move(0, 0); while (!enemy.IsDestroyed) { while (enemy.Position.X < player.Position.X && !PlayerReached(enemy)) { enemy.Move(1, 0); yield return(null); } while (enemy.Position.X > player.Position.X && !PlayerReached(enemy)) { enemy.Move(-1, 0); yield return(null); } enemy.Move(0, 0); yield return(null); } }
void SpawnEnemy() { EnemyShip newEnemy = (EnemyShip)Instantiate(enemyList[0]); newEnemy.BulletManager = BulletManager; newEnemy.path = iTweenPath.paths["SmallFighter1"]; }
/// <summary>Processes the specified entity.</summary> /// <param name="entity">The entity.</param> public override void Process(Entity entity, SpatialFormComponent spatialFormComponent, TransformComponent transformComponent) { if (spatialFormComponent != null) { this.spatialName = spatialFormComponent.SpatialFormFile; if (transformComponent.X >= 0 && transformComponent.Y >= 0 && transformComponent.X < this.spriteBatch.GraphicsDevice.Viewport.Width && transformComponent.Y < this.spriteBatch.GraphicsDevice.Viewport.Height) { ///very naive render ... if (string.Compare("PlayerShip", this.spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { PlayerShip.Render(this.spriteBatch, this.contentManager, transformComponent); } else if (string.Compare("Missile", this.spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { Missile.Render(this.spriteBatch, this.contentManager, transformComponent); } else if (string.Compare("EnemyShip", this.spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { EnemyShip.Render(this.spriteBatch, this.contentManager, transformComponent); } else if (string.Compare("BulletExplosion", this.spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { Explosion.Render(this.spriteBatch, this.contentManager, transformComponent, Color.Red, 10); } else if (string.Compare("ShipExplosion", this.spatialName, StringComparison.InvariantCultureIgnoreCase) == 0) { ShipExplosion.Render(this.spriteBatch, this.contentManager, transformComponent, Color.Yellow, 30); } } } }
public new void Start() { _ship = new Ship(GameRef.Game.Content.Load<Texture2D>("ship"), GameRef.Game.Content.Load<Texture2D>("bullet"), this); AddEntity(_ship); _enemyship = new EnemyShip(GameRef.Game.Content.Load<Texture2D>("enemyship"), GameRef.Game.Content.Load<Texture2D>("bullet"), this); AddEntity(_enemyship); _ship.Collision.AddPartner(_enemyship); _enemyship.Collision.AddPartner(_ship); for (var i = 0; i < 10; i++) { var a = new Asteroid(GameRef.Game.Content.Load<Texture2D>("asteroid"), this); while (a.Collision.TestCollision(_ship)) { a = new Asteroid(GameRef.Game.Content.Load<Texture2D>("asteroid"), this); } _ship.Collision.AddPartner(a); a.Collision.AddPartner(_ship); AddEntity(a); } _font = GameRef.Game.Content.Load<SpriteFont>("font"); }
static void DrawInterestingAreas(EnemyShip enemyShip, GizmoType gizmoType) { Gizmos.color = Color.red; enemyShip.activeArea.DrawGizmo(); Gizmos.color = Color.magenta; enemyShip.shootingArea.DrawGizmo(); }
public override void RemoveObject(KeyValuePair <string, ShipAddOn> shipAddOnPair) { base.RemoveObject(shipAddOnPair); ShipAddOn addOn = shipAddOnPair.Value; if (addOn.ShipAddOnData.AddOnType == "ShipEngine") { ParentShip.EngineHardPoints.Add(addOn.HardPointOffset); } else { ParentShip.OtherHardPoints.Add(addOn.HardPointOffset); } PlayerShip playerShip = ParentShip as PlayerShip; EnemyShip enemyShip = ParentShip as EnemyShip; if (playerShip != null) { if (addOn.ShipAddOnData.AddOnType == "ShipEngine") { playerShip.HardPointUI.Enable(addOn.HardPointOffset, HardPointType.Engine); } else { playerShip.HardPointUI.Enable(addOn.HardPointOffset, HardPointType.Other); } } else { Session.Money += (int)(addOn.ShipAddOnData.Price * 0.1f); } }
void GenerateUFO() { float chance = Random.Range(0.0f, 1.0f) * 100; if (chance <= ufo_chance_) { Vector3 position; Vector3 direction; int corner = GenerateCornerPositionAndDirection(out position, out direction, false, 0); //Checks if the UFO is gonna be spawned too close to the player if (!IsSafeDistance(position)) { int new_corner = (corner % 4) + 2; GenerateCornerPositionAndDirection(out position, out direction, true, new_corner); } EnemyShip ufo = (EnemyShip)GameObject.Instantiate(ufo_prefab_, position, Quaternion.identity); if ((num_generated_ufos_ + 1) % 4 == 0) { ufo.GetComponent <EnemyShip>().SetSmall(); } ufo.GetComponent <EnemyShip>().projectile_speed_ = ufo_projectile_speed_; ufo.GetComponent <EnemyShip>().shooting_delay_ = ufo_shooting_delay_; float ufo_speed = Random.Range(min_ufo_speed_, max_ufo_speed_); ufo.GetComponent <Rigidbody2D>().velocity = direction * (ufo_speed * 50) * Time.deltaTime; num_generated_ufos_++; } }
public EnemyShip GenerateRandomEnemy(int x, int y, int seed) { Random.seed = (int)Time.realtimeSinceStartup + seed; float totalChance = 0; foreach (float f in enemiesChance) { totalChance += f; } float ran = Random.Range(0f, totalChance * spawnChance); float accu = 0; EnemyShip clone = null; transform.position = new Vector2(x, y); for (int i = 0; i < enemies.Length; i++) { accu += enemiesChance[i]; if (accu > ran) { clone = Instantiate(enemies[i], transform.position, enemies[i].transform.rotation) as EnemyShip; clone.DespawnIn(15); break; } } return(clone); }
public void spawnAnEnemy(int minLevel, int maxLevel, int quantity) { bool found = false; EnemyShip enemy = null; // float bound = Vars.planetType.getDistanceToStar(); for (int i = 0; i < quantity; i++) { found = false; enemy = null; foreach (EnemyShip ship in Vars.enemyShipsPool) { if (ship.destroed) { enemy = ship; found = true; break; } } if (!found) { enemy = Instantiate <Transform>(enemyShipPrefab).GetComponent <EnemyShip>(); Vars.enemyShipsPool.Add(enemy); } enemy.initRandomShip(Random.Range(minLevel, maxLevel + 1), playerShip.transform); enemy.transform.position = playerShip.transform.position + new Vector3(3, 3, 0); //new Vector3(Random.Range(-bound, bound), Random.Range(-bound, bound)); minimap.addEnemy(enemy.transform); } }
void OnTriggerEnter2D(Collider2D hitInfo) { // Debug.Log(hitInfo.name); //da se ne sudara sa colliderom od igraca if (hitInfo.gameObject.name == "Player") { return; } //projektil naseg shipa se ne unistava prilikom sudara sa neprijateljskim projektilom if (hitInfo.gameObject.name == "Plazm(Clone)") { return; } Enemy enemy = hitInfo.GetComponent <Enemy>(); EnemyShip enemyShip = hitInfo.GetComponent <EnemyShip>(); EnemyBoss boss = hitInfo.GetComponent <EnemyBoss>(); if (boss != null) { boss.TakeDamage(damage); } if (enemyShip != null) { enemyShip.TakeDamage(damage); } if (enemy != null) { enemy.TakeDamage(damage); } Destroy(gameObject); }
public override void Run () { Vector2 spawnpos = (Vector2)PlayerShip.instance.transform.position + (Vector2)Random.insideUnitCircle * 300f; clone = Instantiate(enemy, spawnpos, Quaternion.identity) as EnemyShip; clone.target = PlayerShip.instance; Message m = new Message ("Ship detected! Closing in fast!\n Their signature reads.. Oh no.. \nSPACEPIRATES! Save me mommy!", "Captn S"); Messenger.instance.AddMessage (m); }
public EnemyShipSprite(EnemyShip data) { _sprite = new SFML.Graphics.Sprite(); _enemyShipData = data; _sprite.Texture = new SFML.Graphics.Texture(data._shipSprite, new SFML.Graphics.IntRect(10, 10, 32, 32)); _sprite.Position = new SFML.Window.Vector2f(100, 0); }
void Start() { _gameController = FindObjectOfType(typeof(GameController)) as GameController; _interactions = FindObjectsOfType(typeof(Interaction)) as Interaction[]; _enemyShip = FindObjectOfType(typeof(EnemyShip)) as EnemyShip; _myPos = Camera.mainCamera.WorldToScreenPoint(transform.position); }
void EnemyHit(EnemyShip enemyShip) { int id = levelManager.enemyShips.IndexOf(enemyShip); Slider healthSlider = enemyHealthSliders[id]; healthSlider.value = (1f / enemyShip.health) * enemyShip.currentHealth; }
public AsteroidsGame(IGameWindow parent, IGameController gameController) : base(parent) { _gameScoreKeeper = new GameScoreKeeper(parent); _gameController = gameController; _ship = new PlayerShip(parent); _enemyShip = new EnemyShip(parent); StartNewRound(); }
private void Remove(EnemyShip enemyShip) { enemyShips.Remove(enemyShip); if (enemyShips.Count == 0) { DI.Resolve <GameplayState>().Win(); } }
private EnemyShip SpawnBoss() { var ship = new EnemyShip(BossId, 7, bossMissile, new Vector2(-25, 35), new Vector2(25, 35)); runner.Run(BossBehavior(ship)); runner.Run(ConstantFire(ship)); EventBroker.Dispatch(new SpawnEvent(ship, new Vector2(0, -Consts.ScreenHeight / 2 - 100))); return(ship); }
public EnemyShipShooterService(EnemyShip enemyShip) { _enemyShip = enemyShip; for (int i = 0; i < 20; i++) { _photons[i] = new Photon(); } }
public void ReturnEnemyShip(EnemyShip enemyShip) { if (!enemyShipsPoolsDisctionary.ContainsKey(enemyShip.GetEnemyPoolTag)) { return; } enemyShipsPoolsDisctionary[enemyShip.GetEnemyPoolTag].AddObjectInPool(enemyShip); }
//Gera uma fileira de naves a partir de determinado prefab. public void EnemyGenerator() { for (int i = 0; i < 8; i++) { EnemyShip enemy = EnemyShip.Instantiate(this.enemyShip, this.transform.position, Quaternion.identity); enemy.transform.parent = transform; shipsList.Add(enemy); } }
IEnumerator NewShip() { yield return(new WaitForSeconds(delayBeforeNewShip)); ship = Instantiate(shipPrefab, transform.position, transform.rotation); yield return(new WaitForSeconds(delayBeforeNewShip)); hasShip = true; }
public static string doStuffEnemy(EnemyShip anEnemyShip) { string ret = ""; ret += anEnemyShip.followHeroShip(); ret += anEnemyShip.displayEnemyShip(); ret += anEnemyShip.enemyShipShoots(); return(ret); }
public EnemyShipShooterService(EnemyShip enemyShip, IGameWindow parent) { _enemyShip = enemyShip; for (int i = 0; i < 20; i++) { _photons[i] = new Photon(parent); } }
private GameObject EnemySpawn(int num) { enemy = _enemyShipsInfo[0]; GameObject _enemy = _enemyShips[num - 1]; _enemy.GetComponent <ShipInfo>().Health = enemy.Health; _enemy.GetComponent <Transform>().position = transform.position; return(enemyGO); }
void Spawn(int i, float y) { if (i < wave.Length) { enemy = Instantiate(wave [i], this.transform); enemy.startPosition = new Vector3(0.0f, y, 110.0f + Random.Range(0.0f, 30.0f)); enemy.transform.position = new Vector3(enemy.transform.position.x, enemy.startPosition.y, -60.0f); } }
private void SpawnStrongEnemy() { var x = Assets.Random.Next(-Consts.ScreenWidth / 2, Consts.ScreenWidth / 2); var y = -Consts.ScreenHeight / 2 - 100; var ship = new EnemyShip(3, 3, fastMissile, new Vector2(0, 20)); runner.Run(SimpleEnemy(ship)); runner.Run(ConstantFire(ship)); EventBroker.Dispatch(new SpawnEvent(ship, new Vector2(x, y))); }
private void ResetFalldown(EnemyShip ship) { var position = NewRandomTeleportPosition(ship); ship.Teleport(position.X, position.Y); int xSpeed = VALUES.random.Next(-withSpeed, withSpeed); moveCount = VALUES.HEIGHT / withSpeed; ship.Speed = new Vector(xSpeed, withSpeed); }
// Use this for initialization void Start() { ship = GetComponent<EnemyShip>(); col = GetComponent<CircleCollider2D>(); if (col) { colRadius = col.radius; } if (ship == null) { body = GetComponentInParent<Rigidbody2D>(); ship = GetComponentInParent<EnemyShip>(); } startPos = transform.position; }
/*** Internals ***/ // Check if we should spawn any enemy groups yet private void UpdateEnemySpawn() { // Ignore if no spawning groups if(EnemyGroups.Count <= 0) return; // Peek at front of list: do we spawn these guys yet? if(TotalTime > EnemyGroups.Peek().SpawnTime) { // Spawn the ships info LevelManager_SpawnGroup Group = EnemyGroups.Dequeue(); // Declare message OverlayView.PushMessage(Color.yellow, TextEvents.GetIncomingMessage()); // Get spawn pos for(int i = 0; i < Group.Class0Count; i++) { // Randomize offset Vector2 Offset = new Vector2(UnityEngine.Random.Range(-100, 100), UnityEngine.Random.Range(-100, 100)); EnemyShip Enemy = new EnemyShip(0); Enemy.SetPos(Group.SpawnPos + Offset); ShipManager.ShipsList.Add(Enemy); } for(int i = 0; i < Group.Class1Count; i++) { // Randomize offset Vector2 Offset = new Vector2(UnityEngine.Random.Range(-100, 100), UnityEngine.Random.Range(-100, 100)); EnemyShip Enemy = new EnemyShip(1); Enemy.SetPos(Group.SpawnPos + Offset); ShipManager.ShipsList.Add(Enemy); } for(int i = 0; i < Group.Class2Count; i++) { // Randomize offset Vector2 Offset = new Vector2(UnityEngine.Random.Range(-100, 100), UnityEngine.Random.Range(-100, 100)); EnemyShip Enemy = new EnemyShip(2); Enemy.SetPos(Group.SpawnPos + Offset); ShipManager.ShipsList.Add(Enemy); } // Declare what's comming OverlayView.PushMessage(Color.yellow, String.Format("{0} Fighters, {1} Destroyers, {2} Carriers", Group.Class0Count, Group.Class1Count, Group.Class2Count)); // Change music to combat SongManager.TransitionAudio(true); } }
public void AddEnemyShip(EnemyShip enemy_ship) { enemy_ships_.Add(enemy_ship); }
public virtual void Start() { ship = GetComponent<EnemyShip> (); }
// Use this for initialization void Start() { patrolPoints = new Vector3[2]; ship = GetComponent<EnemyShip>(); if (ship == null) { body = GetComponentInParent<Rigidbody2D>(); ship = GetComponentInParent<EnemyShip>(); } startPos = transform.position; }
public EnemyDeathEvent(EnemyShip s) { ship = s; }
void RenderShip(EnemyShip enemy_ship) { line_material_.SetPass(0); GL.PushMatrix(); Matrix4x4 trs_matrix = Matrix4x4.TRS(enemy_ship.gameObject.transform.position, enemy_ship.gameObject.transform.rotation, enemy_ship.gameObject.transform.localScale); GL.MultMatrix(trs_matrix); //DrawBoundingBox(); DrawLines(); //DrawSquares(0.1f); GL.PopMatrix(); }