Exemple #1
0
            public void Draw(float3 center, float3 normal, float3 arm, float angle, Color color, bool delimit = false)
            {
                delimit &= angle < 2 * math.PI;
                var q          = quaternion.AxisAngle(normal, angle / _res);
                var currentArm = arm;

                if (delimit)
                {
                    _lines.Draw(center, center + currentArm, color);
                }
                for (var i = 0; i < _res; i++)
                {
                    var nextArm = math.mul(q, currentArm);
                    _lines.Draw(center + currentArm, center + nextArm, color);
                    currentArm = nextArm;
                }

                if (delimit)
                {
                    _lines.Draw(center, center + currentArm, color);
                }
                else
                {
                    _lines.Draw(0, 0, default);
                    _lines.Draw(0, 0, default);
                }
            }
Exemple #2
0
            public void Draw(float3 x, float3 v, Color color)
            {
                var x0 = x;
                var x1 = x + v;

                _lines.Draw(x0, x1, color);

                var length = Math.NormalizeWithLength(v, out var dir);

                Math.CalculatePerpendicularNormalized(dir, out var perp, out var perp2);
                float3 scale = length * 0.2f;

                _lines.Draw(x1, x1 + (perp - dir) * scale, color);
                _lines.Draw(x1, x1 - (perp + dir) * scale, color);
                _lines.Draw(x1, x1 + (perp2 - dir) * scale, color);
                _lines.Draw(x1, x1 - (perp2 + dir) * scale, color);

                perp  *= length;
                perp2 *= length;

                _lines.Draw(x0 + perp + perp2, x0 + perp - perp2, color);
                _lines.Draw(x0 + perp - perp2, x0 - perp - perp2, color);
                _lines.Draw(x0 - perp - perp2, x0 - perp + perp2, color);
                _lines.Draw(x0 - perp + perp2, x0 + perp + perp2, color);
            }
Exemple #3
0
            public void Draw(float3 point, float3 axis, float angle, Color color)
            {
                var    scale = Math.NormalizeWithLength(axis, out var dir);
                float3 arm;
                {
                    Math.CalculatePerpendicularNormalized(dir, out var perp1, out _);
                    arm = math.mul(quaternion.AxisAngle(perp1, angle), dir) * scale;
                }
                var q = quaternion.AxisAngle(dir, 2.0f * math.PI / Res);

                for (var i = 0; i < Res; i++)
                {
                    var nextArm = math.mul(q, arm);
                    _lines.Draw(point, point + arm, color);
                    _lines.Draw(point + arm, point + nextArm, color);
                    arm = nextArm;
                }
            }
        protected override unsafe void OnUpdate()
        {
            Entities
            .WithBurst()
            .ForEach((ObstacleTreeComponent tree, DrawComponent color, LocalToWorld ltw) =>
            {
                var lines = new Lines(tree.TreeRef.Count);
                var e     = tree.TreeRef.GetEnumerator(Allocator.Temp);
                while (e.MoveNext())
                {
                    var a = math.transform(ltw.Value, e.Current.Point.ToXxY());
                    var b = math.transform(ltw.Value, e.Current.Next->Point.ToXxY());
                    lines.Draw(a, b, color.Color);
                }
            })
            .Schedule();

            DotsNavRenderer.Handle = JobHandle.CombineDependencies(DotsNavRenderer.Handle, Dependency);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            //instantiation
            person person = new person();

            //call set on FirstName
            person.FirstName = "Ali";
            //class get on FirstName
            Console.WriteLine(person.FirstName);

            //passing values to constructor parameters
            _02_ConstructorAndDestructor myObj = new _02_ConstructorAndDestructor("myLastName");

            //Encapsulation
            WheeledVehicles car = new WheeledVehicles();

            car.Color = "Green";
            car.ChangeColor();


            //Polymorphism
            _01_ShapesExample[] shapes = new _01_ShapesExample[4];
            shapes[0] = new _01_ShapesExample();
            shapes[1] = new Circle();
            shapes[2] = new Square();
            foreach (_01_ShapesExample sh in shapes)
            {
                if (sh != null)
                {
                    sh.Draw();
                }
            }


            //Abstraction
            Lines line = new Lines();

            line.SayHi();
            line.Draw();
        }
Exemple #6
0
 public void Draw(float3 pos, quaternion rot, float size = 1)
 {
     _lines.Draw(pos, pos + math.mul(rot, new float3(size, 0, 0)), Color.red);
     _lines.Draw(pos, pos + math.mul(rot, new float3(0, size, 0)), Color.green);
     _lines.Draw(pos, pos + math.mul(rot, new float3(0, 0, size)), Color.blue);
 }
Exemple #7
0
            public void Draw(float3 size, float3 center, quaternion orientation, Color color)
            {
                var mat = math.float3x3(orientation);
                var x   = mat.c0 * size.x * 0.5f;
                var y   = mat.c1 * size.y * 0.5f;
                var z   = mat.c2 * size.z * 0.5f;
                var c0  = center - x - y - z;
                var c1  = center - x - y + z;
                var c2  = center - x + y - z;
                var c3  = center - x + y + z;
                var c4  = center + x - y - z;
                var c5  = center + x - y + z;
                var c6  = center + x + y - z;
                var c7  = center + x + y + z;

                _lines.Draw(c0, c1, color); // ring 0
                _lines.Draw(c1, c3, color);
                _lines.Draw(c3, c2, color);
                _lines.Draw(c2, c0, color);

                _lines.Draw(c4, c5, color); // ring 1
                _lines.Draw(c5, c7, color);
                _lines.Draw(c7, c6, color);
                _lines.Draw(c6, c4, color);

                _lines.Draw(c0, c4, color); // between rings
                _lines.Draw(c1, c5, color);
                _lines.Draw(c2, c6, color);
                _lines.Draw(c3, c7, color);
            }
Exemple #8
0
        public void draw()
        {
            Game1.game.spriteBatch.Begin();

            if (_isInPlay)
            {
                Game1.game.spriteBatch.DrawString(_font, "Score:" + _score, new Vector2(0, 20), Color.White, 0, Vector2.Zero, .5f, SpriteEffects.None, 0);
                Game1.game.spriteBatch.DrawString(_font, "Percent Multiplier:" + _percentMultiplier * 100 + "%", new Vector2(0, 0), Color.White, 0, Vector2.Zero, .5f, SpriteEffects.None, 0);
                Game1.game.spriteBatch.DrawString(_font, "Bases:" + _missileBases, new Vector2(Game1.game.GraphicsDevice.Viewport.Width - _font.MeasureString("Bases:" + _missileBases).X * .5f - 10f, 0), Color.White, 0, Vector2.Zero, .5f, SpriteEffects.None, 0);
                Game1.game.spriteBatch.DrawString(_font, "Cities:" + _city, new Vector2(Game1.game.GraphicsDevice.Viewport.Width - _font.MeasureString("Cities" + _city).X * .5f - 10f, 20), Color.White, 0, Vector2.Zero, .5f, SpriteEffects.None, 0);
            }

            _line.Draw(Game1.game.spriteBatch);
            _missileManager.Draw(Game1.game.spriteBatch, Game1.game.GraphicsDevice);


            for (int i = 0; i < _buildings.Length; i++)
            {
                if (_buildings[i] != null)
                {
                    _buildings[i].Draw(Game1.game.spriteBatch);
                }
            }

            if (_isInPlay)
            {
                _leftBaseCoolDown.Draw(_leftBase.GetRectangle.Width + 40, Game1.game.spriteBatch);
                _middleBaseCoolDown.Draw(_leftBase.GetRectangle.Width + 40, Game1.game.spriteBatch);
                _rightBaseCoolDown.Draw(_leftBase.GetRectangle.Width + 40, Game1.game.spriteBatch);
            }
            //draws the 3 bases
            _leftBase.Draw(Game1.game.spriteBatch);
            _rightBase.Draw(Game1.game.spriteBatch);
            _middleBase.Draw(Game1.game.spriteBatch);

            if (this._selectedArrow == 3)
            {
                Game1.game.spriteBatch.DrawString(_font, "Q", new Vector2(_leftBase.GetRectangle.Left, _leftBase.GetRectangle.Bottom + 10), Color.Red, 0, Vector2.Zero, .5f, SpriteEffects.None, 0);
            }
            else
            {
                Game1.game.spriteBatch.DrawString(_font, "Q", new Vector2(_leftBase.GetRectangle.Left, _leftBase.GetRectangle.Bottom + 10), Color.White, 0, Vector2.Zero, .5f, SpriteEffects.None, 0);
            }

            if (this._selectedArrow == 2)
            {
                Game1.game.spriteBatch.DrawString(_font, "W", new Vector2(_middleBase.GetRectangle.Left, _middleBase.GetRectangle.Bottom + 10), Color.Red, 0, Vector2.Zero, .5f, SpriteEffects.None, 0);
            }
            else
            {
                Game1.game.spriteBatch.DrawString(_font, "W", new Vector2(_middleBase.GetRectangle.Left, _middleBase.GetRectangle.Bottom + 10), Color.White, 0, Vector2.Zero, .5f, SpriteEffects.None, 0);
            }

            if (this._selectedArrow == 1)
            {
                Game1.game.spriteBatch.DrawString(_font, "E", new Vector2(_rightBase.GetRectangle.Left, _rightBase.GetRectangle.Bottom + 10), Color.Red, 0, Vector2.Zero, .5f, SpriteEffects.None, 0);
            }
            else
            {
                Game1.game.spriteBatch.DrawString(_font, "E", new Vector2(_rightBase.GetRectangle.Left, _rightBase.GetRectangle.Bottom + 10), Color.White, 0, Vector2.Zero, .5f, SpriteEffects.None, 0);
            }
            //draws overlay
            // spriteBatch.Draw(_uiRender.Texture, Vector2.Zero, Color.White);
            Game1.game.spriteBatch.End();
        }