Esempio n. 1
0
 /// <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;
 }
Esempio n. 2
0
 public SquaretopiaShip(GameEnvironment env, SpawnPoint sp)
     : base(env, sp)
 {
     Position = sp.Position;
     Initialize(sp);
     env.squares.Add(this);
 }
Esempio n. 3
0
        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.");
        }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
        public Camera2D(GameEnvironment env)
        {
            Environment = env;
            MoveSpeed = 1.5f;

            // Set default window size.
            WindowSizeChanged();
        }
Esempio n. 6
0
 public BossAI(GameEnvironment env, Boss boss, Vector2[] points)
 {
     this.index = 1;
     this.points = points;
     this.env = env;
     this.boss = boss;
     boss.Position = points[0];
 }
Esempio n. 7
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;
 }
Esempio n. 8
0
 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);
 }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
 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);
 }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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)));
        }
Esempio n. 13
0
        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;
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        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>();
        }
Esempio n. 16
0
        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;
        }
Esempio n. 17
0
 public SaphereBoss(GameEnvironment env, SpawnPoint sp)
     : base(env, sp)
 {
 }
Esempio n. 18
0
 public GameEntity(GameEnvironment env)
 {
     Environment = env;
 }
Esempio n. 19
0
 public Boss(GameEnvironment env, SpawnPoint sp)
     : base(env, sp)
 {
     initialize();
     Position = sp.Position;
 }
Esempio n. 20
0
 public Boss(GameEnvironment env)
     : base(env)
 {
     initialize();
 }
Esempio n. 21
0
 public Ship(GameEnvironment env, SpawnPoint sp)
     : base(env, sp)
 {
     Initialize();
     SpawnPoint.RespawnCooldown = 0.0f;
 }
Esempio n. 22
0
 public Ship(GameEnvironment env, Vector2 pos)
     : base(env)
 {
     Position = pos;
     Initialize();
 }
Esempio n. 23
0
 public GameEntity(GameEnvironment env, SpawnPoint sp)
 {
     Environment = env;
     SpawnPoint = sp;
 }
Esempio n. 24
0
 public SquaretopiaShip(GameEnvironment env, Vector2 pos, SpawnPoint sp)
     : base(env, pos)
 {
     Initialize(sp);
     env.squares.Add(this);
 }
Esempio n. 25
0
        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;
        }
Esempio n. 26
0
 internal Pair(GameEnvironment _env, SpawnPoint _first, SpawnPoint _second)
 {
     Environment = _env;
     First = _first;
     Second = _second;
 }
Esempio n. 27
0
 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);
 }
Esempio n. 28
0
 public CircloidShip(GameEnvironment env, Vector2 pos, SpawnPoint sp)
     : base(env, pos)
 {
     Initialize(sp);
     env.circles.Add(this);
 }
Esempio n. 29
0
 /// <summary>
 ///  Creates a new Player
 /// </summary>
 public PlayerController(GameEnvironment env)
 {
     m_env = env;
 }
Esempio n. 30
0
 public EnvironmentalForceField(GameEnvironment env, SpawnPoint sp)
     : base(env, sp)
 {
     Position = sp.Position;
     initialize();
 }