Example #1
0
        /// <summary>
        /// Конструктор
        /// </summary>
        /// <param name="shipVerts"></param>
        private Ship(PointF position, float length, float width)
        {
            float depth = 0;
            List<Vector3> shipVerts = new List<Vector3>();
            shipVerts.Add(new Vector3(-1f * width / 2 + position.X, -1f * length / 2 + position.Y, depth));
            shipVerts.Add(new Vector3(-1f * width / 2 + position.X, 0.25f * length / 2 + position.Y, depth));
            shipVerts.Add(new Vector3(0 * width / 2 + position.X, 1f * length / 2 + position.Y, depth));
            shipVerts.Add(new Vector3(1f * width / 2 + position.X, 0.25f * length / 2 + position.Y, depth));
            shipVerts.Add(new Vector3(1f * width / 2 + position.X, -1f * length / 2 + position.Y, depth));
            shipVerts.Add(new Vector3(-1f * width / 2 + position.X, -1f * length / 2 + position.Y, depth));

            //mechanics = VehicleWithGearboxAspect.Create(this);
            physics = PhysicsAspect.Create(this);
            mass = MassAspect.Create(this);
            Thruster thruster1 = Thruster.Create(this, physics.Facing);
            Thruster thruster2 = Thruster.Create(this, physics.Facing);
            IList<Thruster> thrusters = new List<Thruster>(2);
            thrusters.Add(thruster1);
            thrusters.Add(thruster2);
            thrusterController = ThrusterController.Create(this, thrusters);
            graphics = GraphicsAspect.Create(this, shipVerts, 3, Color.White, Color.Red);
            bounds = BoundSetAspect.Create(this, shipVerts);
            //bounds.GetOuterContour();
            bounds.SetAttribute(Strings.CollisionDetectionSpeedType, Strings.CollisionDetectionSpeedTypeSlowOrStatic);

            rearCannon = Weapon.Create(this, Side.Rear);
            leftCannon = Weapon.Create(this, Side.Left);
            rightCannon = Weapon.Create(this, Side.Right);
            damage = DamageAspect.Create(this, 100);

            messageHandler.Handlers.Add(typeof(Kill), HandleKill);
            messageHandler.Handlers.Add(typeof(BoundSetCollision), HandleBoundSetCollision);
        }
Example #2
0
 public static Weapon Create(object owner, Side weaponSide)
 {
     Weapon aspect = new Weapon(owner, weaponSide);
     aspect.RegisterAllStuff();
     return aspect;
 }