Example #1
0
        public Wizard(Vector2 position, Player playerInstance)
        {
            this.position   = position;
            spriteSource    = new Rectangle(1474, 1090, 51, 59);
            spriteLocations = new Rectangle[] { new Rectangle(1474, 1090, 51, 59), new Rectangle(1542, 1082, 47, 67), new Rectangle(1602, 1086, 51, 63), new Rectangle(1662, 1094, 55, 55) };

            this.playerInstance = playerInstance;

            this.area = new Rectangle(0, 0, 51, 61);

            this.direction = new Vector2(0, 0);
            this.dir       = 1;
            this.speed     = 0.15f;
            this.color     = Color.White;
            this.alpha     = 1f;

            this.hp            = 100f;
            this.dmg           = 10f;
            timeFromLastAttack = 1000000;
            this.isAlive       = true;

            this.frameTimer     = 0;
            this.frameLimitTime = 170f;
            this.frame          = 0;

            currentState = WizardStates.Normal;
        }
Example #2
0
        private void PhaseOutUpdate(GameTime gameTime)
        {
            color  = Color.White * alpha;
            alpha -= 0.05f;

            if (alpha < 0)
            {
                alpha = 0f;
                float distToPlayer = 0;
                do
                {
                    int x = SoundManager.rnd.Next(-250, +250);
                    int y = SoundManager.rnd.Next(-200, +200);

                    position = Vector2.Add(playerInstance.position, new Vector2(x, y));

                    position.X = Math.Min(1204 - area.Width - 2, position.X);
                    position.X = Math.Max(22, position.X);

                    position.Y = Math.Min(640 - area.Height - 2, position.Y);
                    position.Y = Math.Max(22, position.Y);

                    distToPlayer = Math.Abs(Vector2.Distance(position, playerInstance.position));
                } while (distToPlayer < 150);

                currentState = WizardStates.PhaseIn;
            }
        }
Example #3
0
        private void PhaseInUpdate(GameTime gameTime)
        {
            color  = Color.White * alpha;
            alpha += 0.05f;

            if (alpha > 1f)
            {
                alpha        = 1f;
                currentState = WizardStates.Normal;
                stateTimer   = 0f;
                speed        = 0.15f;
            }
        }
Example #4
0
        private void NormalStateUpdate(GameTime gameTime)
        {
            this.position = Vector2.Add(Vector2.Multiply(Vector2.Multiply(this.direction, this.speed), gameTime.ElapsedGameTime.Milliseconds), position);

            this.area.X = (int)position.X;
            this.area.Y = (int)position.Y;

            this.direction = Vector2.Normalize(Vector2.Subtract(playerInstance.area.Center.ToVector2(), this.area.Center.ToVector2()));

            if (float.IsNaN(this.direction.X))
            {
                this.direction.X = 0;
            }

            if (float.IsNaN(this.direction.Y))
            {
                this.direction.Y = 0;
            }

            if (this.direction.X >= 0)
            {
                this.dir = 1;
            }
            else
            {
                this.dir = -1;
            }

            if (stateTimer >= 5000f)
            {
                speed        = 0;
                direction    = new Vector2(0, 0);
                currentState = WizardStates.PhaseOut;
                stateTimer   = 0;
            }
        }