public override void createParticle()
        {
            int nextIndex = -1;

            do
            {
                nextIndex = RANDOM.Next(this.SPAWN_LOCATIONS.Length);
            } while (this.lastUsedIndex == nextIndex);
            this.lastUsedIndex           = nextIndex;
            base.particleParams.Position = this.SPAWN_LOCATIONS[this.lastUsedIndex];
            ConstantSpeedParticle     particle    = new ConstantSpeedParticle(base.particleParams);
            ScaleOverTimeEffectParams effectParms = new ScaleOverTimeEffectParams {
                Reference = particle,
                ScaleBy   = new Vector2(1f)
            };

            particle.addEffect(new ScaleOverTimeEffect(effectParms));
            RotateOverTimeEffectParams rotateEffectParms = new RotateOverTimeEffectParams {
                Reference = particle,
                RotateBy  = 2f
            };

            particle.addEffect(new RotateOverTimeEffect(rotateEffectParms));
            FadeEffectParams fadeEffectParms = new FadeEffectParams {
                Reference           = particle,
                State               = FadeEffect.FadeState.Out,
                TotalTransitionTime = TIME_TO_LIVE,
                OriginalColour      = COLOUR
            };

            particle.addEffect(new FadeEffect(fadeEffectParms));

            base.particles.Add(particle);
            base.createParticle();
        }
 protected override IEnumerable <object> GenerateData(BooleanColumnPOCO column, int recordsCount)
 {
     while (recordsCount-- > 0)
     {
         yield return(RANDOM.Next(0, 2));
     }
 }
Ejemplo n.º 3
0
        private BtrieveFile CreateBtrieveFile()
        {
            var btrieveFile = new BtrieveFile()
            {
                RecordLength = RECORD_LENGTH,
                FileName     = $"{RANDOM.Next() % 100_000_000}.DAT",
                RecordCount  = 3,
            };

            var key = new BtrieveKey();

            key.Segments.Add(new BtrieveKeyDefinition()
            {
                Number     = 0,
                Attributes = EnumKeyAttributeMask.UseExtendedDataType | EnumKeyAttributeMask.Duplicates,
                DataType   = EnumKeyDataType.Zstring,
                Offset     = 0,
                Length     = 32,
                Segment    = false,
            });

            btrieveFile.Keys.Add(0, key);

            btrieveFile.Records.Add(new BtrieveRecord(1, CreateRecord("ABC", 1)));
            btrieveFile.Records.Add(new BtrieveRecord(2, CreateRecord("ABC", 2)));
            btrieveFile.Records.Add(new BtrieveRecord(3, CreateRecord("abc", 3)));
            btrieveFile.Records.Add(new BtrieveRecord(4, CreateRecord("abc", 4)));
            btrieveFile.Records.Add(new BtrieveRecord(5, CreateRecord("test", 5)));
            btrieveFile.Records.Add(new BtrieveRecord(6, CreateRecord("yyz", 6)));

            return(btrieveFile);
        }
Ejemplo n.º 4
0
        public void DoFire()
        {
            int counter = 0;
            int rand    = RANDOM.Next(0, 255);
            int curSrc  = FIRE_WIDTH;

            do
            {
                int srcOffset = (curSrc + counter);
                int pixel     = FIRE_PIXELS[srcOffset];
                int step      = 2;
                rand       = SpreadFire(pixel, curSrc, counter, srcOffset, rand, FIRE_WIDTH);
                curSrc    += FIRE_WIDTH;
                srcOffset += FIRE_WIDTH;

                do
                {
                    pixel      = FIRE_PIXELS[srcOffset];
                    step      += 2;
                    rand       = SpreadFire(pixel, curSrc, counter, srcOffset, rand, FIRE_WIDTH);
                    pixel      = FIRE_PIXELS[srcOffset + FIRE_WIDTH];
                    curSrc    += FIRE_WIDTH;
                    srcOffset += FIRE_WIDTH;
                    rand       = SpreadFire(pixel, curSrc, counter, srcOffset, rand, FIRE_WIDTH);
                    curSrc    += FIRE_WIDTH;
                    srcOffset += FIRE_WIDTH;
                } while (step < FIRE_HEIGHT);

                counter++;
                curSrc -= ((FIRE_WIDTH * FIRE_HEIGHT) - FIRE_WIDTH);
            } while (counter < FIRE_WIDTH);
        }
Ejemplo n.º 5
0
        //Allow the player to guess one player's goals
        protected override int GuessGoal(Player player)
        {
            int coinTotal = 20;

            foreach (Tuple <string, int> record in Tracking)
            {
                if (record.Item1 == player.Name)
                {
                    //AI track purchases perfectly, so this artificially adds some uncertainty to their guessing
                    int badness = RANDOM.Next(-1, 2);
                    coinTotal += record.Item2 + badness;
                }
            }


            if (coinTotal < 7)
            {
                return(3);
            }
            if (coinTotal < 15)
            {
                return(10);
            }
            if (coinTotal < 25)
            {
                return(20);
            }
            if (coinTotal < 35)
            {
                return(30);
            }
            return(40);
        }
		public override void createParticle() {
			if (Emitt) {
				float x = RANDOM.Next(0, 180);
				if (RANDOM.Next(0, 2) == 1) {
					x = -x;
				}
				float y = RANDOM.Next(0, 180);
				if (RANDOM.Next(0, 2) == 1) {
					y = -y;
				}
				float rotation = (float)Math.Atan2(x, -y);

				BaseParticle2DParams particleParms = new BaseParticle2DParams();
				particleParms.TimeToLive = 1000;
				particleParms.Texture = base.particleTexture;
				particleParms.Scale = new Vector2(.75f);
				particleParms.Position = this.position;
				particleParms.Origin = new Vector2(Constants.TILE_SIZE / 2);
				particleParms.Direction = new Vector2(x, y);
				particleParms.Acceleration = new Vector2(.15f);
				particleParms.Rotation = rotation;
				particleParms.LightColour = Color.White;


				ConstantSpeedParticle particle = new ConstantSpeedParticle(particleParms);
				base.particles.Add(particle);
				base.createParticle();
			}
		}
Ejemplo n.º 7
0
        //Assign one of the goals to each player
        protected virtual void AssignGoals()
        {
            List <int> goalAssignments = new List <int>(GOALS);

            for (int i = Players.Count; i > 0; i--)
            {
                Players[i - 1].Goal = goalAssignments.Pull(RANDOM.Next(0, i));
            }
        }
        protected override IEnumerable <object> GenerateData(NumberColumnPOCO column, int recordsCount)
        {
            int columnMax = GetColumnMax(column);
            int columnMin = GetColumnMin(column);

            while (recordsCount-- > 0)
            {
                yield return(RANDOM.Next(columnMin, columnMax));
            }
        }
        public MBBSEmuIntegrationTestBase()
        {
            _modulePath = GetModulePath();

            _serviceResolver = new ServiceResolver(SessionBuilder.ForTest($"MBBSDb_{RANDOM.Next()}"));

            _serviceResolver.GetService <IAccountRepository>().Reset("sysop");
            _serviceResolver.GetService <IAccountKeyRepository>().Reset();
            Directory.CreateDirectory(_modulePath);
        }
Ejemplo n.º 10
0
 public static void AddNoise(SpriteBatch spriteBatch, int noiseAmount)
 {
     for (int a = 0; a <= noiseAmount; a++)
     {
         for (int i = 0; i <= SCREEN_SIZE.X; i++)
         {
             spriteBatch.Draw(Sprites.SPR_WHITEPIXEL, new Vector2(i + RANDOM.Next(-5, 5), RANDOM.Next(SCREEN_SIZE.Y)), null, null, null, (float)RANDOM.NextDouble() * 2f, null, Color.Gray);
         }
     }
 }
Ejemplo n.º 11
0
        protected override IEnumerable <object> GenerateData(ChoiceColumnPOCO column, int recordsCount)
        {
            var choiceCount = column.Choices.Count();

            while (recordsCount-- > 0)
            {
                var idx = RANDOM.Next(choiceCount);
                yield return(column.Choices[idx]);
            }
        }
Ejemplo n.º 12
0
        public static object ListRandom(
            [DekiScriptParam("list value")] ArrayList list
            )
        {
            if (list.Count == 0)
            {
                return(null);
            }
            int index = RANDOM.Next(list.Count);

            return(list[index]);
        }
Ejemplo n.º 13
0
        protected override IEnumerable <object> GenerateData(TextColumnPOCO column, int recordsCount)
        {
            var textSamples = textDAO.GetRandomTexts(recordsCount);

            while (recordsCount-- > 0)
            {
                var text      = textSamples[recordsCount % textSamples.Count()];
                var maxLength = Math.Min(text.Length, column.MaxLength);
                var length    = RANDOM.Next(column.MinLength, maxLength);
                yield return(text.Substring(0, length));
            }
        }
Ejemplo n.º 14
0
 //Extend Lists to allow obtaining a random item
 public static T GetRandom <T>(this IList <T> list)
 {
     if (list.Count == 0)
     {
         throw new Exception("Empty List!");
     }
     if (list.Count == 1)
     {
         return(list[0]);
     }
     return(list[RANDOM.Next(0, list.Count)]);
 }
Ejemplo n.º 15
0
    public override void Update(object gameTime)
    {
        base.Update(gameTime);
        if (GameStats.InWave)
        {
            if (RANDOM.Next(50) == 0 && resources > 0)
            {
                double   type_a = Math.Sqrt(Math.Min(LIST_ENEMIES.Count, (int)(GameStats.Wave / 3)));
                double   type_b = Math.Sqrt(Math.Min(LIST_ENEMIES.Count, (int)(GameStats.Wave / 3)));
                string   eType  = LIST_ENEMIES[RANDOM.Next((int)(type_a * type_b))];
                Type     t      = Type.GetType(eType);         //Get the type of the object
                object   temp   = Activator.CreateInstance(t); //Create an instance of that object
                Enemy    obj    = temp as Enemy;               //Cast it as an Enemy
                GridNode node   = available[RANDOM.Next(available.Count)];

                obj.startNode = node;
                obj.Position  = node.Position;
                plane.Add(obj);
                resources -= obj.cost;
            }

            bool         AllDeath = true;
            List <Enemy> list     = plane.FindByType <Enemy>();
            foreach (Enemy e in list)
            {
                if (!e.kill)
                {
                    AllDeath = false;
                    break;
                }
            }
            if (AllDeath && GameStats.InWave && resources <= 0)
            {
                GameStats.InWave    = false;
                GameStats.WaveTimer = 10 * 60;
            }
        }

        if (!GameStats.InWave && GameStats.WaveTimer > 0)
        {
            GameStats.WaveTimer--;
            if (GameStats.WaveTimer <= 0)
            {
                GameStats.InWave = true;
                int x = GameStats.Wave++;

                resources = (int)(500 + 2 * Math.Pow(x, (Math.Sqrt(x / 100) + 1)) + 400 * (float)Math.Sqrt(x));
            }
        }
    }
Ejemplo n.º 16
0
            public override void SetupRules()
            {
                int maxQueryFailures  = RANDOM.Next(1, MAX_ATTEMPTS);
                int maxUpdateFailures = MAX_ATTEMPTS - maxQueryFailures;

                Console.WriteLine("Max UPDATE fault failures: " + maxUpdateFailures);
                Console.WriteLine("Max QUERY fault failures: " + maxQueryFailures);

                Rules.Add(new FaultRule(MongoRepositoryHelper.Method.UPDATE_CAS,
                                        CustomConditions.TriggerRandomlyWithMax(maxUpdateFailures),
                                        BuiltInFaults.ThrowExceptionFault(expectedFault)));
                Rules.Add(new FaultRule(MongoRepositoryHelper.Method.SINGLE,
                                        CustomConditions.TriggerRandomly(1, maxQueryFailures),
                                        BuiltInFaults.ThrowExceptionFault(expectedFault)));
            }
Ejemplo n.º 17
0
 public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     if (RANDOM.Next(8) == 0)
     {
         SortingThread.AddRequest(this);
     }
     base.Draw(gameTime, spriteBatch);
     //Draw the grid outlines
     for (int i = 0; i < (LEVEL_SIZE.X + LEVEL_SIZE.Y); ++i)
     {
         //Right to left
         DrawingHelper.DrawLine(spriteBatch, GlobalPosition + new Vector2(LEVEL_SIZE.X * NODE_SIZE.X - NODE_SIZE.X * i, 0), GlobalPosition + new Vector2(LEVEL_SIZE.X * NODE_SIZE.X, NODE_SIZE.Y * i), Color.Black, 2, 0.0f);
         //Left to right
         DrawingHelper.DrawLine(spriteBatch, GlobalPosition + new Vector2(NODE_SIZE.X * i, 0), GlobalPosition + new Vector2(0, NODE_SIZE.Y * i), Color.Black, 2, 0.0f);
     }
 }
Ejemplo n.º 18
0
        //(Generic) Decide on what action to take for the turn
        public virtual string DecideAction(int currentShareValue)
        {
            string action = "";

            //50% chance to buy or pass
            if (RANDOM.Next(2) == 1)
            {
                action = ACTION_BUY;
            }
            else
            {
                action = ACTION_PASS_ROUND;
            }

            return(action);
        }
Ejemplo n.º 19
0
        //Fill any open spots in the game with computer players
        void GetComputerPlayers()
        {
            List <string> ComputerNames = new List <string> {
                "Groot", "Thor", "Hulk", "Mantis", "Thanos", "Spider-Man",
                "Captain America", "Iron Man", "Black Panther", "Doctor Strange", "Scarlet Witch",
                "Star-Lord", "Loki", "Gamora", "Black Widow", "Vision", "Bucky", "Nebula", "Drax", "Ant-Man (Not Pictured)"
            };

            while (Players.Count < 5)
            {
                NonBlockingSleep(1);
                Player tempPlayer = new DumbAIPlayer(ComputerNames.Pull(RANDOM.Next(ComputerNames.Count())), RANDOM.Next());
                Players.Add(tempPlayer);
                WriteLine(tempPlayer.Name + " joined the game!");
            }
        }
Ejemplo n.º 20
0
    public virtual Enemy findTarget()
    {
        for (int i = enemies.Count - 1; i >= 0; --i)
        {
            if (CalculateDistance(GlobalPosition, enemies[i].GlobalPositionCenter) > TowerRange(type, stats))
            {
                enemies.RemoveAt(i);
            }
        }
        if (enemies.Count > 0)
        {
            return(enemies[RANDOM.Next(enemies.Count)]);
        }


        return(null);
    }
Ejemplo n.º 21
0
        public Clouds(Vector2 position)
        {
            velocity      = new Vector2(1, -0.3f);
            rotation      = RANDOM.Next(1, 20);
            this.position = position;

            opacity = (float)RANDOM.NextDouble() * 0.3f;

            if (RANDOM.NextDouble() > 0.5)
            {
                currentTexture = Sprites.SPR_CLOUD1;
            }
            else
            {
                currentTexture = Sprites.SPR_CLOUD2;
            }
        }
Ejemplo n.º 22
0
        public int SpreadFire(int pixel, int curSrc, int counter, int srcOffset, int rand, int width)
        {
            if (pixel != 0)
            {
                int randIdx = RANDOM.Next(0, 255);
                int tmpSrc;
                rand   = ((rand + 2) & 255);
                tmpSrc = (curSrc + (((counter - (randIdx & 3)) + 1) & (width - 1)));
                FIRE_PIXELS[tmpSrc - FIRE_WIDTH] = pixel - (randIdx & 1);
            }
            else
            {
                FIRE_PIXELS[srcOffset - FIRE_WIDTH] = 0;
            }

            return(rand);
        }
Ejemplo n.º 23
0
 void AddPlayerMethod()
 {
     if (CurrentGame.Players.Count < 5)
     {
         HumanPlayer tempPlayer = new HumanPlayer(NameField.Text, RANDOM.Next());
         tempPlayer.OnTakingTurn      += TakingTurn;
         tempPlayer.OnGuessingGoal    += Guessing;
         tempPlayer.OnCoinValueChange += UpdateCoinDisplay;
         CurrentGame.Players.Add(tempPlayer);
         WriteLine(NameField.Text + " joined the game!");
         NameField.Clear();
         DoneButton.Show();
     }
     else
     {
         WriteLine("Cannot add new player.");
     }
 }
Ejemplo n.º 24
0
 //Generate initial spread of special tiles in distributionGrid. distributionGrid is used to hold and edit the distribution of special tiles before they are added to the level
 public void PopulateDistributionGrid(int tileType, int initialRatio)
 {
     //Keep the borders of the grid clear of special tiles during distribution
     for (int x = 1; x < LEVEL_SIZE.X - 1; x++)
     {
         for (int y = 2; y < LEVEL_SIZE.Y - 2; y++)
         {
             if (RANDOM.Next(100) < initialRatio)
             {
                 //Keep the center, as well as a horizontal and vertical line through the middle of the grid clear of special tiles during distribution
                 if ((x < LEVEL_SIZE.X / 2 - 3) || (x > LEVEL_SIZE.X / 2 + 3) || (y < LEVEL_SIZE.Y / 2 - 6) || (y > LEVEL_SIZE.Y / 2 + 6))
                 {
                     if ((x != LEVEL_SIZE.X / 2) && (y != LEVEL_SIZE.Y / 2))
                     {
                         distributionGrid[x, y] = true;
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 25
0
    public override void Update(object gameTime)
    {
        base.Update(gameTime);

        handler.Update(gameTime);

        if (!scoreAdded)
        {
            Add(scoreForm);
            scoreAdded = true;
        }

        if (backButton.Pressed)
        {
            GameEnvironment.GameStateManager.SwitchTo("MainMenuState");
        }

        if (RANDOM.NextDouble() > 0.97)
        {
            pc.AddExplosion(new Vector2(RANDOM.Next(0, 1920), RANDOM.Next(0, 1080)));
            PlaySound(ContentImporter.Sounds.SND_EXPLOSION);
        }
    }
Ejemplo n.º 26
0
        protected ExportedModuleTestBase(string modulePath)
        {
            _serviceResolver = new ServiceResolver(fakeClock, SessionBuilder.ForTest($"MBBSDb_{RANDOM.Next()}"));
            var textVariableService = _serviceResolver.GetService <ITextVariableService>();

            mbbsEmuMemoryCore   = mbbsEmuProtectedModeMemoryCore = new ProtectedModeMemoryCore(_serviceResolver.GetService <ILogger>());
            mbbsEmuCpuCore      = new CpuCore(_serviceResolver.GetService <ILogger>());
            mbbsEmuCpuRegisters = mbbsEmuCpuCore;

            var testModuleConfig = new ModuleConfiguration {
                ModulePath = modulePath, ModuleEnabled = true
            };

            mbbsModule = new MbbsModule(FileUtility.CreateForTest(), fakeClock, _serviceResolver.GetService <ILogger>(), testModuleConfig, mbbsEmuProtectedModeMemoryCore);

            testSessions = new PointerDictionary <SessionBase>();
            testSessions.Allocate(new TestSession(null, textVariableService));
            testSessions.Allocate(new TestSession(null, textVariableService));

            majorbbs = new HostProcess.ExportedModules.Majorbbs(
                _serviceResolver.GetService <IClock>(),
                _serviceResolver.GetService <ILogger>(),
                _serviceResolver.GetService <AppSettings>(),
                _serviceResolver.GetService <IFileUtility>(),
                _serviceResolver.GetService <IGlobalCache>(),
                mbbsModule,
                testSessions,
                _serviceResolver.GetService <IAccountKeyRepository>(),
                _serviceResolver.GetService <IAccountRepository>(),
                textVariableService);

            galgsbl = new HostProcess.ExportedModules.Galgsbl(
                _serviceResolver.GetService <IClock>(),
                _serviceResolver.GetService <ILogger>(),
                _serviceResolver.GetService <AppSettings>(),
                _serviceResolver.GetService <IFileUtility>(),
                _serviceResolver.GetService <IGlobalCache>(),
                mbbsModule,
                testSessions,
                textVariableService);

            mbbsEmuCpuCore.Reset(
                mbbsEmuMemoryCore,
                (ordinal, functionOrdinal) => ExportedFunctionDelegate(ordinal, functionOrdinal, offsetsOnly: false),
                null,
                null);
        }
Ejemplo n.º 27
0
 public static int choose(List <int> list)
 {
     return(list[RANDOM.Next(list.Count)]);
 }
Ejemplo n.º 28
0
 protected FileTestBase() : base(Path.Join(Path.GetTempPath(), $"mbbsemu{RANDOM.Next()}"))
 {
     Directory.CreateDirectory(mbbsModule.ModulePath);
 }
Ejemplo n.º 29
0
        public BtrieveRuntime_Tests()
        {
            _modulePath = GetModulePath();

            _serviceResolver = new ServiceResolver(SessionBuilder.ForTest($"MBBSExeRuntime_{RANDOM.Next()}"));

            Directory.CreateDirectory(_modulePath);
        }
Ejemplo n.º 30
0
        //(Generic) Allow the player to guess one player's goal
        protected virtual int GuessGoal(Player player)
        {
            int guess = GOALS[RANDOM.Next(GOALS.Count())];

            return(guess);
        }