コード例 #1
0
 public void AddNewSpice(Spice spice)
 {
     ownedSpices.Add(spice, 1);
     OnSpicePicked?.Invoke(this, new OnSpicePickedUp {
         spiceIcon = spice.spiceIcon, spiceName = spice.spiceName
     });
 }
コード例 #2
0
 public void AddSpice(Spice spice)
 {
     ownedSpices[spice]++;
     OnSpicePicked?.Invoke(this, new OnSpicePickedUp {
         spiceIcon = spice.spiceIcon, spiceName = spice.spiceName
     });
 }
コード例 #3
0
ファイル: Action.cs プロジェクト: kondvit/Spice-Road
    protected bool Remove(Spice spice, int amount, State postConditions)
    {
        int currentAmount = postConditions[Inventory.Player][spice] + postConditions[Inventory.Caravan][spice];

        if (currentAmount >= amount)
        {
            //prioritize taking from players inventory
            if (postConditions[Inventory.Player][spice] >= amount)
            {
                postConditions[Inventory.Player][spice] -= amount;
            }
            else
            {
                //if backpack is full, need to stash and take stuff needed for it
                //need taking from backpack action
                //this is a method, if bp is full need to stash take out and take out again to reach the end state
                isMethod = true; //it's a method, since it requires withdrawing from the caravans

                postConditions[Inventory.Caravan][spice] -= amount - postConditions[Inventory.Player][spice];
                postConditions[Inventory.Player][spice]   = 0;
                //Debug.Log("Did transfer from caravan, current back pack : " + SpiceCount() );
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #4
0
ファイル: BowlController.cs プロジェクト: TheCoCe/factory
 void Update()
 {
     if (debug)
     {
         FillSpice(setSpice, addAmount, setRefill);
         currentSpice  = spice;
         currentAmount = amount;
     }
 }
コード例 #5
0
    public void VerifyBlackRoseIsHot()
    {
        string subject = "Black Rose";

        Spice.Level expectedSpice;
        // Here's the ease of use. Pass a string, get an enum and whether it's a valid string
        var result = Spice.TryGet(subject, out expectedSpice);

        //Some Assertion from a unit test library
        Assert.True(result, $"Unable to find spice '{subject}', when it should exist");
        Assert.True(Spice.Level.Hot.Equals(expectedSpice), $"The returned spice '{ Spice.SpiceName(expectedSpice) }' was not the value 'Hot' as expected");
    }
コード例 #6
0
ファイル: Action.cs プロジェクト: kondvit/Spice-Road
 protected bool Add(Spice spice, int amount, State postConditions)
 {
     if (SpiceCount(postConditions) <= 4)
     {
         postConditions[Inventory.Player][spice] += amount;
         return(SpiceCount(postConditions) <= 4); //verify again after adding, if the backpack would be overfilled
     }
     else
     {
         return(false);
     }
 }
コード例 #7
0
 public ActionResult EditSpice(Spice model)
 {
     if (ModelState.IsValid)
     {
         unitOfWork.Spices.Edit(model);
         unitOfWork.Complete();
         unitOfWork.Dispose();
         return(RedirectToAction("Index", "Spice"));
     }
     else
     {
         return(View(model));
     }
 }
コード例 #8
0
ファイル: BowlController.cs プロジェクト: TheCoCe/factory
 private void SetSpiceGraphic(Spice s)
 {
     if (spiceGraphic == null)
     {
         return;
     }
     if (s == Spice.Empty)
     {
         spiceGraphic.SetActive(false);
         return;
     }
     spiceGraphic.SetActive(true);
     spiceGraphic.GetComponent <Renderer>().material = spiceMat[(int)s];
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: panyz522/NaifSpiceSharp
        static void Main(string[] args)
        {
            unsafe
            {
                var metaFilePath = Environment.ExpandEnvironmentVariables(@"%appdata%\SPICE\mk\solar_system_v0033.tm");

                Console.WriteLine(metaFilePath);
                fixed(byte *pathChars = Encoding.ASCII.GetBytes(metaFilePath))
                {
                    Spice.FURNSH_C(pathChars);
                }

                // Get Ephemeris Time
                double tdb;
                fixed(byte *timeChars = CStr("2020 MAY 04 15:40:21.3"))
                {
                    Spice.STR2ET_C(timeChars, &tdb);
                }

                // Calc position and velocity
                double *state = stackalloc double[6]; // (x, y, z, vx, vy, vz)
                for (int i = 0; i < 6; i++)
                {
                    state[i] = 0;
                }
                double lt; // Light time
                fixed(byte *target = CStr("EARTH"))
                fixed(byte *obs   = CStr("SUN"))
                fixed(byte *frame = CStr("ECLIPJ2000"))
                fixed(byte *corr  = CStr("NONE"))
                {
                    Spice.SPKEZ_C(301 /*Moon*/, tdb, frame, corr, 399 /*Earth*/, state, &lt);
                }
                Console.WriteLine("Position of moon observed from earth");
                for (int i = 0; i < 6; i++)
                {
                    Console.Write($"{state[i]} ");
                }
                Console.WriteLine();
                double rad;
                double lon;
                double lat;
                Spice.RECLAT_C(state, &rad, &lon, &lat);
                Console.WriteLine("Lon and lat in ECLIPJ2000");
                Console.WriteLine($"{lon * 180 / Math.PI} {lat * 180 / Math.PI} {rad}");
            }
        }
コード例 #10
0
 public ActionResult AddSpice(Spice model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             unitOfWork.Spices.Add(model);
             unitOfWork.Complete();
             unitOfWork.Dispose();
             return(RedirectToAction("Index", "Spice"));
         }
     }
     catch (Exception ex)
     {
         //TODO: We want to show an error message
         return(View());
     }
     return(View());
 }
コード例 #11
0
ファイル: BowlController.cs プロジェクト: TheCoCe/factory
 public void FillSpice(Spice s, float a, bool refill)
 {
     if (spice == Spice.Count)
     {
         return;
     }
     if (spice == Spice.Empty)
     {
         SetSpiceGraphic(Spice.Empty);
         amount = 0;
     }
     if (spice == s || refill)
     {
         spice   = s;
         amount += a;
     }
     if (amount != 0)
     {
         SetSpiceGraphic(spice);
         return;
     }
     SetSpiceGraphic(Spice.Empty);
 }
コード例 #12
0
ファイル: SpiceHolder.cs プロジェクト: MatiGP/MageChef
 public void SetUpSpice(Spice spice)
 {
     sr.sprite  = spice.spiceIcon;
     this.spice = spice;
 }
コード例 #13
0
 public void SetUpSpice(Spice spice, int count)
 {
     spiceIcon.sprite = spice.spiceIcon;
     spiceName.text   = spice.spiceName;
     spiceCount.text  = count.ToString();
 }
コード例 #14
0
        public async Task <IActionResult> Create([Bind("Name,Calories,Place_of_Origin")] Seasoning seasoning, [Bind("Hotness")] Spice spice)
        {
            if (ModelState.IsValid)
            {
                _context.Seasoning.Add(seasoning);
                spice.Id = seasoning.Id;
                _context.Add(spice);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Id"] = new SelectList(_context.Seasoning, "Id", "Id", spice.Id);
            return(View(spice));
        }
コード例 #15
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Calories,Place_of_Origin")] Seasoning seasoning, [Bind("Hotness")] Spice spice)
        {
            if (id != spice.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    seasoning.Id = id;
                    _context.Seasoning.Update(seasoning);
                    _context.Update(spice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpiceExists(spice.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Id"] = new SelectList(_context.Seasoning, "Id", "Id", spice.Id);
            return(View(spice));
        }
コード例 #16
0
ファイル: Action.cs プロジェクト: kondvit/Spice-Road
    //public abstract void ApplyActionOnState(State state);

    //can always add to caravan
    protected void AddToCaravan(Spice spice, int amount, State postConditions)
    {
        postConditions[Inventory.Caravan][spice] += amount;
    }
コード例 #17
0
ファイル: BowlController.cs プロジェクト: TheCoCe/factory
 public void FillSpice(Spice s, float a)
 {
     FillSpice(s, a, false);
 }
コード例 #18
0
 public bool HasSpice(Spice spice)
 {
     return(ownedSpices.ContainsKey(spice));
 }
コード例 #19
0
 public SpiceDog(HotDog hotdog, Spice spice)
     : base(hotdog.Name + " " + spice.ToString(), hotdog)
 {
     this.spice = spice;
 }
コード例 #20
0
ファイル: SimpleGa.cs プロジェクト: supcry/MotifSeeker
        private void Grow()
        {
            var tot = 1L << (2*_pars.SpiceLen);
            var ng = new List<Spice>(_pars.PopSize);
            var failed = 0;
            while (ng.Count < _pars.PopSize)
            {
                foreach (var i in _rnd.GetShuffleFlow(_curPop.Length))
                {
                    var sp = _curPop[i];
                    if (_rnd.Next(2) == 0)
                    {
                        var spMut = sp.MutateByCount(_rnd.Next(_pars.SpiceLen/2) + 1, _rnd.Next());
                        if (spMut.IsFailed)
                        {
                            failed++;
                            continue;
                        }
                        ng.Add(spMut);
                    }
                    else
                    {
                        var j = i == 0 ? _rnd.Next(_curPop.Length - 1) + 1 : _rnd.Next(i);
                        var sp2 = _curPop[j];
                        var spCrs = Spice.Cross(_rnd.Next(), sp, sp2);
                        if (spCrs.IsFailed)
                        {
                            failed++;
                            continue;
                        }
                        ng.Add(spCrs);
                    }
                }
                for (int i = 0; i < _pars.PopSize / 10; i++)
                {
                    var spR = new Spice(_pars.SpiceLen, _rnd.Next());
                    if (spR.IsFailed)
                    {
                        failed++;
                        continue;
                    }
                    ng.Add(spR);
                }
            }
            if (failed > ng.Count*500)
            {
                Console.WriteLine("Перебрали значительную часть результатов: failed=" + failed + ", population=" + ng.Count);
                Console.WriteLine("Всего возможных комбинаций: =" + tot + ", из них перебрали:" + Spice.HashUniq.Count + ", i.e.: " + Math.Round(100.0*Spice.HashUniq.Count/tot,2) + "%");
                Finished = true;
            }

            if(BestSpice != null)
                ng.Add(BestSpice);
            _curPop = ng.ToArray();
        }