Esempio n. 1
0
        internal void UpdateDrawNode()
        {
            var         bounds         = VisibleBoundsWorldspace;
            const float LINE_WIDTH     = 20f;
            const float BAR_WIDTH      = 40f;
            const float BAR_BOX_HEIGHT = BAR_WIDTH + LINE_WIDTH * 2;
            float       barBoxWidth    = bounds.Size.Width - MULTIPL_BOX_SIZE.Width;

            DrawNode.Clear();
            // draw the combo bar box and the multiplier box
            DrawNode.DrawRect(new CCRect(0, 0, barBoxWidth, BAR_BOX_HEIGHT), CCColor4B.White);
            DrawNode.DrawRect(new CCRect(barBoxWidth, 0, MULTIPL_BOX_SIZE.Width, MULTIPL_BOX_SIZE.Height), CCColor4B.White);
            DrawNode.DrawRect(new CCRect(barBoxWidth + LINE_WIDTH, LINE_WIDTH, MULTIPL_BOX_SIZE.Width - 2 * LINE_WIDTH, MULTIPL_BOX_SIZE.Height - 2 * LINE_WIDTH), CCColor4B.Black);
            // draw the combo bar
            CCRect barFull = new CCRect(LINE_WIDTH, LINE_WIDTH, barBoxWidth - 2 * LINE_WIDTH, BAR_WIDTH);
            CCRect bar     = new CCRect(LINE_WIDTH, LINE_WIDTH, barFull.Size.Width * MultiplProgressVisible, BAR_WIDTH);
            // choose the color
            var barColor       = MultiplierBarColor(Multiplier);
            var barColorBehind = MultiplierBarColor(Multiplier - 1);

            DrawNode.DrawRect(barFull, barColorBehind);
            DrawNode.DrawRect(bar, barColor);
            //DrawNode.DrawPolygon(new CCPoint[] { CCPoint.Zero, new CCPoint(barBoxWidth, 0), new CCPoint(barBoxWidth, 0), new CCPoint(barBoxWidth, BAR_BOX_HEIGHT), new CCPoint(0, BAR_BOX_HEIGHT) }, 4, CCColor4B.Transparent, LINE_WIDTH, CCColor4B.White);    // bar box
            //DrawNode.DrawPolygon(new CCPoint[] { new CCPoint(barBoxWidth, 0), new CCPoint(bounds.Size.Width, 0), new CCPoint(bounds.Size.Width, MULTIPL_BOX_SIZE.Height), new CCPoint(barBoxWidth, MULTIPL_BOX_SIZE.Height) }, 4, CCColor4B.Transparent, LINE_WIDTH, CCColor4B.White);    // multiplier box
        }
Esempio n. 2
0
        public override void Update(float dt)
        {
            base.Update(dt);
            if (!RedrawRequested)
            {
                return;
            }
            RedrawRequested = false;

            DrawNode.Clear();
            List <HexagonNode> handledPositions = new List <HexagonNode>();

            foreach (var structure in World.StructureManager)
            {
                if (structure is Construction)
                {
                    continue;
                }
                handledPositions.Add(structure.Position);
                foreach (var accessibleNode in structure.Position.GetAccessibleAdjacentHexagonNodes(World.HexagonManager).Where(h => !handledPositions.Contains(h)))
                {
                    var p1    = structure.Position.GetWorldPosition(World.GameSettings.LayoutSettings.HexagonRadius, World.GameSettings.LayoutSettings.HexagonMargin);
                    var p2    = accessibleNode.GetWorldPosition(World.GameSettings.LayoutSettings.HexagonRadius, World.GameSettings.LayoutSettings.HexagonMargin);
                    var color = World.GameSettings.VisualSettings.ColorCollection.EdgeBackground;
                    DrawNode.DrawSegment(p1, p2, World.GameSettings.VisualSettings.EdgeThickness, color);
                }
            }
        }
Esempio n. 3
0
        protected override void AddedToScene()
        {
            base.AddedToScene();
            DrawNode.Clear();

            var blocks = HelpText.Split(new[] { "$" }, StringSplitOptions.RemoveEmptyEntries);

            var   rects  = new CCRect[blocks.Length];
            float margin = VisibleBoundsWorldspace.Size.Width / 1080 * 10;
            float width  = VisibleBoundsWorldspace.Size.Width - margin * 2;
            float height = VisibleBoundsWorldspace.Size.Height / blocks.Length;


            for (int i = 0; i < blocks.Length; i++)
            {
                float x = VisibleBoundsWorldspace.MinX + margin;
                float y = VisibleBoundsWorldspace.MaxY - margin - height * (i + 1);
                rects[i] = new CCRect(x, y, width, height);
            }

            for (int i = 0; i < rects.Length; i++)
            {
                DrawNode.DrawText(rects[i].Center, blocks[i].Replace("$", ""), Font.ArialFonts[VisualSettings.HelpTextFontSize], rects[i].Size * 0.95f);
            }
        }
Esempio n. 4
0
 private void Render()
 {
     DrawNode.Clear();
     foreach (var hexagon in World.HexagonManager)
     {
         RenderHexagon(hexagon);
     }
 }
Esempio n. 5
0
        private void Render()
        {
            DrawNode.Clear();
            var settings = World.GameSettings;

            foreach (var structure in Structures)
            {
                structure.Render(DrawNode, structure.Position.GetWorldPosition(settings.LayoutSettings.HexagonRadius, settings.LayoutSettings.HexagonMargin), settings.VisualSettings.BuildingRadius);
            }
        }
Esempio n. 6
0
        internal void SetSize(CCSize size)
        {
            ContentSize = size;
            DrawNode.Clear();
            DrawNode.DrawRect(new CCRect(0, 0, size.Width, size.Height), CCColor4B.White);
            DrawNode.DrawRect(new CCRect(BORDER, BORDER, size.Width - 2 * BORDER, size.Height - 2 * BORDER), CCColor4B.Black);
            var mathSize = new CCSize(size.Width - 12 * BORDER, size.Height - 12 * BORDER);

            MathSprite.FitToBox(mathSize);
            MathSprite.Position = (CCPoint)ContentSize / 2;
        }
Esempio n. 7
0
 private void Render()
 {
     DrawNode.Clear();
     foreach (var kvp in Packages)
     {
         var package  = kvp.Key;
         var radius   = World.GameSettings.VisualSettings.ResourcePackageRadius;
         var position = package.GetWorldPosition(World.GameSettings.LayoutSettings.HexagonRadius, World.GameSettings.LayoutSettings.HexagonMargin);
         //DrawNode.DrawCircle(position, radius, World.GameSettings.VisualSettings.ColorCollection.ResourcePackageBackground, 3, World.GameSettings.VisualSettings.ColorCollection.ResourcePackageBorder);
         kvp.Value.Position    = position;
         kvp.Value.ContentSize = new CCSize(radius * 2, radius * 2) * 1f;
     }
 }
Esempio n. 8
0
        private void Render()
        {
            {
                DrawNode.Clear();
                var   visualSettings = World.GameSettings.VisualSettings;
                int   fontSize       = visualSettings.StatisticsFontSize;
                var   spriteSize     = fontSize * 2f;
                var   margin         = 10;
                float x  = visualSettings.StatisticsMargin;
                float y0 = VisibleBoundsWorldspace.MaxY - visualSettings.StatisticsMargin - spriteSize * 0 - margin * 0;
                float y1 = VisibleBoundsWorldspace.MaxY - visualSettings.StatisticsMargin - spriteSize * 1 - margin * 1;
                float y2 = VisibleBoundsWorldspace.MaxY - visualSettings.StatisticsMargin - spriteSize * 2 - margin * 2;
                float y3 = VisibleBoundsWorldspace.MaxY - visualSettings.StatisticsMargin - spriteSize * 3 - margin * 3;

                var resourceManager = World.GlobalResourceManager;

                var s0 = resourceManager.EnvironmentResource.Energy.ToString(CultureInfo.InvariantCulture);
                var s1 = resourceManager.Knowledge.Knowledge1.ToString();
                var s2 = resourceManager.Knowledge.Knowledge2.ToString();
                var s3 = resourceManager.Knowledge.Knowledge3.ToString();
                DrawNode.DrawText(x + spriteSize - spriteSize / 8 + (float)Sqrt(s0.Length) / 1.5f * fontSize, y0, s0, Font.ArialFonts[fontSize], CCSize.Zero);
                DrawNode.DrawText(x + spriteSize - spriteSize / 8 + (float)Sqrt(s1.Length) / 1.5f * fontSize, y1, s1, Font.ArialFonts[fontSize], CCSize.Zero);
                DrawNode.DrawText(x + spriteSize - spriteSize / 8 + (float)Sqrt(s2.Length) / 1.5f * fontSize, y2, s2, Font.ArialFonts[fontSize], CCSize.Zero);
                DrawNode.DrawText(x + spriteSize - spriteSize / 8 + (float)Sqrt(s3.Length) / 1.5f * fontSize, y3, s3, Font.ArialFonts[fontSize], CCSize.Zero);

                DrawNode.DrawCircle(new CCPoint(x, y0), spriteSize / 2, CCColor4B.White);
                DrawNode.DrawCircle(new CCPoint(x, y1), spriteSize / 2, CCColor4B.White);
                DrawNode.DrawCircle(new CCPoint(x, y2), spriteSize / 2, CCColor4B.White);
                DrawNode.DrawCircle(new CCPoint(x, y3), spriteSize / 2, CCColor4B.White);

                EnergySprite.Position     = new CCPoint(x, y0);
                Knowledge1Sprite.Position = new CCPoint(x, y1);
                Knowledge2Sprite.Position = new CCPoint(x, y2);
                Knowledge3Sprite.Position = new CCPoint(x, y3);

                EnergySprite.ContentSize = Knowledge1Sprite.ContentSize = Knowledge2Sprite.ContentSize = Knowledge3Sprite.ContentSize = new CCSize(spriteSize * 0.8f, spriteSize * 0.8f);
            }
            {
                var colorCollection = World.GameSettings.VisualSettings.ColorCollection;
                var margin          = World.GameSettings.VisualSettings.StatisticsMargin;
                var radius          = 45;
                var x        = VisibleBoundsWorldspace.MaxX - margin;
                var y        = VisibleBoundsWorldspace.MaxY - margin;
                var position = new CCPoint(x, y);
                DrawNode.DrawCircle(position, radius, colorCollection.FastForewardBackground, 2, colorCollection.FastForewardBorder);
                FastForewardSprite.Color       = new CCColor3B(World.GameSpeed.GetColor(colorCollection));
                FastForewardSprite.Position    = position + new CCPoint(2, 0);
                FastForewardSprite.ContentSize = new CCSize(radius * 2, radius * 2) * 0.8f;
            }
            RenderEnvironmentValues();
        }
Esempio n. 9
0
 public void Clear()
 {
     DrawNode.Clear();
     foreach (var sprite in Sprites)
     {
         RemoveChild(sprite, false);
     }
     Cleanup();
     Sprites.Clear();
     foreach (var label in Labels.Keys)
     {
         label.Visible = false;
     }
     UsageIndex = 0;
 }
Esempio n. 10
0
 public override void Update(float dt)
 {
     base.Update(dt);
     if (!RedrawRequested)
     {
         return;
     }
     DrawNode.Clear();
     foreach (var button in Buttons.OfType <BuildButton>())
     {
         var position = button.Position;
         var delta    = GameSettings.VisualSettings.BuildButtonRadius * 0.5f;
         DrawNode.DrawCircle(position, GameSettings.VisualSettings.BuildButtonRadius, GameSettings.VisualSettings.ColorCollection.BuildButtonBackground, GameSettings.VisualSettings.StructureBorderThickness, GameSettings.VisualSettings.ColorCollection.BuildButtonBorder);
         DrawNode.DrawSegment(position - CCPoint.AnchorUpperLeft * delta, position + CCPoint.AnchorUpperLeft * delta, GameSettings.VisualSettings.PlusCrossRadius, GameSettings.VisualSettings.ColorCollection.BuildButtonForeground);
         DrawNode.DrawSegment(position - CCPoint.AnchorLowerRight * delta, position + CCPoint.AnchorLowerRight * delta, GameSettings.VisualSettings.PlusCrossRadius, GameSettings.VisualSettings.ColorCollection.BuildButtonForeground);
     }
 }