Ejemplo n.º 1
0
        public void Update()
        {
            if (On == false)
            {
                _speed = _speedMax;
                _door.Update(new Vector2(0, _speed));
                {
                    if (_door.Boundary.Position.Y >= Position.Y)
                    {
                        _speed = 0;
                        _door.Boundary.Position = new Vector2(_door.Boundary.Position.X, Position.Y);
                    }
                }
            }
            else
            {
                _speed = -_speedMax;
                _door.Update(new Vector2(0, _speed));

                if (_door.Boundary.Position.Y <= Position.Y - 128)
                {
                    _speed = 0;
                    _door.Boundary.Position = new Vector2(_door.Boundary.Position.X, Position.Y - 128);
                }
            }
        }
Ejemplo n.º 2
0
        public void Update()
        {
            if (On == false)
            {
                Speed = 0;
            }
            else
            {
                Speed = SpeedMax;

                if (from == 0)
                {
                    _platform.Update(new LineSegmentF(Start, Nodes[0]).NormalizedWithZeroSolution() * Speed);

                    if (LineSegmentF.Lenght(Start, Nodes[0]) < LineSegmentF.Lenght(Start, _platform.Boundary.Origin))
                    {
                        _platform.Origin = Nodes[0];
                        from++;
                    }
                }

                if (from > 0 && from < Nodes.Count)
                {
                    _platform.Update(new LineSegmentF(Nodes[from - 1], Nodes[from]).NormalizedWithZeroSolution() * Speed);

                    if (LineSegmentF.Lenght(Nodes[from - 1], Nodes[from]) < LineSegmentF.Lenght(Nodes[from - 1], _platform.Boundary.Origin))
                    {
                        _platform.Origin = Nodes[from];
                        from++;
                    }
                }

                if (from == Nodes.Count)
                {
                    _platform.Update(new LineSegmentF(Nodes[from - 1], Start).NormalizedWithZeroSolution() * Speed);

                    if (LineSegmentF.Lenght(Nodes[from - 1], Start) < LineSegmentF.Lenght(Nodes[from - 1], _platform.Boundary.Origin))
                    {
                        _platform.Origin = Start;
                        from             = 0;
                    }
                }
            }
        }