Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        //Get Components
        entity      = GetComponent <Entity2D>();
        bCollider   = GetComponent <BoxCollider2D>();
        sRenderer   = GetComponent <SpriteRenderer>();
        dustSystem  = GetComponent <ParticleSystem>();
        animator    = GetComponent <Animator>();
        audioSource = GetComponent <AudioSource>();

        //Setup Input
        controls = new ControlScheme();
        controls.InGame.Enable();
        controls.InGame.Right.started  += Right_started;
        controls.InGame.Right.canceled += Right_canceled;
        controls.InGame.Left.started   += Left_started;
        controls.InGame.Left.canceled  += Left_canceled;

        controls.InGame.Jump.started  += Jump_started;
        controls.InGame.Jump.canceled += Jump_canceled;

        controls.InGame.Respawn.started += Respawn_started;

        //Makes a save at the start if one does not exsist
        if (!File.Exists(Path.Combine(Application.persistentDataPath, SaveGame.fileName)))
        {
            GameSaveData gsd = new GameSaveData(transform.position.x, transform.position.y, this);
            SaveGame.Save(gsd);
        }

        Application.targetFrameRate = 60;
    }
Exemplo n.º 2
0
        public void NoErrorIfThereAreNoVertices()
        {
            var entity = new Entity2D(Rectangle.One);

            entity.Add(new OutlineColor(Color.Red));
            Assert.DoesNotThrow(entity.OnDraw <DrawPolygon2DOutlines>);
        }
Exemplo n.º 3
0
        public void SaveAndLoadFromMemoryStream()
        {
            var entity = new Entity2D(Rectangle.HalfCentered);

            entity.OnDraw <MockDrawBehavior>();
            Assert.AreEqual(0, entity.NumberOfComponents);
            var data = BinaryDataExtensions.SaveToMemoryStream(entity);

            byte[]    savedBytes         = data.ToArray();
            int       bytesForName       = "Entity2D".Length + 1;
            const int VersionNumberBytes = 4;
            int       componentBytes     = 1 + "Rectangle".Length + 1 + 16 + "IsVisible".Length + 1 + 1 + 2;
            const int BehaviorBytes      = 27;

            Assert.AreEqual(bytesForName + VersionNumberBytes + componentBytes + BehaviorBytes,
                            savedBytes.Length);
            var loadedEntity = data.CreateFromMemoryStream() as Entity2D;

            Assert.AreEqual(0, loadedEntity.NumberOfComponents);
            Assert.IsTrue(loadedEntity.IsActive);
            Assert.AreEqual(Rectangle.HalfCentered, loadedEntity.DrawArea);
            Assert.AreEqual(1, loadedEntity.GetDrawBehaviors().Count);
            Assert.AreEqual("MockDrawBehavior",
                            loadedEntity.GetDrawBehaviors()[0].GetShortNameOrFullNameIfNotFound());
        }
Exemplo n.º 4
0
        private static float GetKeyLabelYCoordinate(Entity2D graph, int index)
        {
            int   row          = 1 + index / 6;
            float borderHeight = graph.DrawArea.Height * Graph.Border;

            return(graph.DrawArea.Bottom + (4 * row) * borderHeight);
        }
Exemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        entitiy = GetComponent <Entity2D>();

        if (entitiy == null)
        {
            movingSolid = GetComponent <MoveingSolid>();

            if (movingSolid == null)
            {
                Debug.LogWarning("Object : " + gameObject.name + " needs and Entity2D or MoveingSolid to use EntityFollowAlongPath.");
            }
        }


        initPos = transform.position;

        float inc = (Mathf.PI * 2.0f) / Percision;
        float cur = 0;

        for (int i = 0; i <= Percision; i++)
        {
            cur += inc;
            Vector2 newPos = new Vector2(Mathf.Cos(cur), Mathf.Sin(cur)) * Radius;
            pointPositions.Add((Vector2)initPos + newPos);
        }

        listIndex = listIndex % Percision;

        transform.position = pointPositions[listIndex];
        Speed = Speed * Physics2DExtra.PIXEL_UNIT;
    }
Exemplo n.º 6
0
        public void LastColorAddsColorComponentIfNotAddedBefore()
        {
            var entity = new Entity2D(Rectangle.Zero);

            entity.LastColor = Color.Red;
            Assert.AreEqual(Color.Red, entity.LastColor);
        }
Exemplo n.º 7
0
		protected void AddChild(Entity2D entity)
		{
			if (children.Any(c => c.Entity2D == entity))
				return;
			children.Add(new Child(entity));
			entity.RenderLayer = RenderLayer + children.Count;
		}
        // Initializor=============================================
        public override void Initialize()
        {
            // Initialize the keyboard
            keyboard = Engine.Services.GetService<KeyboardDevice>();
            mouseDevice = Engine.Services.GetService<MouseDevice>();
            mouseDevice.ResetMouseAfterUpdate = false;

            // Initialize buttons
            Texture2D texture;

            hand = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\hand"),
                    new Vector2(mouseDevice.State.X, mouseDevice.State.Y), this);

            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuReturnBtn");
            returnBtn = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 270), this);

            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuMenuBtn");
            menuBtn = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 320), this);

            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuQuitBtn");
            quitBtn = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 370), this);

            pauseText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"),
                new Vector2((Engine.Viewport.Width / 2)-40, 200), "PAUSE", this);

            // Initialize the black texture
            black = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"),
                    Vector2.Zero, this);
            black.Alpha = 0.4f;

            base.Initialize();
        }
Exemplo n.º 9
0
        private void AddToBatch(Entity2D entity)
        {
            var points = entity.GetInterpolatedList <Vector2D>();

            if (points.Count < 3)
            {
                return;
            }
            if (points.Count > CircularBuffer.TotalMaximumVerticesLimit)
            {
                throw new TooManyVerticesForPolygon(points.Count);                 //ncrunch: no coverage
            }
            var color = entity.Color;

            if (offset + points.Count > vertices.Length)
            {
                ResizeVertices();                 //ncrunch: no coverage
            }
            for (int num = 0; num < points.Count; num++)
            {
                vertices[offset + num] =
                    new VertexPosition2DColor(ScreenSpace.Current.ToPixelSpace(points[num]), color);
            }
            BuildIndices(points.Count);
            offset += points.Count;
        }
Exemplo n.º 10
0
		public void Remove(Entity2D control)
		{
			controls.Remove(control);
			if (control is Control)
				((Control)control).SceneDrawArea = Rectangle.Unused;
			control.Dispose();
		}
Exemplo n.º 11
0
		private float GetPercentileYCoordinate(Entity2D graph, int index)
		{
			float borderHeight = graph.DrawArea.Height * Graph.Border;
			float interval = (graph.DrawArea.Height - 2 * borderHeight) / NumberOfPercentiles;
			float bottom = graph.DrawArea.Bottom - borderHeight;
			return bottom - index * interval;
		}
Exemplo n.º 12
0
        private static Rectangle GetKeyLabelDrawArea(Entity2D graph, int index)
        {
            float x = GetKeyLabelXCoordinate(graph, index);
            float y = GetKeyLabelYCoordinate(graph, index);

            return(new Rectangle(x, y, 1.0f, 1.0f));
        }
Exemplo n.º 13
0
        // Constructors =======================================//
        public Hud(GameScreen parent)
            : base(parent)
        {
            // Initialize Fields
            maxDamage = 100f;
            damageValue = 100f;
            resistanceValue = 100f;
            scoreValue = GlobalVariables.score;
            moneyValue = GlobalVariables.money;

            hudSprite = Engine.Content.Load<Texture2D>("Content\\Textures\\damage");
            SpriteFont font1 = Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24");

            // Initialize the Damage bars
            damageText = new Entity2D(hudSprite, new Vector2(15f, 30f), this.Parent);
            damageText.Rectangle = new Rectangle(0, 150, 260, 50);

            damageBox = new Entity2D(hudSprite, new Vector2(10f, 10f), this.Parent);
            damageBox.Rectangle = new Rectangle(0, 0, 260, 50);

            damageBarGlass = new Entity2D(hudSprite, new Vector2(10f, 20f), this.Parent);
            damageBarGlass.Rectangle = new Rectangle(0, 50, 260, 50);

            damageBar = new Entity2D(hudSprite, new Vector2(20f, 20f), this.Parent);
            damageBar.Rectangle = new Rectangle(0, 100, 238, 50);

            // Initialize the text
            Vector2 bgHudPos = new Vector2(0, Engine.Viewport.Height - 90);

            levelText = new EntityText(font1, new Vector2(10, 11), "Level:"+GlobalVariables.level.ToString(), this.Parent);
            levelText.Position = new Vector2(Engine.Viewport.Width-120, bgHudPos.Y + 15);

            scoreText = new EntityText(font1, new Vector2(10, 11), GlobalVariables.score.ToString(), this.Parent);
            scoreText.Position = new Vector2(230, bgHudPos.Y + 15);

            moneyText = new EntityText(font1, new Vector2(10, 35), GlobalVariables.money.ToString(), this.Parent);
            moneyText.Position = new Vector2(530, bgHudPos.Y + 15);

            hudSprite = Engine.Content.Load<Texture2D>("Content\\Textures\\moneyHUD");

            // Initialize the score and money fields
            scoreGlass = new Entity2D(hudSprite, new Vector2(10, bgHudPos.Y), this.Parent);
            scoreGlass.Rectangle = new Rectangle(0, 200, 300, 100);

            moneyGlass = new Entity2D(hudSprite, new Vector2(300, bgHudPos.Y), this.Parent);
            moneyGlass.Rectangle = new Rectangle(0, 200, 300, 100);

            score = new Entity2D(hudSprite, new Vector2(10, bgHudPos.Y), this.Parent);
            score.Rectangle = new Rectangle(0, 0, 300, 100);

            money = new Entity2D(hudSprite, new Vector2(300, bgHudPos.Y), this.Parent);
            money.Rectangle = new Rectangle(0, 100, 300, 100);

            // Initialize the black Texture
            black = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"),
                    new Vector2(0, 400), this.Parent);
            black.Rectangle = new Rectangle(0, 0, 800, 75);
            black.Position = bgHudPos;
            black.Alpha = 0.3f;
        }
Exemplo n.º 14
0
        private Vector2D GetPercentileEndPoint(Entity2D graph, int index)
        {
            float borderWidth = graph.DrawArea.Width * Graph.Border;
            float endX        = graph.DrawArea.Right - borderWidth;

            return(new Vector2D(endX, GetPercentileYCoordinate(graph, index)));
        }
Exemplo n.º 15
0
        private Vector2D GetPercentileStartPoint(Entity2D graph, int index)
        {
            float borderWidth = graph.DrawArea.Width * Graph.Border;
            float startX      = graph.DrawArea.Left + borderWidth;

            return(new Vector2D(startX, GetPercentileYCoordinate(graph, index)));
        }
Exemplo n.º 16
0
			protected Child() {} //ncrunch: no coverage

			public Child(Entity2D control)
			{
				Entity2D = control;
				Control = control as Control;
				WasEnabled = true;
				WasActive = true;
				WasVisible = true;
			}
Exemplo n.º 17
0
            }                                //ncrunch: no coverage

            public Child(Entity2D control)
            {
                Entity2D   = control;
                Control    = control as Control;
                WasEnabled = true;
                WasActive  = true;
                WasVisible = true;
            }
Exemplo n.º 18
0
		private static float GetKeyLabelXCoordinate(Entity2D graph, int index)
		{
			float borderWidth = graph.DrawArea.Width * Graph.Border;
			float left = graph.DrawArea.Left + borderWidth;
			int column = index % 6;
			float interval = (graph.DrawArea.Width - 2 * borderWidth) / 6;
			return left + column * interval;
		}
Exemplo n.º 19
0
        private float GetPercentileYCoordinate(Entity2D graph, int index)
        {
            float borderHeight = graph.DrawArea.Height * Graph.Border;
            float interval     = (graph.DrawArea.Height - 2 * borderHeight) / NumberOfPercentiles;
            float bottom       = graph.DrawArea.Bottom - borderHeight;

            return(bottom - index * interval);
        }
Exemplo n.º 20
0
        public void RotatedDrawAreaContainsWithNoRotation()
        {
            var entity = new Entity2D(new Rectangle(0.4f, 0.4f, 0.2f, 0.1f));

            Assert.IsTrue(entity.RotatedDrawAreaContains(new Vector2D(0.45f, 0.45f)));
            Assert.IsTrue(entity.RotatedDrawAreaContains(new Vector2D(0.55f, 0.45f)));
            Assert.IsFalse(entity.RotatedDrawAreaContains(new Vector2D(0.55f, 0.55f)));
        }
Exemplo n.º 21
0
			private static void UpdatePhysics(Entity2D entity, Data physics)
			{
				physics.Velocity += physics.Gravity * Time.Delta;
				entity.Center += physics.Velocity * Time.Delta;
				physics.Elapsed += Time.Delta;
				if (physics.Duration > 0.0f && physics.Elapsed >= physics.Duration)
					entity.IsActive = false;
			}
Exemplo n.º 22
0
 //ncrunch: no coverage start
 private void TranslateOnTouch(Entity2D ellipse)
 {
     Vector2D position = Resolve<Touch>().GetPosition(0);
     var drawArea = ellipse.DrawArea;
     drawArea.Left = position.X;
     drawArea.Top = position.Y;
     ellipse.DrawArea = drawArea;
 }
Exemplo n.º 23
0
        public void SettingDrawAreaWithoutInterpolationSetsLastDrawAreaAlso()
        {
            var entity = new Entity2D(Rectangle.One);

            Assert.AreEqual(Rectangle.One, entity.LastDrawArea);
            entity.SetWithoutInterpolation(Rectangle.HalfCentered);
            Assert.AreEqual(Rectangle.HalfCentered, entity.DrawArea);
            Assert.AreEqual(Rectangle.HalfCentered, entity.LastDrawArea);
        }
Exemplo n.º 24
0
        public void GetComponentsForEntityDebugger()
        {
            var           entityWithComponent = new Entity2D(Rectangle.HalfCentered);
            List <object> components          = entityWithComponent.GetComponentsForEditing();

            Assert.AreEqual(5, components.Count);
            Assert.AreEqual(Rectangle.HalfCentered, GetComponent <Rectangle>(components));
            Assert.IsTrue(GetComponent <bool>(components));
        }
Exemplo n.º 25
0
        protected void RemoveChild(Entity2D entity)
        {
            var child = children.FirstOrDefault(c => c.Entity2D == entity);

            if (child != null)
            {
                children.Remove(child);
            }
        }
Exemplo n.º 26
0
 public void Remove(Entity2D control)
 {
     controls.Remove(control);
     if (control is Control)
     {
         ((Control)control).SceneDrawArea = Rectangle.Unused;
     }
     control.Dispose();
 }
Exemplo n.º 27
0
			private bool CheckIfCanChangeCursorToMove(Entity2D control)
			{
				if (!control.DrawArea.Contains(mousePos))
					return false;
				service.Viewport.Window.SetCursorIcon(MoveCursor);
				CurrentCursor = MoveCursor;
				usedControl = (Control)control;
				return true;
			}
Exemplo n.º 28
0
		public virtual void Add(Entity2D control)
		{
			if (controls.Contains(control))
				return;
			if (control is Control)
				((Control)control).SceneDrawArea = DrawArea;
			controls.Add(control);
			control.IsActive = isShown;
		}
Exemplo n.º 29
0
        private static float GetKeyLabelXCoordinate(Entity2D graph, int index)
        {
            float borderWidth = graph.DrawArea.Width * Graph.Border;
            float left        = graph.DrawArea.Left + borderWidth;
            int   column      = index % 6;
            float interval    = (graph.DrawArea.Width - 2 * borderWidth) / 6;

            return(left + column * interval);
        }
Exemplo n.º 30
0
			private bool CheckIfCanChangeCursorToRotate(Entity2D control)
			{
				if (!controlProcessor.GizmoList[1].DrawArea.Contains(mousePos))
					return false;
				service.Viewport.Window.SetCursorIcon(RotateCursor);
				CurrentCursor = RotateCursor;
				usedControl = (Control)control;
				return true;
			}
Exemplo n.º 31
0
        //ncrunch: no coverage start
        private void TranslateOnTouch(Entity2D ellipse)
        {
            Vector2D position = Resolve <Touch>().GetPosition(0);
            var      drawArea = ellipse.DrawArea;

            drawArea.Left    = position.X;
            drawArea.Top     = position.Y;
            ellipse.DrawArea = drawArea;
        }         //ncrunch: no coverage end
Exemplo n.º 32
0
        private void RemoveSelectedControl(int index)
        {
            Entity2D entity2D = Scene.Controls[index];

            UIImagesInList.RemoveAt(index);
            Scene.Remove(entity2D);
            SetNewControlAfterDelete(index);
            UpdateControlListAfterDelete();
        }
Exemplo n.º 33
0
 protected void AddChild(Entity2D entity)
 {
     if (children.Any(c => c.Entity2D == entity))
     {
         return;
     }
     children.Add(new Child(entity));
     entity.RenderLayer = RenderLayer + children.Count;
 }
Exemplo n.º 34
0
		public void ApplyUpdateWithVelocity()
		{
			var entity2D = new Entity2D(new Rectangle(0, 0, 1, 1));
			entity2D.Add(velocity);
			entity2D.Start<Velocity2D.PositionUpdate>();
			var originalPosition = entity2D.Center;
			entity2D.Get<Velocity2D.Data>().Accelerate(2.0f, 90.0f);
			AdvanceTimeAndUpdateEntities();
			Assert.AreNotEqual(originalPosition, entity2D.Center);
		}
Exemplo n.º 35
0
		private Rectangle GetPercentileLabelDrawArea(Entity2D graph, int index)
		{
			float borderWidth = graph.DrawArea.Width * Graph.Border;
			float x = graph.DrawArea.Right + 2 * borderWidth;
			float borderHeight = graph.DrawArea.Height * Graph.Border;
			float interval = (graph.DrawArea.Height - 2 * borderHeight) / NumberOfPercentiles;
			float bottom = graph.DrawArea.Bottom - borderHeight;
			float y = bottom - index * interval;
			return new Rectangle(x, y - interval / 2, 1.0f, interval);
		}
Exemplo n.º 36
0
 private void AdjustLastFrameComponents(Entity2D tile)
 {
     float lastPositionX = tile.LastDrawArea.Left -
         (lastRenderingTopLeft.X - (int)data.RenderingTopLeft.X) * TileWidth;
     float lastPositionY = tile.LastDrawArea.Top -
         (lastRenderingTopLeft.Y - (int)data.RenderingTopLeft.Y) * TileHeight;
     tile.LastDrawArea = new Rectangle(lastPositionX, lastPositionY, tile.Size.Width,
         tile.Size.Height);
     tile.LastColor = tile.Color;
 }
Exemplo n.º 37
0
        public void RotatedDrawAreaContainsRotatedAroundItsCenter()
        {
            var entity = new Entity2D(new Rectangle(0.4f, 0.4f, 0.2f, 0.1f))
            {
                Rotation = 90
            };

            Assert.IsTrue(entity.RotatedDrawAreaContains(new Rectangle(0.4f, 0.4f, 0.2f, 0.1f).Center));
            Assert.IsFalse(entity.RotatedDrawAreaContains(new Vector2D(0.4f, 0.4f)));
        }
Exemplo n.º 38
0
        public void AddNewComponent()
        {
            var entity = new Entity2D(Rectangle.Zero);

            Assert.AreEqual(Rectangle.Zero, entity.DrawArea);
            Assert.AreEqual(Color.White, entity.Color);
            Assert.AreEqual(0, entity.NumberOfComponents);
            entity.Add(Size.Zero);
            Assert.AreEqual(1, entity.NumberOfComponents);
        }
Exemplo n.º 39
0
 private void CreateDisplayedImage()
 {
     if (renderExample != null)
     {
         renderExample.IsActive = false;
     }
     renderExample =
         new Sprite(new Material(ShaderFlags.Position2DColoredTextured, selectedImage),
                    Rectangle.HalfCentered);
 }
Exemplo n.º 40
0
            private void AddVertices(Entity2D entity)
            {
                var area = entity.DrawArea;

                foreach (Vector2D pos in entity.Get <Data>().LinePoints)
                {
                    vertices.Add(new VertexPosition2DColor(
                                     ScreenSpace.Current.ToPixelSpaceRounded(pos * area.Height + area.Center), entity.Color));
                }
            }
        public void ShowStartContent()
        {
            if (!ShowingContentManager)
            {
                return;
            }
            ClearEntities();
            int row    = 0;
            int column = 0;

            if (service.Viewport != null)
            {
                service.Viewport.CenterViewOn(Vector2D.Half);                 //ncrunch: no coverage
            }
            foreach (var content in DisplayContentList)
            {
                if (service.GetTypeOfContent(content.Name) == ContentType.Image ||
                    service.GetTypeOfContent(content.Name) == ContentType.SpriteSheetAnimation ||
                    service.GetTypeOfContent(content.Name) == ContentType.ImageAnimation)
                {
                    if (content.Name.Contains("Font"))
                    {
                        continue;
                    }
                    Entity2D entity = null;
                    try
                    {
                        entity = TryCreateEntityAndSetDrawAreaPosition(content, row, column);
                        if (UpdateRowAndColumn(ref column, ref row))
                        {
                            return;
                        }
                    }                     //ncrunch: no coverage start
                    catch (Exception)
                    {
                        if (entity != null)
                        {
                            entity.IsActive = false;
                        }
                    }                     //ncrunch: no coverage end
                }
                else if (service.GetTypeOfContent(content.Name) == ContentType.Material)
                {
                    try
                    {
                        var canUpdate = TryLoadMaterialCreateSpriteAndSetDrawAreaPosition(content, row, column);
                        if (canUpdate && UpdateRowAndColumn(ref column, ref row))
                        {
                            return;
                        }
                    }
                    catch (Exception) {}                     //ncrunch: no coverage
                }
            }
        }
Exemplo n.º 42
0
		public static void AnchorSelectedControls(Entity2D anchoringControl,
			List<Entity2D> selectedControls)
		{
			foreach (Entity2D attachingControl in selectedControls)
			{
				if (attachingControl == anchoringControl)
					continue;
				AnchorVertical((Control)anchoringControl, (Control)attachingControl);
				AnchorHorizontal((Control)anchoringControl, (Control)attachingControl);
			}
		}
        private Rectangle GetPercentileLabelDrawArea(Entity2D graph, int index)
        {
            float borderWidth  = graph.DrawArea.Width * Graph.Border;
            float x            = graph.DrawArea.Right + 2 * borderWidth;
            float borderHeight = graph.DrawArea.Height * Graph.Border;
            float interval     = (graph.DrawArea.Height - 2 * borderHeight) / NumberOfPercentiles;
            float bottom       = graph.DrawArea.Bottom - borderHeight;
            float y            = bottom - index * interval;

            return(new Rectangle(x, y - interval / 2, 1.0f, interval));
        }
Exemplo n.º 44
0
        public void LastColorReplacesColorComponentValue()
        {
            var entity = new Entity2D(Rectangle.Zero)
            {
                Color = Color.Red
            };

            Assert.AreEqual(Color.Red, entity.LastColor);
            entity.LastColor = Color.Blue;
            Assert.AreEqual(Color.Blue, entity.LastColor);
        }
Exemplo n.º 45
0
 public void UpdateMaterialsInViewPort(Entity2D selectedEntity2D)
 {
     Messenger.Default.Send(SelectedMaterial, "SetMaterial");
     Messenger.Default.Send(SelectedHoveredMaterial, "SetHoveredMaterial");
     Messenger.Default.Send(SelectedPressedMaterial, "SetPressedMaterial");
     Messenger.Default.Send(SelectedDisabledMaterial, "SetDisabledMaterial");
     SetEnabledButtons(selectedEntity2D != null ? selectedEntity2D.GetType().ToString() : "");
     Messenger.Default.Send("SetHorizontalAllignmentToNull", "SetHorizontalAllignmentToNull");
     Messenger.Default.Send("SetHorizontalAllignmentToNull", "SetHorizontalAllignmentToNull");
     Messenger.Default.Send("SetVerticalAllignmentToNull", "SetVerticalAllignmentToNull");
 }
Exemplo n.º 46
0
        private void AdjustLastFrameComponents(Entity2D tile)
        {
            float lastPositionX = tile.LastDrawArea.Left -
                                  (lastRenderingTopLeft.X - (int)data.RenderingTopLeft.X) * TileWidth;
            float lastPositionY = tile.LastDrawArea.Top -
                                  (lastRenderingTopLeft.Y - (int)data.RenderingTopLeft.Y) * TileHeight;

            tile.LastDrawArea = new Rectangle(lastPositionX, lastPositionY, tile.Size.Width,
                                              tile.Size.Height);
            tile.LastColor = tile.Color;
        }
Exemplo n.º 47
0
 internal void MoveImage(Vector2D mousePosition, Entity2D selectedEntity2D, bool isDragging,
     bool isSnappingToGrid, UIEditorScene scene)
 {
     if (selectedEntity2D == null || isDragging)
         return; //ncrunch: no coverage
     if (uiEditorViewModel.GridWidth == 0 || uiEditorViewModel.GridHeight == 0 ||
         !isSnappingToGrid || !scene.IsDrawingGrid)
         MoveImageWithoutGrid(mousePosition, selectedEntity2D);
     else
         MoveImageUsingTheGrid(mousePosition, selectedEntity2D, scene);
     UpdateOutLines(selectedEntity2D);
 }
Exemplo n.º 48
0
		public void SetControlSize(Entity2D control, Material material, UIEditorScene scene)
		{
			if (material.DiffuseMap.PixelSize.Width < 10 || material.DiffuseMap.PixelSize.Height < 10)
				return;
			if (scene.SceneResolution.AspectRatio > 1)
				control.DrawArea = new Rectangle(control.DrawArea.TopLeft,
					new Size(((material.DiffuseMap.PixelSize.Width / scene.SceneResolution.Width)),
						((material.DiffuseMap.PixelSize.Height / scene.SceneResolution.Width))));
			else
				control.DrawArea = new Rectangle(control.DrawArea.TopLeft,
					new Size(((material.DiffuseMap.PixelSize.Width / scene.SceneResolution.Height)),
						((material.DiffuseMap.PixelSize.Height / scene.SceneResolution.Height))));
		}
Exemplo n.º 49
0
 internal void UpdateOutLines(Entity2D selectedSprite)
 {
     ClearLines();
     if (selectedSprite == null)
         return;
     var drawArea = selectedSprite.DrawArea;
     OutLines[0].StartPoint = drawArea.TopLeft;
     OutLines[0].EndPoint = drawArea.TopRight;
     OutLines[1].StartPoint = drawArea.TopLeft;
     OutLines[1].EndPoint = drawArea.BottomLeft;
     OutLines[2].StartPoint = drawArea.BottomLeft;
     OutLines[2].EndPoint = drawArea.BottomRight;
     OutLines[3].StartPoint = drawArea.BottomRight;
     OutLines[3].EndPoint = drawArea.TopRight;
 }
Exemplo n.º 50
0
        // Initializor=============================================
        public override void Initialize()
        {
            // Initialize the keyboard
            keyboard = Engine.Services.GetService<KeyboardDevice>();

            fade = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"),
                    Vector2.Zero, this);

            // Initialize the GameOverText

            // Initialize the black texture
            background = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\intro"),
                                Vector2.Zero, this);

            base.Initialize();
        }
Exemplo n.º 51
0
		private void AddToBatch(Entity2D entity)
		{
			var points = entity.GetInterpolatedList<Vector2D>();
			if (points.Count < 3)
				return;
			if (points.Count > CircularBuffer.TotalMaximumVerticesLimit)
				throw new TooManyVerticesForPolygon(points.Count); //ncrunch: no coverage
			var color = entity.Color;
			if (offset + points.Count > vertices.Length)
				ResizeVertices(); //ncrunch: no coverage
			for (int num = 0; num < points.Count; num++)
				vertices[offset + num] =
					new VertexPosition2DColor(ScreenSpace.Current.ToPixelSpace(points[num]), color);
			BuildIndices(points.Count);
			offset += points.Count;
		}
Exemplo n.º 52
0
 public AnimationEditorViewModel(Service service)
 {
     this.service = service;
     metaDataCreator = new ContentMetaDataCreator();
     LoadedImageList = new ObservableCollection<string>();
     ImageList = new ObservableCollection<string>();
     AnimationList = new ObservableCollection<string>();
     Duration = 1;
     LoadImagesFromProject();
     LoadAnimationsFromProject();
     SetMessengers();
     var material = CreateDefaultMaterial2D();
     renderExample = new Sprite(material, new Rectangle(0.25f, 0.25f, 0.5f, 0.5f));
     AnimationName = "MyAnimation";
     CheckIfCanSave();
     CanSaveAnimation = false;
     SetButtonEnableStates();
 }
Exemplo n.º 53
0
		private void AddToBatch(Entity2D entity)
		{
			var color = entity.Get<OutlineColor>().Value;
			List<Vector2D> points = null;
			if (entity.Contains<List<Vector2D>>())
				points = entity.Get<List<Vector2D>>();
			if (points == null || points.Count <= 1)
			{
				points = new List<Vector2D>();
				points.Add(entity.DrawArea.TopLeft);
				points.Add(entity.DrawArea.BottomLeft);
				points.Add(entity.DrawArea.BottomRight);
				points.Add(entity.DrawArea.TopRight);
			}
			lastPoint = points[points.Count - 1];
			foreach (Vector2D point in points)
				AddLine(point, color);
		}
        // Initializor=============================================
        public override void Initialize()
        {
            // Initialize the keyboard
            keyboard = Engine.Services.GetService<KeyboardDevice>();
            mouseDevice = Engine.Services.GetService<MouseDevice>();
            mouseDevice.ResetMouseAfterUpdate = false;

            Texture2D texture;
            Texture2D level_finish_bg=Engine.Content.Load<Texture2D>("Content\\Textures\\level_finish_bg");

            hand = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\hand"),
                    new Vector2(mouseDevice.State.X, mouseDevice.State.Y), this);

            // Initialize the Game Text
            string level="LEVEL " + GlobalVariables.level.ToString() + " COMPLETE";
            titleText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"),
                new Vector2((Engine.Viewport.Width / 2) - 20, 200), level, this);

            string score = "Score: " + GlobalVariables.score.ToString()+" points.";
            scoreText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"),
                new Vector2((Engine.Viewport.Width / 2) - 120, 270), score, this);

            string money = "Money: " + GlobalVariables.money.ToString() + " Dirhams";
            moneyText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"),
                new Vector2((Engine.Viewport.Width / 2) - 120, 330), money, this);

            // Initialize the black texture
            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\next_btn");
            nextBtn = new Button(texture, new Vector2(475, 380), this);

            background = new Entity2D(level_finish_bg,
                                Vector2.Zero, this);
            background.Alpha = 0f;
            background.Position = new Vector2((Engine.Viewport.Width / 2) - (background.Texture.Width / 2),
                                             (Engine.Viewport.Height / 2) - (background.Texture.Height / 2));

            fade = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"),
                    Vector2.Zero, this);
            fade.Alpha = 0.4f;

            base.Initialize();
        }
Exemplo n.º 55
0
        public override void Initialize()
        {
            // Initialize the keyboard
            keyboard = Engine.Services.GetService<KeyboardDevice>();

            // Initialize Components
            Texture2D texture;

            black = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"),
                                Vector2.Zero, this);

            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\loadingText");
            loading = new Entity2D(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 493), this);

            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\Press_ENTER");
            pressEnter = new Entity2D(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 493), this);
            pressEnter.Visible = false;

            background = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\LoadScreen"), Vector2.Zero, this);

            base.Initialize();
        }
Exemplo n.º 56
0
        public override void Initialize()
        {
            // Initialize the keyboard
            keyboard = Engine.Services.GetService<KeyboardDevice>();
            mouseDevice = Engine.Services.GetService<MouseDevice>();
            mouseDevice.ResetMouseAfterUpdate=false;

            // Initialize Components
            Texture2D texture;

            black = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"),
                                Vector2.Zero, this);

            hand = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\hand"),
                                new Vector2(mouseDevice.State.X, mouseDevice.State.Y), this);

            // Initialize Buttons
            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuPlayBtn");
            menuPlay = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 270), this);

            //texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuOptionsBtn");
            //menuOptions = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 315), this);

            //texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuWhoBtn");
            //menuWho = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 360), this);

            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuQuitBtn");
            menuQuit = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 325), this);

            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\MenuTitle");
            menuTitle = new Entity2D(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 155), this);

            texture=Engine.Content.Load<Texture2D>("Content\\Textures\\MenuBall");
            menuBall = new Entity2D(texture, new Vector2(473,81), this);

            background = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\MenuBackground"), Vector2.Zero, this);

            base.Initialize();
        }
        // Initializor=============================================
        public override void Initialize()
        {
            // Initialize the keyboard
            keyboard = Engine.Services.GetService<KeyboardDevice>();

            fade = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"),
                    Vector2.Zero, this);

            // Initialize the GameOverText
            gameOverText = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\gameOver"),
                new Vector2((Engine.Viewport.Width / 2) - 40, (Engine.Viewport.Height / 2)), this);
            gameOverText.Position = new Vector2((Engine.Viewport.Width / 2) - (gameOverText.Texture.Width/2) ,
                                                (Engine.Viewport.Height / 2) - (gameOverText.Texture.Height / 2));
            // Initialize the black texture
            background = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\MenuBackground"),
                                Vector2.Zero, this);

            GlobalVariables.speedFactor = 0.10f;
            GlobalVariables.level = 1;
            GlobalVariables.score = 0;
            GlobalVariables.resistance = 0;

            base.Initialize();
        }
Exemplo n.º 58
0
			private static void UpdateDuration(Entity2D entity, Data physics)
			{
				physics.Elapsed += Time.Delta;
				if (physics.Duration > 0.0f && physics.Elapsed >= physics.Duration)
					entity.Dispose();
			}
Exemplo n.º 59
0
 private void AddVertices(Entity2D entity)
 {
     var area = entity.DrawArea;
     foreach (Vector2D pos in entity.Get<Data>().LinePoints)
         vertices.Add(new VertexPosition2DColor(
             ScreenSpace.Current.ToPixelSpaceRounded(pos * area.Height + area.Center), entity.Color));
 }
Exemplo n.º 60
0
		public void UpdateMaterialsInViewPort(Entity2D selectedEntity2D)
		{
			Messenger.Default.Send(SelectedMaterial, "SetMaterial");
			Messenger.Default.Send(SelectedHoveredMaterial, "SetHoveredMaterial");
			Messenger.Default.Send(SelectedPressedMaterial, "SetPressedMaterial");
			Messenger.Default.Send(SelectedDisabledMaterial, "SetDisabledMaterial");
			SetEnabledButtons(selectedEntity2D != null ? selectedEntity2D.GetType().ToString() : "");
			Messenger.Default.Send("SetHorizontalAllignmentToNull", "SetHorizontalAllignmentToNull");
			Messenger.Default.Send("SetHorizontalAllignmentToNull", "SetHorizontalAllignmentToNull");
			Messenger.Default.Send("SetVerticalAllignmentToNull", "SetVerticalAllignmentToNull");
		}