Beispiel #1
0
    public void CancelSelection()
    {
        switch (curChar)
        {
        case SelectableCharacters.Leslie:
            CD.GetComponent <Collider2D>().isTrigger = true;
            Leslie.GetComponent <Image>().sprite     = HoverImages[0];
            break;

        case SelectableCharacters.Jona:
            ND.GetComponent <Collider2D>().isTrigger = true;
            Jona.GetComponent <Image>().sprite       = HoverImages[1];
            break;

        case SelectableCharacters.Ashita:
            NED.GetComponent <Collider2D>().isTrigger = true;
            Ashita.GetComponent <Image>().sprite      = HoverImages[2];
            break;

        case SelectableCharacters.Catarine:
            ED.GetComponent <Collider2D>().isTrigger = true;
            Catarine.GetComponent <Image>().sprite   = HoverImages[3];
            break;

        case SelectableCharacters.Ramsey:
            SED.GetComponent <Collider2D>().isTrigger = true;
            Ramsey.GetComponent <Image>().sprite      = HoverImages[4];
            break;

        case SelectableCharacters.Drogas:
            SD.GetComponent <Collider2D>().isTrigger = true;
            Drogas.GetComponent <Image>().sprite     = HoverImages[5];
            break;

        case SelectableCharacters.Sylvia:
            SWD.GetComponent <Collider2D>().isTrigger = true;
            Sylvia.GetComponent <Image>().sprite      = HoverImages[6];
            break;

        case SelectableCharacters.Bjin:
            WD.GetComponent <Collider2D>().isTrigger = true;
            Bjin.GetComponent <Image>().sprite       = HoverImages[7];
            break;

        case SelectableCharacters.Xavier:
            NWD.GetComponent <Collider2D>().isTrigger = true;
            Xavier.GetComponent <Image>().sprite      = HoverImages[8];
            break;

        case SelectableCharacters.None:
            break;

        default:
            break;
        }
        weaponSelect.SetActive(false);
        weaponSelectActive = false;
        characterChosen    = false;
    }
        /// <summary>The method used to arbitrate N allocations</summary>
        public List <ZoneWaterAndN> GetUptakeEstimates(SoilState soilstate, IArbitration[] Organs)
        {
            // Get all water supplies.
            double waterSupply = 0;  //NOTE: This is in L, not mm, to arbitrate water demands for spatial simulations.

            List <double[]>      supplies = new List <double[]>();
            List <ZoneWaterAndN> zones    = new List <ZoneWaterAndN>();

            foreach (ZoneWaterAndN zone in soilstate.Zones)
            {
                foreach (IOrgan o in Organs)
                {
                    if (o is IWaterNitrogenUptake)
                    {
                        double[] organSupply = (o as IWaterNitrogenUptake).CalculateWaterSupply(zone);
                        if (organSupply != null)
                        {
                            supplies.Add(organSupply);
                            zones.Add(zone);
                            waterSupply += MathUtilities.Sum(organSupply) * zone.Zone.Area;
                        }
                    }
                }
            }

            // Calculate total water demand.
            double waterDemand = 0; //NOTE: This is in L, not mm, to arbitrate water demands for spatial simulations.

            foreach (IHasWaterDemand WD in WaterDemands)
            {
                waterDemand += WD.CalculateWaterDemand() * plant.Zone.Area;
            }

            // Calculate demand / supply ratio.
            double fractionUsed = 0;

            if (waterSupply > 0)
            {
                fractionUsed = Math.Min(1.0, waterDemand / waterSupply);
            }

            // Apply demand supply ratio to each zone and create a ZoneWaterAndN structure
            // to return to caller.
            List <ZoneWaterAndN> ZWNs = new List <ZoneWaterAndN>();

            for (int i = 0; i < supplies.Count; i++)
            {
                // Just send uptake from my zone
                ZoneWaterAndN uptake = new ZoneWaterAndN(zones[i]);
                uptake.Water = MathUtilities.Multiply_Value(supplies[i], fractionUsed);
                uptake.NO3N  = new double[uptake.Water.Length];
                uptake.NH4N  = new double[uptake.Water.Length];
                uptake.PlantAvailableNO3N = new double[uptake.Water.Length];
                uptake.PlantAvailableNH4N = new double[uptake.Water.Length];
                ZWNs.Add(uptake);
            }
            return(ZWNs);
        }
Beispiel #3
0
 private void UpdateD()
 {
     if (!Dispatcher.CheckAccess())
     {
         WD d = UpdateD;
         Dispatcher.Invoke(d);
     }
     else
     {
         Update();
     }
 }
Beispiel #4
0
        /// <summary>
        /// Set the sw uptake for today
        /// </summary>
        public override void SetActualWaterUptake(List <ZoneWaterAndN> zones)
        {
            // Calculate the total water supply across all zones.
            double waterSupply = 0;   //NOTE: This is in L, not mm, to arbitrate water demands for spatial simulations.

            foreach (ZoneWaterAndN Z in zones)
            {
                // Z.Water calculated as Supply * fraction used
                waterSupply += MathUtilities.Sum(Z.Water) * Z.Zone.Area;
            }

            // Calculate total plant water demand.
            WDemand = 0.0; //NOTE: This is in L, not mm, to arbitrate water demands for spatial simulations.
            foreach (IArbitration o in Organs)
            {
                if (o is IHasWaterDemand)
                {
                    WDemand += (o as IHasWaterDemand).CalculateWaterDemand() * Plant.Zone.Area;
                }
            }

            // Calculate the fraction of water demand that has been given to us.
            double fraction = 1;

            if (MathUtilities.IsPositive(WDemand))
            {
                fraction = Math.Min(1.0, waterSupply / WDemand);
            }

            // Proportionally allocate supply across organs.
            WAllocated = 0.0;

            foreach (IHasWaterDemand WD in WaterDemands)
            {
                double demand     = WD.CalculateWaterDemand();
                double allocation = fraction * demand;
                WD.WaterAllocation = allocation;
                WAllocated        += allocation;
            }

            // Give the water uptake for each zone to Root so that it can perform the uptake
            // i.e. Root will do pass the uptake to the soil water balance.
            foreach (ZoneWaterAndN zone in zones)
            {
                StoreWaterVariablesForNitrogenUptake(zone);
            }

            foreach (ZoneWaterAndN zone in zones)
            {
                Plant.Root.DoWaterUptake(zone.Water, zone.Zone.Name);
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            // Ievadi vārdu kura burtus izmantot meklēšanai
            Console.WriteLine("Ievadi burtus no kuriem veidot vārdus");
            String UL = Console.ReadLine();

            //  ieladējam visu vārdus no vārdnīcas
            string[] WFD = File.ReadAllLines(@"C:\Users\ArnisB\Desktop\PRG\Progmari\words.txt");
            //Izmantojot ciklu apstrādājam vārdus
            foreach (var WD in WFD)
            {
                // Izveidojam mainīgo - ja/ne
                bool navburts = false;
                // Izveidojam ciklu , apstrādājam burtu katrā vārdā
                for (int i = 0; i < UL.Length; i++)
                {
                    char CurrentSymbol = UL[i];
                    //Pārbaudam vai burts atrodas vārdnīcas vārdā
                    if (WD.Contains(CurrentSymbol) == false)
                    {
                        // ja neatrodas burts, tad piefiksējam, ka nav labs
                        navburts = true;
                    }
                }
                //Pārbaudām vai visis vārdnīcas vārda burti atrodami lietotaja ievadītajā vārdā !
                //Izmantojot ciklu , apstrādājam katru burtu vārdnīcas vārdā
                foreach (char symbol in WD)
                {
                    // Pārbaudam vai burts ir atrasts lietotāja ievadītajā vārdā
                    if (UL.Contains(symbol) == false)
                    {
                        //Ja neatrodas , tad piefiksējam, ka lieks burts ir atrasts
                        navburts = true;
                    }
                }
                // Kad vārdu apstrāde beigusies
                //pārbaudam vai vai vārdnīcas vārdā ir atrasti nevajadzīgi burti
                if (navburts == false)
                {
                    Console.ReadLine();
                }
                {
                    // Ja nav tad izvadam uz ekrāna
                    Console.WriteLine(WD);
                }
            }
        }
    // Use this for initialization
    void Start()
    {
        //Check if instance already exists
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(this.gameObject);

        // Look at the WordDictionary
        wd = new WD();

        wordsFound = new HashSet <string> ();
    }
        public static void Main(string[] args)
        {
            DisA DisplayA = new DisA();
            DisB DisplayB = new DisB();
            DisC DisplayC = new DisC();

            WD Dataweather = new WD();

            Dataweather.add(DisplayA);
            Dataweather.add(DisplayB);
            Dataweather.add(DisplayC);

            Dataweather.setMeasurements(18.2324, 183.342, 11.8334);

            Dataweather.remove(DisplayA);

            Dataweather.setMeasurements(10.2647, 78.2234, 19.5672);
        }
        /// Calculating the actual water uptake across all zones.
        public void SetActualUptakes(List <ZoneWaterAndN> zones, IArbitration[] Organs)
        {
            // Calculate the total water supply across all zones.
            double waterSupply = 0;   //NOTE: This is in L, not mm, to arbitrate water demands for spatial simulations.

            foreach (ZoneWaterAndN Z in zones)
            {
                waterSupply += MathUtilities.Sum(Z.Water) * Z.Zone.Area;
            }
            // Calculate total plant water demand.
            WDemand = 0.0; //NOTE: This is in L, not mm, to arbitrate water demands for spatial simulations.
            foreach (IArbitration o in Organs)
            {
                if (o is IHasWaterDemand)
                {
                    WDemand += (o as IHasWaterDemand).CalculateWaterDemand() * plant.Zone.Area;
                }
            }

            // Calculate the fraction of water demand that has been given to us.
            double fraction = 1;

            if (WDemand > 0)
            {
                fraction = Math.Min(1.0, waterSupply / WDemand);
            }

            // Proportionally allocate supply across organs.
            WAllocated = 0.0;

            foreach (IHasWaterDemand WD in WaterDemands)
            {
                double demand     = WD.CalculateWaterDemand();
                double allocation = fraction * demand;
                WD.WaterAllocation = allocation;
                WAllocated        += allocation;
            }
            foreach (ZoneWaterAndN Z in zones)
            {
                StoreWaterVariablesForNitrogenUptake(Z);
            }
        }
Beispiel #9
0
    /*IEnumerator Example()
     * {
     *  print(Time.time);
     *  yield return new WaitForSeconds(5);
     *  print(Time.time);
     *  this.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, -10));
     *  yield return new WaitForSeconds(5);
     *  this.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, -10));
     * }
     */

    void OnTriggerStay2D(Collider2D other)
    {
        if (other == WL.GetComponent <Collider2D>() || other == WR.GetComponent <Collider2D>())
        {
            /*
             * out1 = true;
             * time0 = 0f;
             * time1 = 1.1f;
             * rmode = 0;
             * if ((D2 % 360f >= 180f && D2 % 360f < 360f) || (D2 % 360f >= -180f && D2 % 360f < 0f))
             *  D1 = 3f;
             * if ((D2 % 360f < 180f && D2 % 360f >= 0f) || (D2 % 360f < -180f && D2 % 360f >= -360f))
             *  D1 = -3f;
             */
            D2 = 180f - D2;
            T1.Rotate(Vector3.forward * (2f * D2 - 180f));
        }

        /*
         * if (other == WR.GetComponent<Collider2D>())
         * {
         *  out1 = true;
         *  time0 = 0f;
         *  time1 = 1.1f;
         *  rmode = 0;
         *
         *  if ((D2 % 360f >= 180f && D2 % 360f < 360f) || (D2 % 360f >= -180f && D2 % 360f < 0f))
         *      D1 = -3f;
         *  if ((D2 % 360f < 180f && D2 % 360f >= 0f) || (D2 % 360f < -180f && D2 % 360f >= -360f))
         *      D1 = 3f;
         *
         * }
         */
        if (other == WU.GetComponent <Collider2D>() || other == WD.GetComponent <Collider2D>())
        {
            D2 = -D2;
            T1.Rotate(Vector3.forward * 2 * D2);

            /*
             * out1 = true;
             * time0 = 0f;
             * time1 = 1.1f;
             * rmode = 0;
             * if ((D2 % 360f >= 90f && D2 % 360f < 270f) || (D2 % 360f >= -270f && D2 % 360f < -90f))
             *  D1 = 3f;
             * if ((D2 % 360f < 90f && D2 % 360f >= 270f) || (D2 % 360f < -270f && D2 % 360f >= -90f))
             *  D1 = -3f;
             */
        }

        /*
         * if (other == WD.GetComponent<Collider2D>())
         * {
         *  out1 = true;
         *  time0 = 0f;
         *  time1 = 1.1f;
         *  rmode = 0;
         *  if ((D2 % 360f >= 90f && D2 % 360f < 270f) || (D2 % 360f >= -270f && D2 % 360f < -90f))
         *      D1 = -3f;
         *  if ((D2 % 360f < 90f && D2 % 360f >= 270f) || (D2 % 360f < -270f && D2 % 360f >= -90f))
         *      D1 = 3f;
         *
         * }
         */

        if (other == Room.GetComponent <Collider2D>())
        {
            Debug.Log(out1);
        }
    }
Beispiel #10
0
        public Independed(string[] ports)
        {
            watch = WD.NULL;

            List <string> cmports = new List <string>();

            try
            {
                RegistryKey comdevices = Registry.LocalMachine.OpenSubKey("HARDWARE").OpenSubKey("DEVICEMAP").OpenSubKey("SERIALCOMM");
                string[]    devices    = comdevices.GetValueNames();

                foreach (string s in devices)
                {
                    Match m = Regex.Match(s, @"QCUSB_COM", RegexOptions.IgnoreCase);

                    if (m.Success)
                    {
                        Object o1 = comdevices.GetValue(s);
                        cmports.Add(o1.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
            }

            for (int i = 0; i < ports.Length; i++)
            {
                if (cmports.Count > 0)
                {
                    string s = cmports.Find(p => p == ports[i]);

                    if (!String.IsNullOrEmpty(s))
                    {
                        continue;
                    }
                }

                try
                {
                    osmp = new Osmp(ports[i]);
                    string ident = osmp.Identification();

                    if (ident.IndexOf("WDT") > -1)
                    {
                        Version = ident;
                        watch   = WD.OSMP;
                        break;
                    }
                    else
                    {
                        osmp.Close();
                    }
                }
                catch (Exception ex)
                { }
            }

            if (watch == WD.NULL)
            {
                try
                {
                    sobaka = new Sobaka();

                    byte WDTType = sobaka.DrvDevType();

                    if (WDTType != 0)
                    {
                        Version = "Type " + WDTType.ToString();
                        watch   = WD.SOBAKA;
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Beispiel #11
0
    public void selectChar()
    {
        switch (curChar)
        {
        case SelectableCharacters.Leslie:
            TextObject.GetComponentInChildren <Text>().text = "Leslie Selected";
            Leslie.GetComponent <Image>().sprite            = SelectedImages[0];
            CD.GetComponent <Collider2D>().isTrigger        = false;
            break;

        case SelectableCharacters.Jona:
            TextObject.GetComponentInChildren <Text>().text = "Jona Selected";
            Jona.GetComponent <Image>().sprite       = SelectedImages[1];
            ND.GetComponent <Collider2D>().isTrigger = false;
            break;

        case SelectableCharacters.Ashita:
            TextObject.GetComponentInChildren <Text>().text = "Ashita Selected";
            Ashita.GetComponent <Image>().sprite            = SelectedImages[2];
            NED.GetComponent <Collider2D>().isTrigger       = false;
            break;

        case SelectableCharacters.Catarine:
            TextObject.GetComponentInChildren <Text>().text = "Catarine Selected";
            Catarine.GetComponent <Image>().sprite          = SelectedImages[3];
            ED.GetComponent <Collider2D>().isTrigger        = false;
            break;

        case SelectableCharacters.Ramsey:
            TextObject.GetComponentInChildren <Text>().text = "Ramsey Selected";
            Ramsey.GetComponent <Image>().sprite            = SelectedImages[4];
            SED.GetComponent <Collider2D>().isTrigger       = false;
            break;

        case SelectableCharacters.Drogas:
            TextObject.GetComponentInChildren <Text>().text = "Drogas Selected";
            Drogas.GetComponent <Image>().sprite            = SelectedImages[5];
            SD.GetComponent <Collider2D>().isTrigger        = false;
            break;

        case SelectableCharacters.Sylvia:
            TextObject.GetComponentInChildren <Text>().text = "Sylvia Selected";
            Sylvia.GetComponent <Image>().sprite            = SelectedImages[6];
            SWD.GetComponent <Collider2D>().isTrigger       = false;
            break;

        case SelectableCharacters.Bjin:
            TextObject.GetComponentInChildren <Text>().text = "Bjin Selected";
            Bjin.GetComponent <Image>().sprite       = SelectedImages[7];
            WD.GetComponent <Collider2D>().isTrigger = false;
            break;

        case SelectableCharacters.Xavier:
            TextObject.GetComponentInChildren <Text>().text = "Xavier Selected";
            Xavier.GetComponent <Image>().sprite            = SelectedImages[8];
            NWD.GetComponent <Collider2D>().isTrigger       = false;
            break;

        default:
            break;
        }
        characterChosen = true;
        weaponMenu();
    }