Ejemplo n.º 1
0
        public bool IsVisible(RenderObjectType type)
        {
            bool visible;

            dictVisible.TryGetValue(type, out visible);
            return(visible);
        }
Ejemplo n.º 2
0
        public RenderObject(GameObject GameObject, System.Windows.UIElement element, RenderObjectType objectType, Dimension Size, System.Windows.Controls.Canvas Canvas, Renderer controller)
        {
            //Create new UI Element
            if (element is null)
            {
                switch (objectType)
                {
                case RenderObjectType.rectangle:
                    element = new System.Windows.Shapes.Rectangle()
                    {
                        Width                 = Size.Width,
                        Height                = Size.Height,
                        Fill                  = new System.Windows.Media.SolidColorBrush(GameObject.color),
                        Stroke                = new System.Windows.Media.SolidColorBrush(GameObject.color),
                        RenderTransform       = new System.Windows.Media.TransformGroup(),
                        RenderTransformOrigin = new System.Windows.Point(0.5, 0.5)
                    };
                    System.Windows.Media.TransformGroup transformGroup = (System.Windows.Media.TransformGroup)element.RenderTransform;
                    rotateTransform = new System.Windows.Media.RotateTransform(90);     //Rotation is different system than used
                    transformGroup.Children.Add(rotateTransform);
                    translateTransform = new System.Windows.Media.TranslateTransform(GameObject.position.x * Renderer.FieldSize, GameObject.position.y * Renderer.FieldSize);
                    transformGroup.Children.Add(translateTransform);
                    element.RenderTransform = transformGroup;
                    break;

                case RenderObjectType.image:
                    element = new System.Windows.Controls.Image()
                    {
                        Width                 = Size.Width * Renderer.FieldSize, //TODO: Fix the difference in size between the two types
                        Height                = Size.Height * Renderer.FieldSize,
                        Source                = Renderer.BitmapToImageSource(new System.Drawing.Bitmap(((ImageEntity)GameObject).CurrentImage())),
                        RenderTransform       = new System.Windows.Media.TransformGroup(),
                        RenderTransformOrigin = new System.Windows.Point(0.5, 0.5)
                    };
                    transformGroup  = (System.Windows.Media.TransformGroup)element.RenderTransform;
                    rotateTransform = new System.Windows.Media.RotateTransform(90);     //Rotation is different system than used
                    transformGroup.Children.Add(rotateTransform);
                    translateTransform = new System.Windows.Media.TranslateTransform(GameObject.position.x * Renderer.FieldSize, GameObject.position.y * Renderer.FieldSize);
                    transformGroup.Children.Add(translateTransform);
                    element.RenderTransform = transformGroup;
                    break;

                default:
                    break;
                }
            }

            gameObject = GameObject;
            uIElement  = element;
            type       = objectType;
            size       = Size;
            renderer   = controller;
            canvas     = Canvas;

            Canvas.Children.Add(uIElement);
        }
Ejemplo n.º 3
0
        public void AddEntity(GameObject gameObject, RenderObjectType type)
        {
            RenderObject item = new RenderObject(gameObject, null, type, gameObject.size, canvas, this);

            renderObjects.Add(item);
            //Calculate
            Point pos     = item.gameObject.position * FieldSize + offset;
            bool  LowerX  = offset.x - screen.Width * FieldSize / 2 - item.gameObject.size.Width * FieldSize <= pos.x;
            bool  HigherX = pos.x <= offset.x + screen.Width * FieldSize / 2 + item.gameObject.size.Width * FieldSize;
            bool  LowerY  = offset.y - screen.Height * FieldSize / 2 - item.gameObject.size.Height * FieldSize <= pos.y;
            bool  HigherY = pos.y <= offset.y + screen.Height * FieldSize / 2 + item.gameObject.size.Height * FieldSize;

            item.Enabled = LowerX && HigherX && LowerY && HigherY;

            //Set the correct offset
            item.gameObject.animate = true;
            item.Update(forced: true);
        }
Ejemplo n.º 4
0
        public static ObjectClass RenderTypeToObjectClass(RenderObjectType type)
        {
            switch (type)
            {
            case RenderObjectType.Mob:
                return(ObjectClass.Mob);

            case RenderObjectType.Foothold:
                return(ObjectClass.Foothold);

            case RenderObjectType.Npc:
                return(ObjectClass.Npc);

            case RenderObjectType.LadderRope:
                return(ObjectClass.LadderRope);

            case RenderObjectType.Portal:
                return(ObjectClass.CrossMapPortal);    //TODO: Classify portal
            }
            return(ObjectClass.Unknown);
        }
Ejemplo n.º 5
0
 public RenderObjectHandle(LightSource light)
 {
     obj = light;
     type = RenderObjectType.LIGHT;
 }
Ejemplo n.º 6
0
 public RenderObjectHandle(PrimitiveList prims)
 {
     obj = new Geometry(prims);
     type = RenderObjectType.GEOMETRY;
 }
Ejemplo n.º 7
0
 public RenderObjectHandle(Instance instance)
 {
     obj = instance;
     type = RenderObjectType.INSTANCE;
 }
Ejemplo n.º 8
0
 public RenderObjectHandle(Modifier modifier)
 {
     obj = modifier;
     type = RenderObjectType.MODIFIER;
 }
Ejemplo n.º 9
0
 public RenderObjectHandle(ITesselatable tesselatable)
 {
     obj = new Geometry(tesselatable);
     type = RenderObjectType.GEOMETRY;
 }
Ejemplo n.º 10
0
 public RenderObjectHandle(PrimitiveList prims)
 {
     obj  = new Geometry(prims);
     type = RenderObjectType.GEOMETRY;
 }
Ejemplo n.º 11
0
 public RenderObjectHandle(IShader shader)
 {
     obj = shader;
     type = RenderObjectType.SHADER;
 }
Ejemplo n.º 12
0
 public RenderObjectHandle(Modifier modifier)
 {
     obj  = modifier;
     type = RenderObjectType.MODIFIER;
 }
Ejemplo n.º 13
0
 public RenderObjectHandle(IShader shader)
 {
     obj  = shader;
     type = RenderObjectType.SHADER;
 }
Ejemplo n.º 14
0
 public RenderObjectHandle(Options options)
 {
     obj  = options;
     type = RenderObjectType.OPTIONS;
 }
Ejemplo n.º 15
0
 public TargetItem(SceneItem item, Rectangle rectangle, RenderObjectType type) : this(item, rectangle)
 {
     Type = RenderTypeToObjectClass(type);
 }
Ejemplo n.º 16
0
 public RenderObjectHandle(CameraBase camera)
 {
     obj  = camera;
     type = RenderObjectType.CAMERA;
 }
Ejemplo n.º 17
0
 public RenderObjectHandle(LightSource light)
 {
     obj  = light;
     type = RenderObjectType.LIGHT;
 }
Ejemplo n.º 18
0
 public RenderObjectHandle(Instance instance)
 {
     obj  = instance;
     type = RenderObjectType.INSTANCE;
 }
Ejemplo n.º 19
0
 public RenderObjectHandle(CameraBase camera)
 {
     obj = camera;
     type = RenderObjectType.CAMERA;
 }
Ejemplo n.º 20
0
 private void SetVisible(RenderObjectType type, bool visible)
 {
     this.dictVisible[type] = visible;
 }
Ejemplo n.º 21
0
 public RenderObjectHandle(Options options)
 {
     obj = options;
     type = RenderObjectType.OPTIONS;
 }
Ejemplo n.º 22
0
 public RenderObjectHandle(ITesselatable tesselatable)
 {
     obj  = new Geometry(tesselatable);
     type = RenderObjectType.GEOMETRY;
 }