Beispiel #1
0
        public BroadPolygon(GraphicsDevice graphicsDevice, Effect effect, Texture2D texture, float startAlpha, Vector2 size, Timer aliveTimer, IChangeAble change)
        {
            this.graphicsDevice = graphicsDevice;
            this.effect         = effect.Clone();
            this.texture        = texture;
            this.startAlpha     = startAlpha;
            this.size           = size;
            this.change         = change.Clone();

            vertexPositions = new VertexPositionTexture[4];
            targetPosition  = Vector3.Zero;
            broadSize       = new Vector2(texture.Width, texture.Height);
            alpha           = 1;

            InitializeEffect();
            VertexUpdate(Vector3.Zero);
            this.aliveTimer = aliveTimer;
        }
Beispiel #2
0
        public void AddParticles(string name,
                                 int countMin, int countMax,
                                 Vector2 positionLT, Vector2 positionRB,
                                 float speedMin, float speedMax,
                                 float sizeMin, float sizeMax,
                                 float alphaMin, float alphaMax,
                                 int angleMin, int angleMax,
                                 float aliveMin, float aliveMax,
                                 IMoveAble move,
                                 IChangeAble change
                                 )
        {
            //gameDevice.GetSound.PlaySE(name);

            //パーティクルの色を決める(明るい色にする)
            float[] color = new float[4] {
                (float)rand.NextDouble() + 0.5f,
                (float)rand.NextDouble() + 0.5f,
                (float)rand.NextDouble() + 0.5f,
                1.0f
            };
            int count = rand.Next(countMin, countMax);

            for (int i = 0; i < count; i++)
            {
                Vector2 position = new Vector2(
                    (float)rand.Next((int)positionLT.X, (int)positionRB.X),
                    (float)rand.Next((int)positionLT.Y, (int)positionRB.Y));
                float   speed     = (float)rand.Next((int)(speedMin * 10), (int)(speedMax * 10)) / 10;
                Vector2 size      = Vector2.One * (float)rand.Next((int)(sizeMin * 10), (int)(sizeMax * 10)) / 10;
                float   alpha     = (float)rand.Next((int)(alphaMin * 10), (int)(alphaMax * 10)) / 10;
                float   aliveTime = (float)rand.Next((int)(aliveMin * 10), (int)(aliveMax * 10)) / 10;

                float   angle    = rand.Next(angleMin, angleMax);
                float   radian   = MathHelper.ToRadians(angle);
                Vector2 velocity = new Vector2(1, 0);
                velocity = Method.RotateVector2(velocity, (int)angle);

                particles.Add(new Particle(graphicsDevice, name, position, velocity, speed, size, alpha, radian, aliveTime, move, change, color));
            }
        }
Beispiel #3
0
        public Particle(GraphicsDevice graphicsDevice, string name, Vector2 position, Vector2 velocity,
                        float speed, Vector2 size, float alpha, float radian, float aliveTime, IMoveAble move, IChangeAble change, float[] color)
        {
            this.graphicsDevice = graphicsDevice;
            this.name           = name;
            this.position       = position;
            this.velocity       = velocity;
            this.speed          = speed;
            this.size           = size;
            this.alpha          = alpha;
            this.radian         = radian;
            this.move           = move.Clone();
            this.change         = change.Clone();
            this.color          = color;

            aliveTimer = new Timer(aliveTime);
            isDead     = false;

            InitializeBroadPolygon();
            UpdateBroad();
        }