コード例 #1
0
ファイル: ObjectFactory.cs プロジェクト: shusso/Strategy-Game
        public static GameObject FenceVertical()
        {
            GameObject go = new GameObject();
            go.SetImage("Fence_vertical.png");

            return go;
        }
コード例 #2
0
ファイル: ObjectFactory.cs プロジェクト: shusso/Strategy-Game
        public static GameObject FenceHorizontal()
        {
            GameObject go = new GameObject();
            go.SetImage("Fence_horizontal.png");

            return go;
        }
コード例 #3
0
ファイル: Lab10.cs プロジェクト: ravikamath/CPI311
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            GameObject terrainObject = new GameObject();
            terrainObject.Transform.LocalScale *= new Vector3(1, 5, 1);
            terrain = terrainObject.Add<TerrainRenderer>();
            terrain.Initialize(
                Content.Load<Texture2D>("Textures/Heightmap"),
                Vector2.One * 100, Vector2.One * 200);
            terrain.NormalMap = Content.Load<Texture2D>("Textures/Normalmap");
            effect = Content.Load<Effect>("Effects/TerrainShader");

            GameObject cameraObject = new GameObject();
            cameraObject.Transform.LocalPosition = Vector3.Backward * 5 + Vector3.Right * 5 + Vector3.Up * 5;
            camera = cameraObject.Add<Camera>();
        }
コード例 #4
0
ファイル: Lab08.cs プロジェクト: ravikamath/CPI311
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            gunSound = Content.Load<SoundEffect>("Sounds/Gun");
            cube = Content.Load<Model>("Models/Cube");
            sphere = Content.Load<Model>("Models/Sphere");

            GameObject gameObject;
            gameObject = new GameObject();
            gameObject.Transform.LocalPosition = new Vector3(1, 0, 0);
            objects.Add(gameObject);
            BoxCollider boxCollider = gameObject.Add<BoxCollider>();
            boxCollider.Size = 1;
            colliders.Add(boxCollider);

            gameObject = new GameObject();
            gameObject.Transform.LocalPosition = new Vector3(-1, 0, 0);
            objects.Add(gameObject);
            SphereCollider sphereCollider = gameObject.Add<SphereCollider>();
            sphereCollider.Radius = 1;
            colliders.Add(sphereCollider);

            // Front Camera
            gameObject = new GameObject();
            gameObject.Transform.LocalPosition = Vector3.Backward * 5;
            camera = gameObject.Add<Camera>();
            camera.Position = new Vector2(0f, 0f);
            camera.Size = new Vector2(0.5f, 1f);
            camera.AspectRatio = camera.Viewport.AspectRatio;
            cameras.Add(camera);
            // Top Down Camera
            gameObject = new GameObject();
            gameObject.Transform.LocalPosition = Vector3.Up * 10;
            gameObject.Transform.Rotate(Vector3.Right, -MathHelper.PiOver2);
            camera = gameObject.Add<Camera>();
            camera.Position = new Vector2(0.5f, 0f);
            camera.Size = new Vector2(0.5f, 1f);
            camera.AspectRatio = camera.Viewport.AspectRatio;
            cameras.Add(camera);

            camera = cameras[0];
        }
コード例 #5
0
ファイル: Lab04.cs プロジェクト: ravikamath/CPI311
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     // Let's load our model
     model = Content.Load<Model>("Models/Torus");
     // Ask our model to do "default" lighting"
     foreach (ModelMesh mesh in model.Meshes)
         foreach (BasicEffect effect in mesh.Effects)
         {
             effect.EnableDefaultLighting();
             effect.Alpha = 1;
         }
     parentObject = new GameObject();
     childObject = new GameObject();
     childObject.Transform.Parent = parentObject.Transform;
     childObject.Transform.LocalPosition = Vector3.Right * 10;
     cameraObject = new GameObject();
     cameraObject.Transform.LocalPosition = Vector3.Backward * 50;
     camera = cameraObject.Add<Camera>();
 }
コード例 #6
0
ファイル: ChaseCamera.cs プロジェクト: STPKITT/OpenNFS1
 public void FollowObject(GameObject obj)
 {
     _chasePosition = obj.Position;
     _chaseDirection = obj.Orientation;
 }
コード例 #7
0
ファイル: GameScene.cs プロジェクト: Molus/LSE
 public void RemoveElement(GameObject element)
 {
     this.elements.Remove(element);
 }
コード例 #8
0
ファイル: GameScene.cs プロジェクト: Molus/LSE
 public void AddElement(GameObject element)
 {
     this.elements.Add(element);
 }
コード例 #9
0
ファイル: ObjectSystem.cs プロジェクト: shusso/Strategy-Game
        internal GameObject SelectCurrentObject(ref int currentIndex)
        {
            if (currentIndex > _own.Count - 1)
                currentIndex = 0;
            if (currentIndex < 0)
                currentIndex = _own.Count - 1;

            _selected =  _own[currentIndex];

            return _selected;
        }
コード例 #10
0
ファイル: MoveComponent.cs プロジェクト: shusso/Strategy-Game
        private Point getNewMoveTo(Point location, Point movingTo, GameObject closest)
        {
            Point retVal = null;

            double minValue = double.MaxValue;
            double dist;
            List<GameObject> objectsInTheWay = new List<GameObject>();

            objectsInTheWay = owner.QuadTreeProperty.Query(location, closest.Rectangle.UpLeft);
            if (objectsInTheWay.Count <= 1)
            {
                if (objectsInTheWay[0] != null && objectsInTheWay[0] == owner)
                {
                    dist = MathHelper.Length(movingTo, closest.Rectangle.UpLeft);
                    if (dist < minValue)
                    {
                        minValue = dist;
                        retVal = new Point(closest.Rectangle.UpLeft.X - owner.Radius * 4, closest.Rectangle.UpLeft.Y - owner.Radius * 4);
                    }
                }
            }

            objectsInTheWay = owner.QuadTreeProperty.Query(location, closest.Rectangle.UpRight);
            if (objectsInTheWay.Count <= 1)
            {
                if (objectsInTheWay[0] != null && objectsInTheWay[0] == owner)
                {
                    dist = MathHelper.Length(movingTo, closest.Rectangle.UpRight);
                    if (dist < minValue)
                    {
                        minValue = dist;
                        retVal = new Point(closest.Rectangle.UpRight.X + owner.Radius * 4, closest.Rectangle.UpRight.Y - owner.Radius * 4);
                    }
                }
            }

            objectsInTheWay = owner.QuadTreeProperty.Query(location, closest.Rectangle.DownLeft);
            if (objectsInTheWay.Count <= 1)
            {
                if (objectsInTheWay[0] != null && objectsInTheWay[0] == owner)
                {
                    dist = MathHelper.Length(movingTo, closest.Rectangle.DownLeft);
                    if (dist < minValue)
                    {
                        minValue = dist;
                        retVal = new Point(closest.Rectangle.DownLeft.X - owner.Radius * 4, closest.Rectangle.DownLeft.Y + owner.Radius * 4);
                    }
                }
            }

            objectsInTheWay = owner.QuadTreeProperty.Query(location, closest.Rectangle.DownRight);
            if (objectsInTheWay.Count <= 1)
            {
                if (objectsInTheWay[0] != null && objectsInTheWay[0] == owner)
                {
                    dist = MathHelper.Length(movingTo, closest.Rectangle.DownRight);
                    if (dist < minValue)
                    {
                        minValue = dist;
                        retVal = new Point(closest.Rectangle.DownRight.X + owner.Radius * 4, closest.Rectangle.DownRight.Y + owner.Radius * 4);
                    }
                }
            }

            return retVal;
        }
コード例 #11
0
ファイル: SimpleCamera.cs プロジェクト: STPKITT/OpenNFS1
 public void FollowObject(GameObject obj)
 {
 }
コード例 #12
0
ファイル: Lab05.cs プロジェクト: ravikamath/CPI311
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     // Let's load our model
     model = Content.Load<Model>("Models/Torus");
     parentObject = new GameObject();
     childObject = new GameObject();
     childObject.Transform.Parent = parentObject.Transform;
     childObject.Transform.LocalPosition = Vector3.Right * 10;
     cameraObject = new GameObject();
     cameraObject.Transform.LocalPosition = Vector3.Backward * 50;
     camera = cameraObject.Add<Camera>();
     texture = Content.Load<Texture2D>("Textures/Square");
     effect = Content.Load<Effect>("Effects/SimpleShading");
 }
コード例 #13
0
ファイル: GameWorld.cs プロジェクト: anlugifa/GameEngine
        /// <summary>
        /// Load the level file into the game world
        /// </summary>
        /// <param name="levelFile"></param>
        public void LoadLevel(string levelFile)
        {
            using (var sr = new StreamReader(levelFile))
            {
                string line = sr.ReadLine();

                string[] levelSizeItems = line.Split(new char[] { ',' });

                //size of the level

                LevelSize.Width = Convert.ToInt32(levelSizeItems[0]);
                LevelSize.Height = Convert.ToInt32(levelSizeItems[1]);
                LevelDepth = Convert.ToInt32(levelSizeItems[0]);

                Bitmap temp;
                Color transparentColour;

                line = sr.ReadLine();
                while (line != ENDGRAPHICS)
                {
                    levelSizeItems = line.Split(new char[] { ',' });

                    temp = new Bitmap("images\\" + levelSizeItems[1]);

                    int r = Convert.ToInt32(levelSizeItems[2]);
                    int g = Convert.ToInt32(levelSizeItems[3]);
                    int b = Convert.ToInt32(levelSizeItems[4]);
                    transparentColour = Color.FromArgb(r, g, b);

                    temp.MakeTransparent(transparentColour);

                    //image name name, bitmap
                    GraphicLibrary.Add(levelSizeItems[0], temp);

                    line = sr.ReadLine();
                }

                bool vertical = false;
                line = sr.ReadLine();
                while (line != ENDANIMATIONS)
                {
                    levelSizeItems = line.Split(new char[] { ',' });

                    vertical = levelSizeItems[7] == "Y";

                    var oname = levelSizeItems[0];
                    var image = levelSizeItems[1];
                    var local = new Point(Convert.ToInt32(levelSizeItems[2]), Convert.ToInt32(levelSizeItems[3]));
                    var size = new Size(Convert.ToInt32(levelSizeItems[4]), Convert.ToInt32(levelSizeItems[5]));
                    int numFrames = Convert.ToInt32(levelSizeItems[6]);

                    var go = new GraphicObject(image, size, local, numFrames, vertical);

                    GraphicObjects.Add(oname, go);

                    line = sr.ReadLine();
                }

                Background tmpBgnd;
                line = sr.ReadLine();
                while (line != ENDBACKGROUNDS)
                {
                    string map = sr.ReadLine();

                    tmpBgnd = new Background(line, map);

                    Background.AddParallax(tmpBgnd);

                    line = sr.ReadLine();
                }

                // Next the bump map
                line = sr.ReadLine();

                levelSizeItems = line.Split(new char[] { ',' });

                BumpMapSize.X = Convert.ToInt32(levelSizeItems[0]);
                BumpMapSize.Y = Convert.ToInt32(levelSizeItems[1]);

                int width = LevelSize.Width / BumpMapSize.X;
                int height = LevelSize.Height / BumpMapSize.Y;
                BumpMap = new int[width, height];

                var gridTransfer = new Point(width, height);
                var gridPosition = new Point(0, 0);

                int bump = 0;
                while (gridPosition.Y < gridTransfer.Y) // intuitivo
                {
                    while (gridPosition.X < gridTransfer.X)
                    {
                        if (levelSizeItems[2][bump] == '0')
                            BumpMap[gridPosition.X, gridPosition.Y] = 0;
                        else
                            BumpMap[gridPosition.X, gridPosition.Y] = 1;

                        bump++;
                        gridPosition.X++;
                    }

                    gridPosition.X = 0;
                    gridPosition.Y++;
                }

                // Next the objects
                line = sr.ReadLine();

                while (line != ENDOBJECTS)
                {
                    levelSizeItems = line.Split(new char[] { ',' });

                    if (levelSizeItems.Length == 17)
                    {
                        var objType = levelSizeItems[0];

                        var animTopLeft = levelSizeItems[1];
                        var animTop = levelSizeItems[2];
                        var animTopRight = levelSizeItems[3];
                        var animLeft = levelSizeItems[4];
                        var animStay = levelSizeItems[5];
                        var animRight = levelSizeItems[6];

                        var animBottomLeft = levelSizeItems[7];
                        var animBottom = levelSizeItems[8];
                        var animBottomRight = levelSizeItems[9];

                        var x = levelSizeItems[10];
                        var y = levelSizeItems[11];
                        var z = levelSizeItems[12];
                        var spx = levelSizeItems[13];
                        var spy = levelSizeItems[14];
                        var spz = levelSizeItems[15];
                        var ghost = levelSizeItems[16];

                        var go = new GameObject(objType, animTopLeft, animTop, animTopRight, animLeft, animStay, animRight, animBottomLeft, animBottom, animBottomRight, x, y, z, spx, spy, spz, ghost);
                        WorldObjects.Add(go);
                    }
                    else
                    {
                        var objType = levelSizeItems[0];

                        var animStay = levelSizeItems[1];

                        var x = levelSizeItems[2];
                        var y = levelSizeItems[3];
                        var z = levelSizeItems[4];
                        var spx = levelSizeItems[5];
                        var spy = levelSizeItems[6];
                        var spz = levelSizeItems[7];
                        var ghost = levelSizeItems[8];

                        var go = new GameObject(objType, animStay, x, y, z, spx, spy, spz, ghost);
                        WorldObjects.Add(go);
                    }

                    line = sr.ReadLine();
                }

                // CAMERAS
                line = sr.ReadLine();
                while (line != ENDCAMERAS)
                {
                    levelSizeItems = line.Split(new char[] { ',' });

                    var camType = CameraType.Standard;

                    if (levelSizeItems[6] == "L")
                        camType = CameraType.Left3D;
                    else if (levelSizeItems[6] == "R")
                        camType = CameraType.Right3D;

                    var resolution = new Size(Convert.ToInt32(levelSizeItems[0]), Convert.ToInt32(levelSizeItems[1]));
                    var drawLocation = new Rectangle(Convert.ToInt32(levelSizeItems[2]), Convert.ToInt32(levelSizeItems[3]), Convert.ToInt32(levelSizeItems[4]), Convert.ToInt32(levelSizeItems[5]));

                    var camera = new Camera(resolution, drawLocation, camType);

                    WorldCameras.Add(camera);
                }
            }
        }
コード例 #14
0
ファイル: ObjectFactory.cs プロジェクト: shusso/Strategy-Game
        public static GameObject House()
        {
            GameObject go = new GameObject();
            go.SetImage("House.png");

            return go;
        }