Пример #1
0
        public override void Execute(float deltaTime)
        {
            Debug.Assert(this.pGameObject != null);
            ForwardIterator pFwdItor = new ForwardIterator(this.pGameObject);

            Component  pNode    = pFwdItor.First();
            GameObject pGameObj = (GameObject)pNode;

            // Move the first node before getting speed
            // just in case the move method changes the speed
            pGameObj.Move();

            float groupSpeedX = pGameObj.speedX;
            float groupSpeedY = pGameObj.speedY;

            pGameObj = (GameObject)pFwdItor.Next();
            while (!pFwdItor.IsDone())
            {
                // Apply group speed to every game object in the group.
                pGameObj.speedX = groupSpeedX;
                pGameObj.speedY = groupSpeedY;

                pGameObj.Move();

                pGameObj = (GameObject)pFwdItor.Next();
            }

            // Add itself back to timer
            TimerManager.Add(this.name, this, deltaTime);
        }
Пример #2
0
        public override void Execute(float deltaTime)
        {
            Debug.Assert(this.pGameObject != null);

            //--------------------------------------
            MotionHolder pMotionHolder = (MotionHolder)this.pCurrentMotion;

            Debug.Assert(pMotionHolder != null);

            if (pMotionHolder.pMotion.motionAdvance == true)
            {
                //set advance flag back to false
                pMotionHolder.pMotion.motionAdvance = false;
                // advance to next motion
                pMotionHolder = (MotionHolder)pMotionHolder.pNext;

                // if at end of list, set to first
                if (pMotionHolder == null)
                {
                    pMotionHolder = (MotionHolder)poFirstMotion;
                }
            }

            // squirrel away for next timer event
            this.pCurrentMotion = pMotionHolder;

            // computer x and y deltas using composition position info
            Motion motion = pMotionHolder.pMotion;

            motion.ApplyMotion(pGameObject.poColObj.poColRect.x, pGameObject.poColObj.poColRect.y, pGameObject.poColObj.poColRect.width, pGameObject.poColObj.poColRect.height);

            // Update Composition Speeds
            pGameObject.speedX = motion.deltaX;
            pGameObject.speedY = motion.deltaY;

            // Move the Composition using the updated speeds
            pGameObject.Move(); // no longer used.

            // Add itself back to timer
            TimerManager.Add(this.name, this, deltaTime);
        }