Пример #1
0
        public void InitializeParticlePropertiesRespawn(DefaultSprite3DBillboardParticle cParticle)
        {
            //-----------------------------------------------------------
            // TODO: Initialize all of the Particle's properties here.
            // If you plan on simply using the default InitializeParticleUsingInitialProperties
            // Particle Initialization Function (see the LoadParticleSystem() function above),
            // then you may delete this function all together.
            //-----------------------------------------------------------
            // Set the Particle's Lifetime (how long it should exist for)
            cParticle.Lifetime = 1.0f;

            // Set the Particle's initial Position to be wherever the Emitter is
            cParticle.Position = Vector3.Zero;
            cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation);


            // Set the Particle's Velocity
            cParticle.Velocity = DPSFHelper.PointOnSphere(RandomNumber.Between(0, MathHelper.TwoPi), RandomNumber.Between(0, MathHelper.TwoPi), radius);

            // Adjust the Particle's Velocity direction according to the Emitter's Orientation
            cParticle.Velocity  = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);
            cParticle.Position += Emitter.PositionData.Position;


            // Give the Particle a random Size
            // Since we have Size Lerp enabled we must also set the Start and End Size
            cParticle.Width      = cParticle.StartWidth = cParticle.EndWidth = cParticle.EndHeight =
                cParticle.Height = cParticle.StartHeight = size;

            // Give the Particle a random Color
            // Since we have Color Lerp enabled we must also set the Start and End Color
            cParticle.Color    = cParticle.StartColor = Color.White;
            cParticle.EndColor = Color.Blue;
        }
Пример #2
0
        private void EndCombat(Monster monster)
        {
            // End combat, reward XP, gold and items if any
            InCombat = false;

            ShowMessage("You received: " + monster.RewardExperiencePoints.ToString() + " EXP");
            _player.RewardGold(monster.RewardGold);
            ShowMessage("You received: " + monster.RewardGold.ToString() + " gold!");
            List <InventoryItem> lootedItems = new List <InventoryItem>();

            foreach (LootItem lootItem in _currentMonster.LootTable)
            {
                if (RandomNumber.Between(1, 100) <= lootItem.DropPercentage)
                {
                    lootedItems.Add(new InventoryItem(lootItem.Details, 1));
                }
            }
            if (lootedItems.Count != 0)
            {
                foreach (InventoryItem inventoryItem in lootedItems)
                {
                    _player.AddItem(inventoryItem.Details, inventoryItem.Quantity);
                    ShowMessage("You received: " + inventoryItem.Quantity.ToString() + " " + inventoryItem.Details.Name);
                }
            }
            RewardXP(monster.RewardExperiencePoints);
            _player.RemoveAllBuffs();
            UpdateUI();
        }
Пример #3
0
        public static string RandomString(int length)
        {
            const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

            return(new string(Enumerable.Repeat(chars, length)
                              .Select(s => s[RandomNumber.Between(0, s.Length - 1)]).ToArray()));
        }
        public void CanServeKeyValueStore()
        {
            int      port      = RandomNumber.Between(8081, 65535);
            string   testKey   = 16.RandomLetters();
            string   testValue = 500.RandomLetters();
            Database sessionDb = DataProvider.Current.GetAppDatabase($"{nameof(KeyValueStoreServer)}_Sessions");

            sessionDb.TryEnsureSchema <SecureSession>();
            Db.For <SecureSession>(sessionDb);
            ConsoleLogger logger = new ConsoleLogger {
                AddDetails = false
            };
            DirectoryInfo       testStorage = new DirectoryInfo(Path.Combine(nameof(CanServeKeyValueStore), 8.RandomLetters()));
            KeyValueStoreServer server      = new KeyValueStoreServer(testStorage, logger)
            {
                Port = port
            };

            server.Started += (o, a) => OutLine("Server started", ConsoleColor.Green);
            server.Start();
            KeyValueStoreClient client = new KeyValueStoreClient("localhost", port, logger);

            client.StartSession();
            Expect.IsTrue(client.Set(testKey, testValue));
            Console.WriteLine(testStorage.FullName);
            server.Stop();
        }
        public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle)
        {
            particle.Lifetime      = RandomNumber.Between(0.3f, 0.7f);
            particle.Color         = particle.StartColor = ExplosionColor;
            particle.EndColor      = Color.Black;
            particle.Position      = Emitter.PositionData.Position + new Vector3(RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25));
            particle.Velocity      = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(1, 50);
            particle.ExternalForce = new Vector3(0, 80, 0);  // We want the smoke to rise
            particle.Size          = particle.StartSize = 1; // Have the particles start small and grow
            particle.EndSize       = ExplosionParticleSize;

            // Give the particle a random initial orientation and random rotation velocity (only need to Roll the particle since it will always face the camera)
            particle.Rotation           = RandomNumber.Between(0, MathHelper.TwoPi);
            particle.RotationalVelocity = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2);

            // Randomly pick which texture coordinates to use for this particle
            Rectangle textureCoordinates;

            switch (RandomNumber.Next(0, 4))
            {
            default:
            case 0: textureCoordinates = _flameSmoke1TextureCoordinates; break;

            case 1: textureCoordinates = _flameSmoke2TextureCoordinates; break;

            case 2: textureCoordinates = _flameSmoke3TextureCoordinates; break;

            case 3: textureCoordinates = _flameSmoke4TextureCoordinates; break;
            }

            particle.SetTextureCoordinates(textureCoordinates);
        }
Пример #6
0
        public static void ChangeRotation()
        {
            var magNorth = -Input.compass.magneticHeading;

            StartingRotation = Quaternion.Euler(0, magNorth + RandomNumber.Between(-180, 180), 0);
            OnRotationChanged?.Invoke(StartingRotation);
        }
Пример #7
0
        private static IdTree CreateRandomTree(int numberOfLevels, int maximumNumberOfNodes)
        {
            if (_idCount >= maximumNumberOfNodes)
            {
                return(null);
            }

            var randomTree = new IdTree {
                RootNode = new IdNode {
                    Id = _idCount++
                }
            };

            if (numberOfLevels == 0)
            {
                return(randomTree);
            }

            var numberOfChildren = RandomNumber.Between(1, 5);
            var nextLevel        = numberOfLevels - 1;

            for (int i = 0; i < numberOfChildren; i++)
            {
                var tree = CreateRandomTree(nextLevel, maximumNumberOfNodes);
                if (tree != null)
                {
                    tree.RootNode.Parent = randomTree.RootNode;
                    randomTree.RootNode.Children.Add(tree.RootNode);
                }
            }

            return(randomTree);
        }
Пример #8
0
        public void CreateAppShouldFireAppropriateEvents()
        {
            BamServer server = CreateServer(MethodBase.GetCurrentMethod().Name);
            bool?     ed     = false;
            bool?     ing    = false;

            server.CreatingApp += (s, ac) =>
            {
                ing = true;
            };

            server.CreatedApp += (s, ac) =>
            {
                ed = true;
            };

            Expect.IsFalse(ing.Value);
            Expect.IsFalse(ed.Value);

            string appName = "TestApp_".RandomLetters(4);

            server.CreateApp(appName, null, RandomNumber.Between(8000, 9999));

            Expect.IsTrue(ing.Value);
            Expect.IsTrue(ed.Value);

            if (Directory.Exists(server.ContentRoot))
            {
                Directory.Delete(server.ContentRoot, true);
            }
        }
Пример #9
0
        private decimal GetComplexityCoefficient(QuestСomplexity questСomplexity)
        {
            int coefficient;

            switch (questСomplexity)
            {
            case QuestСomplexity.Easy:
                coefficient = RandomNumber.Between(8, 10);
                break;

            case QuestСomplexity.Medium:
                coefficient = RandomNumber.Between(6, 8);;
                break;

            case QuestСomplexity.Hard:
                coefficient = RandomNumber.Between(3, 6);;
                break;

            case QuestСomplexity.Impossible:
                coefficient = RandomNumber.Between(1, 3);;
                break;

            default:
                coefficient = 10000;
                break;
            }

            return(coefficient);
        }
Пример #10
0
 public void LoadContent(ContentManager aContentManager, string[] anAssets, string aWeaponAsset)
 {
     myContentManager = aContentManager;
     myAssets         = anAssets;
     myWeaponAsset    = aWeaponAsset;
     if (mySubSpeed < 70)
     {
         //slow sub
         AccessSpeed    *= 0.5f;
         myDropFrequency = RandomNumber.Between(800, 1000);
         LoadContent(aContentManager, anAssets[0]);
     }
     else if (mySubSpeed < 100)
     {
         //fast sub
         AccessSpeed    *= 0.8f;
         myDropFrequency = RandomNumber.Between(700, 900);
         LoadContent(aContentManager, anAssets[1]);
     }
     else
     {
         // fastest sub
         AccessSpeed    *= 1.2f;
         myDropFrequency = RandomNumber.Between(400, 600);
         LoadContent(aContentManager, anAssets[2]);
     }
     foreach (MineElement mine in myMineList)
     {
         mine.LoadContent(aContentManager, aWeaponAsset);
         mine.AccessPosition = new Vector2(AccessPosition.X + AccessSize.Width / 2, AccessPosition.Y + AccessSize.Height / 2);
     }
 }
Пример #11
0
 private void GenerateNewCreature()
 {
     myCreatureSpeed = RandomNumber.Between(40, 130);
     GetDepth        = RandomNumber.Between(450, 850);
     AccessDirection = myDirectionLevels[RandomNumber.Between(1, 2) - 1];
     //Only initial position for Depth value, it will be final after LoadContent
     AccessPosition = new Vector2(myManager.PreferredBackBufferWidth, GetDepth);
 }
Пример #12
0
 public AsyncCallbackService(AsyncCallbackRepository repo, AppConf conf) : base(repo, conf)
 {
     HostPrefix = new HostPrefix {
         HostName = Machine.Current.DnsName, Port = RandomNumber.Between(49152, 65535)
     };
     AsyncCallbackRepository = repo;
     _pendingRequests        = new ConcurrentDictionary <string, Action <AsyncExecutionResponse> >();
 }
Пример #13
0
 private void SetInactive()
 {
     AccessActive       = false;
     AccessLowering     = false;
     AccessHovering     = false;
     AccessLifting      = false;
     AccessHoveringTime = 0;
     AccessPosition     = new Vector2(RandomNumber.Between(0, myManager.PreferredBackBufferWidth - AccessSize.Width), 0 - AccessSize.Height);
 }
Пример #14
0
 protected void UpdateParticleChangeVelocityAndRotation(DefaultTexturedQuadParticle cParticle, float fElapsedTimeInSeconds)
 {
     if (RandomNumber.Next(0, 100) == 50)
     {
         Vector3 sChange = new Vector3(RandomNumber.Next(-3, 3), RandomNumber.Next(-3, 3), RandomNumber.Next(-3, 3));
         cParticle.Velocity             += sChange;
         cParticle.RotationalVelocity.Z += RandomNumber.Between(-MathHelper.PiOver4, MathHelper.PiOver4);
     }
 }
Пример #15
0
        public static void CreateServer(out string baseAddress, out BamServer server)
        {
            BamConf conf = new BamConf();

            server = new BamServer(conf);
            server.DefaultHostPrefix.Port = RandomNumber.Between(8081, 65535);
            baseAddress = server.DefaultHostPrefix.ToString();
            Servers.Add(server);
        }
Пример #16
0
        public void AddComputeNodeShouldAddSlot()
        {
            int            slotCount = RandomNumber.Between(8, 16);
            RepositoryRing ring      = new RepositoryRing(slotCount);

            ring.AddArc(new RepositoryService());
            Expect.AreEqual(slotCount + 1, ring.Arcs.Length);

            PrintSlots(ring);
        }
Пример #17
0
        private void GenerateInitialIceberg(ContentManager myContent)
        {
            myIceberg = new StaticElement(1.0f, new Vector2(0, 0));
            myIceberg.LoadContent(myContent, "Elements/Iceberg");
            int minX     = ((myGraphics.PreferredBackBufferWidth / myIceberg.AccessSize.Width) - 2) * myIceberg.AccessSize.Width;
            int maxX     = myGraphics.PreferredBackBufferWidth - myIceberg.AccessSize.Width;
            int icebergX = RandomNumber.Between(minX, maxX);
            int icebergY = 130;

            myIceberg.AccessPosition = new Vector2(icebergX, icebergY);
        }
Пример #18
0
        public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle)
        {
            particle.Lifetime      = RandomNumber.Between(0.5f, 1.0f);
            particle.Color         = ExplosionColor;
            particle.Position      = Emitter.PositionData.Position + new Vector3(RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25));
            particle.Velocity      = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(30, 50);
            particle.ExternalForce = new Vector3(0, 20, 0);
            particle.Size          = ExplosionParticleSize;

            particle.SetTextureCoordinates(_roundSparkTextureCoordinates);
        }
Пример #19
0
        //===========================================================
        // Particle Update Functions
        //===========================================================

        //-----------------------------------------------------------
        // TODO: Place your Particle Update functions here, using the
        // same function prototype as below (i.e. public void FunctionName(DPSFParticle, float))
        //-----------------------------------------------------------

        /// <summary>
        /// Example of how to create a Particle Event Function
        /// </summary>
        /// <param name="cParticle">The Particle to update</param>
        /// <param name="fElapsedTimeInSeconds">How long it has been since the last update</param>
        protected void UpdateParticlePositionBySphereLerp(DefaultSpriteParticle cParticle, float fElapsedTimeInSeconds)
        {
            cParticle.Position = DPSFHelper.PointOnSphere(RandomNumber.Between(0, MathHelper.TwoPi), RandomNumber.Between(0, MathHelper.TwoPi), cParticle.NormalizedElapsedTime * radius);
            cParticle.Position = Vector3.Transform(cParticle.Position, Emitter.OrientationData.Orientation);



            // Adjust the Particle's Velocity direction according to the Emitter's Orientation
            //cParticle.Velocity = Vector3.Transform(cParticle.Velocity, Emitter.OrientationData.Orientation);
            cParticle.Position += Emitter.PositionData.Position;
            // Place code to update the Particle here
            // Example: cParticle.Position += cParticle.Velocity * fElapsedTimeInSeconds;
        }
Пример #20
0
        public void InitializeParticleExplosion(DefaultTextureQuadTextureCoordinatesParticle particle)
        {
            particle.Lifetime = RandomNumber.Between(0.5f, 1.0f);
            particle.Color    = ExplosionColor;
            particle.Position = Emitter.PositionData.Position;
            particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(175, 225);
            particle.Right    = -particle.Velocity;
            particle.Width    = ExplosionParticleSize;
            particle.Height   = ExplosionParticleSize * _textureAspectRatio;

            // Set the spark particle's texture coordinates
            particle.SetTextureCoordinates(_sparkTextureCoordinates, Texture.Width, Texture.Height);
        }
Пример #21
0
        private void GenerateRandomCloud(ContentManager myContent, GraphicsDeviceManager myGraphics, GameTime aGameTime)
        {
            float tempRandomSpeed = RandomNumber.Between(3, 8) / 10.0f;

            myLatestAddedCloud = aGameTime.TotalGameTime.Seconds;
            CloudElement aCloudElement = new CloudElement(0.6f, -1.0f, 0.0f, tempRandomSpeed, new Vector2(myGraphics.PreferredBackBufferWidth, RandomNumber.Between(1, 50)), myGraphics);

            aCloudElement.LoadContent(myContent, new string[] { "Elements/cloud1", "Elements/cloud2", "Elements/cloud3", "Elements/cloud4", "Elements/ShittySeagull" });
            myClouds.Add(aCloudElement);
            foreach (CloudElement cloud in myClouds.Where(s => s.AccessOutOfBounds).ToList())
            {
                myClouds.Remove(cloud);
            }
        }
Пример #22
0
        public void Shuffle()
        {
            List <Card> shuffled = new List <Card>();
            List <Card> current  = new List <Card>(Cards);
            int         count    = current.Count;

            for (int i = 0; i < count; i++)
            {
                int randomPosition = RandomNumber.Between(0, current.Count);
                shuffled.Add(current[randomPosition]);
                current.RemoveAt(randomPosition);
            }
            Cards = shuffled;
        }
Пример #23
0
        public void SlotShouldMakeFullCircleAfterInit()
        {
            RepositoryRing ring      = new RepositoryRing();
            int            slotCount = RandomNumber.Between(8, 16);

            ring.SetArcCount(slotCount);
            PrintSlots(ring);

            Expect.AreEqual(slotCount, ring.Arcs.Length);
            double fullCircle = 360;
            double endAngle   = ring.Arcs[ring.Arcs.Length - 1].EndAngle;

            Expect.AreEqual(fullCircle, endAngle);
        }
Пример #24
0
 public void Rest(object args = null)
 {
     Utils.Endl(2);
     Characters.ForEach(character =>
     {
         double maxHealth = character.EntityStats.MaxHealth;
         int healthPoints = RandomNumber.Between((int)maxHealth / 8, (int)maxHealth / 4);
         character.Regen(healthPoints);
         Utils.Cconsole.Green.WriteLine("After a little rest you recovered {0} health points", healthPoints);
         Utils.Cconsole.WriteLine("{0} has now {1} health points", character.Name, character.EntityStats.Health);
         Utils.Endl();
     });
     Utils.Endl(2);
 }
Пример #25
0
        public void ShouldBeAbleToCreateAppByName()
        {
            BamServer server  = CreateServer(MethodBase.GetCurrentMethod().Name);
            string    appName = "TestApp_".RandomLetters(4);

            server.CreateApp(appName, null, RandomNumber.Between(8000, 9999));
            DirectoryInfo appDir = new DirectoryInfo(Path.Combine(server.ContentRoot, "apps", appName));

            Expect.IsTrue(appDir.Exists);

            if (Directory.Exists(server.ContentRoot))
            {
                Directory.Delete(server.ContentRoot, true);
            }
        }
Пример #26
0
        private List <string> GenerateAvailableFonts(EWindowsVersion winVersion)
        {
            HashSet <string> source = new HashSet <string>();
            List <string>    list   = FakeProfileFactory._allFonts.ToList <string>();
            int count = list.Count;
            int int32 = Convert.ToInt32((double)count * 0.6);

            for (int index = 0; index < list.Count; ++index)
            {
                if (RandomNumber.Between(0, count) < int32)
                {
                    source.Add(list[index]);
                }
            }
            return(source.ToList <string>());
        }
Пример #27
0
        public void TriggerRightMonster()
        {
            double percent = 0;
            double random  = RandomNumber.Between(0, 100) + new Random().NextDouble();

            for (int i = 0; i < Spawnings.Count; ++i)
            {
                Spawning spawning = Spawnings[i];

                if (random <= (percent += spawning.Percent))
                {
                    GameMenu.Game.TriggerMonster(spawning.MonsterId);
                    return;
                }
            }
        }
Пример #28
0
        internal static BamServer CreateServer(string rootDir = "")
        {
            BamServer     server = new BamServer(BamConf.Load());
            ConsoleLogger logger = CreateLogger();

            server.MainLogger = logger;
            if (string.IsNullOrEmpty(rootDir))
            {
                rootDir = ".\\Test_".RandomLetters(5);
            }
            server.ContentRoot            = rootDir;
            server.DefaultHostPrefix.Port = RandomNumber.Between(8081, 65535);
            server.SaveConf(true);
            _servers.Add(server);
            return(server);
        }
Пример #29
0
        private void btn_submitCommand_Click(object sender, EventArgs e)
        {
            statusBar.Text = "Processing command";
            logger.Info("Sent Text - \"{0}\"", userInput.Text);
            System.Threading.Thread.Sleep(RandomNumber.Between(0, settings.companionSettings.randomWaitToRespondMaxMs));
            string returnValue = "";

            if (userInput.Text.ToLower().StartsWith("say"))
            {
                returnValue = userInput.Text.Substring(4, userInput.Text.Length - 4);
            }
            else if (userInput.Text.ToLower().StartsWith("clear screen"))
            {
                tb_console.Text = "";
                returnValue     = "Cleared screen.";
            }
            else if (userInput.Text.ToLower().StartsWith("stop talking"))
            {
                synthesisEngine.SpeakAsyncCancelAll();
                returnValue = "Sounds good.";
            }
            else if (settings.disableChatBot == false)
            {
                Request r;
                Result  res;

                r           = new Request(userInput.Text.ToString(), user, companion);
                res         = companion.Chat(r);
                returnValue = res.Output;
            }

            if (returnValue == "" || returnValue == null)
            {
                logger.Info("Could not generate a response.");
            }
            else
            {
                logger.Info("Response - \"{0}\"", returnValue.ToString());
            }
            userInput.Text = "";

            if (settings.silentMode == false)
            {
                synthesisEngine.SpeakAsync(returnValue);
            }
            statusBar.Text = "Awaiting user input";
        }
Пример #30
0
 public void LoadContent(ContentManager aContentManager, string[] anAssets)
 {
     myContentManager = aContentManager;
     myAssets         = anAssets;
     if (myCreatureSpeed < 95)
     {
         // Whale
         AccessSpeed = (float)RandomNumber.Between(4, 8) / 10;
         LoadContent(aContentManager, anAssets[0]);
     }
     else
     {
         // Shark
         AccessSpeed = (float)RandomNumber.Between(10, 15) / 10;
         LoadContent(aContentManager, anAssets[1]);
     }
 }