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();
        }
Esempio n. 2
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);
        }
 protected override IEnumerable <object> GenerateData(BooleanColumnPOCO column, int recordsCount)
 {
     while (recordsCount-- > 0)
     {
         yield return(RANDOM.Next(0, 2));
     }
 }
Esempio n. 4
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);
        }
Esempio 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();
			}
		}
Esempio n. 7
0
 public void injectFireballs()
 {
     for (int i = 0; i < _power * 10; i++)
     {
         float    speed    = RANDOM.getFloat(5, 15);
         Fireball fireball = new Fireball(position, RANDOM.getRotation, 1, 0, speed, -1);
         _fireballs.Add(fireball);
     }
 }
Esempio n. 8
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);
        }
Esempio n. 11
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);
         }
     }
 }
Esempio n. 12
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]);
            }
        }
        protected override IEnumerable <object> GenerateData(NumberColumnPOCO column, int recordsCount)
        {
            var columnMin = GetColumnMin(column);
            var columnMax = GetColumnMax(column);

            while (recordsCount-- > 0)
            {
                yield return(RANDOM.NextDouble() * (columnMax - columnMin) + columnMin);
            }
        }
Esempio n. 14
0
        protected override IEnumerable <object> GenerateData(DateTimeColumnPOCO column, int recordsCount)
        {
            var milisecondsRange = (column.MaxValue - column.MinValue).TotalMilliseconds;

            while (recordsCount-- > 0)
            {
                var miliseconds = RANDOM.NextDouble() * milisecondsRange;
                yield return(column.MinValue.AddMilliseconds(miliseconds));
            }
        }
Esempio n. 15
0
        //-----------------------------------------------------------------------------------------------------
        // ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■


        //====================================================================================================
        // ■ START
        //====================================================================================================
        void Start()
        {
            var position = Transform.Position;

            Height = math.distance(position, new float3(0, 0, 0));

            HitCount         = RANDOM.Int(1, 20);
            OriginalHitCount = HitCount;

            Color = OriginalColor;
        }
Esempio n. 16
0
 public override void Update(object gameTime)
 {
     if (GlobalPosition.Y + Origin.Y * 10 < 0 && GlobalPosition.X + Origin.X * 10 > SCREEN_SIZE.X)
     {
         opacity  = (float)RANDOM.NextDouble() * 0.3f;
         position = new Vector2(-Origin.X * 10, SCREEN_SIZE.Y + Origin.Y * 10);
     }
     else
     {
         position += velocity;
     }
 }
Esempio n. 17
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)]);
 }
Esempio n. 18
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]);
        }
Esempio n. 19
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));
            }
        }
Esempio n. 20
0
        //====================================================================================================
        // ■ ADD ASTEROID
        //====================================================================================================
        void AddAsteroid()
        {
            var obj = (GAMEOBJECT)Instantiate(AsteroidObject);

            obj.SetActive(true);
            obj.Tag = "Asteroid";
            obj.Transform.Parent = AsteroidInstances.Transform;

            var planetAxis          = new float3(RANDOM.Float(-1, 1), RANDOM.Float(-1, 1), RANDOM.Float(-1, 1));
            var planetRotationSpeed = RANDOM.Float(20, 200);

            obj.Transform.RotateAround(new float3(0, 0, 0), planetAxis, planetRotationSpeed);
        }
Esempio n. 21
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));
            }
        }
    }
Esempio n. 22
0
        //====================================================================================================
        // ■ UPDATE
        //====================================================================================================
        void Update()
        {
            if (AlienCount < AlienMaxCount)
            {
                var position = new float3(RANDOM.Float(-1, 1), RANDOM.Float(-1, 1), RANDOM.Float(-1, 1));
                var normal   = math.normalize(position);

                var height = GAMEOBJECT.Find("Center").GetComponent <CENTER>().GetHeight();

                position = math.normalize(position) * height;

                PutAlien(position, normal);
            }
        }
Esempio n. 23
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)));
            }
Esempio n. 24
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);
     }
 }
Esempio n. 25
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);
        }
Esempio n. 26
0
        //----------------------------------------------------------------------------------------------------
        // ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■


        //====================================================================================================
        // ■ START
        //====================================================================================================
        void Start()
        {
            Axis          = new float3(RANDOM.Float(-1, 1), RANDOM.Float(-1, 1), RANDOM.Float(-1, 1));
            RotationSpeed = RANDOM.Float(5, 20);

            //Planet
            PlanetAxis          = new float3(RANDOM.Float(-1, 1), RANDOM.Float(-1, 1), RANDOM.Float(-1, 1));
            PlanetRotationSpeed = RANDOM.Float(5, 20);

            HitCount         = RANDOM.Int(10, 100);
            OriginalHitCount = HitCount;

            var position = Transform.Position;

            Height = math.distance(position, new float3(0, 0, 0));
        }
Esempio n. 27
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!");
            }
        }
Esempio n. 28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testUpper()
        public virtual void testUpper()
        {
            for (int i = 0; i < 10; i++)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double x = A + 5 * Math.log(RANDOM.nextDouble());
                double x = A + 5 * Math.Log(RANDOM.NextDouble());
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double y = 5 * NORMAL.nextRandom();
                double y = 5 * NORMAL.nextRandom();
                assertRoundTrip(UPPER_LIMIT, x);
                assertReverseRoundTrip(UPPER_LIMIT, y);
                assertGradient(UPPER_LIMIT, x);
                assertInverseGradient(UPPER_LIMIT, y);
                assertGradientRoundTrip(UPPER_LIMIT, x);
            }
        }
Esempio n. 29
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);
    }
Esempio n. 30
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);
        }