コード例 #1
0
 /// <summary>
 /// Writes a CAN packet with SyncWriteLine.
 /// </summary>
 public void TransmitPacket(Can.Packet packet)
 {
     string hex_id = packet.ID.ToString("X3");
     string hex_length = packet.Length.ToString("X1");
     byte[] bytes = BitConverter.GetBytes(packet.Data);
     string hex_data = BitConverter.ToString(bytes).Replace("-", String.Empty);
     this.port.LockWriteLine("t" + hex_id + hex_length + hex_data);
 }
コード例 #2
0
 /// <summary>
 /// 缶spawn時初期化
 /// </summary>
 /// <param name="can"></param>
 private void OnCanSpawn(Can can)
 {
     can.onCanKicked.AddListener(OnCanKicked);
     kickables.Add(can.kickable);
 }
コード例 #3
0
        protected override void init()
        {
            stool.Move(new Vector3(0f, -0.03f, -1f));
            ball = new Ball(ballRadius);
            ball.SetLimits(ballLimitLow, ballLimitHigh);
            ballSpeed = new Vector3(0.5f, 0.5f, 0.5f);
            ball.SetSpeed(ballSpeed);
            ball.SetLightPosition(new Vector3(0f, 0f, -1f));
            ball.SetOffset(new Vector3(-0.75f, 0.75f, -1f));
            for (int i = 0; i < 6; i++)
            {
                Can c = new Can();
                c.RotateShape(new Vector3(1f, 0f, 0f), 90f);
                c.SetColor(Colors.BLUE_COLOR);
                switch (i)
                {
                    case 0: c.Move(new Vector3(-xSeparation, 0f, canZ)); break;
                    case 1: c.Move(new Vector3(0f, 0f, canZ)); break;
                    case 2: c.Move(new Vector3(xSeparation, 0f, canZ)); break;
                    case 3: c.Move(new Vector3(-xSeparation/2, ySeparation, canZ)); break;
                    case 4: c.Move(new Vector3(xSeparation/2, ySeparation, canZ)); break;
                    case 5: c.Move(new Vector3(0f, 2*ySeparation, canZ)); break;
                }
                c.SetSpeed(new Vector3(0f, 0f, 0f));
                c.AddPaddle(ball);

                cans.Add(c);
            }
            SetupDepthAndCull();
            updateProgram();
        }
コード例 #4
0
 public async void AddCan(Can can)
 {
     await _context.Cans.AddAsync(can);
 }
コード例 #5
0
        public Duck()
        {
            if (nCrack == 0)
            {
                nCrack = random.Next(1, 169);
            }

            ++nDuck;

            if (nDuck == nCrack)
            {
                Crack = -1;
            }

            int i = 13;

            while (i > 0)
            {
                switch (i)
                {
                case 13:

                    house = random.Next(0, 1) == 0 ? true : false;
                    if (house)
                    {
                        know = "знает где она живет";
                    }
                    else
                    {
                        know = "не знает где она живет";
                    }
                    break;

                case 12:
                    name = $"Duck_{++numDuck}";

                    break;

                case 11:
                    weight = random.Next(2, 9);
                    break;

                case 10:
                    SizeFoot = random.Next(1, 5);
                    break;

                case 9:
                    FavoriteDish = masFavoriteDish[random.Next(0, 8)];
                    break;

                case 8:
                    endurance = random.Next(0, 3);
                    break;

                case 7:
                    SizeBeak = random.Next(1, 5);
                    break;

                case 6:
                    WingShape = masWingShape[random.Next(0, 1)];
                    break;

                case 5:
                    ColorBeak = Color[random.Next(0, 4)];
                    break;

                case 4:
                    dexterity = random.Next(0, 3);
                    break;

                case 3:
                    ColorShape = Color[random.Next(0, 4)];
                    break;

                case 2:
                    typeDuck = (TypeDuck)random.Next(0, 5);
                    break;

                case 1:

                    can = (Can)GetNumCun();    //random.Next(0, 5);
                    break;
                }
                --i;
            }
            int    lovk;
            int    SizeLap;
            string LoveFood;
            string knowhouse;

            if (typeDuck == TypeDuck.Каменушки)
            {
                knowhouse = know;
                can       = Can.летать;
                SizeLap   = SizeFoot;
                LoveFood  = FavoriteDish;
            }
            else if (typeDuck == TypeDuck.Нырки)
            {
                can = Can.бегать;
            }
            else if (typeDuck == TypeDuck.Шилохвость)
            {
                can = Can.плавать;
            }
            else if (typeDuck == TypeDuck.ХохлатаяУтка)
            {
                can = Can.ползать;
            }
            else if (typeDuck == TypeDuck.Крохали)
            {
                can = Can.плавать;
            }
            else if (typeDuck == TypeDuck.ЛайсанскаКряква)
            {
                can = Can.клевать;
            }
        }
コード例 #6
0
ファイル: Garbage.cs プロジェクト: somnomania/smapi-mod-dump
        private static Item GetLootForDateAndCan(SDate date, Can can,
                                                 bool hatOnly, out bool special)
        {
            // Logic from StardewValley.Locations.Town.checkAction()
            // as implemented in Stardew Predictor by MouseyPounds.

            special = false;

            // Handle the presence of SVE's altered town map.
            Can standardCan = (Can)((int)can % 100);
            int canValue    = (int)standardCan;

            // Handle the special case of JojaMart/MovieTheater.
            bool hasTheater = Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheater") &&
                              !Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheaterJoja");

            if ((hasTheater && can == Can.JojaMart) ||
                (!hasTheater && can == Can.MovieTheater))
            {
                return(null);
            }
            if (can == Can.MovieTheater)
            {
                canValue = (int)Can.JojaMart;
            }

            // Create and prewarm the random generator.
            Random rng = new Random((int)Game1.uniqueIDForThisGame / 2 +
                                    date.DaysSinceStart + 777 + canValue * 77);
            int prewarm = rng.Next(0, 100);

            for (int i = 0; i < prewarm; i++)
            {
                rng.NextDouble();
            }
            prewarm = rng.Next(0, 100);
            for (int j = 0; j < prewarm; j++)
            {
                rng.NextDouble();
            }

            // Roll for regular items.
            uint trashCansChecked = Game1.stats.getStat("trashCansChecked") + 1;
            bool regular          = trashCansChecked > 20 && rng.NextDouble() < 0.01;

            // Roll for the Garbage Hat.
            if (trashCansChecked > 20 && rng.NextDouble() < 0.002)
            {
                return(new Hat(66));
            }
            else if (hatOnly)
            {
                return(null);
            }

            // If the regular roll failed, roll for luck and then give up.
            // Use today's luck for today, else a liquidated value.
            bool   today     = date == SDate.Now();
            double dailyLuck = today ? Game1.player.DailyLuck
                                : Game1.player.hasSpecialCharm ? 0.125 : 0.1;

            if (!regular && !(rng.NextDouble() < 0.2 + dailyLuck))
            {
                return(null);
            }

            // Roll for a generic or seasonal item.
            int itemID = rng.Next(10) switch
            {
                1 => 167,                 // Joja Cola
                2 => 170,                 // Broken Glasses
                3 => 171,                 // Broken CD
                4 => 172,                 // Soggy Newspaper
                5 => 216,                 // Bread
                6 => - 1,                 // seasonal item
                7 => 403,                 // Field Snack
                8 => 309 + rng.Next(3),   // Acorn, Maple Seed, Pine Cone
                9 => 153,                 // Green Algae
                _ => 168,                 // Trash
            };
            bool seasonal = false;

            if (itemID == -1)
            {
                seasonal = true;
                itemID   = Utility.getRandomItemFromSeason(date.Season,
                                                           (CanLocations[can].X * 653) + (CanLocations[can].Y * 777) +
                                                           date.DaysSinceStart, false, false);
            }

            // Roll for location-specific overrides. These do not care about
            // SVE, so take the standard can identity.
            bool locationSpecific = false;

            switch (standardCan)
            {
            case Can.ArchaeologyHouse:
                if (rng.NextDouble() < 0.2 + dailyLuck)
                {
                    locationSpecific = true;
                    if (rng.NextDouble() < 0.05)
                    {
                        itemID = 749;                         // Omni Geode
                    }
                    else
                    {
                        itemID = 535;                         // Geode
                    }
                }
                break;

            case Can.Blacksmith:
                if (rng.NextDouble() < 0.2 + dailyLuck)
                {
                    locationSpecific = true;
                    itemID           = 378 + (rng.Next(3) * 2); // Copper Ore, Iron Ore, Coal
                    rng.Next(1, 5);                             // unused
                }
                break;

            case Can.Saloon:
                if (rng.NextDouble() < 0.2 + dailyLuck)
                {
                    locationSpecific = true;
                    if (!today)
                    {
                        itemID = 217;                         // placeholder for dish of the day
                    }
                    else if (Game1.dishOfTheDay != null)
                    {
                        itemID = Game1.dishOfTheDay.ParentSheetIndex;
                    }
                }
                break;

            case Can.JoshHouse:
                if (rng.NextDouble() < 0.2 + dailyLuck)
                {
                    locationSpecific = true;
                    itemID           = 223;           // Cookie
                }
                break;

            case Can.JojaMart:
                if (rng.NextDouble() < 0.2 &&
                    !Utility.HasAnyPlayerSeenEvent(191393))
                {
                    locationSpecific = true;
                    itemID           = 167;           // Joja Cola
                }
                break;

            case Can.MovieTheater:
                if (rng.NextDouble() < 0.2)
                {
                    locationSpecific = true;
                    itemID           = (rng.NextDouble() < 0.25)
                                                ? 809 : 270; // Movie Ticket, Corn
                }
                break;
            }

            special = seasonal || locationSpecific;
            return(new SObject(itemID, 1));
        }