/// <summary> /// Creates a new AI with given start and finish positions of patrol path and given environment /// </summary> public AIController(Vector2 s, Vector2 f, GameEnvironment e) { start = s; finish = f; env = e; goingStart = true; }
public SquaretopiaShip(GameEnvironment env, SpawnPoint sp) : base(env, sp) { Position = sp.Position; Initialize(sp); env.squares.Add(this); }
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 Camera2D(GameEnvironment env) { Environment = env; MoveSpeed = 1.5f; // Set default window size. WindowSizeChanged(); }
public BossAI(GameEnvironment env, Boss boss, Vector2[] points) { this.index = 1; this.points = points; this.env = env; this.boss = boss; boss.Position = points[0]; }
// Create force field dynamically. public ForceField(GameEnvironment env, Vector2 pos, float angle, GameEntity o) : base(env) { Position = pos; m_angle = angle; Initialize(); owner = o; }
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 Ship(AIController ai, GameEnvironment env) : base() { this.ai = ai; this.maxSpeed = 50.0f; this.maxTurn = 0.025f; shooter = new BulletEmitter(env, BulletEmitter.BulletStrength.Medium, IsFriendly()); env.AddChild(shooter); }
public TestShip(float x, float y, float vx, float vy,GameEnvironment env) { LoadTexture(env.contentManager, "Sputnik"); Registration = new Vector2(Texture.Width, Texture.Height) * 0.5f; CreateCollisionBody(env.CollisionWorld, BodyType.Dynamic, CollisionFlags.DisableSleep); AddCollisionCircle(Texture.Width * 0.5f, Vector2.Zero); Position = new Vector2(x, y); SetPhysicsVelocityOnce(new Vector2(vx, vy)); controller = new PlayerController(env); }
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 Bullet(GameEnvironment env, Vector2 position, double angle, bool playerShotBullet) { LoadTexture(env.contentManager, "bullet"); ShotByPlayer = playerShotBullet; Zindex = 0.0f; CreateCollisionBody(env.CollisionWorld, FarseerPhysics.Dynamics.BodyType.Dynamic, CollisionFlags.IsBullet | CollisionFlags.DisableSleep | CollisionFlags.FixedRotation); //AddCollisionRectangle(new Vector2(13.0f, 4.5f), new Vector2(18.0f, 9.5f)); AddCollisionCircle(4.5f, Vector2.Zero); VisualRotationOnly = true; Registration = new Vector2(18.0f, 9.5f); CollisionBody.LinearDamping = 0.0f; Position = position; Rotation = (float) angle; SetPhysicsVelocityOnce(new Vector2(k_speed * (float) Math.Cos(angle), k_speed * (float) Math.Sin(angle))); }
public Bullet(GameEnvironment env, TakesDamage s,Vector2 position, double angle) : base(env) { owner = s; LoadTexture(env.contentManager, "bullet"); Registration = new Vector2(Texture.Width, Texture.Height) * 0.5f; Zindex = 0.0f; CreateCollisionBody(env.CollisionWorld, FarseerPhysics.Dynamics.BodyType.Dynamic, CollisionFlags.IsBullet | CollisionFlags.DisableSleep | CollisionFlags.FixedRotation); AddCollisionCircle(Texture.Height/2, Vector2.Zero); VisualRotationOnly = true; CollisionBody.LinearDamping = 0.0f; Position = position; Rotation = (float) angle; SetPhysicsVelocityOnce(new Vector2(k_speed * (float) Math.Cos(angle), k_speed * (float) Math.Sin(angle))); AllowTeleport = 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 static List<Entity> FindAll(GameEnvironment env, Vector2 position, float theta, float spread, float maxDistance) { // Find all entities that are within the possible AABB. FarseerPhysics.Collision.AABB aabb = VisionAABB(position, theta, spread, maxDistance); List<Entity> all = QueryAABB(env.CollisionWorld, aabb); float maxDistSq = maxDistance * maxDistance; // Narrow it down to entities that are directly visible. all.RemoveAll(match => { // Limit angle. float a = Angle.DistanceMag(Angle.Direction(position, match.Position), theta); if (a > spread) return true; // Verify that nothing is in the way and that the distance fits the threshold. float distanceSq; Entity closest = ClosestEntity(env.CollisionWorld, position, match.Position, out distanceSq); if (closest != match || distanceSq > maxDistSq) return true; return false; }); return all; }
public SaphereBoss(GameEnvironment env, SpawnPoint sp) : base(env, sp) { }
public GameEntity(GameEnvironment env) { Environment = env; }
public Boss(GameEnvironment env, SpawnPoint sp) : base(env, sp) { initialize(); Position = sp.Position; }
public Boss(GameEnvironment env) : base(env) { initialize(); }
public Ship(GameEnvironment env, SpawnPoint sp) : base(env, sp) { Initialize(); SpawnPoint.RespawnCooldown = 0.0f; }
public Ship(GameEnvironment env, Vector2 pos) : base(env) { Position = pos; Initialize(); }
public GameEntity(GameEnvironment env, SpawnPoint sp) { Environment = env; SpawnPoint = sp; }
public SquaretopiaShip(GameEnvironment env, Vector2 pos, SpawnPoint sp) : base(env, pos) { Initialize(sp); env.squares.Add(this); }
private float weakBulletInterval = 1.0f / 8.0f; // our threshold for when our bullet should be shot #endregion Fields #region Constructors // type public BulletEmitter(GameEnvironment e, BulletStrength type, bool playerShotBullet) { env = e; strength = type; ShotByPlayer = playerShotBullet; }
internal Pair(GameEnvironment _env, SpawnPoint _first, SpawnPoint _second) { Environment = _env; First = _first; Second = _second; }
public void TestShip(float x, float y,float vx, float vy, float sx, float sy, float fx, float fy, GameEnvironment env) { LoadTexture(env.contentManager, "circloid"); Registration = new Vector2(Texture.Width, Texture.Height) * 0.5f; CreateCollisionBody(env.CollisionWorld, BodyType.Dynamic, CollisionFlags.DisableSleep); AddCollisionCircle(Texture.Width * 0.5f, Vector2.Zero); Position = new Vector2(x, y); SetPhysicsVelocityOnce(new Vector2(vx, vy)); ai = new AIController(new Vector2(sx, sy), new Vector2(fx, fy), env); }
public CircloidShip(GameEnvironment env, Vector2 pos, SpawnPoint sp) : base(env, pos) { Initialize(sp); env.circles.Add(this); }
/// <summary> /// Creates a new Player /// </summary> public PlayerController(GameEnvironment env) { m_env = env; }
public EnvironmentalForceField(GameEnvironment env, SpawnPoint sp) : base(env, sp) { Position = sp.Position; initialize(); }