Exemplo n.º 1
0
        public override void CheckIfCollisionWithPlayer(DrawableObject item)
        {
            Player player = item as Player;

            if (base.CheckIfCollisionWith(item))
            {
                if (!player.IsMoving)
                {
                    if (IsUnderwater)
                    {
                        player.Die();
                    }
                    else
                    {
                        player.IsMounted = true;
                        player.Xcoord   += Xmovement;
                        player.Ycoord   += Ymovement;
                        if (player.Xcoord < -player.Width || player.Xcoord > mapInfo.Width)
                        {
                            player.Die();
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void CheckIfPlayerCanGetIn(DrawableObject item, Direction direction, Action <bool> action)
        {
            switch (direction)
            {
            case Direction.LEFT:
                if (item.Ycoord + item.Height >= Ycoord && item.Ycoord < Ycoord + Height)
                {
                    action(false);
                }
                else
                {
                    action(true);
                }
                break;

            case Direction.RIGHT:
                if (item.Ycoord + item.Height >= Ycoord && item.Ycoord < Ycoord + Height)
                {
                    action(false);
                }
                else
                {
                    action(true);
                }
                action(true);
                break;

            default:
                action(true);
                break;
            }
        }
Exemplo n.º 3
0
        protected override void Update()
        {
            base.Update();

            Size     = DrawableObject.DrawSize;
            Position = Parent.ToLocalSpace(DrawableObject.ToScreenSpace(Vector2.Zero));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Used to centerize with a sprite as reference
        /// </summary>
        /// <param name="d1">Main sprite</param>
        /// <param name="obj">Sprite as Reference</param>
        /// <param name="type">How it will be centerized</param>
        /// <returns></returns>
        public static PositionerStyle CenterTo(this PositionerStyle p1, DrawableObject obj, CenterType type)
        {
            // Calculate bounds
            var d1   = p1.Modified;
            var pos1 = p1.Modified.BoundingBox;
            var pos2 = obj.BoundingBox;

            switch (type)
            {
            case CenterType.Horizontally:
                d1.Position = new Vector2((pos2.X + (pos2.Width / 2)) - (pos1.Width / 2), pos1.Y);
                break;

            case CenterType.Vertically:
                d1.Position = new Vector2(pos1.X, (pos2.Y + (pos2.Height / 2)) - (pos1.Height / 2));
                break;

            case CenterType.Both:
                // To avoid copying code, we do this
                p1.CenterTo(obj, CenterType.Horizontally);
                p1.CenterTo(obj, CenterType.Vertically);
                break;
            }

            return(p1);
        }
Exemplo n.º 5
0
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            DrawableObject obj   = context.Instance as DrawableObject;
            DrawingSheet   sheet = obj.OwnerDraw.OwnerSheet;

            return(new StandardValuesCollection(VariableCollection.GetIndirectOutputsList(sheet)));
        }
Exemplo n.º 6
0
 public CheckMessage(MessageTypes messageType, string message, DrawableObject drawableObject, DrawableObject drawableObject2 = null)
 {
     type    = messageType;
     text    = message;
     @object = drawableObject;
     object2 = drawableObject2;
 }
Exemplo n.º 7
0
 public AnimationService(DrawableObject targetObject, SharpAudioDevice audioDevice)
 {
     this.targetObject  = (Character)targetObject;
     slideAnimation     = new SlideAnimation(targetObject);
     backSlideAnimation = new SlideAnimation(targetObject);
     rotationAnimation  = new RotationAnimation(targetObject, "yawRotation");
 }
 public RotationAnimation(DrawableObject targetObject, string type) : base(targetObject)
 {
     this.type = type;
     Parameters.Add("initialRotation", null);
     Parameters.Add("targetRotation", null);
     Parameters.Add("offset", null);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initialize the positioner.
 /// </summary>
 /// <param name="toModify">The drawable to modify</param>
 public static PositionerStyle Init(DrawableObject toModify)
 {
     return(new PositionerStyle()
     {
         Modified = toModify
     });
 }
Exemplo n.º 10
0
        private void AddObjectTree(DrawableObject @object)
        {
            var tree = GetNode(@object);

            tree.Nodes.Add(@object.Node);
            tree.Expand();
        }
Exemplo n.º 11
0
 public SelectionRectangle(DrawableObject _obj, ResizingTypes _clip, Point _point, bool _focus)
 {
     point = _point;
     obj   = _obj;
     clip  = _clip;
     focus = _focus;
 }
Exemplo n.º 12
0
        protected override bool OnMouseDown(MouseDownEvent e)
        {
            ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
            DragPosition            = DrawableObject.ToLocalSpace(e.ScreenSpaceMousePosition);

            return(base.OnMouseDown(e));
        }
Exemplo n.º 13
0
        protected override void OnDrag(DragEvent e)
        {
            base.OnDrag(e);

            ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
            DragPosition            = DrawableObject.ToLocalSpace(e.ScreenSpaceMousePosition);
        }
Exemplo n.º 14
0
 public IntroFont(GameObject letterPrefab)
 {
     color    = DrawableObject.getRandomColor();
     size     = new Vector2(42, 60);
     hspacing = 0.6f;
     prefab   = letterPrefab;
 }
Exemplo n.º 15
0
        public SimpleTransition GetTransition(List <Instruction> inst, DrawableObject select, Dictionary <int, DrawableObject> list)
        {
            Point[] pts = new Point[4] {
                inst[1].Point(0),
                inst[2].Point(0),
                inst[3].Point(0),
                inst[4].Point(0)
            };
            SimpleTransition trans = new SimpleTransition(Owner.OwnerDraw, pts, null);

            trans.Name = Owner.OwnerDraw.OwnerSheet.NextObjectName(trans.GetFormName());
            Owner.OwnerDraw.AddObject(trans);
            trans.StartObject = select;
            Point point = trans.StartPoint;

            trans.StartObject.Intersect(trans.StartPoint, ref point, ref trans.StartAngle);
            trans.EndObject = list[StateId];
            point           = trans.EndPoint;
            trans.EndObject.Intersect(trans.EndPoint, ref point, ref trans.EndAngle);
            trans.Condition = Text[1];
            trans.OutputsList.AddRange(Text[3].Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries));
            Point textPoint = Util.Center(new Point[] { Point(0), Point(3) });

            trans.SetTextPoint(textPoint);
            return(trans);
        }
Exemplo n.º 16
0
        public Cursor Moving(Point position, Matrix transform)
        {
            foreach (SelectionRectangle sre in SelectionRectangles)
            {
                if (sre.Rectangle(transform.Elements.First()).Contains(position))
                {
                    CursorType   = CursorTypes.Resize;
                    ResizingType = sre.clip;
                    if (sre.obj is State || sre.obj is SuperState)
                    {
                        OnObject = sre.obj;
                    }
                    else if (sre.obj is Transition)
                    {
                        OnTransition = (Transition)sre.obj;
                        if (sre.clip == ResizingTypes.Spline0 && OnTransition.StartObject != null)
                        {
                            OnObject = OnTransition.StartObject;
                        }
                        else if (sre.clip == ResizingTypes.Spline3 && OnTransition.EndObject != null)
                        {
                            OnObject = OnTransition.EndObject;
                        }
                    }
                    switch (sre.clip)
                    {
                    case ResizingTypes.Left_Top:
                    case ResizingTypes.Right_Bottom:
                        return(Cursors.SizeNWSE);

                    case ResizingTypes.Left_Bottom:
                    case ResizingTypes.Right_Top:
                    case ResizingTypes.Spline0:
                    case ResizingTypes.Spline1:
                    case ResizingTypes.Spline2:
                    case ResizingTypes.Spline3:
                        return(Cursors.SizeNESW);

                    case ResizingTypes.Left:
                    case ResizingTypes.Right:
                        return(Cursors.SizeWE);

                    case ResizingTypes.Top:
                    case ResizingTypes.Bottom:
                        return(Cursors.SizeNS);
                    }
                }
            }
            foreach (DrawableObject obj in SelectedObjects)
            {
                if (obj.IsSelectablePoint(position))
                {
                    CursorType = CursorTypes.Move;
                    return(Cursors.SizeAll);
                }
            }
            CursorType = CursorTypes.Default;
            return(Cursors.Default);
        }
Exemplo n.º 17
0
        public static Point SnapPoint(DrawableObject obj, Point startPoint, Point location, int span)
        {
            DrawableObject shadow = obj.OwnerDraw.Shadow.First(sh => sh.Equals(obj));
            int            x      = (location.X + Math.Sign(location.X) * span / 2) / span * span + startPoint.X % span + shadow.Center.X % span;
            int            y      = (location.Y + Math.Sign(location.Y) * span / 2) / span * span + startPoint.Y % span + shadow.Center.Y % span;

            return(new Point(x, y));
        }
Exemplo n.º 18
0
 public void SelectionFocus(DrawableObject @object)
 {
     if (@object == null || !(@object is State || @object is SuperState))
     {
         return;
     }
     selectedObjectFocusedIndex = selectedObjects.IndexOf(@object);
 }
Exemplo n.º 19
0
 public void AddToSelection(DrawableObject obj)
 {
     selectedObjects.Add(obj);
     if (selectedObjectFocusedIndex == -1 && (obj is State || obj is SuperState))
     {
         selectedObjectFocusedIndex = selectedObjects.IndexOf(obj);
     }
 }
Exemplo n.º 20
0
            public void DrawToBuffer() //Здесь будет происходить отрисовка кадра в буфер
            {
                int drawNum = 0;
                //List<DrawableObject> list = new List<DrawableObject>();
                SortedList <int, DrawableObject> list = new SortedList <int, DrawableObject>();

                if (System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.Z) == true)
                {
                    //if (System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.Space)>0) //Отлично, для этого он просит запилить потоки и прочую чешую. Разобраться
                    grafx.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 128, 0, 0)), 0, 0, view.width, view.height);
                }
                else
                {
                    grafx.Graphics.FillRectangle(Brushes.Black, 0, 0, view.width, view.height);
                }

                foreach (Layer layer in game.objectManager.Layers)
                {
                    DrawableObject obj = layer.getNextObject();
                    while (obj != null)
                    {
                        if ((obj.position.X + obj.width > view.x) && (obj.position.X < view.x + view.width) && (obj.position.Y + obj.height * 2 > view.y) && (obj.position.Y < view.y + view.height))
                        {
                            //list.Add(obj.depth, obj);
                            obj.Draw(grafx, (float)(obj.position.X - view.x), (float)(obj.position.Y - view.y));
                            drawNum++;
                        }
                        obj = layer.getNextObject();
                    }
                }
                ;

                /*list.Sort(delegate(DrawableObject x, DrawableObject y)
                 * {
                 *  if (x.depth == y.depth) return 0;
                 *  else if (x.depth > y.depth) return -1;
                 *  else return 1;
                 * });*/
                for (int i = 0; i < list.Count; i++)
                {
                    DrawableObject obj = list.ElementAt(i).Value;
                    obj.Draw(grafx, (float)(obj.position.X - view.x), (float)(obj.position.Y - view.y));
                }
                // foreach (DrawableObject obj in list)
                //  {
                //     obj.Draw(grafx, (float)(obj.position.X - view.x), (float)(obj.position.Y - view.y));
                // }

                grafx.Graphics.DrawString(Convert.ToString(fps), font, Brushes.Red, new Point(0, 0));
                grafx.Graphics.DrawString(Convert.ToString(drawNum), font, Brushes.Red, new Point(0, 30));
                grafx.Graphics.DrawLine(new Pen(Color.White, 64.0f), new Point((int)-view.x, game.gameLogic.stageHeight - (int)view.y), new Point(game.gameLogic.stageWidth - (int)view.x, game.gameLogic.stageHeight - (int)view.y));
                int l = Cursor.Position.X;
                int s = Cursor.Position.Y;

                Stats.SetStat("lives", l);
                Stats.SetStat("scores", s);
                Stats.Draw(grafx);
            }
Exemplo n.º 21
0
        private void CheckIfCollisionWithPlayer(DrawableObject item)
        {
            Player player = item as Player;

            if (base.CheckIfCollisionWith(item))
            {
                player?.Die();
            }
        }
Exemplo n.º 22
0
        public StandState(DrawableObject o, Image source)
        {
            this.DrawingObject = o;

            Anim = new Animation
                       (source,
                       0, 0, 20, 20, 1, 0.04F, 1, false);
            Direct = Direction.Right;
        }
        protected override bool OnDrag(DragEvent e)
        {
            var result = base.OnDrag(e);

            ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
            DragPosition            = DrawableObject.ToLocalSpace(e.ScreenSpaceMousePosition);

            return(result);
        }
Exemplo n.º 24
0
 public static int Get(DrawableObject @object)
 {
     if (@object is SimpleTransition)
     {
         return(ImageIndex.Transition);
     }
     if (@object is SimpleState)
     {
         return(ImageIndex.State);
     }
     if (@object is Alias)
     {
         return(ImageIndex.Alias);
     }
     if (@object is Origin)
     {
         return(ImageIndex.Origin);
     }
     if (@object is End)
     {
         return(ImageIndex.End);
     }
     if (@object is Abort)
     {
         return(ImageIndex.Abort);
     }
     if (@object is SuperState)
     {
         return(ImageIndex.SuperState);
     }
     if (@object is SuperTransition)
     {
         return(ImageIndex.SuperTransition);
     }
     if (@object is Nested)
     {
         return(ImageIndex.Nested);
     }
     if (@object is Relation)
     {
         return(ImageIndex.Transition);
     }
     if (@object is Text)
     {
         return(ImageIndex.Texts);
     }
     if (@object is StateAlias)
     {
         return(ImageIndex.Alias);
     }
     if (@object is Equation)
     {
         return(ImageIndex.Texts);
     }
     throw new Exception("Missing object type.");
 }
Exemplo n.º 25
0
        //Обрабатывает последствия столкновения
        public bool Collision(DrawableObject a, DrawableObject b)
        {
            return (Math.Abs(a.position.X - b.position.X) < (a.width / 2 + b.width / 2) &&
                        Math.Abs(a.position.Y - b.position.Y) < (a.height / 2 + b.height / 2)); //correct collision with && is boooring

            //!(this.position.Y < (b.position.Y + b.height) ||
            //    (this.position.Y + this.height) > b.position.Y ||
            //    (this.position.X + this.width) < b.position.X ||
            //    this.position.X > (b.position.X + b.width));
        }
Exemplo n.º 26
0
 public Unit(DrawableObject Target)
 {
     Texture = "Unit";
     //! Spawns the Unit somewhere on the Screen.
     Position = new Coordinate(Helper.Random.Next((int)Program.Size.width - 8), Helper.Random.Next((int)Program.Size.height - 16));
     //! Makes the feed the center of the Unit.
     Offset      = new Coordinate(4, 16);
     Size        = new Size(128, 128);
     this.Target = Target;
 }
Exemplo n.º 27
0
        public bool Collision(DrawableObject a, DrawableObject b) //Обрабатывает последствия столкновения
        {
            return(Math.Abs(a.position.X - b.position.X) < (a.width / 2 + b.width / 2) &&
                   Math.Abs(a.position.Y - b.position.Y) < (a.height / 2 + b.height / 2));      //correct collision with && is boooring

            //!(this.position.Y < (b.position.Y + b.height) ||
            //    (this.position.Y + this.height) > b.position.Y ||
            //    (this.position.X + this.width) < b.position.X ||
            //    this.position.X > (b.position.X + b.width));
        }
Exemplo n.º 28
0
        /// <summary>
        /// Put an object side by another
        /// </summary>
        /// <param name="d1">Main sprite</param>
        /// <param name="obj">Sprite as Reference</param>
        /// <param name="side">From which side</param>
        /// <returns></returns>
        public static PositionerStyle SideBy(this PositionerStyle p1, DrawableObject obj, SideFrom side)
        {
            // Calculate bounds
            var d1   = p1.Modified;
            var pos1 = p1.Modified.BoundingBox;
            var pos2 = obj.BoundingBox;

            d1.Position = GetSideBy(pos1, pos2, side);

            return(p1);
        }
Exemplo n.º 29
0
        public void CheckIfCollisionWithPlayer(DrawableObject item)
        {
            Player player = item as Player;

            if (!player.IsMoving && !player.IsMounted)
            {
                if (base.CheckIfCollisionWith(item))
                {
                    player.Die();
                }
            }
        }
Exemplo n.º 30
0
        public MoveState(DrawableObject o, Unit u, State backState)
        {
            DrawingObject = o;
            _unit         = u;
            _backState    = backState;
            Anim          = new Animation
                                (Properties.Resources.spriteMoveWithoutTower,
                                0, 5, 40, 40, 7, 0.02F, 10);

            _timerShiftPicture.Interval = ShiftInterval;
            _timerShiftPicture.Tick    += _timerShiftPicture_Tick;
        }
Exemplo n.º 31
0
        public RespawnState(DrawableObject o, Bullet b, State backState)
        {
            this.DrawingObject = o;
            this._bullet       = b;
            _backState         = backState;
            Anim = new Animation
                       (Properties.Resources.bulResp,
                       0, 0, 20, 20, 1, 0.04F, 1, false);

            _timer.Interval = 30;
            _timer.Tick    += _timer_Tick;
        }
Exemplo n.º 32
0
 public void Remove(DrawableObject mo)
 {
     removeStack.Add(mo);
 }
Exemplo n.º 33
0
 public void Awake()
 {
     drawStuff = GetComponent<DrawableObject>();
 }
Exemplo n.º 34
0
 public void Add(DrawableObject mo)
 {
     addStack.Add(mo);
 }
Exemplo n.º 35
0
 /// <summary>
 /// Draw all graphics2d objects
 /// </summary>
 /// <param name="style">Style for drawing</param>
 /// <param name="draw">The drawable object to draw</param>
 /// <param name="g"></param>
 public static void Draw(this Graphics g, DrawStyle style, DrawableObject draw)
 {
     new Graphics2D(g).Draw(style, draw);
 }
Exemplo n.º 36
0
 /// <summary>
 /// Draw all graphics2d objects
 /// </summary>
 /// <param name="style">Style for drawing</param>
 /// <param name="draw">The drawable object to draw</param>
 public void Draw(DrawStyle style, DrawableObject draw)
 {
     draw.Draw(Graphics, style);
 }