Exemple #1
0
        public GameObject(string objType, string animTopLeft, string animTop, string animTopRight, string animLeft, string animStay, string animRight, 
            string animBottomLeft, string animBottom, string animBottomRight, string x, string y, string z, string speedX, string speedY, string speedZ, string ghostYorN)
        {
            this.ObjectType = objType;

            BaseObject[0, 0] = animTopLeft;
            BaseObject[1, 0] = animTop;
            BaseObject[2, 0] = animTopRight;

            BaseObject[0, 1] = animLeft;
            BaseObject[1, 1] = animStay;
            BaseObject[2, 1] = animRight;

            BaseObject[0, 2] = animBottomLeft;
            BaseObject[1, 2] = animBottom;
            BaseObject[2, 2] = animBottomLeft;

            CurrentObject = animStay;

            Location = new Point3D(Convert.ToInt32(x), Convert.ToInt32(y), Convert.ToInt32(z));

            Speed = new Point3D(Convert.ToInt32(speedX), Convert.ToInt32(speedY), Convert.ToInt32(speedZ));

            this.Ghost = ghostYorN == "Y";
        }
Exemple #2
0
        public void DrawGraphic(ref Hashtable graphicLibrary, int frameNumber, Point3D location, Size objSize, ref Bitmap image)
        {
            if (location.X >= 0 || location.Y >= 0 ||
                location.X + ((Bitmap)graphicLibrary[BaseImage]).Width >= 0 ||
                location.Y + ((Bitmap)graphicLibrary[BaseImage]).Height >= 0 &&
                location.X > NumberOfFrames)
                frameNumber -= NumberOfFrames;

            var gfx = Graphics.FromImage(image);

            var grab = FrameInitialOffset;
            if (Vertical)
            {
                grab.Y = FrameInitialOffset.Y + FrameSize.Height * (frameNumber - 1);
            }
            else
            {
                grab.X = FrameInitialOffset.X + FrameSize.Width * (frameNumber - 1);
            }

            var destRec = new Rectangle(location.X, location.Y, objSize.Width, objSize.Height);
            var srcRec = new Rectangle(grab, FrameSize);

            gfx.DrawImage(graphicLibrary[BaseImage] as Bitmap, destRec, srcRec, GraphicsUnit.Pixel);
        }
Exemple #3
0
        // Only for one animation
        public GameObject(string objType, string animStay, string x, string y, string z, string speedX, string speedY, string speedZ, string ghostYorN)
        {
            this.AutoChangeAnimation = false;
            this.ObjectType = objType;

            CurrentObject = animStay;

            Location = new Point3D(Convert.ToInt32(x), Convert.ToInt32(y), Convert.ToInt32(z));

            Speed = new Point3D(Convert.ToInt32(speedX), Convert.ToInt32(speedY), Convert.ToInt32(speedZ));

            this.Ghost = ghostYorN == "Y";
        }
Exemple #4
0
        public Camera(Point3D offset, Size resolution, Rectangle drawLocation, CameraType cameraStyle)
        {
            this.Offset = offset;

            this.CameraScreen = new Bitmap(resolution.Width, resolution.Height);

            this.DrawLocation = drawLocation;

            this.StartZDraw = 0;
            this.EndZDraw = 20;

            this.CameraStyle = cameraStyle;

            this.ShowBackground = true;
        }
Exemple #5
0
 public void MoveCameraRelative(Point3D newOffset)
 {
     this.Offset.X += newOffset.X;
     this.Offset.Y += newOffset.Y;
     this.Offset.Z += newOffset.Z;
 }
Exemple #6
0
 public void MoveCameraActual(Point3D newOffset)
 {
     this.Offset = newOffset;
 }
Exemple #7
0
 public void Move(Point3D offset)
 {
     Location.X += offset.X;
     Location.Y += offset.Y;
     Location.Z += offset.Z;
 }
Exemple #8
0
 public void SetLocationRelative(Point3D offset)
 {
     Location.X += offset.X;
     Location.Y += offset.Y;
     Location.Z += offset.Z;
 }
Exemple #9
0
 public void SetGravity(Point3D gravityLevel)
 {
     this.Gravity = gravityLevel;
 }
Exemple #10
0
 public void SetLocationActual(Point3D location)
 {
     this.Location = location;
 }
Exemple #11
0
        public void Redraw(Camera cam, ref Hashtable graphicLibrary, ref Hashtable graphicObjects)
        {
            int xOffset = 0;

            var currentObject = graphicObjects[CurrentObject] as GraphicObject;

            if (MaxFrame == 0)
            {
                MaxFrame = currentObject.NumberOfFrames;

                if (ObjectSize.Width == -1 || AutoSizeWithAnimation)
                {
                    ObjectSize = currentObject.FrameSize;
                }
            }

            if (cam.CameraStyle == CameraType.Left3D)
                xOffset += Location.Z;
            else if (cam.CameraStyle == CameraType.Right3D)
                xOffset -= Location.Z;
            else
                xOffset = 0;

            var location = new Point3D(Location.X - cam.Offset.X + xOffset, Location.Y - cam.Offset.Y, Location.Z);
            currentObject.DrawGraphic(ref graphicLibrary, CurrentFrame, location, ObjectSize, ref cam.CameraScreen);
        }
Exemple #12
0
 public void SetGravity(string group, bool includeGhosts, Point3D gravityLevel)
 {
     foreach(GameObject item in WorldObjects)
     {
         if (includeGhosts || !item.Ghost)
         {
             if (group == "All")
             {
                 item.SetGravity(gravityLevel);
             }
             else
             {
                 if (item.ObjectType == group)
                     item.SetGravity(gravityLevel);
             }
         }
     }
 }
Exemple #13
0
        /// <summary>
        /// Draws the current environment into all cameras
        /// </summary>
        public void Frame()
        {
            foreach (Camera cam in WorldCameras)
            {
                // Check boundaries
                var offset = new Point3D(cam.Offset.X, cam.Offset.Y, cam.Offset.Z);

                if (offset.X > LevelSize.Width) // intuitivo
                {
                    offset.X = 0;
                }
                else if (cam.Offset.X + cam.CameraScreen.Width > LevelSize.Width)
                {
                    offset.X = LevelSize.Width - cam.CameraScreen.Width;
                }

                if (offset.Y > LevelSize.Height) // intuitivo
                {
                    offset.Y = 0;
                }
                else if (cam.Offset.Y + cam.CameraScreen.Height > LevelSize.Height)
                {
                    offset.Y = LevelSize.Height - cam.CameraScreen.Height;
                }

                cam.MoveCameraActual(offset);

                if (cam.ShowBackground)
                    Background.Redraw(cam, LevelSize);

                // Draw items in z-order
                int currentZOrder = cam.StartZDraw;
                while (currentZOrder < cam.EndZDraw) // intuitivo
                {
                    foreach(GameObject item in WorldObjects)
                    {
                        if (item.Location.Z == currentZOrder)
                            item.Redraw(cam, ref GraphicLibrary, ref GraphicObjects);
                    }

                    currentZOrder++;
                }

                // Draw Foreground

                Foreground.Redraw(cam, LevelSize);
            }
        }
Exemple #14
0
        /// <summary>
        /// Check if a single point touched the bump map array.
        /// </summary>
        /// <param name="location">The point to test.</param>        
        /// <returns>True if touchs</returns>
        public bool CheckBumpMap(ref Point3D location)
        {
            if (BumpMapSize.X > 0) // intuitivo
            {
                if (location.X > 0 && location.Y > 0)
                {
                    int leftX = location.X / BumpMapSize.X;
                    int leftY = location.Y / BumpMapSize.Y;

                    return BumpMap[leftX, leftY] != 0;
                }
            }

            return false;
        }
Exemple #15
0
        /// <summary>
        /// Check to see if any part of an object  has toouched a '1' inside of bump map array. All four corners of the objet are tested.        
        /// 
        /// </summary>
        /// <param name="location">Object location</param>
        /// <param name="objSize">Object size</param>
        /// <returns>True if is has touched</returns>
        public bool CheckBumpMap(ref Point3D location, ref Size objSize)
        {
            if (BumpMapSize.X > 0) // intuitivo
            {
                if (location.X > 0 && location.Y > 0)
                {
                    // test two corners
                    int leftX = location.X / BumpMapSize.X;
                    int leftY = location.Y / BumpMapSize.Y;

                    int rightX = (location.X + objSize.Width) / BumpMapSize.X;
                    int rightY = (location.Y + objSize.Height) / BumpMapSize.Y;

                    return BumpMap[leftX, leftY] != 0 || BumpMap[rightX, rightY] != 0;
                }
            }

            return false;
        }