示例#1
0
        public void TheGameHasGameObjects()
        {
            var gameObject = new Raindrop(new Vector(1, 1));

            Game.TryAdd(gameObject);
            Assert.Contains(gameObject, Game.GameGrid.GameObjects);
        }
示例#2
0
        public void GameObjectsHaveALocation()
        {
            var gameObject = new Raindrop(new Vector(2, 3));

            Game.TryAdd(gameObject);
            Assert.AreEqual(2, gameObject.Location.X);
            Assert.AreEqual(3, gameObject.Location.Y);
            Assert.AreEqual(gameObject, Game.GameGrid.Get(new Vector(2, 3)));
        }
示例#3
0
        public void GameObjectsCanBeMoved()
        {
            var gameObject = new Raindrop(new Vector(1, 2));

            Game.Move(new MoveCommand(gameObject, new Vector(1, 1)));
            Assert.AreEqual(2, gameObject.Location.X);
            Assert.AreEqual(3, gameObject.Location.Y);
            Assert.AreEqual(gameObject, Game.GameGrid.Get(new Vector(2, 3)));
        }
 /// <summary>
 /// Creates the raindrop.
 /// </summary>
 /// <returns>A game object base</returns>
 private GameObjects.IGameObject CreateRaindrop()
 {
     var fallingObject = new Raindrop();
     fallingObject.Size = new System.Drawing.Size(50, 50);
     fallingObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     fallingObject.ImageLocation = ConfigurationManager.AppSettings["Fallingobjectspic"];
     fallingObject.Name = "Falling";
     return fallingObject;
 }
示例#5
0
        private static void AddRainbowRaindrops(int countUnder100, int countAbove200, double volume, int red, int green,
                                                int blue)
        {
            if (countUnder100 == 2 && countAbove200 == 1)
            {
                Raindrop raindrop = new Raindrop(volume, red, green, blue);

                raindrops.Add(raindrop);
            }
        }
    //instantiating a new raindrop instance
    void CreateRaindrop(Vector3 pos, float speed, float size)
    {
        GameObject drop  = Instantiate(prefabDrop);
        Raindrop   dropR = drop.GetComponent <Raindrop>();

        dropR.speed               = speed;
        dropR.size                = size;
        drop.transform.position   = pos;
        drop.transform.localScale = new Vector3(size, size, size);
    }
示例#7
0
 public void recycleRaindrop(Raindrop raindrop)
 {
     if (raindrop.GetParent() == this)
     {
         CallDeferred("remove_child", raindrop);
     }
     //RemoveChild(raindrop);
     raindrop.SetPhysicsProcess(false);
     raindrop.Visible = false;
     _drop_q.Enqueue(raindrop);
 }
        public void TheRaindropMovingPastTheBoundaryWrapsAround()
        {
            var randomNotReally = new NonRandomNumberGenerator();
            var startLocationX  = RandomNumberGenerator.Instance.Next(0, GameWidth); //Anywhere along the horizontal
            int startLocationY  = GameHeight - 1;                                    //Bottom of the screen
            var raindrop        = new Raindrop(randomNotReally, new Vector(startLocationX, startLocationY));

            Game.TryAdd(raindrop);
            Game.Move(new MoveCommand(raindrop, new Vector(0, 1))); //Move down
            Assert.AreEqual(randomNotReally.Result, raindrop.Location.Y);
            Assert.AreEqual(randomNotReally.Result, raindrop.Location.X);
        }
示例#9
0
        public void GameObjectsCanCollide()
        {
            var gameObject1 = new Raindrop(new Vector(1, 2));
            var gameObject2 = new Raindrop(new Vector(2, 3));

            Game.TryAdd(gameObject1);
            Game.TryAdd(gameObject2);
            var collisionEvent = Game.Move(new MoveCommand(gameObject1, new Vector(1, 1)));

            Assert.NotNull(collisionEvent);
            Assert.AreEqual(gameObject1, collisionEvent.Source);
            Assert.AreEqual(gameObject2, collisionEvent.Destination);
        }
示例#10
0
        public void AddingGameObjectsCanCauseCollisions()
        {
            var gameObject1 = new Raindrop(new Vector(1, 2));
            var gameObject2 = new Raindrop(new Vector(1, 2));

            Game.TryAdd(gameObject1);
            var collision = Game.TryAdd(gameObject2);

            Assert.NotNull(collision);
            //Notice how they are switched. In this case, the second is trying to move into the place of the first.
            Assert.AreEqual(gameObject2, collision.Source);
            Assert.AreEqual(gameObject1, collision.Destination);
        }
示例#11
0
    public override void _ExitTree()
    {
        while (_drop_q.Count > 0)
        {
            var node = _drop_q.Dequeue();
            node.QueueFree();
        }

        if (add_next != null)
        {
            add_next.QueueFree(); add_next = null;
        }
    }
示例#12
0
        public void ThePlayerCanCollideWithARaindrop()
        {
            var player   = new Player(new Vector(0, 0));
            var raindrop = new Raindrop(new Vector(1, 0));

            Game.TryAdd(player);
            Game.TryAdd(raindrop);
            var collisionEvent = Game.Move(new MoveCommand(player, new Vector(1, 0)));

            Assert.NotNull(collisionEvent);
            Assert.AreEqual(player, collisionEvent.Source);
            Assert.AreEqual(raindrop, collisionEvent.Destination);
        }
示例#13
0
        public void AddRaindrop()
        {
            var gameSize      = new Vector(GameWidth, GameHeight);
            var startLocation = Raindrop.GetValidStartLocation(gameSize, RandomNumberGenerator.Instance);
            var raindrop      = new Raindrop(startLocation);

            while (_gameController.TryAdd(raindrop) != null)
            {
                //A collision occured. Try add it somewhere new
                startLocation = Raindrop.GetValidStartLocation(gameSize, RandomNumberGenerator.Instance);
                raindrop      = new Raindrop(startLocation);
            }
            _raindrops.Add(raindrop);
            GameObjects.Add(new RaindropControl(raindrop));
        }
示例#14
0
    public override void _PhysicsProcess(float delta)
    {
        if (add_next != null && add_next.GetParent() == null && GetChildCount() < MAX_DROPS)
        {
            add_next.Position     = new Vector2((float)random.NextDouble() * GDKnyttAssetManager.TILE_WIDTH, 12f);
            add_next.max_distance = (KnyttArea.AREA_HEIGHT - Coords.y) * GDKnyttAssetManager.TILE_HEIGHT;
            add_next.reset(this);
            CallDeferred("add_child", add_next);
            add_next = null;
        }

        if (add_next == null && ((float)random.NextDouble()) * .4f < delta)
        {
            add_next = nextRaindrop();
        }
    }
示例#15
0
    IEnumerator SpawnRaindrops()
    {
        ///   Instead of calling Instantiate(), use this:
        ///       SimplePool.Spawn(somePrefab, somePosition, someRotation);
        ///
        ///   Instead of destroying an object, use this:
        ///       SimplePool.Despawn(myGameObject);
        ///
        ///   If desired, you can preload the pool with a number of instances:
        ///       SimplePool.Preload(somePrefab, 20);
        while (dropsCollected < dropsToCatch)
        {
            if (Paused)
            {
                yield return(new WaitForSeconds(0.5f));

                continue;
            }

            //GameObject go = GameObject.Instantiate(raindropObject);
            float newX;
            if (dropsCollected == 0)
            {
                newX = Random.Range((playerCS.starting_X - playerCS.boundary_X),
                                    (playerCS.starting_X + playerCS.boundary_X));
                lastSpawnedDropPosition = new Vector3(newX, 6, 0);
            }
            else
            {
                newX = Random.Range(Mathf.Max((lastSpawnedDropPosition.x - currentLevelSet[currentLevel].maxHorizDistanceBetweenDrops),
                                              (playerCS.starting_X - playerCS.boundary_X)),
                                    Mathf.Min((lastSpawnedDropPosition.x + currentLevelSet[currentLevel].maxHorizDistanceBetweenDrops),
                                              (playerCS.starting_X + playerCS.boundary_X)));
            }
            GameObject go   = SimplePool.Spawn(raindropObject, new Vector3(newX, 6, 0), Quaternion.identity);
            Raindrop   rdcs = go.GetComponent <Raindrop>();
            rdcs.Setup();
            rdcs.speed = Random.Range(currentLevelSet[currentLevel].minDropSpeed, currentLevelSet[currentLevel].maxDropSpeed) * currentDiff.masterSpeed;
            lastSpawnedDropPosition = go.transform.position;
            yield return(new WaitForSeconds(Random.Range(currentLevelSet[currentLevel].minTimeBetweenDrops, currentLevelSet[currentLevel].maxTimeBetweenDrops)));
        }
        yield return(null);
    }
示例#16
0
 IEnumerator DoFancyRaindrops()
 {
     doingArtisticRaindrops = true;
     rainPlayer.Play();
     while (doingArtisticRaindrops)
     {
         GameObject go = SimplePool.Spawn(artsyRaindropObject, new Vector3(Random.Range((playerCS.starting_X - playerCS.boundary_X),
                                                                                        (playerCS.starting_X + playerCS.boundary_X)),
                                                                           6,
                                                                           0), Quaternion.identity);
         float factor = Random.Range(0.5f, 2.5f);
         go.transform.localScale = new Vector3(0.06f, 0.06f, 1.0f) * factor;
         Raindrop rdcs = go.GetComponent <Raindrop>();
         rdcs.Setup();
         rdcs.speed = Random.Range(7.0f, 15.0f);
         yield return(new WaitForSeconds(Random.Range(0.01f, 0.05f)));
     }
     yield return(null);
 }
示例#17
0
    // Update is called once per frame
    void Update()
    {
        #region Fading
        if (FadeOn && LightOn)
        {
            if (lightObj.GetComponent <Light>().color.a > alphaC)
            {
                lightObj.GetComponent <Light>().color = new Vector4(lightObj.GetComponent <Light>().color.r, lightObj.GetComponent <Light>().color.g, lightObj.GetComponent <Light>().color.b, lightObj.GetComponent <Light>().color.a - FadeIntensity);
            }
            if (lightObj.GetComponent <Light>().color.a < alphaC)
            {
                lightObj.GetComponent <Light>().color = new Vector4(lightObj.GetComponent <Light>().color.r, lightObj.GetComponent <Light>().color.g, lightObj.GetComponent <Light>().color.b, lightObj.GetComponent <Light>().color.a + FadeIntensity);
            }

            if (lightObj.GetComponent <Light>().color.r > redC)
            {
                lightObj.GetComponent <Light>().color = new Vector4(lightObj.GetComponent <Light>().color.r - FadeIntensity, lightObj.GetComponent <Light>().color.g, lightObj.GetComponent <Light>().color.b, lightObj.GetComponent <Light>().color.a);
            }
            if (lightObj.GetComponent <Light>().color.r < redC)
            {
                lightObj.GetComponent <Light>().color = new Vector4(lightObj.GetComponent <Light>().color.r + FadeIntensity, lightObj.GetComponent <Light>().color.g, lightObj.GetComponent <Light>().color.b, lightObj.GetComponent <Light>().color.a);
            }

            if (lightObj.GetComponent <Light>().color.g > greenC)
            {
                lightObj.GetComponent <Light>().color = new Vector4(lightObj.GetComponent <Light>().color.r, lightObj.GetComponent <Light>().color.g - FadeIntensity, lightObj.GetComponent <Light>().color.b, lightObj.GetComponent <Light>().color.a);
            }
            if (lightObj.GetComponent <Light>().color.g < greenC)
            {
                lightObj.GetComponent <Light>().color = new Vector4(lightObj.GetComponent <Light>().color.r, lightObj.GetComponent <Light>().color.g + FadeIntensity, lightObj.GetComponent <Light>().color.b, lightObj.GetComponent <Light>().color.a);
            }

            if (lightObj.GetComponent <Light>().color.b > blueC)
            {
                lightObj.GetComponent <Light>().color = new Vector4(lightObj.GetComponent <Light>().color.r, lightObj.GetComponent <Light>().color.g, lightObj.GetComponent <Light>().color.b - FadeIntensity, lightObj.GetComponent <Light>().color.a);
            }
            if (lightObj.GetComponent <Light>().color.b < blueC)
            {
                lightObj.GetComponent <Light>().color = new Vector4(lightObj.GetComponent <Light>().color.r, lightObj.GetComponent <Light>().color.g, lightObj.GetComponent <Light>().color.b + FadeIntensity, lightObj.GetComponent <Light>().color.a);
            }
        }
        #endregion
        if (delayTime < startDelay)
        {
            delayTime += Time.deltaTime;
            return;
        }
        if (raindrops < 0)
        {
            raindrops = 0;
        }
        if (spawnOn)
        {
            time += Time.deltaTime;
            if (time >= timeLeft && raindrops < maxRain)
            {
                time = 0;
                if (timeArray[count] <= 0)
                {
                    rainArray[count] = new Raindrop(rainSize);
                    timeArray[count] = 5.0f;
                    maggots          = Random.Range(-50, 50);
                    while (maggots >= -27.5 && maggots <= 10.5)
                    {
                        maggots = Random.Range(-50, 50);
                    }

                    locker = Random.Range(-50, 50);
                    while (locker >= -17 && locker <= 19)
                    {
                        locker = Random.Range(-50, 50);
                    }

                    rainArray[count].SetLocation(new Vector3(maggots, in_a, locker));
                    rainArray[count].SetRainDropColour(objColour);
                    raindrops++;
                    count++;
                    if (count == maxRain)
                    {
                        count = 0;
                    }
                }
            }
        }
        for (int i = 0; i < maxRain; i++)
        {
            if (timeArray[i] > 0)
            {
                timeArray[i] -= Time.deltaTime;
            }
            else
            {
                //if (rainArray[i].gameObject != null)
                {
                    //if (rainArray[i] != null)
                    {
                        rainArray[i].dropDestroy();
                        raindrops--;
                    }
                }
            }
        }
        //for (int i = 0; i < maxRain; i++)
        //{
        //    if (rainArray[i] !=  null)
        //    {
        //        rainArray[i].rainFnct();
        //        //if (rainArray[i] == null)
        //        //{
        //        //    raindrops--;
        //        //}
        //    }
        //    if (rainArray[i].gameObject == null)
        //    {
        //        raindrops--;
        //    }
        //}
    }
 public RaindropControl(Raindrop raindrop)
     : base(raindrop)
 {
     InitializeComponent();
 }
示例#19
0
 public void GivenAFactorOfThreeFiveAndSeven_WhenIEnterThatNumberIntoRaindropMethod_PlingPlangPlongWillBeReturned(int number)
 {
     Assert.That(Raindrop.Raindrops(number), Is.EqualTo("PlingPlangPlong"));
 }
示例#20
0
 public void GivenIHaveANumberThatIsntAFactorOfThreeFiveOrSeven_WhenIEnterThatNumberIntoRaindropMethod_TheNumberWillBeReturned(int number)
 {
     Assert.That(Raindrop.Raindrops(number), Is.EqualTo(number.ToString()));
 }
示例#21
0
 public void GivenIHaveNegativeNumbers_WhenIEnterThemNumbersIntoRaindropMethod_TheCorrectStringWillBeReturned(int number, string solution)
 {
     Assert.That(Raindrop.Raindrops(number), Is.EqualTo(solution));
 }