Example #1
0
    public override void SensorsUpdate(ShipStatusInfo shipStatusInfo, IActiveSensors activeSensors, PassiveSensors passiveSensors, float deltaTime)
    {
        //Student code goes here
        timePassed += deltaTime;
        if (timePassed >= 1)
        {
            timePassed = 0;
            List <EMSReading> spaceObj;

            spaceObj = activeSensors.PerformScan(shipStatusInfo.forwardVector.Angle(), 2 * Mathf.Pi, 500);

            DefenceController.ls_asteroids.Clear();
            for (int index = 0; index < spaceObj.Count; index++)
            {
                if (spaceObj[index].ScanSignature == "Rock:90|Common:10")
                {
                    float x = spaceObj[index].Amplitude * activeSensors.GConstant * Mathf.Cos((spaceObj[index].Angle));
                    float y = spaceObj[index].Amplitude * activeSensors.GConstant * Mathf.Sin((spaceObj[index].Angle));
                    x += shipStatusInfo.positionWithinSystem.x;
                    y += shipStatusInfo.positionWithinSystem.y;
                    DefenceController.ls_asteroids.Add(new EMSReport(x, y));
                }
            }
        }
    }
Example #2
0
    public override void DefenceUpdate(ShipStatusInfo shipStatusInfo, TurretControls turretControls, float deltaTime)
    {
        cannotShootCheck(turretControls);

        if (ls_asteroids.Count != 0) //check if the list is empty
        {
            locationAsteroid(turretControls, shipStatusInfo);
            fireTorpedo(turretControls);
        }
    }
    public override void PropulsionUpdate(ShipStatusInfo shipStatusInfo, ThrusterControls thrusters, float deltaTime)
    {
        //Student code goes here

        //Enable the UFO drive override
        thrusters.IsUFODriveEnabled = true;

        // fly down and to the right at a speed of 141 pixels per second
        Vector2 velocity = new Vector2(0, -100);

        thrusters.UFODriveVelocity = velocity;
    }
Example #4
0
    private void locationAsteroid(TurretControls turretControls, ShipStatusInfo shipStatusInfo)
    {
        // double amplitude = (double)ls_asteroids[0].Amplitude;
        // double angle = (double)ls_asteroids[0].Angle;
        // double x = Math.Cos(angle)*amplitude;
        // double y = Math.Sin(angle)*amplitude;
        int    index = shortestDistance(shipStatusInfo);
        double x     = (double)ls_asteroids[index].x;
        double y     = (double)ls_asteroids[index].y;

        turretControls.aimTo = new Vector2((float)x, (float)y);
        ls_asteroids.RemoveAt(index);
    }
Example #5
0
    private int shortestDistance(ShipStatusInfo shipStatusInfo)
    {
        double distance = 100000000000000.0;
        int    index    = 0;

        for (int i = 0; i < ls_asteroids.Count; ++i)
        {
            double x_asteroid          = (double)ls_asteroids[0].x;
            double y_asteroid          = (double)ls_asteroids[0].y;
            double distance_ship_x     = shipStatusInfo.positionWithinSystem.x;
            double distance_ship_y     = shipStatusInfo.positionWithinSystem.y;
            double relative_distance_x = distance_ship_x - x_asteroid;
            double relative_distance_y = distance_ship_y - y_asteroid;
            double relative_distance   = Math.Sqrt(((relative_distance_x * relative_distance_x) + (relative_distance_y + relative_distance_y)));
            if (relative_distance < distance)
            {
                distance = relative_distance;
                index    = i;
            }
        }
        return(index);
    }
Example #6
0
    public event Action <ColonyShip, string, string> OnShipWarped; //this, departure solar system anme, arrival solar system name
    //public event Action<ColonyShip, string> JumpDriveTriggered; //this, destination solar system name
    //public event Action<ColonyShip, bool> LandingSequenceTriggered; //this, is ship above Kepler438

    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        gameCore               = FindParent("GameCore") as GameCore;
        collisionShape         = GetNode <CollisionShape2D>("CollisionShape2D");
        portForeThruster       = GetNode <Thruster>("PortForeThruster");
        starboardForeThruster  = GetNode <Thruster>("StarboardForeThruster");
        portAftThruster        = GetNode <Thruster>("PortAftThruster");
        starboardAftThruster   = GetNode <Thruster>("StarboardAftThruster");
        mainThruster           = GetNode <Thruster>("MainThruster");
        portRetroThruster      = GetNode <Thruster>("PortRetroThruster");
        starboardRetroThruster = GetNode <Thruster>("StarboardRetroThruster");
        TorpedoesFired         = 0;
        overlapArea2D          = GetNode <Area2D>("OverlapArea2D");

        ThrusterControls = new ThrusterControls(mainThruster, portForeThruster, portAftThruster, starboardForeThruster, starboardAftThruster, portRetroThruster, starboardRetroThruster);
        ThrusterControls.OnWarpJumpTriggered        += TriggerJumpDrive;
        ThrusterControls.OnLandingSequenceTriggered += TriggerLandingSequence;

        turret         = FindNode("Turret") as Turret;
        PassiveSensors = GetNode <PassiveSensors>(nameof(PassiveSensors));
        ActiveSensors  = GetNode <ActiveSensors>(nameof(ActiveSensors));
        ActiveSensors.OnScanPerformed += HandleScanPerformed;

        ufoDriveParticles = GetNode <UFODriveParticles>("UFODriveParticles");

        SensorsController               = FindNode("SensorsSubsystemController") as AbstractSensorsController;
        NavigationController            = FindNode("NavigationSubsystemController") as AbstractNavigationController;
        PropulsionController            = FindNode("PropulsionSubsystemController") as AbstractPropulsionController;
        DefenceController               = FindNode("DefenceSubsystemController") as AbstractDefenceController;
        SensorsController.parentShip    = this;
        NavigationController.parentShip = this;
        PropulsionController.parentShip = this;
        DefenceController.parentShip    = this;

        shipStatusInfo = new ShipStatusInfo();

        UpdateShipStatusInfo();
    }
 public override void SensorsUpdate(ShipStatusInfo shipStatusInfo, IActiveSensors activeSensors, PassiveSensors passiveSensors, float deltaTime)
 {
     //Student code goes here
 }
 public override void NavigationUpdate(ShipStatusInfo shipStatusInfo, GalaxyMapData galaxyMapData, float deltaTime)
 {
     //Student code goes here
 }
 public override void DefenceUpdate(ShipStatusInfo shipStatusInfo, TurretControls turretControls, float deltaTime)
 {
     //Student code goes here
 }
Example #10
0
 public override void PropulsionUpdate(ShipStatusInfo shipStatusInfo, ThrusterControls thrusters, float deltaTime)
 {
     //Student code goes here
 }
    /*
     * bool sensorsControllerEnabled = true;
     * public event Action<bool> OnSensorsControllerEnabledChanged;
     * public bool IsSensorsControllerEnabled {get{return sensorsControllerEnabled;} set{sensorsControllerEnabled = value; OnSensorsControllerEnabledChanged?.Invoke(sensorsControllerEnabled);}}
     *
     *
     * bool navigationControllerEnabled = true;
     * public event Action<bool> OnNavigationControllerEnabledChanged;
     * public bool IsNavigationControllerEnabled {get{return navigationControllerEnabled;} set{navigationControllerEnabled = value; OnNavigationControllerEnabledChanged?.Invoke(navigationControllerEnabled);}}
     *
     * bool propulsionControllerEnabled = true;
     * public event Action<bool> OnPropulsionControllerEnabledChanged;
     * public bool IsPropulsionControllerEnabled {get{return propulsionControllerEnabled;} set{propulsionControllerEnabled = value; OnPropulsionControllerEnabledChanged?.Invoke(propulsionControllerEnabled);}}
     *
     * bool defenceControllerEnabled = true;
     * public event Action<bool> OnDefenceControllerEnabledChanged;
     * public bool IsDefenceControllerEnabled {get{return defenceControllerEnabled;} set{defenceControllerEnabled = value; OnDefenceControllerEnabledChanged?.Invoke(defenceControllerEnabled);}}
     */
    /*
     * //Subsystems
     * public AbstractSensorsController Sensors { get; private set; }
     * public AbstractNavigationController Navigation { get; private set; }
     * public AbstractDefenceController Defence { get; private set; }
     * public AbstractPropulsionController Propulsion { get; private set; }
     *
     * public SubsystemReferences(AbstractSensorsController sensors, AbstractNavigationController navigation, AbstractDefenceController defence, AbstractPropulsionController propulsion)
     * {
     *
     *  Sensors = sensors;
     *  Defence = defence;
     *  Navigation = navigation;
     *  Propulsion = propulsion;
     * }
     */

    public abstract void ProcessPhysics(ShipStatusInfo shipStatusInfo, float deltaTime, ActiveSensors ActiveSensors, PassiveSensors passiveSensors, GalaxyMapData galaxyMapData, ThrusterControls thrusterControls, TurretControls turretControls);
Example #12
0
 public abstract void SensorsUpdate(ShipStatusInfo shipStatusInfo, IActiveSensors activeSensors, PassiveSensors passiveSensors, float deltaTime);
Example #13
0
 public abstract void DefenceUpdate(ShipStatusInfo shipStatusInfo, TurretControls turretControls, float deltaTime);
Example #14
0
 public abstract void PropulsionUpdate(ShipStatusInfo shipStatusInfo, ThrusterControls thrusters, float deltaTime);
 public abstract void NavigationUpdate(ShipStatusInfo shipStatusInfo, GalaxyMapData galaxyMapData, float deltaTime);