예제 #1
0
		private static Vector2f CreateOrigin(LObject o, Origin origin) {
			Vector2f v = new Vector2f(o.X(), o.Y());
			switch (origin) {
			case Origin.CENTER:
				v.Set(o.GetWidth() / 2f, o.GetHeight() / 2f);
				return v;
			case Origin.TOP_LEFT:
				v.Set(0.0f, o.GetHeight());
				return v;
			case Origin.TOP_RIGHT:
				v.Set(o.GetWidth(), o.GetHeight());
				return v;
			case Origin.BOTTOM_LEFT:
				v.Set(0.0f, 0.0f);
				return v;
			case Origin.BOTTOM_RIGHT:
				v.Set(o.GetWidth(), 0.0f);
				return v;
			case Origin.LEFT_CENTER:
				v.Set(0.0f, o.GetHeight() / 2f);
				return v;
			case Origin.TOP_CENTER:
				v.Set(o.GetWidth() / 2f, o.GetHeight());
				return v;
			case Origin.BOTTOM_CENTER:
				v.Set(o.GetWidth() / 2f, 0.0f);
				return v;
			case Origin.RIGHT_CENTER:
				v.Set(o.GetWidth(), o.GetHeight() / 2f);
				return v;
			default:
				return v;
			}
		}
예제 #2
0
 public virtual void BottomOn(LObject obj0)
 {
     BottomOn(obj0, GetWidth(), GetHeight());
 }
예제 #3
0
 public virtual void RightOn(LObject obj0)
 {
     RightOn(obj0, GetWidth(), GetHeight());
 }
예제 #4
0
 public virtual void TopOn(LObject obj0)
 {
     TopOn(obj0, GetWidth(), GetHeight());
 }
예제 #5
0
 public virtual void CenterOn(LObject obj0)
 {
     CenterOn(obj0, GetWidth(), GetHeight());
 }
예제 #6
0
 public static void BottomOn(LObject obj0, int w, int h)
 {
     obj0.SetLocation(w / 2 - obj0.GetWidth() / 2,
             h - obj0.GetHeight());
 }
예제 #7
0
 public static void RightOn(LObject obj0, int w, int h)
 {
     obj0.SetLocation(w - obj0.GetWidth(), h / 2 - obj0.GetHeight()
             / 2);
 }
예제 #8
0
		private static void SetLocation(LObject objToBePositioned, float atp_W,
				float atp_H, float obj_X, float obj_Y, float obj_XW, float obj_YH,
				Position position) {
			switch (position) {
			case Position.CENTER:
				objToBePositioned.SetX((obj_XW / 2f) - atp_W / 2f);
				objToBePositioned.SetY((obj_YH / 2f) - atp_H / 2f);
				break;
			case Position.SAME:
				objToBePositioned.SetLocation(obj_X, obj_Y);
				break;
			case Position.LEFT:
				objToBePositioned.SetLocation(obj_X, obj_YH / 2f - atp_H / 2f);
				break;
			case Position.TOP_LEFT:
				objToBePositioned.SetLocation(obj_X, obj_YH - atp_H);
				break;
			case Position.TOP_LEFT_CENTER:
				objToBePositioned.SetLocation(obj_X - atp_W / 2f, obj_YH - atp_H
						/ 2f);
				break;
			case Position.TOP_RIGHT:
				objToBePositioned.SetLocation(obj_XW - atp_W, obj_YH - atp_H);
				break;
			case Position.TOP_RIGHT_CENTER:
				objToBePositioned.SetLocation(obj_XW - atp_W / 2f, obj_YH - atp_H
						/ 2f);
				break;
			case Position.TOP_CENTER:
				objToBePositioned.SetLocation(obj_XW / 2f - atp_W / 2f, obj_YH
						- atp_H);
				break;
			case Position.BOTTOM_LEFT:
				objToBePositioned.SetLocation(obj_X, obj_Y);
				break;
			case Position.BOTTOM_LEFT_CENTER:
				objToBePositioned.SetLocation(obj_X - atp_W / 2f, obj_Y - atp_H
						/ 2f);
				break;
			case Position.BOTTOM_RIGHT:
				objToBePositioned.SetLocation(obj_XW - atp_W, obj_Y);
				break;
			case Position.BOTTOM_RIGHT_CENTER:
				objToBePositioned.SetLocation(obj_XW - atp_W / 2f, obj_Y - atp_H
						/ 2f);
				break;
			case Position.BOTTOM_CENTER:
				objToBePositioned.SetLocation(obj_XW / 2f - atp_W / 2f, obj_Y);
				break;
			case Position.RIGHT_CENTER:
				objToBePositioned.SetLocation(obj_XW - atp_W, obj_YH / 2f - atp_H
						/ 2f);
				break;
			default:
				objToBePositioned.SetLocation(objToBePositioned.GetX(),
						objToBePositioned.GetY());
				break;
			}
		}
예제 #9
0
 public static void TopOn(LObject obj0, int w, int h)
 {
     obj0.SetLocation(w / 2 - h / 2, 0);
 }
예제 #10
0
 public static void CenterOn(LObject obj0, int w, int h)
 {
     obj0.SetLocation(w / 2 - obj0.GetWidth() / 2,
             h / 2 - obj0.GetHeight() / 2);
 }
예제 #11
0
        public Vector2f GetTileCollision(LObject o, float newX, float newY)
        {
            newX = MathUtils.Ceil(newX);
            newY = MathUtils.Ceil(newY);

            float fromX = MathUtils.Min(o.GetX(), newX);
            float fromY = MathUtils.Min(o.GetY(), newY);
            float toX = MathUtils.Max(o.GetX(), newX);
            float toY = MathUtils.Max(o.GetY(), newY);

            int fromTileX = field.PixelsToTilesWidth(fromX);
            int fromTileY = field.PixelsToTilesHeight(fromY);
            int toTileX = field.PixelsToTilesWidth(toX + o.GetWidth() - 1f);
            int toTileY = field.PixelsToTilesHeight(toY + o.GetHeight() - 1f);

            for (int x = fromTileX; x <= toTileX; x++)
            {
                for (int y = fromTileY; y <= toTileY; y++)
                {
                    if ((x < 0) || (x >= this.GetWidth()))
                    {
                        return new Vector2f(x, y);
                    }
                    if ((y < 0) || (y >= this.GetHeight()))
                    {
                        return new Vector2f(x, y);
                    }

                    if (this.IsHit(x, y))
                    {
                        return new Vector2f(x, y);
                    }
                }
            }

            return null;
        }
예제 #12
0
		public static void SetPoisiton(LObject objToBePositioned, float x, float y,
				float width, float height, Position position) {
			float atp_W = objToBePositioned.GetWidth();
			float atp_H = objToBePositioned.GetHeight();
			float obj_X = x;
			float obj_Y = y;
			float obj_XW = width + obj_X;
			float obj_YH = height + obj_Y;
			SetLocation(objToBePositioned, atp_W, atp_H, obj_X, obj_Y, obj_XW,
					obj_YH, position);
		}
예제 #13
0
		public static void SetPoisiton(LObject objToBePositioned,
				LObject objStable, Position position) {
			float atp_W = objToBePositioned.GetWidth();
			float atp_H = objToBePositioned.GetHeight();
			float obj_X = objStable.GetX();
			float obj_Y = objStable.GetY();
			float obj_XW = objStable.GetWidth() + obj_X;
			float obj_YH = objStable.GetHeight() + obj_Y;
			SetLocation(objToBePositioned, atp_W, atp_H, obj_X, obj_Y, obj_XW,
					obj_YH, position);
		}
예제 #14
0
		public static Vector2f MakeOrigin(LObject o, Origin origin) {
            return CreateOrigin(o, origin);
		}
예제 #15
0
 public virtual void Follow(LObject o)
 {
     this.follow = o;
 }
예제 #16
0
 public static void LeftOn(LObject obj0, int w, int h)
 {
     obj0.SetLocation(0, h / 2 - obj0.GetHeight() / 2);
 }
예제 #17
0
 public Bind(Object o)
 {
     if (o is Actor)
     {
         type = 1;
         actorObject = (Actor)o;
         this.isBindPos = true;
         this.isBindGetPos = true;
         this.isBindRotation = true;
         this.isBindGetRotation = true;
         this.isBindUpdate = true;
         this.isBindScale = true;
         this.isBindSize = true;
     }
     else if (o is Shape)
     {
         type = 2;
         shapeObject = (Shape)o;
         this.isBindPos = true;
         this.isBindGetPos = true;
         this.isBindRotation = true;
         this.isBindGetRotation = true;
         this.isBindUpdate = false;
         this.isBindScale = true;
         this.isBindSize = true;
     }
     else if (o is LComponent)
     {
         type = 3;
         compObject = (LComponent)o;
         this.isBindPos = true;
         this.isBindGetPos = true;
         this.isBindRotation = false;
         this.isBindGetRotation = false;
         this.isBindUpdate = true;
         this.isBindScale = false;
         this.isBindSize = true;
     }
     else if (o is LObject)
     {
         type = 4;
         lObject = (LObject)o;
         this.isBindPos = true;
         this.isBindGetPos = true;
         this.isBindRotation = true;
         this.isBindGetRotation = true;
         this.isBindUpdate = true;
         this.isBindScale = false;
         this.isBindSize = true;
     }
     else
     {
         type = 0;
         Bind.BindObject obj0 = BindClass(this.obj = o);
         this.methods = obj0.methods;
         this.isBindPos = obj0.bindPos;
         this.isBindGetPos = obj0.bindGetPos;
         this.isBindRotation = obj0.bindRotation;
         this.isBindGetRotation = obj0.bindGetRotation;
         this.isBindUpdate = obj0.bindUpdate;
         this.isBindScale = obj0.bindScale;
         this.isBindSize = obj0.bindSize;
     }
 }
예제 #18
0
 public void LeftOn(LObject obj0)
 {
     LeftOn(obj0, GetWidth(), GetHeight());
 }