Пример #1
0
        public Leaf(GameManager gameManager, Screen screen)
            : base(gameManager, screen)
        {
            _gameScreen             = (GameScreen)screen;
            _texture                = gameManager.Content.Load<Texture2D>("Textures/circle_white_320");
            _selectedTexture        = gameManager.Content.Load<Texture2D>("Textures/circle_edge_white_320");
            _radius                 = Config.settings["Leaf.Radius"];
            _normalRadius           = _radius;
            _drawRadius             = _radius;
            _parents                = new List<Leaf>();
            _children               = new List<Leaf>();
            _pulseDrain             = 1;
            _pulseStrength          = 0;
            _pulseStage             = PulseStage.Done;
            _radiusScaleVelocity    = 0;
            _doingRadiusAnimation   = false;
            _targetRadius           = 1;
            _drawScale              = _radius/_texture.Width * 2;
            _selectedTextureScale   = _normalRadius/_selectedTexture.Width * 2;
            _pulseSmallRadius       = Config.settings["Leaf.PulseSmallRadius"];
            _pulseLargeRadius       = Config.settings["Leaf.PulseLargeRadius"];
            _pulseSmallOutDuration  = Config.settings["Leaf.PulseSmallOutDuration"];
            _pulseSmallInDuration   = Config.settings["Leaf.PulseSmallInDuration"];
            _pulseLargeOutDuration  = Config.settings["Leaf.PulseLargeOutDuration"];
            _pulseLargeInDuration   = Config.settings["Leaf.PulseLargeInDuration"];
            _lifeLossPerSecond      = Config.settings["Leaf.LifeLossPerSecond"];
            _maxLife                = Config.settings["Leaf.MaxLife"];
            _pulsePassOnTime        = Config.settings["Leaf.PulsePassOnTime"];
            _lastPulseTime          = 0;
            _life                   = _maxLife;
            _doPulsePassOn          = false;
            isSelected              = false;
            _distToColors           = new float[GameManager.NUM_COLORS];
            _isEating               = false;

            for (int i = 0; i < GameManager.NUM_COLORS; i++)
                _distToColors[i] = -1;
        }
Пример #2
0
        /// <summary>
        /// Should be called every update tick to update the scale animation.
        /// Animation parameters are set with 'setTargetScale'.
        /// </summary>
        /// <param name="dT"></param>
        public virtual void updateScaleAnimation(float dT)
        {
            if (_doingRadiusAnimation)
            {
                _drawRadius += _radiusScaleVelocity * dT;
                _drawScale  = _drawRadius/_texture.Width * 2;

                if ((_radiusScaleVelocity > 0 && _drawRadius >= _targetRadius) ||
                    (_radiusScaleVelocity < 0 && _drawRadius <= _targetRadius))
                {
                    _drawRadius             = _targetRadius;
                    _doingRadiusAnimation   = false;

                    switch (_pulseStage)
                    {
                        case PulseStage.outSmall:
                            _pulseStage = PulseStage.inSmall;
                            setTargetRadius(_normalRadius, _pulseSmallInDuration);
                            break;
                        case PulseStage.inSmall:
                            _pulseStage = PulseStage.outLarge;
                            setTargetRadius(_pulseLargeRadius, _pulseLargeOutDuration);
                            break;
                        case PulseStage.outLarge:
                            _pulseStage = PulseStage.inLarge;
                            setTargetRadius(_normalRadius, _pulseLargeInDuration);
                            break;
                        case PulseStage.inLarge:
                            _pulseStage = PulseStage.Done;
                            break;
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Initiates a pulse.
        /// </summary>
        /// <param name="pulseStrength">Determines how far the pulse travels through the children.</param>
        public virtual void pulse(int pulseStrength)
        {
            _pulseStrength = pulseStrength;

            if (pulseStrength > 0)
            {
                _lastPulseTime  = GameManager.CURRENTTIME;
                _doPulsePassOn  = true;
                _life           = _maxLife;
                _pulseStage     = PulseStage.outSmall;
                setTargetRadius(_pulseSmallRadius, _pulseSmallOutDuration);
            }
        }