Exemplo n.º 1
0
        public override void Update(float dt)
        {
            Animations.FountainRipple.Update(dt);
            //_particle.Update(dt);TODO

            //Heal the player when they are close
            if (SmileyUtil.Distance(X, Y, SMH.Player.X, SMH.Player.Y) < Fountain.FountainHealRadius)
            {
                SMH.Player.Heal(0.5f);
            }
        }
Exemplo n.º 2
0
        public override void Draw()
        {
            if (SmileyUtil.Distance(X, Y, SMH.Player.X, SMH.Player.Y) > 1000f)
            {
                return;
            }

            //Bottom fountain part and pool
            SMH.Graphics.DrawSprite(Sprites.FountainBottom, ScreenX, ScreenY);
            SMH.Graphics.DrawAnimation(Animations.FountainRipple, ScreenX, ScreenY - 72f);

            //Top fountain part and pool
            SMH.Graphics.DrawSprite(Sprites.FountainTop, ScreenX, ScreenY - 115f);
            SMH.Graphics.DrawAnimation(Animations.FountainRipple, ScreenX, ScreenY - 215f, Color.White, 0f, 0.35f, 0.4f);

            //TODO:
            //Fountain particle
            //smh->resources->GetParticleSystem("fountain")->MoveTo(smh->getScreenX(x), smh->getScreenY(y - 220.0), true);
            //smh->resources->GetParticleSystem("fountain")->Render();
        }
Exemplo n.º 3
0
        public void Update(float dt)
        {
            CollisionTile collisionAtPlayer = SMH.Player.Tile.Collision;
            SpinDirection dir = SpinDirection.None;

            //Input to change ability
            if (!SMH.WindowManager.IsWindowOpen)
            {
                if (SMH.Input.IsPressed(Input.PreviousAbility))
                {
                    dir = SpinDirection.Left;
                }
                else if (SMH.Input.IsPressed(Input.NextAbility))
                {
                    dir = SpinDirection.Right;
                }
            }

            if (dir != SpinDirection.None)
            {
                if (SelectedAbility == Ability.WATER_BOOTS && SMH.Player.IsSmileyTouchingWater())
                {
                    if (collisionAtPlayer != CollisionTile.DEEP_WATER && collisionAtPlayer != CollisionTile.GREEN_WATER)
                    {
                        //player is on a land tile, but touching water; bump him over and change abilities
                        ChangeAbility(dir);
                        SMH.Player.GraduallyMoveTo(SMH.Player.Tile.X * 64f + 32f, SMH.Player.Tile.Y * 64f + 32f, 500);
                    }
                    else
                    {
                        //player actually on a water tile; cannot take off the sandals; play error message
                        SMH.Sound.PlaySound(Sound.Error);
                    }
                }
                else
                {
                    ChangeAbility(dir);
                }
            }

            float angle, x, y, targetX, targetY;

            for (int i = 0; i < 3; i++)
            {
                //Move towards target slot
                x       = _abilitySlots[i].X;
                y       = _abilitySlots[i].Y;
                targetX = _points[_abilitySlots[i].Slot].X;
                targetY = _points[_abilitySlots[i].Slot].Y;
                angle   = SmileyUtil.GetAngleBetween(x, y, targetX, targetY);
                if (SmileyUtil.Distance(x, y, targetX, targetY) < 600.0 * dt)
                {
                    _abilitySlots[i].X = targetX;
                    _abilitySlots[i].Y = targetY;
                }
                else
                {
                    _abilitySlots[i].X += 600f * (float)Math.Cos(angle) * dt;
                    _abilitySlots[i].Y += 600f * (float)Math.Sin(angle) * dt;
                }

                //Move towards correct size
                if (_abilitySlots[i].Slot == 1 && _abilitySlots[i].Scale < 1f)
                {
                    _abilitySlots[i].Scale += 3f * dt;
                    if (_abilitySlots[i].Scale > 1f)
                    {
                        _abilitySlots[i].Scale = 1f;
                    }
                }
                else if (_abilitySlots[i].Slot != 1 && _abilitySlots[i].Scale > SmallScale)
                {
                    _abilitySlots[i].Scale -= 3f * dt;
                    if (_abilitySlots[i].Scale < SmallScale)
                    {
                        _abilitySlots[i].Scale = SmallScale;
                    }
                }
            }
        }
        /// <summary>
        /// Returns whether or not the circle intersects a rectangle.
        /// </summary>
        /// <param name="rect"></param>
        /// <returns></returns>
        public bool Intersects(Rect rect)
        {
            //Test for when the circle is completely inside the box
            if (rect.Contains(new Vector2(X, Y)))
            {
                return(true);
            }

            //Test the 4 corners of the box
            if (SmileyUtil.Distance(rect.X, rect.Y, X, Y) < Radius)
            {
                return(true);
            }
            if (SmileyUtil.Distance(rect.Right, rect.Y, X, Y) < Radius)
            {
                return(true);
            }
            if (SmileyUtil.Distance(rect.Right, rect.Bottom, X, Y) < Radius)
            {
                return(true);
            }
            if (SmileyUtil.Distance(rect.X, rect.Bottom, X, Y) < Radius)
            {
                return(true);
            }

            //Test middle of box
            if (SmileyUtil.Distance(rect.X + (rect.Right - rect.X) / 2f, rect.Y + (rect.Bottom - rect.Y) / 2f, X, Y) < Radius)
            {
                return(true);
            }

            //Test top and bottom of box
            if (X > rect.X && X < rect.Right)
            {
                if (Math.Abs(rect.Bottom - Y) < Radius)
                {
                    return(true);
                }
                if (Math.Abs(rect.Y - Y) < Radius)
                {
                    return(true);
                }
            }

            //Test left and right side of box
            if (Y > rect.Y && Y < rect.Bottom)
            {
                if (Math.Abs(rect.Right - X) < Radius)
                {
                    return(true);
                }
                if (Math.Abs(rect.X - X) < Radius)
                {
                    return(true);
                }
            }

            //If all tests pass there is no intersection
            return(false);
        }
 /// <summary>
 /// Returns whether or not the circle intersects another circle.
 /// </summary>
 /// <param name="circle"></param>
 /// <returns></returns>
 public bool Intersects(CollisionCircle circle)
 {
     return(SmileyUtil.Distance(X, Y, circle.X, circle.Y) < Radius + circle.Radius);
 }
 /// <summary>
 /// Returns whether or not the circle contains a point.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public bool Contains(float x, float y)
 {
     return(Math.Abs(SmileyUtil.Distance(X, Y, x, y)) < Radius);
 }