Exemple #1
0
        static void Main(string[] args)
        {
            List <Player> PlayersList = new List <Player>();

            Player normalPlayer = new NormalPlayer("Normal Player");

            PlayersList.Add(normalPlayer);

            Player textbookPlayer = new TextBookPlayer("TextBook Player");

            PlayersList.Add(textbookPlayer);

            Player uberPlayer = new UberPlayer("Uber Player");

            PlayersList.Add(uberPlayer);

            Player cheater = new Cheater("Cheater");

            PlayersList.Add(cheater);

            Player uberCheater = new UberCheater("Uber Cheater");

            PlayersList.Add(uberCheater);



            int    bucketweight  = CustomRandom.GetNext();
            Player closestPlayer = null;
            int    closestWeight = 150;

            Console.WriteLine($"{bucketweight} is Bucket Weight");

            bool isgamefinished = false;

            for (int i = 0; i < 100; i++)
            {
                foreach (Player player in PlayersList)
                {
                    int number = player.GetNumber();
                    Console.WriteLine($"{player.Name} select number {number}");
                    if (number == bucketweight)
                    {
                        Console.WriteLine($"{player.Name} won");
                        isgamefinished = true;
                        break;
                    }
                    else if (Math.Abs(number - bucketweight) < closestWeight)
                    {
                        closestWeight = Math.Abs(number - bucketweight);
                        closestPlayer = player;
                    }
                }

                if (isgamefinished)
                {
                    break;
                }
            }

            if (!isgamefinished)
            {
                Console.WriteLine($"{closestPlayer.Name} won because he had closest guess");
            }

            Console.ReadKey();
        }
 private float GetNextRoadCarSpeed(float difficulty)
 {
     carSpeedId++;
     return(Mathf.Lerp(minCarSpeed, Mathf.Lerp(minCarSpeed, maxCarSpeed, difficulty), CustomRandom.Get((uint)carSpeedId)));
 }
 public ComplexCarrierTone GetCarrier(double fundamentalFreq) =>
 new ComplexCarrierTone(
     frequency: fundamentalFreq * freqRatio,
     amplitude: Complex64.FromPolarCoordinates(
         magnitude: amplitude,
         phase: 2.0 * PI * CustomRandom.NextDouble()));
        private IEnumerable <ComplexCarrierTone> CreateSideBands(
            double freqLB,
            double freqUB,
            int count,
            AmplitudeDistribution distribution)
        {
            double freqRatio = Math.Pow((freqUB / freqLB), 1.0 / (count - 1.0));

            if (double.IsNaN(freqRatio) || double.IsInfinity(freqRatio))
            {
                freqRatio = 1.0;
            }

            double freq = freqLB;

            for (int carrierTone = 0; carrierTone < count; carrierTone++)
            {
                yield return(new ComplexCarrierTone(frequency: freq,
                                                    amplitude: Complex64.FromPolarCoordinates(
                                                        magnitude: GetFactor(distribution, freq) * CustomRandom.RayleighDistribution(randomizer.NextDouble()),
                                                        phase: 2.0 * Math.PI * randomizer.NextDouble())));

                freq *= freqRatio;
            }
        }
        static bool CreateNewBounties()
        {
            Debug.Log("[BountyManagerHook] CreateNewBounties(): Function called.");

            // Get an instance of the hook class.
            BountyManagerHook classHook = new BountyManagerHook();

            InventoryControl inventory = GameStateMachine.instance.GetInventory();
            int playerLevel            = inventory.Level;
            int highestHackedLevel     = inventory.GetHighestServerHacked();

            // Bounty level here is the reward level.
            int bountyLevel = highestHackedLevel + 3;

            if (playerLevel < InventoryControl.LEVEL_SOFT_CAP)
            {
                // so they can still use any items they get from this.
                bountyLevel = Mathf.Min(playerLevel + 10, bountyLevel);
            }

            // We don't want negative level bounties.
            bountyLevel = Mathf.Max(1, bountyLevel);

            // Create 3 new bounties.
            for (int i = 0; i < 3; i++)
            {
                bool track = true;

                // Don't replace a bounty that's still valid.
                if (BountyManager.instance.Bounties[i] != null)
                {
                    // Keep track of this so we can reuse it later.
                    track = BountyManager.instance.Bounties[i].Track;

                    if (BountyManager.instance.Bounties[i].CurrentState == Bounty.State.Complete)
                    {
                        continue;
                    }

                    if (BountyManager.instance.Bounties[i].CurrentState != Bounty.State.Redeemed && (BountyManager.instance.Bounties[i].ExpireTime > DateTime.Now || BountyManager.instance.Bounties[i].ExpireTime == DateTime.MinValue))
                    {
                        continue;
                    }
                }
                else if (playerLevel < 5)
                {
                    // No bounties before level MINLEVEL, unless they had some from before.
                    switch (i)
                    {
                    case 0:
                        BountyManager.instance.Bounties[i]       = new LevelUpBounty(new Pulse(RarityType.Rare, 5));
                        BountyManager.instance.Bounties[i].Track = false;
                        break;

                    case 1:
                        BountyManager.instance.Bounties[i]       = new LevelUpBounty(new Heal("Heal", RarityType.Rare, 5));
                        BountyManager.instance.Bounties[i].Track = false;
                        break;

                    case 2:
                        BountyManager.instance.Bounties[i]       = new LevelUpBounty(new Mine("Mine", RarityType.Rare, 5));
                        BountyManager.instance.Bounties[i].Track = false;
                        break;
                    }

                    continue;
                }

                // At this point, we're creating new bounties.
                if (BountyManager.instance.Bounties[i] != null)
                {
                    // Just to be sure.
                    BountyManager.instance.Bounties[i].Remove();
                }

                // Forcing this null so it shouldn't be in memory anymore.
                BountyManager.instance.Bounties[i] = null;

                CustomRandom bountyRandom = new CustomRandom(DateTime.Now.Ticks + i);

                // Determine which bounty based on the level and the RNG.
                String choice = classHook.SelectBountyType(bountyRandom, bountyLevel);
                Type   t      = Type.GetType(classHook.GetFullBountyClassName(choice));

                // Create an object of type t.
                BountyManager.instance.Bounties[i] = (Bounty)Activator.CreateInstance(t, bountyRandom, bountyLevel, i);

                // Maybe add fun names later?
                BountyManager.instance.Bounties[i].Title = "Bounty #" + (i + 1).ToString();

                BountyManager.instance.Bounties[i].Track = true;
            }

            // We don't want to call the original function.
            return(false);
        }
Exemple #6
0
        public void StartMainGame()
        {
            gameState = GameState.MainGame;

            CursorVisible = false;

            entityManager.DeleteAllEntities();
            Entity entity;

            // light
            mainLight = new Light("Directional Light");
            mainLight.transform.position = new Vector3(40, 100, 20);
            mainLight.transform.LookAt(Vector3.Zero);

            // environment
            List <Vector3> AIroute;

            EnvironmentGenerator.GenerateFromFile(@"Map Layout/Layout1.txt", entityManager, out AIroute);

            // HUD/UI creation
            lifeHearths[0] = new Entity("Star 1", new ComponentUI("Hearth Icon.png"));
            lifeHearths[0].transform.position.Xy = new Vector2(Width * 0.85f, Height * 0.95f);
            lifeHearths[0].transform.scale       = new Vector3(75f);
            entityManager.AddEntity(lifeHearths[0]);

            lifeHearths[1] = new Entity("Star 2", new ComponentUI("Hearth Icon.png"));
            lifeHearths[1].transform.position.Xy = new Vector2(Width * 0.91f, Height * 0.95f);
            lifeHearths[1].transform.scale       = new Vector3(75f);
            entityManager.AddEntity(lifeHearths[1]);

            lifeHearths[2] = new Entity("Star 3", new ComponentUI("Hearth Icon.png"));
            lifeHearths[2].transform.position.Xy = new Vector2(Width * 0.97f, Height * 0.95f);
            lifeHearths[2].transform.scale       = new Vector3(75f);
            entityManager.AddEntity(lifeHearths[2]);

            entity = new Entity("Mini Map", new ComponentUI(miniMapCamera.activeRenderTexture, "RenderTexture"));
            entity.transform.position.Xy = new Vector2(Width * 0.12f, Height * 0.2f);
            entity.transform.scale       = new Vector3(300f);
            entityManager.AddEntity(entity);

            entity = new Entity("Crosshair", new ComponentUI("Crosshair.png"));
            entity.transform.position.Xy = new Vector2(Width * 0.5f, Height * 0.5f);
            entity.transform.scale       = new Vector3(150f);
            entityManager.AddEntity(entity);

            // player
            player = new Player("Orbit Camera", mainCamera, entityManager);
            entityManager.AddEntity(player);

            // create drones
            Drone.isDisabled = false;
            drones           = new Drone[numberOfDrones];
            int[] startIndices = CustomRandom.GetDifferentValues(numberOfDrones, 0, AIroute.Count - 1);
            for (int i = 0; i < numberOfDrones; i++)
            {
                drones[i] = new Drone("Drone" + (i + 1).ToString(), AIroute, startIndices[i], player);
                entityManager.AddEntity(drones[i]);
            }

            entity = new Entity("Skybox", new ComponentCube(new string[]
            {
                "Textures/skybox_ft.png",
                "Textures/skybox_bk.png",
                "Textures/skybox_up.png",
                "Textures/skybox_dn.png",
                "Textures/skybox_lf.png",
                "Textures/skybox_rt.png"
            }));
            entityManager.AddEntity(entity);

            systemManager.DeleteAllSystems();
            systemManager.AddSystem(new SystemBehaviour());
            systemManager.AddSystem(new SystemPhysics());
            systemManager.AddSystem(new SystemRender(miniMapCamera, mainLight));
            systemManager.AddSystem(new SystemRender(mainCamera, mainLight));
            systemManager.AddSystem(new SystemRenderSkybox(mainCamera, mainLight));
            systemManager.AddSystem(new SystemCollision(entityManager));
            systemManager.AddSystem(new SystemRenderUI(Width, Height));
        }
 private void generateNewMove()
 {
     moveDuration = CustomRandom.rand(minMoveDuration, maxMoveDuration);
     moveIndex    = CustomRandom.rand(0, movableComponent.all.Length);
 }
 public MazeGenerator(int width, int height, int level)
 {
     this.width  = width;
     this.height = height;
     rand        = new CustomRandom(width, height, level);
 }
        private DrawingType DrawingMethod()
        {
            CustomRandom r = new CustomRandom();

            return(r.Next(1, 200) > 50 ? DrawingType.Vertical : DrawingType.Horizontal);
        }