Esempio n. 1
0
        private void UpdateSwimingFrogs(EntityRegistry registry)
        {
            int count = mWaterborneFrogs.Frogs.Count;

            for (int i = 0; i < count; ++i)
            {
                float swimKickPhase = mWaterborneFrogs.Waterborne[i].SwimKickPhase;
                if (swimKickPhase < 0f)
                {
                    swimKickPhase = swimKickPhase + mTime.DeltaTime;
                    if (swimKickPhase >= 0f)
                    {
                        swimKickPhase = mSwimData.SwimKickDuration;
                    }
                }
                else if ((swimKickPhase > 0f) && (mWaterborneFrogs.ControlState[i].InputDirection != Vector2.Zero))
                {
                    swimKickPhase = Math.Max(0f, swimKickPhase - mTime.DeltaTime);
                }
                else if ((swimKickPhase != mSwimData.SwimKickDuration) && (mWaterborneFrogs.ControlState[i].InputDirection == Vector2.Zero))
                {
                    swimKickPhase = -mSwimData.SwimKickRecharge;
                }
                //TODO: Worth to validate the data changed?
                Waterborne waterBorne = new Waterborne(swimKickPhase);
                registry.SetComponent(mWaterborneFrogs.Frogs[i], waterBorne);
            }
        }
        private void UpdateSwimAnimation(EntityRegistry registry)
        {
            int swimCount = mSwimingFrogSlice.Entity.Count;

            for (int i = 0; i < swimCount; ++i)
            {
                Waterborne waterBorne = mSwimingFrogSlice.Waterborne[i];
                int        frame;
                bool       kicking = (waterBorne.SwimKickPhase >= 0) && (mSwimingFrogSlice.Control[i].InputDirection != Vector2.Zero);
                if (kicking)
                {
                    frame = mData.SwimingFrame;
                }
                else
                {
                    frame = mData.FloatingFrame;
                }
                SetAnimationFrame(registry, mSwimingFrogSlice.Entity[i], frame);
            }
        }