Beispiel #1
0
        public void Start()
        {
            Scene.endGame = false;

            // Background
            SBG = new ScrollingBackground(AM.GetTexture("Background.png"), 100.0);

            // Player
            ShipSpecs specs = new ShipSpecs();

            specs.Level      = 1;
            specs.Velocity   = 400.0;
            specs.HP         = 5;
            specs.MaxHP      = 50;
            specs.Damage     = 25;
            specs.MaxDamage  = 100;
            specs.LazerCount = 1;
            specs.Cooldown   = 0.3;
            player           = new Ship(Scene, new DrawComponent(AM.GetTexture("Ship.png"), new Size(64.0, 64.0)), new TransformComponent(new Point(200.0, 700.0)), specs);
            Scene.NewActors.Add(player);
            PM.CreateBoxComponent(new Size(64.0, 64.0), player);

            State = GameState.InProgress;

            Window.ScoreBar.Maximum = MaxScore;
        }
    public ShipPhysics(Rigidbody rigidbody, ref ShipSpecs specs)
    {
        this.rigidbody = rigidbody;

        if (!specs.IsCapital)
        {
            this.rigidbody.inertiaTensor = Vector3.one * 1000f;
        }

        this.rigidbody.mass        = specs.Physics.Mass;
        this.rigidbody.drag        = specs.Physics.Drag;
        this.rigidbody.angularDrag = specs.Physics.AngularDrag;
    }
Beispiel #3
0
    public void LoadSpecs(ShipSpecs specs)
    {
        Specs = specs;

        name = Specs.TypeName;
        hull = Specs.HullStrength;

        var laserPrefab = greenLaserPrefab;

        if (Specs.Weapons.Color == LaserColor.Red)
        {
            laserPrefab = redLaserPrefab;
        }

        var ownTarget = GetComponent <Target>();

        ownTarget.IsCapital = specs.IsCapital;

        laserBarrels.Clear();
        turrets.Clear();
        foreach (var child in GetComponentsInChildren <Transform>())
        {
            if (child.name.StartsWith("HpLaser"))
            {
                laserBarrels.Enqueue(new Cannon(this, child, laserPrefab, Specs.Weapons));
                continue;
            }

            if (child.name.StartsWith("Turret"))
            {
                var turret = new Turret(
                    this,
                    ownTarget,
                    turretLaserAudio,
                    child,
                    laserPrefab,
                    Pilot.FireChance,
                    Specs.Weapons);

                turrets.Add(turret);
            }
        }
    }
    public void Update(Pilot pilot, ref ShipSpecs specs)
    {
        if (isDestroyed)
        {
            return;
        }

        rigidbody.AddRelativeTorque(
            pilot.Pitch * specs.Engine.Torque * Multiplier,
            pilot.Yaw * specs.Engine.Torque * Multiplier,
            -pilot.Roll * specs.Engine.Torque * Multiplier);

        // Ramp up/down speed for smoother acceleration.
        smoothThrottle = SmoothDamp.Move(
            smoothThrottle,
            pilot.Throttle,
            specs.Engine.Accel,
            Time.fixedDeltaTime);

        rigidbody.AddRelativeForce(
            Vector3.forward * specs.Engine.Thrust * Multiplier * smoothThrottle,
            ForceMode.Force);
    }