protected SinglePointTileContainmantManager(GameState game, IPositionable subject)
        {
            this.game = game;
            this.subject = subject;

            this.Update();
        }
Exemple #2
0
        public HitResult? Shoot(GameState game, bool hitBuildings = true, bool hitProjectileColliders = false)
        {
            HitResult? result = null;

            var bestF = 1f;

            foreach (var tile in game.Level.CastRay(this))
            {
                if (!tile.IsValid)
                    continue;

                var info = tile.Value;

                if (hitBuildings)
                {
                    foreach (var building in info.Buildings)
                    {
                        var r = building.TryHit(this);
                        selectBetterResult(ref result, ref bestF, r);
                    }
                }

                if (hitProjectileColliders)
                {
                    foreach (var collider in info.ProjectileColliders)
                    {
                        var r = collider.TryHit(this);
                        selectBetterResult(ref result, ref bestF, r);
                    }
                }
            }

            return result;
        }
        public ProjectileColliderTileManager(GameState game, IProjectileCollider collider)
        {
            this.game = game;
            this.collider = collider;

            this.Update();
        }
Exemple #4
0
 public CollidingParticle(GameState game,
     Position2 position, Velocity2 velocity,
     Unit z, Speed vz,
     bool collideWithProjectileColliders)
     : base(game)
 {
     this.data = new Data(position, velocity, z, vz, collideWithProjectileColliders);
 }
Exemple #5
0
        protected override void OnLoad(EventArgs e)
        {
            this.renderer = new GameRenderer();

            this.game = new GameState();

            InputManager.Initialize(this.Mouse);
        }
Exemple #6
0
        public Building(GameState game, Position2 topLeft, Difference2 size)
            : base(game)
        {
            this.TopLeft = topLeft;
            this.Size = size;

            this.listAs<Building>();
        }
Exemple #7
0
        public MergedIntersection(GameState game, params Intersection[] intersections)
            : base(game)
        {
            this.intersections = intersections.ToList();
            this.Intersections = this.intersections.AsReadOnly();

            this.listAs<MergedIntersection>();
        }
Exemple #8
0
        public void Draw(GameState game)
        {
            this.surfaces.ModelviewMatrix.Matrix = Matrix4.LookAt(
                new Vector3(0, 0, 50), new Vector3(0, 0, 0), new Vector3(0, 1, 0)
                );

            game.Render();
        }
Exemple #9
0
        public HitResult? Shoot(GameState game, bool hitBuildings, bool hitProjectileColliders, bool debugDraw)
        {
            var result = this.Shoot(game, hitBuildings, hitProjectileColliders);

            if (debugDraw)
                this.drawDebug(result);

            return result;
        }
Exemple #10
0
        public Civilian(GameState game)
            : base(game)
        {
            this.sprite = (Sprite2DGeometry)GeometryManager.Instance.GetSprite("bloob").Geometry;

            this.controller = new CivilianController(game, this);
            this.eventListenerTileManager = new GameEventListenerTileManager(game, this);

            this.initialised = true;
        }
Exemple #11
0
        public Street(GameState game, Intersection node1, Intersection node2, Unit width)
            : base(game)
        {
            this.Node1 = node1;
            this.Node2 = node2;
            this.Width = width;

            node1.AddStreet(this);
            node2.AddStreet(this);

            this.listAs<Street>();
        }
Exemple #12
0
        public Centipede(GameState game, int length = 15)
            : base(game)
        {
            this.head = new CentiHead(game);

            this.tailPath.AddFirst(new CentiPathPart(this.head.Position, 0.U()));

            for (int i = 0; i < length; i++)
            {
                this.parts.Add(new Centipart(game));
            }
        }
Exemple #13
0
        public Level(GameState game, float width, float height)
        {
            var w = width + levelPadding * 2;
            var h = height + levelPadding * 2;

            var tilesX = Mathf.CeilToInt(w / gridSize);
            var tilesY = Mathf.CeilToInt(h / gridSize);

            this.tilemap = new Tilemap<TileInfo>(tilesX, tilesY);

            this.offsetX = -tilesX * gridSizeHalf;
            this.offsetY = -tilesY * gridSizeHalf;

            this.fillTiles();

            this.fillBuildingsIntoTiles(game);
        }
 public GameEventListenerTileManager(GameState game, IGameEventListener listener)
     : base(game, listener)
 {
     this.node.Value = listener;
 }
Exemple #15
0
            public HitResult? Update(GameState game, TimeSpan time)
            {
                var vDelta = this.velocity * time;

                var hitResult = new Ray(this.position, vDelta)
                    .Shoot(game, true, this.collideWithProjectileColliders);

                var f = hitResult.HasValue ? hitResult.Value.RayFactor : 1;

                var zDelta = this.vz * time;

                var z = this.z + zDelta;
                if (z < 0.U())
                {
                    f = this.z / zDelta;
                    z = 0.U();
                    hitResult = new HitResult(this.position + vDelta * f, Direction2.Zero, f, false);
                }

                this.position += vDelta * f;
                this.z = z;

                this.vz += game.Gravity * time;

                return hitResult;
            }
Exemple #16
0
 private void fillBuildingsIntoTiles(GameState game)
 {
     foreach (var building in game.GetList<Building>())
     {
         foreach (var tile in this.TilesIntersecting(building.TopLeft, building.Size))
         {
             tile.Value.AddBuilding(building);
         }
     }
 }
Exemple #17
0
 public Data UpdateTo(GameState game, TimeSpan time, out HitResult? hitResult)
 {
     hitResult = this.Update(game, time);
     return this;
 }