예제 #1
0
        /// <summary>
        /// Called once per frame by the game object.
        /// </summary>
        /// <param name="gameTime">The amount of time that has passed this frame.</param>
        public override void Update(GameTime gameTime)
        {
            // When the DamageCooldown StopWatch
            if (!mDamageCooldown.pIsPaused)
            {
                // Has the effect experied?
                if (mDamageCooldown.IsExpired())
                {
                    // TODO: This should not assume the original colour was white.
                    mSetTintMsg.mColor_In   = Color.White;
                    mSetTintMsg.mColor_In.A = 0;
                    mParentGOH.OnMessage(mSetTintMsg);

                    // Next time through the Update function, this will tell it that the
                    // effect has already expired.
                    mDamageCooldown.pIsPaused = true;

                    // Next time damage is registered we want the color to change right away.
                    mColorCooldown.ForceExpire();
                }
                else
                {
                    // Has enough time passed to switch to the next color?
                    if (mColorCooldown.IsExpired())
                    {
                        // If it has, reset the timer.
                        mColorCooldown.Restart();

                        // Move on to the next color.
                        mCurrentColor++;

                        // Avoid going out of bounds of the array.
                        if (mCurrentColor >= mColors.Length)
                        {
                            mCurrentColor = 0;
                        }

                        // Update sprite to use the new color.
                        mSetTintMsg.mColor_In = mColors[mCurrentColor];
                        mParentGOH.OnMessage(mSetTintMsg);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Call this to initialize a Behaviour with data supplied in a file.
        /// </summary>
        /// <param name="fileName">The file to load from.</param>
        public override void LoadContent(String fileName)
        {
            base.LoadContent(fileName);

            DamageWobbleDefinition def = GameObjectManager.pInstance.pContentManager.Load <DamageWobbleDefinition>(fileName);

            StopWatch watch = StopWatchManager.pInstance.GetNewStopWatch();

            watch.pLifeTime = 4.0f;
            mScaleTween     = new Tween(watch, 0.8f, 1.2f);

            watch           = StopWatchManager.pInstance.GetNewStopWatch();
            watch.pLifeTime = 2.0f;
            mRotationTween  = new Tween(watch, -5, 5);

            mDamageCooldown           = StopWatchManager.pInstance.GetNewStopWatch();
            mDamageCooldown.pLifeTime = def.mFramesToReset;
            mDamageCooldown.ForceExpire();
        }