/// <summary>
        /// 
        /// </summary>
        private void SelectedObjectInput()
        {
            if (EditorHandler.SelectedGameObjects.Count == 0) return;

            foreach (GameObject gameObject in EditorHandler.SelectedGameObjects)
            {
                Vector2 spos = gameObject.Transform.Position;

                if (LeftMouseKeyDown)
                {
                    Rectangle mouseBoundingBox = new Rectangle((int)mouseWorldPosition.X, (int)mouseWorldPosition.Y, 4, 4);
                    Rectangle selectedObjectBoundingBox =
                        new Rectangle((int)spos.X - HANDLER_SIZE / 2, (int)spos.Y - HANDLER_SIZE / 2, HANDLER_SIZE, HANDLER_SIZE);


                    // The mouse is intersecting the selected object?
                    //if (mouseBoundingBox.Intersects(selectedObjectBoundingBox))
                    //{
                    if (!objectHandled)
                    {
                        // Save the current transform for Undo / Redo purposes
                        beforeTransform = (Transform)gameObject.Transform.Clone();
                    }

                    objectHandled = true;
                    //}
                }
                else
                {
                    // The modifications were made?
                    if (objectHandled)
                    {
                        // Save Undo / Redo history
                        InsertUndoRedo();
                    }

                    objectHandled = false;
                }
            }

            if (objectHandled)
            {
                HandleTransformations();
            }
        }
Exemple #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="position"></param>
        /// <param name="rate"></param>
        /// <param name="initialDelay"></param>
        public void To(Vector2 position, float rate, float initialDelay = 0)
        {
            Transform t = new Transform()
            {
                position = position,
                scale = new Vector2(target.Transform.scale.X, target.Transform.scale.Y),
                rotation = target.Transform.rotation
            };

            this.To(t, rate, initialDelay);
        }
Exemple #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="targetTransform"></param>
        /// <param name="rate"></param>
        /// <param name="initialDelay"></param>
        public void To(Transform targetTransform, float rate, float initialDelay = 0)
        {
            this.targetTransform = targetTransform.DeepCopy();
            this.initialTransform = target.Transform.DeepCopy();

            this.rate = rate;
            this.currentElapsed = 0;
            this.paused = false;
            this.initialDelay = initialDelay;

            if (initialDelay != 0)
                waitingForDelay = true;
            else
                waitingForDelay = false;
        }
Exemple #4
0
        protected Transform(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
                throw new ArgumentNullException("info");

            gameObject = info.GetValue("gameObject", typeof(GameObject)) as GameObject;
            parent = info.GetValue("parent", typeof(Transform)) as Transform;
            position = (Vector2)info.GetValue("position", typeof(Vector2));
            rotation = (float)info.GetDouble("rotation");

            object obj = info.GetValue("scale", typeof(object));
            if (obj is Vector2)
                scale = (Vector2)info.GetValue("scale", typeof(Vector2));
            else
                scale = Vector2.One;
        }