Ejemplo n.º 1
0
        private void HandleOrientation(InputState inputState)
        {
            if (_orientation.X != 0 || _orientation.Y != 0)
            {
                _orientation.Normalize();
                rotation = GeometricHelper.GetAngleFromVectorDirection(_orientation);
            }
            InputState.StickPosition currentPosition = InputState.ConvertVectorDirectionToStickPosition(_orientation);
            string newAnimation = "";

            if (animationMap.ContainsKey(currentPosition))
            {
                newAnimation = animationMap[currentPosition];
            }

            if (!newAnimation.Equals(_currentAnimationState))
            {
                _currentAnimationState = newAnimation;
                SetCurrentAnimationState(_currentAnimationState);
            }
            if (_movementVector.X == 0 && _movementVector.Y == 0)
            {
                PauseAnimation();
            }
            else
            {
                ResumeAnimation();
            }
        }
Ejemplo n.º 2
0
 public void Activate(Vector2 fromPosition, Vector2 direction, float speed, float size, int team)
 {
     Show();
     _speed   = 10;
     _team    = team;
     position = fromPosition + (direction * 10);
     SetTextureRectangle(new Rectangle(112 + (32 * team), 80, 10, 8));
     rotation        = GeometricHelper.GetAngleFromVectorDirection(direction);
     directionVector = direction;
     SetScale(size * 2);
     damage     = (int)size;
     _lifeTimer = cTimeToLive;
 }
Ejemplo n.º 3
0
 public void Explode(Vector2 position, Vector2 direction, float spreadInRadians, float maxLifeTime)
 {
     foreach (Fragment fragment in fragments)
     {
         Vector2 randomPosition       = direction * 16 + position;
         float   directionRadians     = GeometricHelper.GetAngleFromVectorDirection(direction);
         int     randomAngleThousands = PlayScreen.random.Next((int)(1000f * (directionRadians - spreadInRadians)), (int)(1000f * (directionRadians + spreadInRadians)));
         Vector2 randomDirection      = GeometricHelper.GetVectorDirectionFromAngle((float)randomAngleThousands / 1000f);
         float   randomVelocity       = (float)PlayScreen.random.NextDouble() * 20 + 10;
         float   randomRotation       = (float)PlayScreen.random.NextDouble() * 0.1f;
         float   randomTime           = PlayScreen.random.Next((int)(maxLifeTime / 2)) + maxLifeTime / 2;
         fragment.Activate(randomPosition, randomDirection, randomVelocity, randomRotation, 1000);
     }
     fragmentsRemaining = fragments.Count;
     _isUsable          = false;
 }