private void AddElementFromPool(Vector2 position)
        {
            if (this.availableEntities.Count <= 0 ||
                this.IsOutOfScreen(position))
            {
                return;
            }

            var elementEntity = this.availableEntities.First();

            this.availableEntities.Remove(elementEntity);
            this.onSceenEntities.Add(elementEntity);
            this.Owner.AddChild(elementEntity.Owner);

            var spriteAtlas = elementEntity.Owner.FindComponent <SpriteAtlas>();
            var rndTexture  = randomService.Next(spriteAtlas.TextureNames.Count());

            spriteAtlas.TextureName = spriteAtlas.TextureNames.ElementAt(rndTexture);

            var spinner     = elementEntity.Owner.FindComponent <Spinner>();
            var rndRotation = this.MinRotationVelocity + (this.MaxRotationVelocity - this.MinRotationVelocity) * (float)randomService.NextDouble();

            spinner.IncreaseZ = rndRotation;

            var virtualScreen = this.Owner.Scene.VirtualScreenManager;

            elementEntity.Position = position;
        }
Example #2
0
        private void AddNewLine()
        {
            l.StartPoint = new Vector3((float)random.NextDouble() * size * (float)Math.Pow(-1, random.Next()),
                                       (float)random.NextDouble() * size * (float)Math.Pow(-1, random.Next()),
                                       (float)random.NextDouble() * size * (float)Math.Pow(-1, random.Next()));

            l.EndPoint = new Vector3((float)random.NextDouble() * size * (float)Math.Pow(-1, random.Next()),
                                     (float)random.NextDouble() * size * (float)Math.Pow(-1, random.Next()),
                                     (float)random.NextDouble() * size * (float)Math.Pow(-1, random.Next()));

            l.Color = new Color((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());

            lines.Add(l);
        }