Пример #1
0
        public void Initalise(GraphicsDevice graphicsDevice, PickupType type)
        {
            switch (type)
            {
            case PickupType.Health:
                texture2D   = content.Load <Texture2D>("Graphics/World/health pickup");
                appearDelay = 6.0f;

                break;

            case PickupType.Magic:
                texture2D   = content.Load <Texture2D>("Graphics/World/mana pickup");
                appearDelay = 5.0f;
                break;
            }

            p_type = type;
            r_type = RefillType.Neutral;

            InitialPosSet = false;

            position = Vector2.Zero;

            // Placing it above the window
            startingPosY = graphicsDevice.Viewport.Y - 100;
            position.Y   = startingPosY;

            bounds = new Rectangle(texture2D.Bounds.X, texture2D.Bounds.Y, texture2D.Width, texture2D.Height);

            appearTimer = 0.0f;

            fallSpeed = 200.0f;
        }
Пример #2
0
        public void Update(float elapsed, GraphicsDevice graphicsDevice)
        {
            // If the timer is up, then initiate the position
            // and make it fall down
            if (appearTimer >= appearDelay)
            {
                if (InitialPosSet == false)
                {
                    // To initiate a new value
                    // at each tick
                    rand = new Random();

                    // Get a random value within the window width
                    position.X = rand.Next(graphicsDevice.Viewport.X + 50,
                                           graphicsDevice.Viewport.Width - 50);
                    position.Y = startingPosY;

                    // Get a random type
                    int type = rand.Next(0, 3);

                    // The amount to refill is adjusted
                    // by the type
                    switch ((RefillType)type)
                    {
                    case RefillType.Mini:
                        refill_points = 5;
                        r_type        = RefillType.Mini;
                        break;

                    case RefillType.Neutral:
                        refill_points = 10;
                        r_type        = RefillType.Neutral;
                        break;

                    case RefillType.Mega:
                        refill_points = 15;
                        r_type        = RefillType.Mega;
                        break;
                    }

                    // The position is now set
                    InitialPosSet = true;
                }

                // Make the pickup fall down
                position.Y += (fallSpeed * elapsed);

                // Reset it once it goes below the screen
                if (GetPosition().Y > graphicsDevice.Viewport.Height + 50.0f)
                {
                    position.Y    = startingPosY;
                    appearTimer   = 0.0f;
                    InitialPosSet = false;
                }
            }
            else
            {
                appearTimer += elapsed;
            }
        }
Пример #3
0
 //constructor
 public Feat(string name, string abilities, bool useRoll, Roll roll,
             bool limited, RefillType refill, int numUses = 0)
 {
     this.name      = name;
     this.abilities = abilities;
     this.useRoll   = useRoll;
     this.roll      = roll;
     this.numUses   = numUses;
     usesLeft       = numUses;
     limitedUse     = limited;
     refillType     = refill;
 }