public SpawnController(GameEnvironment env, IList<Squared.Tiled.ObjectGroup> objectGroupList) { Environment = env; bool spawnedPlayer = false; // Load spawn points. foreach (Squared.Tiled.ObjectGroup objGroup in objectGroupList) { foreach (List<Squared.Tiled.Object> objList in objGroup.Objects.Values) { foreach (Squared.Tiled.Object obj in objList) { if (obj.Type == "possibleBlackhole") { obj.Type = "blackhole"; Environment.PossibleBlackHoleLocations.Add(new SpawnPoint(this, obj)); continue; } else if (obj.Type == "BossPatrolPoint") { Environment.SpawnedBossPatrolPoints.Add(new Vector2(obj.X, obj.Y) + new Vector2(obj.Width, obj.Height) / 2); continue; } SpawnPoint sp = new SpawnPoint(this, obj); if (sp.Entity == null) SpawnPoints.Add(sp); if (sp.EntityType == "blackhole") Environment.SpawnedBlackHoles.Add(sp); else if (sp.EntityType == "spawn") spawnedPlayer = true; } } } if (!spawnedPlayer) throw new InvalidOperationException("Level loaded does not contain player spawn point."); }
public CircloidShip(GameEnvironment env, SpawnPoint sp) : base(env, sp) { Position = sp.Position; Initialize(sp); // FIXME: Find a better way to get positions. env.circles.Add(this); }
public SquaretopiaShip(GameEnvironment env, SpawnPoint sp) : base(env, sp) { Position = sp.Position; Initialize(sp); env.squares.Add(this); }
public BlackHole(GameEnvironment e, SpawnPoint sp) : base(e, sp) { Position = sp.Position; initialize(); Environment.blackHoles.Add(this); // Find where wormhole points. wormHole = Environment.SpawnedBlackHoles.Find(spawn => spawn.Name == SpawnPoint.Name && spawn != SpawnPoint); }
public Asteroid(GameEnvironment env, SpawnPoint sp) : base(env, sp) { Position = sp.Position; LoadTexture(Environment.contentManager, "astroid_1"); Registration = new Vector2(Texture.Width, Texture.Height) * 0.5f; Zindex = 0.4f; CreateAsteroidCollision(true); }
public static Pair CreatePair(GameEnvironment env, Vector2 pos) { SpawnPoint sp = new SpawnPoint(env.SpawnController, "blackhole", pos); sp.Properties.Add("justCreated", "true"); env.SpawnedBlackHoles.Add(sp); sp.Name = "__blackhole_" + s_uniqueId; ++s_uniqueId; // Create wormhole. Random rand = new Random(); List<SpawnPoint> locs = env.PossibleBlackHoleLocations.FindAll(x => !x.Properties.ContainsKey("active")); SpawnPoint wormHole = locs[rand.Next(0, locs.Count)]; wormHole.Properties.Add("active", "true"); wormHole.Properties.Add("justCreated", "true"); wormHole.Name = sp.Name; env.SpawnedBlackHoles.Add(wormHole); env.SpawnController.SpawnPoints.Add(wormHole); sp.Spawn(); return new Pair(env, sp, wormHole); }
private float waitTimer; //countdown timer for ships to stay inert while neutral #endregion Fields #region Constructors /// <summary> /// Creates a new AI with given spawnpoint and given environment /// Initial state is Neutral /// </summary> public AIController(SpawnPoint sp, GameEnvironment e) { timeSinceLastStateChange = 0; spawn = sp; env = e; nextState = State.Neutral; currentState = State.Neutral; target = null; answeringDistressCall = false; lookingFor = null; currentShip = null; timeSinceHitWall = 0; ; timeSinceChangedTargets = 0; waitTimer = 0; patrolPoints = new List<Vector2>(); patrolPoints.Add(randomPatrolPoint()); oldTarget = null; timeSinceMoved = 0; oldPosition = new Vector2(-1000, 1000);//I hope this is improbable timeSinceSawTarget = 0; timeSinceAnsweredDistressCall = 0; targetList = new List<GameEntity>(); }
public SquaretopiaShip(GameEnvironment env, Vector2 pos, SpawnPoint sp) : base(env, pos) { Initialize(sp); env.squares.Add(this); }
private void Initialize(SpawnPoint sp) { shooter = new BulletEmitter(Environment, this,BulletEmitter.BulletStrength.Strong); AddChild(shooter); RelativeShooterPos = new Vector2(50.0f, 0.0f); ai = m_originalAI = new AIController(sp, Environment); LoadTexture(Environment.contentManager, "squaretopia"); Registration = new Vector2(100.0f, 125.0f); CreateCollisionBody(Environment.CollisionWorld, BodyType.Dynamic, CollisionFlags.Default); AddCollisionCircle(50.0f, Vector2.Zero); CollisionBody.LinearDamping = 8.0f; this.health = this.MaxHealth = (int)(this.MaxHealth * 1.5); passiveShield = 20.0f; shield = new Entity(); shield.Zindex = 0.0f; shield.Registration = new Vector2(125.0f, 115.0f); shield.LoadTexture(Environment.contentManager, "shield"); shield.Position = Position; shield.Alpha = 0.0f; AddChild(shield); }
public EnvironmentalForceField(GameEnvironment env, SpawnPoint sp) : base(env, sp) { Position = sp.Position; initialize(); }
public SpawnPoint Other(SpawnPoint current) { if (current == First) return Second; else return First; }
internal Pair(GameEnvironment _env, SpawnPoint _first, SpawnPoint _second) { Environment = _env; First = _first; Second = _second; }
/// <summary> /// Called immediately before Entity is culled this and update the SpawnPoint before an object is culled. /// </summary> public virtual void OnCull() { // Currently does nothing. Update SpawnPoint. SpawnPoint.Reset(); SpawnPoint = null; }
public GameEntity(GameEnvironment env, SpawnPoint sp) { Environment = env; SpawnPoint = sp; }
private void Initialize(SpawnPoint sp) { shooter = new BulletEmitter(Environment, this, BulletEmitter.BulletStrength.Medium); AddChild(shooter); RelativeShooterPos = new Vector2(65.0f, -5.0f); ai = m_originalAI = new AIController(sp, Environment); LoadTexture(Environment.contentManager, "circloid"); Registration = new Vector2(117.0f, 101.0f); CreateCollisionBody(Environment.CollisionWorld, BodyType.Dynamic, CollisionFlags.Default); AddCollisionCircle(60.0f, Vector2.Zero); CollisionBody.LinearDamping = 8.0f; CollisionBody.IgnoreGravity = true; // The circloid will not be affected by its own black hole. this.maxSpeed *= 1.25f; this.health = this.MaxHealth = (int)(this.MaxHealth * 1.25); }
public Ship(GameEnvironment env, SpawnPoint sp) : base(env, sp) { Initialize(); SpawnPoint.RespawnCooldown = 0.0f; }
public CircloidShip(GameEnvironment env, Vector2 pos, SpawnPoint sp) : base(env, pos) { Initialize(sp); env.circles.Add(this); }
public Boss(GameEnvironment env, SpawnPoint sp) : base(env, sp) { initialize(); Position = sp.Position; }
public SaphereBoss(GameEnvironment env, SpawnPoint sp) : base(env, sp) { }