Esempio n. 1
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));
            }
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
 public void setMoveType(IMoveAble newMoveType)
 {
     //IMoveAble 인터페이스 상속받아 구현된 스크립트를 받아온다.
     this.moveType = newMoveType;
 }
Esempio n. 4
0
 public static void Move(this IMoveAble obj, Vector2f vec)
 {
     obj.Position += vec;
 }