Ejemplo n.º 1
0
        public Tornado(Level level, Vector2 position, float lifeDecayRatio)
        {
            ParentLevel = level;

            // initialize variables
            Victims = new List<Victim>();
            Debris = new List<Victim>();
            Position = position;
            Velocity = new Vector2(0f, 0f);
            Acceleration = new Vector2(0f, 0f);
            RotationalSpeed = 10f;
            DamageFactor = 0f;
            Radius = 100.0f;
            TotalMass = 0.0f;
            MaxLife = 1000f;
            Life = MaxLife;
            LifeDecayRatio = lifeDecayRatio;
            Category = TornadoCategory.Gale;
            CategoryValue = 0f;
            MouseControl = new MouseControl();
            GodMode = false;

            CenterFont = ParentLevel.Game.Content.Load<SpriteFont>(@"Graphics\Font\Impact");

            // add the constant debris
            for (int i = 0; i < 20; i++)
            {
                Animation leafAnim = new Animation(ParentLevel.Game.Content.Load<Texture2D>("Graphics\\Objects\\leaf"), 10, 4, 1);
                Victim debris = new VictimLeaf(null,leafAnim,leafAnim,leafAnim,leafAnim, "", Position);

                debris.tornado = this;
                debris.state = Victim.State.Flying;
                Victims.Add(debris);
            }

            ParentLevel.Music.Play(0, true);
        }
Ejemplo n.º 2
0
        private void CalculateCategory(float elapsedMilliseconds)
        {
            List<float> categoryValues = new List<float>();
            categoryValues.Add(GaleValue);
            categoryValues.Add(Category1Value);
            categoryValues.Add(Category2Value);
            categoryValues.Add(Category3Value);
            categoryValues.Add(Category4Value);
            categoryValues.Add(Category5Value);

            CategoryValue = TotalMass;

            // check if needs to go up to next category
            for (int i=1; i <= (int)TornadoCategory.Category5; i++)
            {
                float iCatValue = categoryValues[i];
                if (CategoryValue >= iCatValue && i > (int)Category)
                {
                    Category = (TornadoCategory)i;

                    ParentLevel.Music.Play((int)Category, true);
                }
            }

            // check if needs to go down to previous category
            for (int i=1; i <= (int)TornadoCategory.Category5; i++)
            {
                float iCatValue = categoryValues[i];
                if (CategoryValue < iCatValue * 0.9f && (i - 1) < (int)Category)
                {
                    Category = (TornadoCategory)(i-1);

                    ParentLevel.Music.Play((int)Category, true);
                }
            }
        }