Crash() public method

public Crash ( ) : void
return void
Ejemplo n.º 1
0
        public override void Update(CanvasContext2D context)
        {
            foreach (Npc npc in _npcs)
            {
                npc.Object.Visible = false;
                npc.Distance      += npc.Speed * _level.DeltaTime;

                float distance = npc.Distance - _level.Position;

                if (distance <= 0 || distance > _level.DistanceTable[RaceLevel.Lines])
                {
                    continue;
                }

                float scale = 3500 / distance;

                float y = 600 + (1000000 / distance) - 300;
                float x = 425 + npc.X * scale + _level.Shifts[Math.Floor(600 - y)];

                if (Number.IsNaN(x))
                {
                    continue;
                }

                int index = 3;
                if (distance < 30000)
                {
                    int angle = Math.Floor(_level.Shifts[Math.Floor(600 - y)] + (npc.X * 3500) / distance);
                    index = Math.Floor(Math.Abs(angle) / 60);
                    if (index > 3)
                    {
                        index = 3;
                    }
                    index = 3 + index * (angle / Math.Abs(angle));
                    if (Number.IsNaN(index))
                    {
                        index = 3;
                    }
                }

                npc.Object.Update();
                npc.Object.Visible      = true;
                npc.Object.Location     = new Vector3D(x, y, npc.Distance);
                npc.Object.Scale        = scale;
                npc.Object.CurrentFrame = index;

                if (distance < 4500 && Math.Abs(npc.Object.Location.X - _level.CarSystem.CarObject.Location.X) < 100)
                {
                    _level.Crash();
                }
            }
        }
Ejemplo n.º 2
0
        public override void Update(CanvasContext2D context)
        {
            while (_objectIndex < _objects.Length && _objects[_objectIndex].Distance < _level.Position)
            {
                _objectIndex++;
            }

            for (int i = _objects.Length - 1; i >= _objectIndex; i--)
            {
                RoadObject roadObject = _objects[i];
                roadObject.GameObject.Visible = false;
                float distance = roadObject.Distance - _level.Position;

                if (distance > _level.DistanceTable[RaceLevel.Lines])
                {
                    continue;
                }

                float scale = 1;
                if (distance != 0)
                {
                    scale = 3500 / distance;
                }

                float y = 600 + (1000000 / distance) - 300;
                float x = 425 + roadObject.X * scale + _level.Shifts[Math.Floor(600 - y)];

                if (Number.IsNaN(x))
                {
                    continue;
                }

                roadObject.GameObject.Location = new Vector3D(x, y, roadObject.Distance);
                roadObject.GameObject.Scale    = scale;
                roadObject.GameObject.Visible  = true;

                if (distance < 4500 && Math.Abs(roadObject.GameObject.Location.X - _level.CarSystem.CarObject.Location.X) < 85)
                {
                    _level.Crash();
                }
            }
        }