/// <summary>
        /// See parent.
        /// </summary>
        public override void OnAdd()
        {
            base.OnAdd();

            mLifetime = StopWatchManager.pInstance.GetNewStopWatch();
            mLifetime.pLifeTime = mDef.mLifeTime;
        }
Exemple #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="watch">The watch used for tweening over time. Set it up yourself.</param>
        /// <param name="startVal">The low value.</param>
        /// <param name="finalVal">The high value.</param>
        public Tween(StopWatch watch, Single startVal, Single finalVal)
        {
            mWatch = watch;

            mStartValue = startVal;
            mFinalValue = finalVal;

            mCurrentValue = mStartValue;

            mDirection = true;
        }
        /// <summary>
        /// Called once when the state starts.  This is a chance to do things that should only happen once
        /// during a particular state.
        /// </summary>
        public override void OnBegin()
        {
            base.OnBegin();

            // Make the timer last the same amount of time it will take the camera to reach
            // its destination.
            mWatch = StopWatchManager.pInstance.GetNewStopWatch();
            mWatch.pLifeTime = CameraManager.pInstance.pNumBlendFrames;
            mWatch.pIsPaused = false;

            // Move down to the gameplay camera position.
            CameraManager.pInstance.pTargetPosition = new Vector2(0, -30.0f);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        private StopWatchManager()
        {
            // How many watches this manager creates.  If we go over this limit, the game will 
            // throw an exception.
            Int32 numWatches = 8192 * 2;

            // The active list starts empty and will become populated as clients request new StopWatch objects.
            mActiveWatches = new List<StopWatch>(numWatches);

            // All StopWatch objects we manage start in the expired Stack.
            mExpiredWatches = new Stack<StopWatch>(numWatches);

            for (int i = 0; i < numWatches; i++)
            {
                StopWatch temp = new StopWatch();
                mExpiredWatches.Push(temp);
            }
        }
        /// <summary>
        /// Automatically called when a new state is started.
        /// </summary>
        /// <param name="newState"></param>
        private void EnterState(State newState)
        {
            // Check if we are handling this in one of our states.
            if (mTutorialStates.ContainsKey((Int32)newState))
            {
                mTutorialStates[(Int32)newState].OnEnterState();

                return;
            }

            switch (newState)
            {
                case State.RECEIVING_START:
                {
                    if (mReceiveWatch == null)
                    {
                        mReceiveWatch = StopWatchManager.pInstance.GetNewStopWatch();
                        mReceiveWatch.pLifeTime = 15;
                    }

                    GameObjectManager.pInstance.Add(mTxtTitle);

                    break;
                }

                case State.COMPLETE:
                {
                    pTutorialCompleted = true;

                    AchievementManager.pInstance.UnlockAchievement(AchievementManager.Achievements.Participation);

                    break;
                }
            }
        }
        /// <summary>
        /// Automatically called when changing states.
        /// </summary>
        /// <param name="oldState"></param>
        private void ExitState(State oldState)
        {
            // Check if we are handling this in one of our states.
            if (mTutorialStates.ContainsKey((Int32)oldState))
            {
                mTutorialStates[(Int32)oldState].OnExitState();
            }

            switch (oldState)
            {
                case State.RECEIVING_START:
                {
                    if (mReceiveWatch != null)
                    {
                        StopWatchManager.pInstance.RecycleStopWatch(mReceiveWatch);
                        mReceiveWatch = null;
                    }

                    break;
                }

                case State.COMPLETE_GET_READY:
                {
                    GameObjectManager.pInstance.Remove(mTxtTitle);

                    break;
                }
            }
        }
        /// <summary>
        /// Call this before using the class.
        /// </summary>
        public void Initialize()
        {
            pTutorialCompleted = false;
            pCurState = State.NONE;

            if (CommandLineManager.pInstance["SkipTutorial"] != null)
            {
                pTutorialCompleted = true;
            }

            mTxtWaitForServe = new GameObject("GameObjects\\UI\\Tutorial\\WaitForServe\\WaitForServe");
            mTxtBumpAuto = new GameObject("GameObjects\\UI\\Tutorial\\BumpAuto\\BumpAuto");
            mTxtSetAuto = new GameObject("GameObjects\\UI\\Tutorial\\SetAuto\\SetAuto");
            mTxtWhenBallHigh = new GameObject("GameObjects\\UI\\Tutorial\\WhenBallHigh\\WhenBallHigh");
            mTxtSwipeJump = new GameObject("GameObjects\\UI\\Tutorial\\SwipeJump\\SwipeJump");
            mTxtTap = new GameObject("GameObjects\\UI\\Tutorial\\Tap\\Tap");
            mTxtPlayerTry = new GameObject("GameObjects\\UI\\Tutorial\\PlayerTry\\PlayerTry");
            mTxtTryAgain = new GameObject("GameObjects\\UI\\Tutorial\\TryAgain\\TryAgain");
            mTxtWellDone = new GameObject("GameObjects\\UI\\Tutorial\\NiceWork\\NiceWork");
            mTxtThatsAll = new GameObject("GameObjects\\UI\\Tutorial\\AllThereIs\\AllThereIs");
            mTxtRecap = new GameObject("GameObjects\\UI\\Tutorial\\SwipeTapSmash\\SwipeTapSmash");
            mTxtRules = new GameObject("GameObjects\\UI\\Tutorial\\InRow\\InRow");
            mTxtTitle = new GameObject("GameObjects\\UI\\Tutorial\\Title\\Title");
            mTxtRealThing = new GameObject("GameObjects\\UI\\Tutorial\\RealThing\\RealThing");
            mTxtTapContinue = new GameObject("GameObjects\\UI\\Tutorial\\TapToContinue\\TapToContinue");
            mImgSwipe = new GameObject("GameObjects\\Items\\Tutorial\\Swipe\\Swipe");
            mImgFingerSwipe = new GameObject("GameObjects\\Items\\Tutorial\\FingerSwipe\\FingerSwipe");
            mImgBackdrop = new GameObject("GameObjects\\UI\\Tutorial\\Backdrop\\Backdrop");

            mInputDelay = StopWatchManager.pInstance.GetNewStopWatch();
            mInputDelay.pLifeTime = 15.0f;

            mHighlightPlayerMsg = new HighlightPlayerMessage();
            mHighlightBallMsg = new HighlightBallMessage();
            mHighlightPartnerMsg = new HighlightPartnerMessage();

            mTutorialStates = new Dictionary<Int32, TutorialState>();

            // RECEIVING_TXT
            TutorialState state = new TutorialState(
                new List<GameObject> { mTxtWaitForServe, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage> { mHighlightBallMsg }, 
                mInputDelay, 
                true, 
                true,
                State.RECEIVING_END);
            mTutorialStates[(Int32)State.RECEIVING_TXT] = state;

            // BUMP_TXT
            state = new TutorialState(
                new List<GameObject> { mTxtBumpAuto, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage> { mHighlightBallMsg, mHighlightPlayerMsg },
                mInputDelay,
                true,
                true,
                State.SET);
            mTutorialStates[(Int32)State.BUMP_TXT] = state;

            // SET_TXT
            state = new TutorialState(
                new List<GameObject> { mTxtSetAuto, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage> { mHighlightBallMsg, mHighlightPartnerMsg },
                mInputDelay,
                true,
                true,
                State.SWIPE);
            mTutorialStates[(Int32)State.SET_TXT] = state;

            // SWIPE_TXT_BALL_HIGH
            state = new TutorialState(
                new List<GameObject> { mTxtWhenBallHigh, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage> { mHighlightBallMsg },
                mInputDelay,
                true,
                false,
                State.SWIPE_TXT_JUMP);
            mTutorialStates[(Int32)State.SWIPE_TXT_BALL_HIGH] = state;

            // RECIEVING_END
            state = new TutorialState(
                new List<GameObject> { mTxtSwipeJump, mImgBackdrop, mImgSwipe, mImgFingerSwipe },
                new List<HighlightObjectMessage> { mHighlightBallMsg, mHighlightPlayerMsg },
                mInputDelay,
                false,
                true,
                State.NONE);
            mTutorialStates[(Int32)State.SWIPE_TXT_JUMP] = state;

            // TAP_TXT
            state = new TutorialState(
                new List<GameObject> { mTxtTap, mImgBackdrop },
                new List<HighlightObjectMessage> { mHighlightBallMsg, mHighlightPlayerMsg },
                mInputDelay,
                true,
                true,
                State.NONE);
            mTutorialStates[(Int32)State.TAP_TXT] = state;

            // PLAYER_TRY
            state = new TutorialState(
                new List<GameObject> { mTxtPlayerTry, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage>( ),
                mInputDelay,
                true,
                true,
                State.PLAYER_TRYING);
            mTutorialStates[(Int32)State.PLAYER_TRY] = state;

            // TRY_AGAIN
            state = new TutorialState(
                new List<GameObject> { mTxtTryAgain, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage>(),
                mInputDelay,
                true,
                true,
                State.TRYING_AGAIN);
            mTutorialStates[(Int32)State.TRY_AGAIN] = state;

            // COMPLETE_WELL_DONE
            state = new TutorialState(
                new List<GameObject> { mTxtWellDone, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage>(),
                mInputDelay,
                true,
                true,
                State.COMPLETE_THATS_ALL);
            mTutorialStates[(Int32)State.COMPLETE_WELL_DONE] = state;

            // COMPLETE_THATS_ALL
            state = new TutorialState(
                new List<GameObject> { mTxtThatsAll, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage>(),
                mInputDelay,
                true,
                true,
                State.COMPLETE_RECAP);
            mTutorialStates[(Int32)State.COMPLETE_THATS_ALL] = state;

            // COMPLETE_RECAP
            state = new TutorialState(
                new List<GameObject> { mTxtRecap, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage>(),
                mInputDelay,
                true,
                true,
                State.COMPLETE_RULES);
            mTutorialStates[(Int32)State.COMPLETE_RECAP] = state;

            // COMPLETE_RULES
            state = new TutorialState(
                new List<GameObject> { mTxtRules, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage>(),
                mInputDelay,
                true,
                true,
                State.COMPLETE_GET_READY);
            mTutorialStates[(Int32)State.COMPLETE_RULES] = state;

            // COMPLETE_GET_READY
            state = new TutorialState(
                new List<GameObject> { mTxtRealThing, mImgBackdrop, mTxtTapContinue },
                new List<HighlightObjectMessage>(),
                mInputDelay,
                true,
                true,
                State.COMPLETE);
            mTutorialStates[(Int32)State.COMPLETE_GET_READY] = state;
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="objectsToShow"></param>
 /// <param name="highlighMsgs"></param>
 /// <param name="inputDelay"></param>
 /// <param name="pauseOnEnter"></param>
 /// <param name="resumeOnExit"></param>
 /// <param name="nextStateOnTap"></param>
 public TutorialState(List<GameObject> objectsToShow, 
     List<HighlightObjectMessage> highlighMsgs, 
     StopWatch inputDelay,
     Boolean pauseOnEnter,
     Boolean resumeOnExit,
     TutorialManager.State nextStateOnTap)
 {
     mObjectsToShow = objectsToShow;
     mHighlighMsgs = highlighMsgs;
     mInputDelay = inputDelay;
     mPauseOnEnter = pauseOnEnter;
     mResumeOnExit = resumeOnExit;
     mNextStateOnTap = nextStateOnTap;
     mGesture = new GestureSample();
     mFxMenuSelect = GameObjectManager.pInstance.pContentManager.Load<SoundEffect>("Audio\\FX\\MenuSelect");
 }
        /// <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);

            mCurrentState = State.Idle;

            mBallClassifications = new List<MBHEngineContentDefs.GameObjectDefinition.Classifications>(1);
            mBallClassifications.Add(MBHEngineContentDefs.GameObjectDefinition.Classifications.VOLLEY_BALL);

            mCollisionResults = new List<GameObject>(16);

            mStateTimer = StopWatchManager.pInstance.GetNewStopWatch();

            mKabooomAvail = true;

            mFxHit = GameObjectManager.pInstance.pContentManager.Load<SoundEffect>("Audio\\FX\\HitOpponent");
            mFxHitGround = GameObjectManager.pInstance.pContentManager.Load<SoundEffect>("Audio\\FX\\HitOpponentLand");
            
            mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage();
            mSetSpriteEffectsMsg = new SpriteRender.SetSpriteEffectsMessage();
            mGetAttachmentPointMsg = new SpriteRender.GetAttachmentPointMessage();
            mGetCurrentStateMsg = new Player.GetCurrentStateMessage();
            mGetCurrentHitCountMsg = new HitCountDisplay.GetCurrentHitCountMessage();
        }
        /// <summary>
        /// See parent.
        /// </summary>
        public override void OnAdd()
        {
            mDisplayWatch = StopWatchManager.pInstance.GetNewStopWatch();

            // These numbers vanish in 1 second.
            mDisplayWatch.pLifeTime = 30.0f;
        }
        /// <summary>
        /// Clients wishing to create a StopWatch which is automatically updated should call this and use
        /// the returned StopWatch.
        /// </summary>
        /// <returns>A StopWatch which is managed by this class.</returns>
        public StopWatch GetNewStopWatch()
        {
            // Make sure we didn't go over the limit.
            if (mExpiredWatches.Count == 0)
            {
                System.Diagnostics.Debug.Assert(false, "Ran out of stop watches.  Increase amount.");

                // Hopefully all cases get caught in Debug, but incase one was missed, have a fallback
                // where we allocate additional StopWatch objects to avoid crashes.
                //
                Int32 numWatches = 128;
                for (int i = 0; i < numWatches; i++)
                {
                    StopWatch temp = new StopWatch();
                    mExpiredWatches.Push(temp);
                }
            }

            // Pop another StopWatch off the expired stack, and add it to the active list.
            StopWatch s = mExpiredWatches.Pop();
            mActiveWatches.Add(s);

            // Reset any values already set in this StopWatch from previous uses.
            s.ResetValues();

            // Now return it to the caller for them to use however they wish.
            return s;
        }
        public void RecycleStopWatch(StopWatch watch)
        {
            System.Diagnostics.Debug.Assert(watch != null, "Attempting to remove null watch!");

            // If the watch is being managed by the Active list, remove it from there and put it back into
            // the Expired stack so that someone else can use it.
            if (watch != null) //&& mActiveWatches.Contains(watch))
            {
                mActiveWatches.Remove(watch);
                mExpiredWatches.Push(watch);
            }
        }
        /// <summary>
        /// See parent.
        /// </summary>
        public override void OnAdd()
        {
            base.OnAdd();

            mBG = GameObjectFactory.pInstance.GetTemplate("GameObjects\\UI\\ScoreSummaryBG\\ScoreSummaryBG");
            GameObjectManager.pInstance.Add(mBG);

            mNumRowsShown = 0;
            mCountShown = 1;

            mRevealTimer = StopWatchManager.pInstance.GetNewStopWatch();
            mRevealTimer.pLifeTime = 15;
        }
        /// <summary>
        /// See parent.
        /// </summary>
        public override void OnRemove()
        {
            base.OnRemove();

            GameObjectManager.pInstance.Remove(mBG);
            mBG = null;

            GameObjectManager.pInstance.Remove(mHighScore);
            mHighScore = null;

            StopWatchManager.pInstance.RecycleStopWatch(mRevealTimer);
            mRevealTimer = null;
        }
        /// <summary>
        /// See parent.
        /// </summary>
        public override void OnRemove()
        {
            CleanUpScore();

            if (null == mDisplayWatch)
            {
                StopWatchManager.pInstance.RecycleStopWatch(mDisplayWatch);
                mDisplayWatch = null;
            }
        }
Exemple #16
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)
        {
            PartnerDefinition def = GameObjectManager.pInstance.pContentManager.Load<PartnerDefinition>(fileName);

            base.LoadContent(fileName);

            //DamageFlashDefinition def = GameObjectManager.pInstance.pContentManager.Load<DamageFlashDefinition>(fileName);
            
            mBallClassifications = new List<MBHEngineContentDefs.GameObjectDefinition.Classifications>(1);
            mBallClassifications.Add(MBHEngineContentDefs.GameObjectDefinition.Classifications.VOLLEY_BALL);

            mCollisionResults = new List<GameObject>(16);

            mStateTimer = StopWatchManager.pInstance.GetNewStopWatch();

            mHitCount = 0;

            mFxBump = GameObjectManager.pInstance.pContentManager.Load<SoundEffect>("Audio\\FX\\Bump");

            mStartingRenderPriority = mParentGOH.pRenderPriority;

            mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage();
            mSetSpriteEffectsMsg = new SpriteRender.SetSpriteEffectsMessage();
            mGetCurrentStateMsg = new Player.GetCurrentStateMessage();
            mGetCurrentHitCountMsg = new HitCountDisplay.GetCurrentHitCountMessage();
        }
Exemple #17
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);

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

            mCurrentState = State.WaitForMenu;

            mCollisionWall = new LineSegment();
            mMovementLine = new LineSegment();

            mBallClassifications = new List<MBHEngineContentDefs.GameObjectDefinition.Classifications>(1);
            mBallClassifications.Add(MBHEngineContentDefs.GameObjectDefinition.Classifications.VOLLEY_BALL);

            mCollisionResults = new List<GameObject>(16);

            mStateTimer = StopWatchManager.pInstance.GetNewStopWatch();

            mTopLeft = new Vector2(-90.0f, -80.0f);
            mBottomRight = new Vector2(90.0f, 0.0f);

            mFramesInAir = 0;

            mFxJump = GameObjectManager.pInstance.pContentManager.Load<SoundEffect>("Audio\\FX\\Jump");
            mFxSpikeHit = GameObjectManager.pInstance.pContentManager.Load<SoundEffect>("Audio\\FX\\SpikeHit");
            mFxSpikeMiss = GameObjectManager.pInstance.pContentManager.Load<SoundEffect>("Audio\\FX\\SpikeMiss");
            mFxBump = GameObjectManager.pInstance.pContentManager.Load<SoundEffect>("Audio\\FX\\Bump");

            mStartingRenderPriority = mParentGOH.pRenderPriority;

            mWalkSpeed = 3.0f;

            mHasMultipleHitsBeforePartner = false;

            mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage();
            mGetAttachmentPointMsg = new SpriteRender.GetAttachmentPointMessage();
            mMatchRestartMsg = new OnMatchRestartMessage();
            mGameRestartMsg = new OnGameRestartMessage();
            mGetCurrentHitCountMsg = new HitCountDisplay.GetCurrentHitCountMessage();
            mGetPartnerHitCountMsg = new Partner.GetCurrentHitCountMessage();
        }
Exemple #18
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);

            mCollisionWall = new LineSegment();
            mBallMovementLine = new LineSegment();

            mTimeOnGroundToEndPlay = StopWatchManager.pInstance.GetNewStopWatch();
            mTimeOnGroundToEndPlay.pLifeTime = 10.0f;
            mTimeOnGroundToEndPlay.pIsPaused = true;

            mFxSand = GameObjectManager.pInstance.pContentManager.Load<SoundEffect>("Audio\\FX\\HitSand");

            mOnGround = false;
            mPlayOver = false;
            mHasHitNet = false;

            mStartingRenderPriority = mParentGOH.pRenderPriority;

            mSetActiveAnimationMsg = new SpriteRender.SetActiveAnimationMessage();
            mGetAttachmentPointMsg = new SpriteRender.GetAttachmentPointMessage();
            mOnPlayOverMsg = new OnPlayOverMessage();
            mOnMatchRestartMsg = new Player.OnMatchRestartMessage();
            mIncrementHitCountMsg = new HitCountDisplay.IncrementHitCountMessage();
            mSetServeDestinationMsg = new GetServeDestinationMessage();
            mGetCurrentStateMsg = new Player.GetCurrentStateMessage();
            mGetHasMultipleHitsBeforePartnerMsg = new Player.GetHasMultipleHitsBeforePartnerMessage();
        }