コード例 #1
0
        /// <summary>
        /// Sets decorator life time period in a timer.
        /// </summary>
        /// <param name="baseProps"></param>
        public CarPropsDecorator(CarProps baseProps)
            : base(baseProps.owner)
        {
            this.baseProps = baseProps;
            base.owner     = baseProps.owner;

            this.lifeTimer          = new GameTimer(3f);
            this.lifeTimer.Elapsed += (sender, e) => RemoveDecorator();

            EngineCore.AddGameObject(this);
        }
コード例 #2
0
        /// <summary>
        /// Ctor that set a basic car object settings properly.
        /// </summary>
        public Car()
        {
            spriteRenderer = (SpriteRenderer)AddComponent("SpriteRenderer");
            rigidBody2D    = (RigidBody2D)AddComponent("RigidBody2D");

            // Set defaults for a default car.
            properties     = new CarProps(this);
            this.fuelLevel = properties.MaxFuelLevel;

            // Set default wheelBase value and start car position.
            wheelBase = 80f;
            SetStartCarPosition(new Vector2(150f, 150f));

            // Set default RigidBody parameters for a basic Car object.
            rigidBody2D.mass          = 1200f;
            rigidBody2D.frictionConst = 750f;

            base.collider = new PolyCollider(this, new Vector2(110f, 45f));
            base.collider.ColliderTriggered += FinishLine_ColliderTriggered;
            base.collider.ColliderTriggered += Prize_ColliderTriggered;

            // Difine finished laps array.
            this.laps = new bool[5 + 1];
        }
コード例 #3
0
 /// <summary>
 /// Testing ctor.
 /// </summary>
 public CarPropsDecorator(CarProps baseProps, Car owner)
 {
     this.baseProps = baseProps;
     base.owner     = owner;
 }