public Pax4ConstraintBodyVector(Pax4ObjectPhysicsPart p_physicsPart, float p_velocityFactor, Vector3 p_bodyVector)
            : base(p_physicsPart._body, null)
        {
            _velocityFactor = p_velocityFactor;

            _bodyVector = Pax4Tools.ToJVector(p_bodyVector);
            _bodyVector.Normalize();

            SetPhysicsPart(p_physicsPart);
        }
        public void Launch()
        {
            if (!_spawning)
            {
                if (_body.Position.Y < Pax4ActorWorld._fudgeFactor / _destroyLowerThresholdFactor)
                {
                    Dx();
                }
                else if ((Pax4WorldLavaAndIce._missionType == Pax4WorldLavaAndIce.ELavaAndIceMissionType._ICE ||
                          Pax4WorldLavaAndIce._missionType == Pax4WorldLavaAndIce.ELavaAndIceMissionType._LAVA_AND_ICE) &&
                         Pax4UiStateLavaAndIceMission._currentMissionState._fg &&
                         Pax4Touch._current._currentTouchState._oneTouch == true &&
                         !_launched &&
                         Pax4UiStateLavaAndIceMission._currentMissionState._iceLauncher._toggle &&
                         Pax4Touch._current._currentTouchState._xy.Y > _tapLaunchThreshold &&
                         !Pax4UiStateLavaAndIceMission._currentMissionState._iceLauncher.Touched())
                {
                    if (Pax4UiStateLavaAndIceMission._currentMissionState._lavaLauncher == null ||
                        (Pax4UiStateLavaAndIceMission._currentMissionState._lavaLauncher != null &&
                         !Pax4UiStateLavaAndIceMission._currentMissionState._lavaLauncher.Touched())
                        )
                    {
                        Vector3 _playerAmmoImpulse = Pax4Tools.WorldToScreen(_body.Position) - Pax4Touch._current._currentTouchState._xy;
                        _playerAmmoImpulse.X = -_playerAmmoImpulse.X;

                        DisableConstraint();

                        _playerAmmoImpulse.Normalize();
                        _playerAmmoImpulse *= _playerAmmoMaxImpulseLength;

                        _body.ApplyBodyWorldImpulse(_playerAmmoImpulse, Vector3.Zero);

                        if (_actorPowerUp == EActorPowerUp._DURABILITY)
                        {
                            ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceIceLaunch1.Play();
                        }
                        else
                        {
                            ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceIceLaunch.Play();
                        }

                        _launched = true;//false this for remote control
                    }
                }
            }
            else
            {
                if (_body.Position.Y >= Pax4ActorWorld._fudgeFactor / _destroyLowerThresholdFactor)
                {
                    _spawning = false;
                }
            }
        }
Exemple #3
0
        public override void Enable()
        {
            if (!_isDisabled)
            {
                return;
            }

            base.Enable();

            _matWorld = _matScale * Pax4Tools.ToXnaMatrix(_body.Orientation, _body.Position);

            EnableConstraint();
            EnableHingeJoint();
        }
Exemple #4
0
        public void UpdateThreshold()
        {
            _topLeft     = (_centerPosition - _originScaledDraw);
            _bottomRight = (_centerPosition + _originScaledDraw);

            //Set Touch Thresholds Bouund Based on Viewing Threasholds
            _leftThreshold   = Pax4Tools.BoundOutput((int)_topLeft.X, Pax4Game._graphicsDeviceManager.PreferredBackBufferWidth, _leftViewingThreshold);
            _rightThreshold  = Pax4Tools.BoundOutput((int)_bottomRight.X, _rightViewingThreshold);
            _topThreshold    = Pax4Tools.BoundOutput((int)_topLeft.Y, Pax4Game._graphicsDeviceManager.PreferredBackBufferHeight, _topViewingThreshold);
            _bottomThreshold = Pax4Tools.BoundOutput((int)_bottomRight.Y, _bottomViewingThreshold);
            //_leftThreshold = (int)(_centerPosition.X - _originScaledDraw.X);
            //_rightThreshold = (_leftThreshold + _rectangleScaled.Width);
            //_topThreshold = (int)(_centerPosition.Y - _originScaledDraw.Y);
            //_bottomThreshold = (_topThreshold + _rectangleScaled.Height);
            SetRectangleDraw();
        }
        public virtual void TriggerWorldToScreen()
        {
            if (_disabled || _particleEffectProxy == null)
            {
                return;
            }

            Vector3 effectPosition = Pax4Tools.WorldToScreen(_objectSceneryPart.GetPosition());

            for (int i = 0; i < _particleEffectProxy.Effect.Emitters.Count; i++)
            {
                ((TriggerOffsetController)_particleEffectProxy.Effect.Emitters[i].Controllers[0]).TriggerOffset = effectPosition;
            }

            _particleEffectProxy.Trigger();
        }
Exemple #6
0
        public override void Enter()
        {
            Pax4ParticleEffect._current.Enable();

            _currentMissionState = this;

            _scoreSpriteModifier.Ini(0.0f, 0.0f, true, 0.0f);

            if (Pax4WorldLavaAndIce._missionIndex > 0)
            {
                String highScoreName = Pax4UiStateLavaAndIceChooseQuest._questName + "_" + Pax4WorldLavaAndIce._missionIndex + "_HighScore";
                ((Pax4SpriteText)_highScoreSprite).SetText(Pax4Tools.NumberCommaFormat(Pax4UiLavaAndIceQuestScore._score[highScoreName]));
            }

            base.Enter();
        }
        public virtual void Trigger(bool p_randomOffset, float p_offsetMax = 0.0f)
        {
            if (_disabled || _particleEffectProxy == null || _objectSceneryPart == null)
            {
                return;
            }

            Vector3 effectPosition = Pax4Tools.WorldToScreen(_objectSceneryPart.GetPosition());

            if (p_randomOffset)
            {
                effectPosition += RandomUtil.NextUnitVector3() * p_offsetMax * Pax4Camera._current._scale;
            }

            for (int i = 0; i < _particleEffectProxy.Effect.Emitters.Count; i++)
            {
                ((TriggerOffsetController)_particleEffectProxy.Effect.Emitters[i].Controllers[0]).TriggerOffset = effectPosition;
            }

            _particleEffectProxy.Trigger();
        }
Exemple #8
0
        public void UpdateSelectedObject()
        {
            //if (Pax4Touch._current._currentTouchState._oneTap)
            if (Pax4Touch._current._currentTouchState._clean &&
                Pax4Touch._current._currentTouchState._oneTap)
            {
                JVector rayOrigin;
                JVector rayDirection;

                Pax4Tools.RayTo(Pax4Touch._current._currentTouchState._xy.X,
                                Pax4Touch._current._currentTouchState._xy.Y,
                                out rayOrigin,
                                out rayDirection);

                RigidBody body;
                JVector   hitNormal;
                JVector   hitPoint;
                float     hitDistance = 0.0f;
                float     fraction;

                rayDirection *= Pax4Camera._current._farPlane;

                bool result = _physicsSystem.CollisionSystem.Raycast(rayOrigin,
                                                                     rayDirection, //at this point it's a full length ray ;)
                                                                     RaycastCallback,
                                                                     out body, out hitNormal, out fraction);

                _selectedPhysicsPart = null;

                if (result)
                {
                    hitPoint = rayOrigin + fraction * rayDirection;

                    hitDistance = (hitPoint - rayOrigin).Length();

                    _selectedPhysicsPart = (Pax4ObjectPhysicsPart)body._paxState;
                }
            }
        }
Exemple #9
0
        public override void UpdateController(float dt)
        {
            if (dt <= 0.1f)
            {
                dt = 0.1f;
            }

            _worldHeading    = _wayPointPath._wayPoint[_wayPointIndex] - _physicsPart._body.Position;
            _currentDistance = _worldHeading.Length();

            if (_worldHeading != Vector3.Zero)
            {
                _worldHeading.Normalize();
            }

            float cosTheta = Vector3.Dot(_physicsPart._body.Orientation.Backward, _worldHeading);

            _worldTorque = Vector3.Cross(_physicsPart._body.Orientation.Backward, _worldHeading);

            if (cosTheta < -1 + 0.01f)
            {
                _worldTorque = Vector3.Cross(Vector3.UnitZ, _physicsPart._body.Orientation.Backward);
                if (_worldTorque.Length() < 0.01f)
                {
                    _worldTorque = Vector3.Cross(Vector3.UnitX, _physicsPart._body.Orientation.Backward);
                }
                _worldTorque.Normalize();
            }

            _worldTorque.X = Pax4Tools.FooAggregate(_worldTorque.X, _physicsPart._body.TransformRate.AngularVelocity.X);
            _worldTorque.Y = Pax4Tools.FooAggregate(_worldTorque.Y, _physicsPart._body.TransformRate.AngularVelocity.Y);
            _worldTorque.Z = Pax4Tools.FooAggregate(_worldTorque.Z, _physicsPart._body.TransformRate.AngularVelocity.Z);

            _worldTorque = Vector3.Multiply(_worldTorque, cosTheta / dt);
            _worldTorque = Vector3.Transform(_worldTorque, _physicsPart._body.BodyInertia);

            _physicsPart._body.AddWorldTorque(_worldTorque);

            if (_currentDistance <= _wayPointDistanceThreshold)
            {
                if (_wayPointPath._wayPoint.Length > 1)
                {
                    _wayPointIndex++;
                    if (_wayPointIndex == _wayPointPath._wayPoint.Length)
                    {
                        _wayPointIndex = 0;
                    }

                    _worldHeading    = _wayPointPath._wayPoint[_wayPointIndex] - _physicsPart._body.Position;
                    _currentDistance = _worldHeading.Length();
                    _worldDistance   = _currentDistance;
                }

                if (_currentDistance == 0.0f)
                {
                    return;
                }
            }

            if (_wayPointPath._wayPoint.Length == 1)
            {
                if (_currentDistance <= _wayPointDistanceThreshold)
                {
                    _worldVelocity = _currentDistance * _velocityFactor * _worldHeading;
                }
                else
                {
                    _worldVelocity = _velocityFactor * _worldHeading;
                }
            }
            else
            {
                _worldVelocity = _velocityFactor * _worldHeading;
            }

            _worldForce = ((_worldVelocity - _physicsPart._body.Velocity) * _physicsPart._mass) / dt;
            _physicsPart._body.AddWorldForce(_worldForce);

            if (!_physicsPart._body.IsActive)
            {
                _physicsPart._body.SetActive();
            }
        }
        public static void UpdateScore()
        {
            int    maxMedalCount                  = 0;
            int    medalCount                     = 0;
            String questName                      = null;
            String questNameMissionIndexName      = null;
            Pax4ButtonLavaAndIceQuest questButton = null;
            String    textureName                 = null;
            Texture2D texture                     = null;

            for (int bi = 0; bi < _questButton.Count; bi++)
            {
                questButton = _questButton[bi];
                questName   = questButton._questName;

                if (questName.Equals("Prologue"))
                {
                    maxMedalCount = 19 * 4;//!*update this to the count of missions
                }
                else
                {
                    maxMedalCount = Pax4WorldLavaAndIce._maxMissions * 4;
                }

                for (int i = 0; i < Pax4WorldLavaAndIce._maxMissions; i++)
                {
                    questNameMissionIndexName = questName + "_" + (i + 1).ToString();

                    if (!Pax4UiLavaAndIceQuestScore._score.ContainsKey(questNameMissionIndexName + "_NightmareMedalCount"))
                    {
                        Pax4UiLavaAndIceQuestScore._score.Add(questNameMissionIndexName + "_NightmareMedalCount", 0);
                    }
                    if (Pax4UiLavaAndIceQuestScore._score[questNameMissionIndexName + "_NightmareMedalCount"] > 0)
                    {
                        medalCount++;
                    }

                    if (!Pax4UiLavaAndIceQuestScore._score.ContainsKey(questNameMissionIndexName + "_HardMedalCount"))
                    {
                        Pax4UiLavaAndIceQuestScore._score.Add(questNameMissionIndexName + "_HardMedalCount", 0);
                    }
                    if (Pax4UiLavaAndIceQuestScore._score[questNameMissionIndexName + "_HardMedalCount"] > 0)
                    {
                        medalCount++;
                    }

                    if (!Pax4UiLavaAndIceQuestScore._score.ContainsKey(questNameMissionIndexName + "_NormalMedalCount"))
                    {
                        Pax4UiLavaAndIceQuestScore._score.Add(questNameMissionIndexName + "_NormalMedalCount", 0);
                    }
                    if (Pax4UiLavaAndIceQuestScore._score[questNameMissionIndexName + "_NormalMedalCount"] > 0)
                    {
                        medalCount++;
                    }

                    if (!Pax4UiLavaAndIceQuestScore._score.ContainsKey(questNameMissionIndexName + "_EasyMedalCount"))
                    {
                        Pax4UiLavaAndIceQuestScore._score.Add(questNameMissionIndexName + "_EasyMedalCount", 0);
                    }
                    if (Pax4UiLavaAndIceQuestScore._score[questNameMissionIndexName + "_EasyMedalCount"] > 0)
                    {
                        medalCount++;
                    }
                }

                ((Pax4SpriteText)questButton._pctCompletedValue).SetText((100 * medalCount / maxMedalCount).ToString());

                ((Pax4SpriteText)questButton._totalScoreValue).SetText(Pax4Tools.NumberCommaFormat(Pax4UiLavaAndIceQuestScore._score[questName + "_TotalScore"]));
                ((Pax4SpriteText)questButton._lastScoreValue).SetText(Pax4Tools.NumberCommaFormat(Pax4UiLavaAndIceQuestScore._score[questName + "_LastScore"]));
                ((Pax4SpriteText)questButton._lavaKillsValue).SetText(Pax4Tools.NumberCommaFormat(Pax4UiLavaAndIceQuestScore._score[questName + "_LavaKills"]));
                ((Pax4SpriteText)questButton._iceKillsValue).SetText(Pax4Tools.NumberCommaFormat(Pax4UiLavaAndIceQuestScore._score[questName + "_IceKills"]));
                ((Pax4SpriteText)questButton._monsterKillsValue).SetText(Pax4Tools.NumberCommaFormat(Pax4UiLavaAndIceQuestScore._score[questName + "_MonsterKills"]));

                medalCount = Pax4UiLavaAndIceQuestScore._score[questName + "_NightmareMedalCount"];
                if (medalCount > 0)
                {
                    textureName = "Sprite/lavaandiceNightmareOn";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)questButton._nightmareMedal).SetTexture(texture);
                    ((Pax4SpriteText)questButton._nightmareMedalCount).SetText(Pax4Tools.NumberCommaFormat(medalCount));
                }
                else
                {
                    textureName = "Sprite/lavaandiceNightmareOff";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)questButton._nightmareMedal).SetTexture(texture);
                }

                medalCount = Pax4UiLavaAndIceQuestScore._score[questName + "_HardMedalCount"];
                if (medalCount > 0)
                {
                    textureName = "Sprite/lavaandiceHardOn";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)questButton._hardMedal).SetTexture(texture);
                    ((Pax4SpriteText)questButton._hardMedalCount).SetText(Pax4Tools.NumberCommaFormat(medalCount));
                }
                else
                {
                    textureName = "Sprite/lavaandiceHardOff";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)questButton._hardMedal).SetTexture(texture);
                }

                medalCount = Pax4UiLavaAndIceQuestScore._score[questName + "_NormalMedalCount"];
                if (medalCount > 0)
                {
                    textureName = "Sprite/lavaandiceNormalOn";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)questButton._normalMedal).SetTexture(texture);
                    ((Pax4SpriteText)questButton._normalMedalCount).SetText(Pax4Tools.NumberCommaFormat(medalCount));
                }
                else
                {
                    textureName = "Sprite/lavaandiceNormalOff";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)questButton._normalMedal).SetTexture(texture);
                }

                medalCount = Pax4UiLavaAndIceQuestScore._score[questName + "_EasyMedalCount"];
                if (medalCount > 0)
                {
                    textureName = "Sprite/lavaandiceEasyOn";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)questButton._easyMedal).SetTexture(texture);
                    ((Pax4SpriteText)questButton._easyMedalCount).SetText(Pax4Tools.NumberCommaFormat(medalCount));
                }
                else
                {
                    textureName = "Sprite/lavaandiceEasyOff";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)questButton._easyMedal).SetTexture(texture);
                }
            }
        }
        public virtual bool HandleCollisionDetection(CollisionSkin p_this, CollisionSkin p_other)
        {
            if (_dxRequested)
            {
                return(false);
            }

            Pax4ObjectPhysicsPart other = (Pax4ObjectPhysicsPart)p_other._pax4Object;

            if (((Pax4Actor)other)._actorType == EActorType._WORLD)
            {
                return(true);
            }

            Vector3 effectPosition = Pax4Tools.WorldToScreen(other._body.Position);

            if (((Pax4Actor)other)._actorType != EActorType._PLAYER)
            {
                if (this._actorElementType != ((Pax4Actor)other)._actorElementType)
                {
                    this._health -= _normalHealthStep;
                    if (this._health <= 0.0f)
                    {
                        this.RequestDx();
                    }

                    if (this._actorPowerUp == EActorPowerUp._DURABILITY)
                    {
                        if (this._actorElementType == EActorType._LAVA)
                        {
                            ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceBurning1.Play();
                        }
                        else if (this._actorElementType == EActorType._ICE)
                        {
                            ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceFreezing1.Play();
                        }

                        return(HandleCollisionDetectionOther(effectPosition, (Pax4Actor)other, _durabilityHealthStep));
                    }
                    else if (this._actorPowerUp == EActorPowerUp._NORMAL)
                    {
                        if (((Pax4Actor)other)._actorPowerUp != EActorPowerUp._NULL && ((Pax4Actor)other)._actorClassType == EActorType._AMMO)
                        {
                            if (this == Pax4ActorPlayerAmmoLava._current)
                            {
                                Pax4ActorPlayerAmmoLava._powerUp = ((Pax4Actor)other)._actorPowerUp;
                            }
                            else if (this == Pax4ActorPlayerAmmoIce._current)
                            {
                                Pax4ActorPlayerAmmoIce._powerUp = ((Pax4Actor)other)._actorPowerUp;
                            }
                        }

                        return(HandleCollisionDetectionOther(effectPosition, (Pax4Actor)other, _normalHealthStep));
                    }
                }
                else// (this._actorElementType == other._actorElementType)
                {
                    if (this._actorElementType == EActorType._LAVA)
                    {
                        ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceBurning.Play();
                    }
                    else if (this._actorElementType == EActorType._ICE)
                    {
                        ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceFreezing.Play();
                    }

                    this._health -= _similarHealthStep;
                    if (this._health <= 0.0f)
                    {
                        this.RequestDx();
                    }

                    if (_similarHealthStep >= 1.0f)
                    {
                        return(HandleCollisionDetectionOther(effectPosition, (Pax4Actor)other, _durabilityHealthStep));
                    }
                    else if (this._actorPowerUp == EActorPowerUp._DURABILITY)
                    {
                        return(false);
                    }
                }
            }
            else if (((Pax4Actor)other)._actorType == EActorType._PLAYER &&
                     Pax4ActorPlayerAmmoLava._current._launched &&
                     Pax4ActorPlayerAmmoIce._current._launched)
            {
                ((Pax4ParticleEffectLavaAndIce)Pax4ParticleEffect._current)._particleEffectScore300.Trigger(ref effectPosition);
                ((Pax4ParticleEffectLavaAndIce)Pax4ParticleEffect._current)._particleEffectScoreHelpingHand.Trigger(ref effectPosition);

                Pax4UiStateLavaAndIceMission._currentMissionState._scoreSpriteModifier.Ini(((Pax4WorldLavaAndIce)Pax4World._current)._score, ((Pax4WorldLavaAndIce)Pax4World._current)._score + 300, true, 1.0f);
                Pax4UiStateLavaAndIceMission._currentMissionState._scoreSpriteModifier.Trigger();
                ((Pax4WorldLavaAndIce)Pax4World._current)._score += 300;
            }

            return(true);
        }
Exemple #12
0
        public override void Update(GameTime gameTime)
        {
            if (_done || Pax4Game._pause || _timerDisabled)
            {
                return;
            }

            if (_timer > 0.0f)
            {
                _timer -= (float)gameTime.ElapsedGameTime.TotalSeconds;

                _alarm = false;
                if (_timer <= 20.0f && ((int)_timer) % 2 == 0)
                {
                    if (_timer1)
                    {
                        ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceTimer1.Play();
                        _timer1 = false;
                    }

                    if (_timer <= 8.5f && _timer2)
                    {
                        ((Pax4SoundLavaAndIce)Pax4Sound._current)._lavaandiceTimer2.Play();
                        _timer2 = false;
                    }

                    _alarm = true;

                    if (_timer > 10.0f)
                    {
                        _alarmSprite = _alarmSpriteYellow;
                    }
                    else
                    {
                        _alarmSprite = _alarmSpriteRed;
                    }
                }

                if (_timer <= 0.0f)
                {
                    _timer = 0.0f;
                    _alarm = true;
                }

                ((Pax4SpriteText)_timerValue).SetText(Pax4Tools.FloatSecondsToMinutesSeconds(_timer));
            }
            else
            {
                _done = true;
            }

            if (_normalSprite != null)
            {
                _normalSprite.Update(gameTime);
            }

            if (_alarm && _alarmSprite != null)
            {
                _alarmSprite.Update(gameTime);
            }

            if (_timerValue != null)
            {
                _timerValue.Update(gameTime);
            }
        }
Exemple #13
0
 public override Matrix GetWorld()
 {
     return(Pax4Tools.ToXnaMatrix(_body.Orientation, _body.Position));
 }
        public static void UpdateScore()
        {
            int    medalCount = 0;
            String questNameMissionIndexName          = null;
            Pax4ButtonLavaAndIceMission missionButton = null;
            String    textureName = null;
            Texture2D texture     = null;
            int       medal       = 0;

            for (int bi = 0; bi < _missionButton.Count; bi++)
            {
                medal         = 0;
                missionButton = _missionButton[bi];

                if (missionButton._missionIndex <= 0)
                {
                    continue;
                }

                questNameMissionIndexName = missionButton._questNameMissionIndex;

                ((Pax4SpriteText)missionButton._highScoreValue).SetText(Pax4Tools.NumberCommaFormat(Pax4UiLavaAndIceQuestScore._score[questNameMissionIndexName + "_HighScore"]));
                ((Pax4SpriteText)missionButton._lastScoreValue).SetText(Pax4Tools.NumberCommaFormat(Pax4UiLavaAndIceQuestScore._score[questNameMissionIndexName + "_LastScore"]));

                medalCount = Pax4UiLavaAndIceQuestScore._score[questNameMissionIndexName + "_NightmareMedalCount"];
                if (medalCount > 0)
                {
                    medal++;
                    textureName = "Sprite/lavaandiceNightmareOn";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)missionButton._nightmareMedal).SetTexture(texture);
                    ((Pax4SpriteText)missionButton._nightmareMedalCount).SetText(Pax4Tools.NumberCommaFormat(medalCount));
                }
                else
                {
                    textureName = "Sprite/lavaandiceNightmareOff";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)missionButton._nightmareMedal).SetTexture(texture);
                }

                medalCount = Pax4UiLavaAndIceQuestScore._score[questNameMissionIndexName + "_HardMedalCount"];
                if (medalCount > 0)
                {
                    medal++;
                    textureName = "Sprite/lavaandiceHardOn";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)missionButton._hardMedal).SetTexture(texture);
                    ((Pax4SpriteText)missionButton._hardMedalCount).SetText(Pax4Tools.NumberCommaFormat(medalCount));
                }
                else
                {
                    textureName = "Sprite/lavaandiceHardOff";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)missionButton._hardMedal).SetTexture(texture);
                }

                medalCount = Pax4UiLavaAndIceQuestScore._score[questNameMissionIndexName + "_NormalMedalCount"];
                if (medalCount > 0)
                {
                    medal++;
                    textureName = "Sprite/lavaandiceNormalOn";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)missionButton._normalMedal).SetTexture(texture);
                    ((Pax4SpriteText)missionButton._normalMedalCount).SetText(Pax4Tools.NumberCommaFormat(medalCount));
                }
                else
                {
                    textureName = "Sprite/lavaandiceNormalOff";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)missionButton._normalMedal).SetTexture(texture);
                }

                medalCount = Pax4UiLavaAndIceQuestScore._score[questNameMissionIndexName + "_EasyMedalCount"];
                if (medalCount > 0)
                {
                    medal++;
                    textureName = "Sprite/lavaandiceEasyOn";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)missionButton._easyMedal).SetTexture(texture);
                    ((Pax4SpriteText)missionButton._easyMedalCount).SetText(Pax4Tools.NumberCommaFormat(medalCount));
                }
                else
                {
                    textureName = "Sprite/lavaandiceEasyOff";
                    texture     = Pax4Texture2D._current.Get(textureName);
                    ((Pax4SpriteTexture)missionButton._easyMedal).SetTexture(texture);
                }

                ((Pax4SpriteText)missionButton._pctCompletedValue).SetText(100 * medal / 4 + "%");

                if (medal > 0)
                {
                    Pax4UiLavaAndIceQuestScore._score[missionButton._questName + "_" + (missionButton._missionIndex + 1) + "_Locked"] = 0;
                }

                if (Pax4UiLavaAndIceQuestScore._score[missionButton._questName + "_" + missionButton._missionIndex + "_Locked"] == 0)
                {
                    missionButton.SetLocked(false);
                }
            }
        }
Exemple #15
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (_isDisabled) //Added by Pony
            {
                return;
            }

            bool onetap = false;

            _accelerate = false;

            if (ViewableTouched())
            {
#if WINDOWS
                if (Pax4Touch._current._currentTouchState._clean && Pax4Touch._current._currentTouchState._oneTouch)
#else
                if (Pax4Touch._current._currentTouchState._clean)
#endif
                {
                    _oneTouch = true;

                    _positionModifier.Stop();

                    _tempPosition = _centerPosition;
                    if (_verticalScroll)
                    {
                        _tempPosition.Y += Pax4Touch._current._currentTouchState._dxdy.Y;
                    }
                    else
                    {
                        _tempPosition.X += Pax4Touch._current._currentTouchState._dxdy.X;
                    }

                    SetPositionAbsolute(_tempPosition);

                    _accelerate = true;
                }
                else
                {
                    onetap  = true;
                    _oneTap = Pax4Touch._current._currentTouchState._oneTap;
                }
            }
            else
            { // Cause Flick If touch moves outside Viewable Touch Area
                if (Pax4Touch._current._velocityAvgVal > 30 && _oneTouch)
                {
                    _oneFlick   = true;
                    _accelerate = true;
                    _oneTap     = false;
                    //Pax4Touch._current._currentTouchState._oneTap = false;
                }

                _oneTouch = false;
            }

            if (onetap || _oneFlick)
            {
                if (_oneTouch)
                {
                    if (Pax4Touch._current._currentTouchState._oneFlick)
                    {
                        _accelerate = true;
                    }

                    _oneTouch = false;
                }

                if (_accelerate)
                {
                    if (_verticalScroll)
                    {
                        _velocity.X = 0.0f;
                        _velocity.Y = Pax4Touch._current._velocityAvg.Y;
                    }
                    else
                    {
                        _velocity.X = Pax4Touch._current._velocityAvg.X;
                        _velocity.Y = 0.0f;
                    }

                    _positionModifier.IniVelocity0Acceleration(_velocity, 0.40f, Vector2.Zero, Pax4Game._current.GetPreferredBackBufferVector(), true);
                    _positionModifier.Trigger();

                    _accelerate = false;

                    onetap    = false;
                    _oneFlick = false;
                }
            }

            if (_positionModifier != null && !_positionModifier._done)
            {
                _positionModifier.Update(gameTime);
            }

            //Recover From children being thrown off screen
            if (_childSprite.Count > 0 && !_oneTouch && !_oneTap)
            {
                var lastChildTopLeft      = _childSprite[_childSprite.Count - 1]._centerPositionDraw - _childSprite[_childSprite.Count - 1]._originScaledDraw;
                var firstChildBottomRight = _childSprite[0]._centerPositionDraw + _childSprite[0]._originScaledDraw;

                var bounded = false;

                _tempPosition = _centerPosition;

                if (!_verticalScroll)
                {
                    bounded = Pax4Tools.BoundOutput(ref _tempPosition.X,
                                                    (_centerPositionDraw - firstChildBottomRight).X + _rightViewingThreshold,
                                                    _leftViewingThreshold - (lastChildTopLeft - _centerPositionDraw).X);
                }
                else
                {
                    bounded = Pax4Tools.BoundOutput(ref _tempPosition.Y,
                                                    (_centerPositionDraw - firstChildBottomRight).Y + _bottomViewingThreshold,
                                                    _topViewingThreshold - (lastChildTopLeft - _centerPositionDraw).Y);
                }

                if (bounded)
                {
                    //Recover if PositionModifier is Done moving Or if all Children are not visable.
                    if (_positionModifier != null && (_positionModifier._done || (_childSprite[_childSprite.Count - 1]._isInvisible && _childSprite[0]._isInvisible)))
                    {
                        _positionModifier.Ini(_centerPosition, _tempPosition, .3f);
                        _positionModifier.Trigger();
                    }
                }
            }

            if (_childSprite != null)
            {
                for (int i = 0; i < _childSprite.Count; i++)
                {
                    _childSprite[i].Update(gameTime);
                    _childSprite[i].SetDisabledInvisible();
                }
            }
        }