Example #1
0
    void Awake()
    {
        // Lazy singleton
        inst = this;

        // send one car right and one left randomly
        Car.Direction dirFirst = Random.Range(0, 2) == 1 ? Car.Direction.Left : Car.Direction.Right;
        m_Cars[0].SetDirection(dirFirst);
        m_Cars[1].SetDirection(dirFirst == Car.Direction.Left ? Car.Direction.Right : Car.Direction.Left);
    }
Example #2
0
        /// <summary>
        /// Creates the car.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <returns></returns>
        private static Car CreateCar(Car.Direction direction)
        {
            var car = new Car {
                MovementDirection = direction
            };

            if (direction == Car.Direction.Top)
            {
                Canvas.SetLeft(car, RightX2);
                Canvas.SetTop(car, BottomY);
            }
            else
            {
                Canvas.SetLeft(car, LeftX0);
                Canvas.SetTop(car, TopY);
            }

            return(car);
        }