Пример #1
0
        public Key(Rectangle pos, Map map)
            : base(map)
        {
            Body BodyDec = new Body(map.PhysicalWorld);

            BodyDec.BodyType = BodyType.Static;

            PolygonShape S = new PolygonShape(1f);

            S.SetAsBox(pos.Width / 2, pos.Height / 2);

            Fixture             = BodyDec.CreateFixture(S);
            Fixture.Restitution = 1f;
            Fixture.Friction    = 10f;

            this.Position = pos;

            SetName("Key");

            LightingEngine LE = (LightingEngine)Renderer.GetRenderEffect("LightingEngine");

            light = new PointLight()
            {
                IsEnabled  = true,
                Color      = new Vector4(0.95f, .7f, .05f, 1f),
                Power      = power,
                LightDecay = 350,
                Position   = new Vector3(Position.X, Position.Y, 20),
                Direction  = new Vector3(0, 0, 0)
            };

            LE.AddLight(light);
        }
Пример #2
0
        public WorldScreen(Game Game)
            : base(Game, GeneralManager.ScreenX, GeneralManager.ScreenY)
        {
            GeneralManager.LoadAnimation("TestAnim", Vector2.One * 64, 6, 80);
            GeneralManager.LoadAnimation("PlayerIdle", Vector2.One * 64, 1, 10000);

            DebugWindow.Visible = false;
            DebugWindow.AddGUI(FarseerDebugCheck, DebugWindow);
            AddGUI(DebugWindow);

            LE = new LightingEngine();
            Color a = new Color(ambient, ambient, ambient);

            LE.SetAmbient(a, a);
            //LE.SetAmbient(Color.Gray, Color.Gray);
            Renderer.AddRendererEffect(LE, "LightingEngine");

            LoadContent();

            Map = new Map(this, tileSize, mapSize);
            //Renderer.AddPostProcess(new BlurEffect(), "Blur");
            SE               = new BlurSwitchEffect();
            SE.MaxTime       = 1f;
            SE.TurnOffAction = delegate() { Renderer.RemovePostProcess("Switch"); };
            Renderer.AddPostProcess(SE, "Switch");

            Camera.Init(GeneralManager.GetPartialRect(0, 0, 1, 1), new Rectangle(0, 0, tileSize * mapSize, tileSize * mapSize));

            PlayerLight = new SpotLight()
            {
                IsEnabled         = true,
                Color             = new Vector4(0.9f, .7f, .7f, 1f),
                Power             = .6f,
                LightDecay        = 600,
                Position          = new Vector3(500, 400, 20),
                SpotAngle         = 1.5f,
                SpotDecayExponent = 3,
                Direction         = new Vector3(0.244402379f, 0.969673932f, 0)
            };
            LE.AddLight(PlayerLight);

            Debug = new FarseerPhysics.DebugViews.DebugViewXNA(Map.PhysicalWorld);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.AABB);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.PerformanceGraph);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Joint);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints);
            Debug.DefaultShapeColor  = Color.White;
            Debug.SleepingShapeColor = Color.LightGray;
            Debug.LoadContent(Parent.GraphicsDevice, Parent.Content);

            //Weapon w = new Weapon("test", "Gun", 100, 10, Hands.One, 10, 600, 10, 10, 10);
            //Serializer.Serialize<Weapon>("weapon.xml", w);
        }
Пример #3
0
        public RedAlarmLamp(Rectangle r, Map m)
            : base(m)
        {
            Body BodyDec = new Body(m.PhysicalWorld);

            BodyDec.BodyType = BodyType.Static;

            PolygonShape S = new PolygonShape(1f);

            S.SetAsBox(r.Width / 2, r.Height / 2);

            Fixture             = BodyDec.CreateFixture(S);
            Fixture.Restitution = 1f;
            Fixture.Friction    = 10f;

            Position = r;

            SetName("RedAlarmLamp");


            AlertLight = new SpotLight()
            {
                IsEnabled         = true,
                Color             = new Vector4(0.9f, .1f, .1f, 1f),
                Power             = .6f,
                LightDecay        = 600,
                Position          = new Vector3(r.X, r.Y, 20),
                SpotAngle         = 1.5f,
                SpotDecayExponent = 3,
                Direction         = new Vector3(0.244402379f, 0.969673932f, 0)
            };

            LightingEngine LE = (LightingEngine)Renderer.GetRenderEffect("LightingEngine");

            LE.AddLight(AlertLight);
        }
Пример #4
0
        public override void Generate(Chunk Chunk)
        {
            this.Chunk = Chunk;
            xmax       = (int)Chunk.Size.X;
            ymax       = (int)Chunk.Size.Y;

            LightList   = new List <Vector2>();
            AlarmLights = new List <KeyValuePair <Vector2, Direction> >();

            CreateDungeon((int)Chunk.Size.X, (int)Chunk.Size.Y, 100);
            ConvertDungeon(Chunk);

            LightingEngine LE = (LightingEngine)Renderer.GetRenderEffect("LightingEngine");

            foreach (Vector2 V in LightList)
            {
                PointLight L = new PointLight()
                {
                    IsEnabled  = true,
                    Color      = new Vector4(0.9f, .2f, .2f, 1f),
                    Power      = .85f,
                    LightDecay = 300,
                    Position   = new Vector3(V.X * Chunk.tileSize, V.Y * Chunk.tileSize, 1),
                };

                LE.AddLight(L);
            }

            foreach (KeyValuePair <Vector2, Direction> Alarm in AlarmLights)
            {
                switch (Alarm.Value)
                {
                case Direction.North:
                    for (int i = -2; i <= 2; i++)
                    {
                        if (!(GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y) == Tile.DirtFloor || GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y) == Tile.Corridor) ||
                            (GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y - 1) == Tile.DirtFloor || GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y - 1) == Tile.Corridor))
                        {
                            break;
                        }
                    }

                    new RedAlarmLamp(new Rectangle((int)Alarm.Key.X * 64 + 32, (int)Alarm.Key.Y * 64 + 4, 16, 8), Chunk.map);

                    break;

                case Direction.South:

                    for (int i = -2; i <= 2; i++)
                    {
                        if (!(GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y + 1) == Tile.DirtFloor || GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y + 1) == Tile.Corridor) ||
                            (GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y) == Tile.DirtFloor || GetCellType((int)Alarm.Key.X + i, (int)Alarm.Key.Y) == Tile.Corridor))
                        {
                            break;
                        }
                    }

                    RedAlarmLamp tmp = new RedAlarmLamp(new Rectangle((int)Alarm.Key.X * 64 + 32, (int)Alarm.Key.Y * 64 + 60, 16, 8), Chunk.map);
                    tmp.Fixture.Body.Rotation = (float)Math.PI;

                    break;

                case Direction.East:

                    break;

                case Direction.West:

                    break;
                }
            }
        }
Пример #5
0
        public Player(Rectangle pos, Map m) : base(m)
        {
            Body BodyDec = new Body(m.PhysicalWorld);

            BodyDec.BodyType = BodyType.Dynamic;

            Fixture = BodyDec.CreateFixture(new CircleShape(15f, 1.0f));

            Body BodyDecSensor = new Body(m.PhysicalWorld);

            BodyDecSensor.BodyType = BodyType.Dynamic;

            PlayerSensor = BodyDecSensor.CreateFixture(new CircleShape(15f, .0f));
            PlayerSensor.Body.IsSensor = true;
            PlayerSensor.OnCollision  += OnSensorCollide;

            this.Name       = "player";
            this.texName    = "Mobs/" + Name;
            this.normalName = "Mobs/" + Name + "_normal";

            this.Position = pos;
            hp            = 100;
            def           = 10;
            damage        = 5;
            lucky         = 123135;
            this.map      = m;
            speed         = 15500f;

            weapon = new AK47();

            IdleAnim       = new Animation();
            IdleNormalAnim = new AnimationNormal();

            WalkAnim       = new Animation();
            WalkNormalAnim = new AnimationNormal();

            IdleAnim        = GeneralManager.Animations["PlayerIdle"];
            IdleAnim.Center = Vector2.One * 32;

            IdleNormalAnim.Load("PlayerIdle_normal", Vector2.One * 64, 1, 10000, (LightingEngine)Renderer.GetRenderEffect("LightingEngine"));
            IdleNormalAnim.Center = Vector2.One * 32;

            WalkAnim        = GeneralManager.Animations["TestAnim"];
            WalkAnim.Center = Vector2.One * 32;

            WalkNormalAnim.Load("TestAnim_normal", Vector2.One * 64, 6, 80, (LightingEngine)Renderer.GetRenderEffect("LightingEngine"));
            WalkNormalAnim.Center = Vector2.One * 32;

            LightingEngine LE = (LightingEngine)Renderer.GetRenderEffect("LightingEngine");

            ShootLight = new SpotLight()
            {
                IsEnabled         = true,
                Color             = new Vector4(0.95f, .7f, .05f, 1f),
                Power             = .6f,
                LightDecay        = 600,
                Position          = new Vector3(500, 400, 20),
                SpotAngle         = 2f * 3.1415f,
                SpotDecayExponent = 3,
                Direction         = new Vector3(0.244402379f, 0.969673932f, 0)
            };

            LE.AddLight(ShootLight);

            stoper = new Stopwatch();
            stoper.Start();
        }