Exemple #1
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.");
        }
Exemple #2
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);
 }
Exemple #3
0
 public SquaretopiaShip(GameEnvironment env, SpawnPoint sp)
     : base(env, sp)
 {
     Position = sp.Position;
     Initialize(sp);
     env.squares.Add(this);
 }
Exemple #4
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);
 }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
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>();
        }
Exemple #8
0
 public SquaretopiaShip(GameEnvironment env, Vector2 pos, SpawnPoint sp)
     : base(env, pos)
 {
     Initialize(sp);
     env.squares.Add(this);
 }
Exemple #9
0
        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();
 }
Exemple #11
0
 public SpawnPoint Other(SpawnPoint current)
 {
     if (current == First) return Second;
     else return First;
 }
Exemple #12
0
 internal Pair(GameEnvironment _env, SpawnPoint _first, SpawnPoint _second)
 {
     Environment = _env;
     First = _first;
     Second = _second;
 }
Exemple #13
0
 /// <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;
 }
Exemple #14
0
 public GameEntity(GameEnvironment env, SpawnPoint sp)
 {
     Environment = env;
     SpawnPoint = sp;
 }
Exemple #15
0
        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);
        }
Exemple #16
0
 public Ship(GameEnvironment env, SpawnPoint sp)
     : base(env, sp)
 {
     Initialize();
     SpawnPoint.RespawnCooldown = 0.0f;
 }
Exemple #17
0
 public CircloidShip(GameEnvironment env, Vector2 pos, SpawnPoint sp)
     : base(env, pos)
 {
     Initialize(sp);
     env.circles.Add(this);
 }
Exemple #18
0
 public Boss(GameEnvironment env, SpawnPoint sp)
     : base(env, sp)
 {
     initialize();
     Position = sp.Position;
 }
Exemple #19
0
 public SaphereBoss(GameEnvironment env, SpawnPoint sp)
     : base(env, sp)
 {
 }