public void ConnectingClosedCircuitWith2Elements()
    {
        /*
         * (0)---(1)
         *   \___/
         */
        var cable   = HelperClass.GetRandomCable();
        var battery = new Battery(5, 2);

        cable.Connect(battery);
        battery.Connect(cable);
        battery.GiveProperties();

        Assert.AreEqual(cable.Properties.Amperage, battery.Properties.Amperage);
    }
    public void ConnectingClosedCircuitAndChecking()
    {
        /*
         * (0)--(1)--(2)
         *   \_______/
         */
        var cable1  = HelperClass.GetRandomCable();
        var battery = new Battery(2, 10);
        var cable2  = HelperClass.GetRandomCable();

        cable2.Properties.SetUR(2, 3);

        cable1.Connect(battery);
        battery.Connect(cable2);
        cable2.Connect(cable1);
        battery.GiveProperties();
        Assert.AreEqual(battery.Properties.Amperage, cable1.Properties.Amperage);
    }
    public void BranchResistanceTest()
    {
        /*
         *          (0)<---^
         *          / \    |
         * Branch[(1) (2)  |
         *          \ /    |
         *          (3)---->
         */

        var battery = new Battery(30, 1);
        var branch  = new Branch();
        var el1     = new Cable("test_one", 10, 1);
        var el2     = new Cable("test_one", 10, 1);
        var el3     = new Cable("test_one", 10, 1);

        /*Debug.Log(string.Format("created battery: {0}", battery));
         * Debug.Log(string.Format("created branch: {0}", branch));
         * Debug.Log(string.Format("created element1: {0}", el1));
         * Debug.Log(string.Format("created element2: {0}", el2));
         * Debug.Log(string.Format("created element3: {0}", el3));*/

        battery.Connect(branch);
        el1.Connect(el3);
        branch.Connect(battery);
//        el3.Connect(BranchEndElement.BranchEnd);
//        el2.Connect(BranchEndElement.BranchEnd);
        branch.Branches.Add(el1);
        branch.Branches.Add(el2);

        branch.CloseBranches();

        battery.GiveProperties();

        var r1 = el1.Properties.Resistance;
        var r2 = el2.Properties.Resistance;
        var r3 = el3.Properties.Resistance;

        Assert.AreEqual(HelperClass.GetParallelResistance((new List <double> {
            r1 + r3, r2
        })), branch.Properties.Resistance);
    }
Exemple #4
0
    void RepairAircraft()
    {
        FlightAssist flightAssist = GetComponentInChildren <FlightAssist>();

        if (flightAssist != null)
        {
            flightAssist.assistEnabled = true;
        }
        else
        {
            Debug.Log("Could not fix flight assists");
        }

        RCSController rcsController = GetComponentInChildren <RCSController>();

        if (rcsController != null)
        {
            Traverse.Create(rcsController).Field("alive").SetValue(true);
        }
        else
        {
            Debug.Log("Could not fix rcs controller");
        }

        Battery battery = GetComponentInChildren <Battery>();

        if (battery != null)
        {
            Traverse.Create(battery).Field("isAlive").SetValue(true);
            battery.Connect();
        }
        else
        {
            Debug.Log("Could not fix battery");
        }

        GameObject hud = GameObject.Find("CollimatedHud");

        if (hud != null)
        {
            hud.SetActive(true);
        }
        else
        {
            Debug.Log("Could not fix hud");
        }

        GameObject hudWaypoint = GameObject.Find("WaypointLead");

        if (hudWaypoint != null)
        {
            hudWaypoint.SetActive(true);
        }
        else
        {
            Debug.Log("Could not fix hudWaypoint");
        }

        VRJoystick joystick = GetComponentInChildren <VRJoystick>();

        if (joystick != null)
        {
            joystick.sendEvents = true;
        }
        else
        {
            Debug.Log("Could not fix joystick");
        }

        VRInteractable[] levers = GetComponentsInChildren <VRInteractable>();
        foreach (VRInteractable lever in levers)
        {
            lever.enabled = true;
        }
        Debug.Log("Fixed " + levers.Length + " levers");
    }