Esempio n. 1
0
        public StubColumn(string name, Point startPoint, double length, double width, double kneeBraceLength, KneeBraceClipEnum braceLocation, ViewOrientationEnum viewOrientationEnum)
        {
            geometry = new GeometryManager();

            Name       = name;
            StartPoint = startPoint;
            Length     = length;
            Width      = width;

            BasePlateThickness  = .5;
            SplicePlateThicknes = .5;
            ColumnLength        = Length - BasePlateThickness - SplicePlateThicknes;
            KneeBraceLocation   = ColumnLength * (2f / 3f) - 3;
            BraceLocation       = braceLocation;
            KneeBraceLength     = kneeBraceLength;

            switch (viewOrientationEnum)
            {
            case ViewOrientationEnum.Front:
                LoadFrontView();
                break;

            case ViewOrientationEnum.Top:
                LoadTopView();
                break;

            case ViewOrientationEnum.Left:
                LoadLeftView();
                break;

            default:
                LoadFrontView();
                break;
            }
        }
Esempio n. 2
0
 public override void Draw(GeometryManager geometries)
 {
     foreach (var component in Components)
     {
         component.Draw(geometries);
     }
 }
Esempio n. 3
0
        public PlenumKneeBrace(string name, Point centerPoint, HorizontalOrientationEnum horizontalOrientation)
        {
            geometry = new GeometryManager();

            Name = name;

            CenterPoint = centerPoint;

            BottomLeftPoint  = new Point("Bottom Left Point", CenterPoint.X - Width / 2, CenterPoint.Y - Height / 2);
            BottomRightPoint = new Point("Bottom Right Point", BottomLeftPoint.X + Width, BottomLeftPoint.Y);
            TopRightPoint    = new Point("Top Right Point", BottomRightPoint.X, BottomLeftPoint.Y + Height);
            TopLeftPoint     = new Point("Top Left Point", BottomLeftPoint.X, TopRightPoint.Y);

            if (horizontalOrientation == HorizontalOrientationEnum.Right)
            {
                SecondHolePoint = MyMath.FindPointAtAngle(CenterPoint, 2, TriangleSide.C, 30, HorizontalOrientationEnum.Left, VerticalOrientationEnum.Down);
            }
            else
            {
                SecondHolePoint = MyMath.FindPointAtAngle(CenterPoint, 2, TriangleSide.C, 30, HorizontalOrientationEnum.Right, VerticalOrientationEnum.Down);
            }


            Points = new List <Point>
            {
                BottomLeftPoint,
                BottomRightPoint,
                TopRightPoint,
                TopLeftPoint,
                CenterPoint,
                SecondHolePoint
            };
        }
Esempio n. 4
0
        private void drawHud(GeometryManager geos)
        {
            var p = new Vector2(16f, 9f);

            var text = geos.HudText;

            text.Height = 0.5f;

            foreach (var economy in this.game.Economies)
            {
                text.Color = economy.Body.HealthPercentage > 0 ? Color.White : Color.Red;
                text.DrawString(p, string.Format("{0}", economy.Player.Name), 1);

                p += new Vector2(0, -0.5f);
            }

            foreach (var stat in this.stats)
            {
                stat.Draw(geos);
            }

            p = new Vector2(-16f, 9f - 0.5f * this.stats.Count());

            var damageReduction = (1 - this.economy.DamageFactor) * 100;

            text.DrawString(p, string.Format("Damage Reduction: {0:0.0}%", damageReduction));
        }
        public TopColumn(string name, Point startPoint, double length, double width)
        {
            geometry = new GeometryManager();

            Name       = name;
            StartPoint = startPoint;
            Length     = length;
            Width      = width;

            BasePlateThickness = .5;

            ColumnLength = Length - BasePlateThickness;

            BottomRightPoint  = new Point("Bottom Right Point", startPoint.X + Width, startPoint.Y);
            TopRightPoint     = new Point("Top Right Point", BottomRightPoint.X, BottomRightPoint.Y + length);
            TopLeftPoint      = new Point("Top Left Point", startPoint.X, TopRightPoint.Y);
            BottomCenterPoint = new Point("Bottom Center Point", (startPoint.X + Width) / 2, startPoint.Y);

            Points = new List <Point>
            {
                startPoint,
                BottomRightPoint,
                TopRightPoint,
                TopLeftPoint
            };
        }
 public ChunksEndlessHolder(Vector3Int position, ChunkTracker chunkTracker, GeometryManager geometryManager)
 {
     Position        = position;
     HierarchySize   = Chunk.Settings.MaxHierarchySize;
     ChunkTracker    = chunkTracker;
     GeometryManager = geometryManager;
 }
Esempio n. 7
0
        public FanRingClass(string name, Point centerPoint, double fanDiameter)
        {
            geometry = new GeometryManager();

            Name         = name;
            CenterPoint  = centerPoint;
            FanDiameter  = fanDiameter;
            RingLength   = fanDiameter + 1;
            FlangeLength = RingLength + 2;
            Depth        = 14;

            //Set overall points
            BottomLeftPoint   = new Point("Start Point", CenterPoint.X - FlangeLength / 2, centerPoint.Y - Depth);
            BottomRightPoint  = new Point("Bottom Right Point", BottomLeftPoint.X + FlangeLength, BottomLeftPoint.Y);
            TopRightPoint     = new Point("Top Right Point", BottomRightPoint.X, centerPoint.Y);
            TopLeftPoint      = new Point("Top Left Point", BottomLeftPoint.X, TopRightPoint.Y);
            BottomCenterPoint = new Point("Bottom Center Point", centerPoint.X, BottomLeftPoint.Y);

            //set piece points
            BottomFlangePoint = BottomLeftPoint;
            RingStartPoint    = new Point("Ring Start Point", BottomLeftPoint.X + 1, BottomLeftPoint.Y + .1344);
            TopFlangePoint    = new Point("Top Flange Point", BottomFlangePoint.X, BottomFlangePoint.Y + Depth - .1344);

            Points = new List <Point>
            {
                BottomLeftPoint,
                BottomRightPoint,
                TopRightPoint,
                TopLeftPoint
            };
        }
Esempio n. 8
0
    protected void RotateCanonTowardsTarget()
    {
        if (target != null)
        {
            float canonX  = turretHead.transform.position.x;
            float targetX = target.transform.position.x;
            float canonY  = turretHead.transform.position.y;
            float targetY = target.transform.position.y;

            float deltaX = targetX - canonX;
            float deltaY = targetY - canonY;

            //float angle = Mathf.Atan2(deltaY,deltaX);
            float angle = GeometryManager.GetRadAngleFromXY(deltaX, deltaY);

            //Debug.Log("Angle to meteor: " + angle);

            // To degree
            angle = angle * 180 / Mathf.PI - 90;
            // Take building spot angle into account
            angle -= buildingSpotAngleDeg;

            //Debug.Log("Angle: " + angle);

            turretHead.transform.localEulerAngles = new Vector3(angle, 0, 0);
        }
    }
Esempio n. 9
0
        public void Initialize()
        {
            ServiceRegistration.Get <ILogger>().Debug("SkinEnginePlugin: Registering IGeometryManager service");
            IGeometryManager geometryManager = new GeometryManager();

            ServiceRegistration.Set <IGeometryManager>(geometryManager);

            ServiceRegistration.Get <ILogger>().Debug("SkinEnginePlugin: Registering IInputManager service");
            ServiceRegistration.Set <IInputManager>(InputManager.Instance);

            ServiceRegistration.Get <ILogger>().Debug("SkinEnginePlugin: Registering IClipboardManager service");
            ServiceRegistration.Set <IClipboardManager>(ClipboardManager.Instance);

            ServiceRegistration.Get <ILogger>().Debug("SkinEnginePlugin: Registering ISuperLayerManager service");
            ServiceRegistration.Set <ISuperLayerManager>(SuperLayerManager.Instance);

            ServiceRegistration.Get <ILogger>().Debug("SkinEnginePlugin: Registering IScreenManager service");
            _screenManager = new ScreenManager();
            ServiceRegistration.Set <IScreenManager>(_screenManager);
            GraphicsDevice.ScreenManager = _screenManager;
            _screenManager.Startup();

            ServiceRegistration.Get <ILogger>().Debug("SkinEnginePlugin: Registering ISkinResourceManager service");
            ServiceRegistration.Set <ISkinResourceManager>(_screenManager.SkinResourceManager);
        }
Esempio n. 10
0
 public void Draw(GeometryManager geometries)
 {
     foreach (var particle in Particles)
     {
         particle.Draw(geometries);
     }
 }
Esempio n. 11
0
        private void drawHealthBar(GeometryManager geos)
        {
            var geo = geos.Primitives;

            var shape  = this.body.Shape;
            var center = shape.Center.Vector;
            var r      = shape.Radius.NumericValue + 0.2f;

            var p = this.body.HealthPercentage;

            const float barLength = 1.5f;
            var         barStart  = center + new Vector2(-0.5f * barLength, -r - 0.25f);

            geo.LineWidth = 0.075f;
            geo.Color     = Color.Gray;
            geo.DrawLine(barStart, barStart + new Vector2(barLength, 0));

            var healthColor = Color.FromHSVA(p.Squared() * GameMath.Pi * 2 / 3, 0.8f, 0.8f);

            geo.Color = healthColor;
            geo.DrawLine(barStart, barStart + new Vector2(barLength * p, 0));

            var text = geos.GameText;

            text.Color = healthColor;

            text.Height = 0.5f;
            text.DrawString(center + new Vector2(0, -r - 0.3f),
                            string.Format("{0:0}%", (int)(p * 100)), 0.5f);
        }
        static SpriteElementsInstanced()
        {
            graphicsDevice = Engine.Graphics.GraphicsDevice;
            spriteShader   = AssetManager.GetEffect("Relatus_RelatusEffect");
            spritePass     = spriteShader.Techniques[2].Passes[0];

            sharedGeometry = GeometryManager.GetShapeData(ShapeType.Square);
        }
Esempio n. 13
0
 protected internal Chunk(Vector3Int position, int hierarchySize, IChunkHolder parent, ChunkTracker chunkTracker, GeometryManager geometryManager)
 {
     Position        = position;
     HierarchySize   = hierarchySize;
     Parent          = parent;
     ChunkTracker    = chunkTracker;
     GeometryManager = geometryManager;
 }
Esempio n. 14
0
 protected UIScreenLayer(ScreenLayerCollection parent, GeometryManager geometries, float originX, float originY, bool flipY) : base(parent)
 {
     Geometries   = geometries;
     Screen       = Screen.GetCanvas();
     this.originX = originX;
     this.originY = originY;
     this.flipY   = flipY;
 }
Esempio n. 15
0
 void Awake()
 {
     if (instance != null)
     {
         Debug.LogError("More than one MeteorsManager in scene !"); return;
     }
     instance = this;
 }
Esempio n. 16
0
        public GameUI(ScreenLayerCollection parent, GeometryManager geometries, GameInstance gameInstance, InputManager inputManager) : base(parent)
        {
            var gameRunner = new GameRunner(gameInstance, inputManager);

            AddScreenLayerOnTop(new GameWorldScreenLayer(this, gameInstance, gameRunner, geometries));
            AddScreenLayerOnTop(new BuildingScreenLayer(this, gameInstance, geometries));
            AddScreenLayerOnTop(new GameOverScreenLayer(this, geometries, gameInstance));
        }
Esempio n. 17
0
        public ConsoleScreenLayer(ScreenLayerCollection parent, GeometryManager geometries, Logger logger) : base(parent, geometries, 0, 1, true)
        {
            this.logger = logger;

            bounds = new Bounds(new ScalingDimension(Screen.X), new FixedSizeDimension(Screen.Y, consoleHeight));
            AddComponent(new ConsoleTextComponent(Bounds.Within(bounds, padding, padding, padding + inputBoxHeight, padding), logger));
            AddComponent(consoleInput = new TextInput(Bounds.Within(bounds, consoleHeight - inputBoxHeight, padding, 0, padding)));
        }
Esempio n. 18
0
        public static VertexStream Create(GeometryManager manager, Type vertexType, int size,bool pointsprites, bool dynamic )
        {
            VertexStream newVertexStream = new VertexStream();
            if ( newVertexStream.Initialize( manager,vertexType,size,pointsprites,dynamic ) )
                return newVertexStream;

            return null;
        }
Esempio n. 19
0
        public static IndexStream Create(GeometryManager manager, int size, bool isLarge, bool dynamic )
        {
            IndexStream newStream = new IndexStream();
            if ( newStream.Initialize( manager,size,isLarge,dynamic ) )
                return newStream;

            return null;
        }
Esempio n. 20
0
        protected void InitManagers()
        {
            GeometryManager = new GeometryManager();
            MaterialManager = new MaterialManager();

            Scope.SetVariable("GeometryManager", GeometryManager);
            Scope.SetVariable("MaterialManager", MaterialManager);
        }
Esempio n. 21
0
 public BMDManager(Grendgine_Collada scene)
 {
     Skeleton = new SkinningManager(scene);
     Geometry = new GeometryManager(scene, Skeleton.Drw1Data, Skeleton.SkelData.BindShapeMatrix);
     Geometry.VertexData.TransformPositions(Skeleton.Drw1Data, Skeleton.SkelData.FlatHierarchy);
     Skeleton.SkelData.AssignBoneBoundingBoxes(Geometry.VertexData.Positions, Skeleton.Drw1Data);
     Materials = new MaterialManager(scene, Geometry.BatchData.Batches);
 }
Esempio n. 22
0
        public void DrawDebug(GeometryManager geometries, Level level)
        {
            var geo  = geometries.ConsoleBackground;
            var font = geometries.ConsoleFont;

            geo.LineWidth = HexagonSide * 0.05f;
            geo.Color     = Color.Orange * 0.3f;

            font.Height = HexagonSide;
            font.Color  = Color.Orange;

            const float w = HexagonDistanceX * 0.5f - 0.1f;
            const float h = HexagonDistanceY * 0.5f - 0.1f;

            var i = 0;

            foreach (var tile in updateFront)
            {
                var p = level.GetPosition(new Tile <TileInfo>(null, tile.X, tile.Y)).NumericValue;

                geo.DrawRectangle(p.X - w, p.Y - h, w * 2, h * 2);

                font.DrawString(p, $"{i}", 0.5f, 1f);
                i++;
            }

            font.Height = HexagonSide;
            font.Color  = Color.Yellow;

            foreach (var tile in directions)
            {
                var info = tile.Info;

                var p = level.GetPosition(new Tile <TileInfo>(null, tile.X, tile.Y)).NumericValue;

                var d = info.Direction.Vector() * HexagonWidth;


                if (!info.IsSink)
                {
                    var pointsTo = tile.Neighbour(info.Direction);

                    if (!pointsTo.Info.IsInvalid && pointsTo.Info.Distance >= info.Distance)
                    {
                        geo.Color = Color.Red * 0.3f;
                        geo.DrawRectangle(p.X - w, p.Y - h, w * 2, h * 2);
                    }

                    geo.Color = (pointsTo.Info.IsInvalid ? Color.Red : Color.DarkGreen) * 0.8f;
                    geo.DrawLine(p, p + d);
                }

                if (!info.IsInvalid)
                {
                    font.DrawString(p, $"{info.Distance}", 0.5f);
                }
            }
        }
Esempio n. 23
0
 public GameScreen(
     ScreenManager screenManager, GeometryManager geometryManager, GameState gameState
     ) : base(screenManager)
 {
     _camera     = new Camera3D();
     _gameState  = gameState;
     _game       = new Beardgame(gameState);
     _geometries = geometryManager;
 }
Esempio n. 24
0
    protected override void HandleMovements()
    {
        if (isActivated)
        {
            if (target != null)
            {
                // Set manual destination to target
                SetManualDestination(target.transform.position);

                if (manualDestination != null)
                {
                    // Check if path towards destination intersects with planet
                    if (!IsCloseEnoughToDestination() && (GeometryManager.instance.SegmentIntersectWithPlanet(gameObject.transform.position, manualDestination)))
                    {
                        //Debug.Log("HandleMovements | Setting a temp dest");
                        float spaceshipPosAngle    = GeometryManager.GetRadAngleFromXY(transform.position.x, transform.position.y);
                        float spaceshipPosDistance = GeometryManager.instance.GetDistanceFromPlanetCenter(transform.position);
                        //Debug.Log("spaceshipPosAngle: " + spaceshipPosAngle + " | spaceshipPosDistance: " + spaceshipPosDistance);
                        float manualDestPosAngle    = GeometryManager.GetRadAngleFromXY(manualDestination.x, manualDestination.y);
                        float manualDestPosDistance = GeometryManager.instance.GetDistanceFromPlanetCenter(manualDestination);
                        //Debug.Log("manualDestPosAngle: " + manualDestPosAngle + " | manualDestPosDistance: " + manualDestPosDistance);

                        // Mean angle
                        float meanAngle    = GeometryManager.GetMeanAngle(spaceshipPosAngle, manualDestPosAngle);
                        float meanDistance = Mathf.Max((manualDestPosAngle + manualDestPosDistance) / 2, 10);
                        //Debug.Log("meanAngle: " + meanAngle + " | meanDistance: " + meanDistance);

                        tempDestination = new Vector3(meanDistance * Mathf.Cos(meanAngle), meanDistance * Mathf.Sin(meanAngle), manualDestination.z);
                    }
                    else
                    {
                        // Set temp dest to manual dest
                        tempDestination = manualDestination;
                    }
                }

                if (!IsCloseEnoughToDestination())
                {
                    // Move towards destination
                    transform.position = Vector3.MoveTowards(transform.position, tempDestination, Time.deltaTime * movementSpeed);
                    RotateTowardsTempDest();
                }
                else
                {
                    if (target != null && IsTargetInRange())
                    {
                        RotateTowardsTarget();
                    }
                }
            }
            else
            {
                RotateAroundPlanet();
            }
        }
    }
Esempio n. 25
0
        public void Draw(GeometryManager geometries)
        {
            float lifetime = 1 - (float)(Lifetime / InitialLifetime);

            geometries.SpriteGeometry.Size  = SizeBehavior.Calculate(this, lifetime);
            geometries.SpriteGeometry.Color = new Color(
                ColorBehavior.Calculate(this, lifetime),
                (byte)(255 * AlphaBehavior.Calculate(this, lifetime)));
            geometries.SpriteGeometry.DrawSprite(Position.NumericValue);
        }
Esempio n. 26
0
    protected void RotateAroundPlanet()
    {
        float positionAngle       = GeometryManager.GetRadAngleFromGameObject(gameObject);
        float degreePositionAngle = GeometryManager.RadiansToDegrees(positionAngle);

        //Debug.Log("RotateAroundPlanet | PositionAngleRad [" + positionAngle + "] | DegreePositionAngle [" + degreePositionAngle + "]");

        transform.rotation = Quaternion.Euler(-90 - degreePositionAngle, 90, -90);
        transform.RotateAround(GameManager.instance.mainPlanet.transform.position, Vector3.forward, Time.deltaTime * idleRotationSpeed);
    }
Esempio n. 27
0
        public void CreateGeomManager(int elementID)
        {
            List <double[]> n = new List <double[]>();

            foreach (var line in nodeline)
            {
                double[] x = line.Coordinate;
                if (x == null)
                {
                    continue;
                }
                n.Add(x);
            }

            List <int[]> e = new List <int[]>();

            foreach (var line in elementline)
            {
                int[] x = null;
                switch (elementID)
                {
                case 2:
                {
                    x = line.Triangle;
                    break;
                }

                case 1:
                {
                    x = line.Edge;
                    break;
                }

                case 15:
                {
                    x = line.Vertex;
                    break;
                }
                }

                if (x == null)
                {
                    continue;
                }
                e.Add(x);
            }

            point   = ListToArray <double>(n);
            element = ListToArray <int>(e);

            _geomManager = new GeometryManager(point, element);
        }
Esempio n. 28
0
        public override void Draw(GeometryManager geometries)
        {
            geometries.ConsoleFont.Height = fontSize;
            geometries.ConsoleFont.Color  = Color.White;

            var height = Bounds.YStart + .5f * Bounds.Height;

            geometries.ConsoleFont.DrawString(new Vector2(Bounds.XStart, height), text, 0, .5f);

            var cursorXOffset = Bounds.XStart + geometries.ConsoleFont.StringWidth(text.Substring(0, cursorPosition));

            geometries.ConsoleFont.DrawString(new Vector2(cursorXOffset, height), cursorString, .5f, .5f);
        }
Esempio n. 29
0
        public override void Draw(GeometryManager geometries)
        {
            var geo = geometries.ConsoleBackground;

            geo.Color = Color.GrayScale(60);
            if (BuildManager != null)
            {
                geo.Color = geo.Color.WithAlpha((float)BuildManager.CurrentProgressFraction * .5f + .5f).Premultiplied;
            }
            geo.DrawRectangle(Position.NumericValue - Vector2.One * .3f, Vector2.One * .6f);

            base.Draw(geometries);
        }
Esempio n. 30
0
        public override void Draw(GeometryManager geometries)
        {
            var geo = geometries.ConsoleBackground;

            geo.Color = Color.DarkRed;
            geo.DrawRectangle(Position.NumericValue - Vector2.One * .25f, Vector2.One * .5f);

            var p = Health / (float)Blueprint.Health;

            geo.Color = Color.DarkGray;
            geo.DrawRectangle(Position.NumericValue - new Vector2(0.5f), new Vector2(1, 0.1f));
            geo.Color = Color.FromHSVA(Interpolate.Lerp(Color.Red.Hue, Color.Green.Hue, p), 0.8f, 0.8f);
            geo.DrawRectangle(Position.NumericValue - new Vector2(0.5f), new Vector2(1 * p, 0.1f));
        }
Esempio n. 31
0
        public StartScreen(ScreenLayerCollection parent, GeometryManager geometries, Logger logger, InputManager inputManager)
            : base(parent, geometries)
        {
            this.logger       = logger;
            this.inputManager = inputManager;

            AddComponent(new Menu(
                             Bounds.AnchoredBox(Screen, BoundsAnchor.End, BoundsAnchor.End, new Vector2(220, 200), -25 * Vector2.One),
                             new Func <Bounds, FocusableUIComponent> []
            {
                bounds => new Button(bounds, startServerLobby, "Start lobby", 48, .5f),
                bounds => new Button(bounds, startConnect, "Join lobby", 48, .5f)
            }));
        }
Esempio n. 32
0
    public void BuildBuilding()
    {
        if (selectedBuilding != null)
        {
            float buildingSpotAngle_rad = chosenBuildingSlot.GetComponent <BuildingSlot>().angleRad;
            float buildingSpotAngle_deg = GeometryManager.RadiansToDegrees(buildingSpotAngle_rad);

            Vector3 instantiationPosition = chosenBuildingSlot.transform.position;
            // Instantiate satellite slighly in front of building slot
            if (selectedBuilding.buildingLocationType == BuildingType.BuildingLocationType.Disks)
            {
                instantiationPosition += new Vector3(0f, 0f, -10f);
            }
            GameObject instantiatedBuilding = Instantiate(selectedBuilding.prefab, instantiationPosition, Quaternion.Euler(0f, 0f, buildingSpotAngle_deg));
            buildingList.Add(instantiatedBuilding);
            Building b = instantiatedBuilding.GetComponent <Building>();
            b.buildingType         = selectedBuilding;
            b.buildingSpotAngleRad = buildingSpotAngle_rad;
            b.buildingSpotAngleDeg = buildingSpotAngle_deg;
            b.currentTier          = 1;
            //instantiatedBuilding.GetComponent<Building>().energyConsumption = selectedBuilding.energyConsumption;
            b.buildingSpot = chosenBuildingSlot;
            chosenBuildingSlot.GetComponent <BuildingSlot>().SetBuilding(laserTurretPrefab.GetComponent <LaserTurret>());
            instantiatedBuilding.transform.SetParent(chosenBuildingSlot.transform);
            //Debug.Log("New building instantiated !");

            // Building type lists
            if (selectedBuilding.name == "Recycling Station")
            {
                InfrastructureManager.instance.recyclingStationsList.Add(instantiatedBuilding);
            }
            else if (selectedBuilding.name == "Spaceport")
            {
                InfrastructureManager.instance.SetSpaceport(instantiatedBuilding);
            }

            // Add Info Canvas on building
            AddInfoCanvasOnBuilding(instantiatedBuilding);

            // Distribute the available energy across all buildings
            EnergyPanel.instance.UpdateEnergyProductionAndConsumption();

            // Refresh population effects
            PopulationManager.instance.ApplyPopulationEffects();

            // Transmit info to BuildingShopManager
            BuildingShopManager.instance.OnBuildingBuilt();
        }
    }
        public void Draw(GeometryManager geos)
        {
            var text = geos.HudText;
            text.Height = 0.5f;

            var p = new Vector2(-16f, 9f - 0.5f * (int)this.value);

            var investmentBarBuilder = new StringBuilder(13);

            text.Color = Color.White;
            text.DrawString(p, this.value.ToString());

            var stats = this.economy[this.value];

            text.Color = Color.White;
            text.DrawString(p + new Vector2(3, 0), stats.Value.ToString("0.00"));

            var income = stats.ReturnFactor * stats.Investment * this.economy.Income / this.economy.TotalInvestment;

            text.Color = Color.Gray;
            text.DrawString(p + new Vector2(4.25f, 0), string.Format("+{0:0.000}", income));

            var investment = stats.Investment;
            var barBefore = (int)(investment * 10);

            investmentBarBuilder.Clear();
            investmentBarBuilder.Append('<');
            investmentBarBuilder.Append('-', barBefore);
            investmentBarBuilder.Append('#');
            investmentBarBuilder.Append('-', 10 - barBefore);
            investmentBarBuilder.Append('>');

            text.Color = Color.White;
            text.DrawString(p + new Vector2(6f, 0), investmentBarBuilder.ToString());

            text.Color = Color.Gray;
            text.DrawString(p + new Vector2(9.5f, 0), this.controlString);
        }
        public override void Draw(GeometryManager geos)
        {
            var geo = geos.Primitives;

            geo.Color = Color.Lime * 0.5f;
            geo.LineWidth = 0.1f;

            var shape = this.body.Shape;
            var center = shape.Center.Vector;

            var r = shape.Radius.NumericValue + 0.2f;

            geo.DrawCircle(center, r, false);

            var dVector = this.aimDirection.Vector;

            geo.LineWidth = 0.05f;
            geo.DrawLine(center + dVector * r, center + dVector * (r + 0.25f));

            this.drawHealthBar(geos);
            this.drawProjectilePathPreview(geo);
            this.drawHud(geos);
        }
Esempio n. 35
0
        private bool Initialize(GeometryManager manager,int size, bool isLarge, bool dynamic)
        {
            try
            {
                D3d.Pool d3dPool = D3d.Pool.Managed;
                D3d.Usage d3dUsage = D3d.Usage.WriteOnly;

                if( dynamic )
                {
                    d3dUsage |= D3d.Usage.Dynamic;
                }

                d3dManager = manager;
                d3dIndexSize = size;
                d3dIsLarge = isLarge;

                d3dIndexBuffer = new D3d.IndexBuffer( this.Type,d3dIndexSize,manager.Device.D3dDevice,
                    d3dUsage,d3dPool );

                return true;
            }
            catch (D3d.InvalidCallException e)
            {
                log.Warning("Unable to create index stream: {0}", e.Message);
            }
            catch (D3d.OutOfVideoMemoryException e)
            {
                log.Warning("Unable to create index stream: {0}", e.Message);
            }
            catch (OutOfMemoryException e)
            {
                log.Warning("Unable to create index stream: {0}", e.Message);
            }

            return false;
        }
Esempio n. 36
0
        private bool Initialize(GeometryManager manager, Type vertexType, int size,bool pointsprites,bool dynamic )
        {
            if (IsTypeValid(vertexType))
            {
                try
                {
                    D3d.Pool d3dPool = D3d.Pool.Managed;
                    D3d.Usage d3dUsage = D3d.Usage.WriteOnly;

                    if ( dynamic )
                    {
                        d3dUsage |= D3d.Usage.Dynamic;
                    }

                    if (pointsprites)
                    {
                        d3dUsage |= D3d.Usage.Points;
                    }

                    d3dManager      = manager;
                    d3dVertexType   = vertexType;
                    d3dVertexSize   = size;

                    d3dVertexBuffer = new D3d.VertexBuffer( vertexType,
                                                            size,
                                                            manager.Device.D3dDevice,
                                                            d3dUsage,
                                                            D3d.VertexFormats.None,
                                                            d3dPool);

                    return true;
                }
                catch (D3d.InvalidCallException e)
                {
                    log.Warning("Unable to create vertex stream: {0}", e.Message);
                }
                catch (D3d.OutOfVideoMemoryException e)
                {
                    log.Warning("Unable to create vertex stream: {0}", e.Message);
                }
                catch (OutOfMemoryException e)
                {
                    log.Warning("Unable to create vertex stream: {0}", e.Message);
                }
               }

               return false;
        }
        private void drawHealthBar(GeometryManager geos)
        {
            var geo = geos.Primitives;

            var shape = this.body.Shape;
            var center = shape.Center.Vector;
            var r = shape.Radius.NumericValue + 0.2f;

            var p = this.body.HealthPercentage;

            const float barLength = 1.5f;
            var barStart = center + new Vector2(-0.5f * barLength, -r - 0.25f);

            geo.LineWidth = 0.075f;
            geo.Color = Color.Gray;
            geo.DrawLine(barStart, barStart + new Vector2(barLength, 0));

            var healthColor = Color.FromHSVA(p.Squared() * GameMath.Pi * 2 / 3, 0.8f, 0.8f);

            geo.Color = healthColor;
            geo.DrawLine(barStart, barStart + new Vector2(barLength * p, 0));

            var text = geos.GameText;

            text.Color = healthColor;

            text.Height = 0.5f;
            text.DrawString(center + new Vector2(0, -r - 0.3f),
                string.Format("{0:0}%", (int)(p * 100)), 0.5f);
        }
 public override void Draw(GeometryManager geos)
 {
 }
Esempio n. 39
0
        private bool Initialize(System.Windows.Forms.Control renderWindow )
        {
            d3dSettings     = new Settings();
            d3dDevice       = DeviceUtility.CreateDevice( d3dSettings,renderWindow );

            if (d3dDevice != null)
            {
                d3dCapabilities         = new Capabilities(this);

                // Create subsystems.
                d3dPrimaryFrameBuffer   = FrameBuffer.Create( this );
                d3dGeometryManager      = GeometryManager.Create( this );
                d3dTextureManager       = TextureManager.Create(this);
                d3dQueryManager         = QueryManager.Create(this);
                d3dCompiler             = Compiler.Create(this);

                return true;
            }
            return false;
        }
        private void drawHud(GeometryManager geos)
        {
            var p = new Vector2(16f, 9f);

            var text = geos.HudText;
            text.Height = 0.5f;

            foreach (var economy in this.game.Economies)
            {
                text.Color = economy.Body.HealthPercentage > 0 ? Color.White : Color.Red;
                text.DrawString(p, string.Format("{0}", economy.Player.Name), 1);

                p += new Vector2(0, -0.5f);
            }

            foreach (var stat in this.stats)
            {
                stat.Draw(geos);
            }

            p = new Vector2(-16f, 9f - 0.5f * this.stats.Count());

            var damageReduction = (1 - this.economy.DamageFactor) * 100;

            text.DrawString(p, string.Format("Damage Reduction: {0:0.0}%", damageReduction));
        }