Пример #1
0
 private void RandomLines()
 {
     Lines.Clear();
     for (var i = 0; i < Lines.MaxSize / 10; i++)
     {
         Lines.AddLine(new Vector2(UnityEngine.Random.value - 0.5f, UnityEngine.Random.value - 0.5f),
                       new Vector2(UnityEngine.Random.value - 0.5f, UnityEngine.Random.value - 0.5f));
     }
     Lines.UpdateShader();
 }
Пример #2
0
        protected override void Update(GameTime gameTime)
        {
            lines.Clear();
            Vector2 mpos = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
            Vector2 wpos = this.World.Camera2D.ConvertScreenToWorld(mpos);

            lines.AddLine(wpos, Vector2.Zero);
            base.Update(gameTime);
        }
Пример #3
0
        protected override void Update(GameTime gameTime)
        {
            if (mousepressed)
            {
                lines.isEnabled = true;
                lines.Clear();
                Vector2 mpos = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
                Vector2 wpos = this.World.Camera2D.ConvertScreenToWorld(mpos);

                lines.AddLine(wpos, ball.PhysicObject.Position);
            }
            base.Update(gameTime);
        }
Пример #4
0
        protected override void Update(GameTime gameTime)
        {
            if (mousepressed)
            {
                lines.isEnabled = true;
                lines.Clear();
                Vector2 mpos = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
                Vector2 wpos = this.World.Camera2D.ConvertScreenToWorld(mpos);

                lines.AddLine(wpos, ball.PhysicObject.Position);
            }

            ///handle camera movements =P
            Vector2       camMove       = Vector2.Zero;
            KeyboardState KeyboardState = Keyboard.GetState();

            if (KeyboardState.IsKeyDown(Keys.Up))
            {
                camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (KeyboardState.IsKeyDown(Keys.Down))
            {
                camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (KeyboardState.IsKeyDown(Keys.Left))
            {
                camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (KeyboardState.IsKeyDown(Keys.Right))
            {
                camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (KeyboardState.IsKeyDown(Keys.PageUp))
            {
                this.World.Camera2D.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * this.World.Camera2D.Zoom / 20f;
            }
            if (KeyboardState.IsKeyDown(Keys.PageDown))
            {
                this.World.Camera2D.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * this.World.Camera2D.Zoom / 20f;
            }
            if (camMove != Vector2.Zero)
            {
                this.World.Camera2D.MoveCamera(camMove);
            }

            base.Update(gameTime);
        }
Пример #5
0
        public virtual void Load(Vector2 StartingPoint, Vector2 EndingPoint, ContentManager Content)
        {
            this._endingPoint   = EndingPoint;
            this._startingPoint = StartingPoint;
            this._oldLocation   = StartingPoint;
            this._location      = StartingPoint;
            //the direction of missile
            _Direction = Vector2.Normalize(_endingPoint - _startingPoint) * _velocity;

            //_arrivalTime = (Vector2.Distance(_startingPoint, _endingPoint) / _velocity);
            _arrivialTime.Interval = new TimeSpan(0, 0, 0, 0, (int)((Vector2.Distance(_startingPoint, _endingPoint) / _velocity) * 16));
            _arrivialTime.Tick    += new EventHandler(missileArrived);
            _arrivialTime.Start();

            //adds a starting line
            Lines.AddLine(this._oldLocation, _location);
            //sets up a timer to tell when a missile will put down a line
            _timeBetweenLines.Interval = new TimeSpan(0, 0, 0, 0, 200);
            _timeBetweenLines.Tick    += new EventHandler(_TimeBetweenLineDraw);
            _timeBetweenLines.Start();
        }
Пример #6
0
 public void DrawLine(Vector3 a, Vector3 b)
 {
     currentLines.AddLine(a, b);
 }
Пример #7
0
 public virtual void Update()
 {
     _location += _Direction;
     Lines.AddLine(_location, _Direction + _location);
 }
Пример #8
0
 //puts down a line on the map
 void _TimeBetweenLineDraw(object sender, EventArgs e)
 {
     Lines.AddLine(_oldLocation, _location);
     _oldLocation = _location;
 }