public override void Clear(ExecutionResult executionResult)
        {
            var speed = SpeedCalculator.CalculateBenchmark(executionResult.Output);
            var stat  = new SpeedStat {
                Mode = job.Command.M, Speed = speed.ToString()
            };

            ClientProxyProvider.Client.SendAgentSpeedStats(stat).ConfigureAwait(false);
        }
Beispiel #2
0
 protected override void Awake()
 {
     base.Awake();
     this.speedStat = this.GetComponent <SpeedStat>();
 }
    public void GenerateWeapon()
    {
        int typeSelect = Random.Range(0, 6);

        weaponName = weaponTypes[typeSelect];

        int classSelect = Random.Range(0, 4);

        Class = classTypes[classSelect];

        int modSelect = Random.Range(0, 10);

        modName = Modifier[modSelect];

        int modSelect2 = Random.Range(0, 10);

        modName2 = Modifier2[modSelect2];



        if (Random.Range(0, 2) == 1)
        {
            UniqueType = true;
        }
        else
        {
            UniqueType = false;
        }

        if (UniqueType)
        {
            int uniqueSelect = Random.Range(0, 6);
            myUniqueTypes = uniqueNames[uniqueSelect];
        }
        else
        {
            myUniqueTypes = "";
        }



        weaponName = weaponTypes[typeSelect] + myUniqueTypes;

        if (weaponTypes [typeSelect] == " Axe")
        {
            DamageStat = Random.Range(50, 70);
            Cost       = Random.Range(30, 50);
            SpeedStat  = Random.Range(5, 20);
            Durability = Random.Range(20, 40);
            Class      = classTypes[classSelect];
            modName    = Modifier[modSelect];
            modName2   = Modifier2[modSelect2];
        }
        else if (weaponTypes [typeSelect] == " Sword")
        {
            DamageStat = Random.Range(30, 50);
            Cost       = Random.Range(25, 40);
            SpeedStat  = Random.Range(10, 30);
            Durability = Random.Range(20, 40);
            Class      = classTypes[classSelect];
            modName    = Modifier[modSelect];
            modName2   = Modifier2[modSelect2];
        }
        else if (weaponTypes [typeSelect] == " Dagger")
        {
            DamageStat = Random.Range(20, 40);
            Cost       = Random.Range(5, 20);
            SpeedStat  = Random.Range(20, 50);
            Durability = Random.Range(30, 40);
            Class      = classTypes[classSelect];
            modName    = Modifier[modSelect];
            modName2   = Modifier2[modSelect2];
        }
        else if (weaponTypes [typeSelect] == " Shield")
        {
            DamageStat = Random.Range(5, 10);
            Cost       = Random.Range(30, 60);
            SpeedStat  = Random.Range(0, 10);
            Durability = Random.Range(60, 80);
            Class      = classTypes[classSelect];
            modName    = Modifier[modSelect];
            modName2   = Modifier2[modSelect2];
        }
        else if (weaponTypes [typeSelect] == " Mace")
        {
            DamageStat = Random.Range(20, 30);
            Cost       = Random.Range(20, 40);
            SpeedStat  = Random.Range(30, 50);
            Durability = Random.Range(20, 50);
            Class      = classTypes[classSelect];
            modName    = Modifier[modSelect];
            modName2   = Modifier2[modSelect2];
        }
        else if (weaponTypes [typeSelect] == " Crossbow")
        {
            DamageStat = Random.Range(30, 45);
            Cost       = Random.Range(30, 45);
            SpeedStat  = Random.Range(30, 50);
            Durability = Random.Range(10, 30);
            Class      = classTypes[classSelect];
            modName    = Modifier[modSelect];
            modName2   = Modifier2[modSelect2];
        }

        weaponNameTextObj.GetComponent <Text>().text = weaponName;
        classText.GetComponent <Text>().text         = Class;
        damageText.GetComponent <Text>().text        = DamageStat.ToString() + " %Bonus Damage";
        costText.GetComponent <Text>().text          = Cost.ToString() + " Gold";
        durabilityText.GetComponent <Text>().text    = Durability.ToString() + " %Bonus Durability";
        speedText.GetComponent <Text>().text         = SpeedStat.ToString() + " %Bonus Speed";
        modifierText.GetComponent <Text> ().text     = modName;
        modifier2Text.GetComponent <Text> ().text    = modName2;
    }
Beispiel #4
0
    protected void FireThrusters(Vector3 vOrientationProp)
    {
        //for each axis, applies torque based on the torque available to the axis in the direction indicated by the activation value.
        //-1 means we are applying torque to effect a negative rotation.  +1 does just the opposite.  0 means no torque is needed.
        Vector3 vThrustProp = vOrientationProp;
        Vector3 vXTorque    = Vector3.zero;
        Vector3 vYTorque    = Vector3.zero;
        Vector3 vZTorque    = Vector3.zero;

        if (!InputManager.Instance.NoviceMode)
        {
            vXTorque = tActivation.x * MTransform.TransformDirection(Vector3.right) * torques.x * Mathf.Abs(vThrustProp.x) * Time.fixedDeltaTime;
            vYTorque = tActivation.y * MTransform.TransformDirection(Vector3.up) * torques.y * Mathf.Abs(vThrustProp.y) * Time.fixedDeltaTime;
            vZTorque = tActivation.z * MTransform.TransformDirection(Vector3.forward) * torques.z * Mathf.Abs(vThrustProp.z) * Time.fixedDeltaTime;
        }
        else
        {
            Vector3 vLocalRight = MTransform.TransformDirection(Vector3.right);
            vLocalRight.y = 0;

            vXTorque = tActivation.x * vLocalRight.normalized * torques.x * Mathf.Abs(vThrustProp.x) * Time.fixedDeltaTime;
            vYTorque = tActivation.y * (Vector3.up) * torques.y * Mathf.Abs(vThrustProp.y) * Time.fixedDeltaTime;
        }

        if (!MLandingAbility.Landed)
        {
            Vector3 localVelocity = MTransform.InverseTransformDirection(m_rigidbody.velocity);
            float   ForwardSpeed  = Mathf.Max(0, localVelocity.z);

            Vector3 vTorque = Vector3.zero;

            if (InputManager.Instance.NoviceMode)
            {
                Quaternion localRotation = MTransform.localRotation;
                Quaternion axisRotation  = Quaternion.AngleAxis(localRotation.eulerAngles[0], rotateAround);

                float angleFromMin = Quaternion.Angle(axisRotation, minQuaternion);
                float angleFromMax = Quaternion.Angle(axisRotation, maxQuaternion);

                float fDotUp           = Vector3.Dot(MTransform.forward, Vector3.up);
                float fDotDown         = Vector3.Dot(MTransform.forward, -Vector3.up);
                bool  bDiffUp          = (1f - fDotUp) < 0.1f;
                bool  bDiffDown        = (1f - fDotDown) < 0.1f;
                bool  bDiff            = bDiffUp || bDiffDown;
                bool  bDownDirMovement = bDiffUp && !bDiffDown && tActivation.x > 0;
                bool  bUpDirMovement   = bDiffDown && !bDiffUp && tActivation.x < 0;

                if (!bDiff || bDownDirMovement || bUpDirMovement)
                {
                    if (tActivation.x != 0)
                    {
                        vTorque += vXTorque;
                    }
                }
                else
                {
                    Vector3 vAngular = m_rigidbody.angularVelocity;
                    vAngular.x = 0f;
                    vAngular.z = 0f;
                    m_rigidbody.angularVelocity = vAngular;
                }

                if (tActivation.y != 0)
                {
                    vTorque += vYTorque;
                }
            }
            else
            {
                if (tActivation.x != 0)
                {
                    vTorque += vXTorque;
                }
                if (tActivation.y != 0)
                {
                    vTorque += vYTorque;
                }
                if (tActivation.z != 0)
                {
                    vTorque += vZTorque;
                }
            }

            if (AllowTorquing && !InputManager.Instance.NoviceMode)
            {
                m_rigidbody.AddTorque(vTorque);
            }
            else if (AllowTorquing && InputManager.Instance.NoviceMode)
            {
                m_rigidbody.AddTorque(vTorque);
            }
        }

        if (InputManager.Instance.IsMovement() && !m_playerShip.m_airBrakePress.IsActive)
        {
            SpeedStat.Accelerate();

            if (MTransform.forward.y < 0f)
            {
                Vector3 vDownForce = Physics.gravity.y * GameSimulation.Instance.GravityMultiplier * MTransform.forward.y * MTransform.forward * GameSimulation.Instance.GravityMultiplier;
                m_rigidbody.AddForce(vDownForce, ForceMode.Force);
            }
        }
        else
        {
            SpeedStat.Decelerate();
        }

        if (!MLandingAbility.Landed)
        {
            SpeedStat.AddForce(vThrustProp.x, vThrustProp.y);
        }

        bool bDashCheck = m_playerShip.MDashAbility == null ||
                          (m_playerShip.MDashAbility != null && m_playerShip.MDashAbility.Cooldown.IsMin()) ||
                          (m_playerShip.MSpeedGateEffect.ForcesActive());

        if (m_bAeroSteering)
        {
            if ((Rigidbody.velocity.magnitude > 0 && bDashCheck) || DisableAeroDynamic)
            {
                AeroDynamicEffect.ModifyCurrent(Time.fixedDeltaTime * m_fAeroGainMod);
                // compare the direction we're pointing with the direction we're moving:
                m_AeroFactor = Vector3.Dot(MTransform.forward, Rigidbody.velocity.normalized);
                // multipled by itself results in a desirable rolloff curve of the effect
                m_AeroFactor *= m_AeroFactor;
                // Finally we calculate a new velocity by bending the current velocity direction towards
                // the the direction the plane is facing, by an amount based on this aeroFactor
                Vector3 newVelocity = Vector3.Lerp(Rigidbody.velocity, MTransform.forward * Rigidbody.velocity.magnitude,
                                                   m_AeroFactor * Rigidbody.velocity.magnitude * AeroDynamicEffect.Current * Time.fixedDeltaTime);

                Rigidbody.velocity = newVelocity;
            }
            else
            {
                AeroDynamicEffect.SetToMin();
            }
        }
    }
Beispiel #5
0
    public void ExperimentalOrientationChange(Vector3 vDir, float fMaxDegrees)
    {
        Quaternion desiredRotation = Quaternion.LookRotation(vDir);

        desiredRotation = Quaternion.RotateTowards(Transform.rotation, desiredRotation, fMaxDegrees);

        float      kp  = (6f * m_fFrequency) * (6f * m_fFrequency) * 0.25f;
        float      kd  = 4.5f * m_fFrequency * m_fDamping;
        float      dt  = Time.fixedDeltaTime;
        float      g   = 1 / (1 + kd * dt + kp * dt * dt);
        float      ksg = kp * g;
        float      kdg = (kd + kp * dt) * g;
        Vector3    x;
        float      xMag;
        Quaternion q = desiredRotation * Quaternion.Inverse(MTransform.rotation);

        q.ToAngleAxis(out xMag, out x);
        x.Normalize();
        x *= Mathf.Deg2Rad;
        Vector3    pidv             = kp * x * xMag - kd * Rigidbody.angularVelocity;
        Quaternion rotInertia2World = Rigidbody.inertiaTensorRotation * MTransform.rotation;

        pidv = Quaternion.Inverse(rotInertia2World) * pidv;
        pidv.Scale(Rigidbody.inertiaTensor);
        pidv = rotInertia2World * pidv;

        bool bNaNCheck = float.IsNaN(pidv.x) || float.IsNaN(pidv.y) || float.IsNaN(pidv.z);

        if (!bNaNCheck)
        {
            if (pidv.magnitude > fMaxDegrees)
            {
                pidv = pidv.normalized * fMaxDegrees;
            }

            Rigidbody.AddTorque(pidv);

            if (pidv.sqrMagnitude <= 0.1f)
            {
                m_bReOrientLock = true;
            }
        }

        if (InputManager.Instance.IsMovement())
        {
            SpeedStat.Accelerate();

            if (MTransform.forward.y < 0f)
            {
                Vector3 vDownForce = Physics.gravity.y * GameSimulation.Instance.GravityMultiplier * MTransform.forward.y * MTransform.forward * GameSimulation.Instance.GravityMultiplier;
                m_rigidbody.AddForce(vDownForce, ForceMode.Force);
            }
        }
        else
        {
            SpeedStat.Decelerate();
        }

        if (!MLandingAbility.Landed)
        {
            SpeedStat.AddForce(0f, 0f);
        }

        bool bDashCheck = m_playerShip.MDashAbility == null ||
                          (m_playerShip.MDashAbility != null && m_playerShip.MDashAbility.Cooldown.IsMin()) ||
                          (m_playerShip.MSpeedGateEffect.ForcesActive());

        if ((Rigidbody.velocity.magnitude > 0 && bDashCheck) || DisableAeroDynamic)
        {
            AeroDynamicEffect.ModifyCurrent(Time.fixedDeltaTime * m_fAeroGainMod);
            // compare the direction we're pointing with the direction we're moving:
            m_AeroFactor = Vector3.Dot(MTransform.forward, Rigidbody.velocity.normalized);
            // multipled by itself results in a desirable rolloff curve of the effect
            m_AeroFactor *= m_AeroFactor;
            // Finally we calculate a new velocity by bending the current velocity direction towards
            // the the direction the plane is facing, by an amount based on this aeroFactor
            Vector3 newVelocity = Vector3.Lerp(Rigidbody.velocity, MTransform.forward * Rigidbody.velocity.magnitude,
                                               m_AeroFactor * Rigidbody.velocity.magnitude * AeroDynamicEffect.Current * Time.fixedDeltaTime);

            Rigidbody.velocity = newVelocity;
        }
        else
        {
            AeroDynamicEffect.SetToMin();
        }
    }
    public void GenerateWeapon()
    {
        int typeSelect = Random.Range(0, 6);

        weaponName = weaponTypes[typeSelect];

        int classSelect = Random.Range(0, 3);

        Class = classTypes[classSelect];



        if (Random.Range(0, 2) == 1)
        {
            UniqueType = true;
        }
        else
        {
            UniqueType = false;
        }

        if (UniqueType)
        {
            int uniqueSelect = Random.Range(0, 6);
            myUniqueTypes = uniqueNames[uniqueSelect];
        }
        else
        {
            myUniqueTypes = "";
        }



        weaponName = weaponTypes[typeSelect] + myUniqueTypes;

        if (weaponTypes[typeSelect] == " Axe")
        {
            DamageStat = Random.Range(50, 70);
            Cost       = Random.Range(30, 50);
            SpeedStat  = Random.Range(5, 20);
            Durability = Random.Range(20, 40);
            Class      = "Barbarian";
        }
        else if (weaponTypes[typeSelect] == " Sword")
        {
            DamageStat = Random.Range(30, 50);
            Cost       = Random.Range(25, 40);
            SpeedStat  = Random.Range(10, 30);
            Durability = Random.Range(20, 40);
            Class      = "Barbarian";
        }
        else if (weaponTypes[typeSelect] == " Dagger")
        {
            DamageStat = Random.Range(20, 40);
            Cost       = Random.Range(5, 20);
            SpeedStat  = Random.Range(20, 50);
            Durability = Random.Range(30, 40);
            Class      = "Thief";
        }
        else if (weaponTypes[typeSelect] == " Shield")
        {
            DamageStat = Random.Range(5, 10);
            Cost       = Random.Range(30, 60);
            SpeedStat  = Random.Range(0, 10);
            Durability = Random.Range(60, 80);
            Class      = "Paladin";
        }
        else if (weaponTypes[typeSelect] == " Mace")
        {
            DamageStat = Random.Range(20, 30);
            Cost       = Random.Range(20, 40);
            SpeedStat  = Random.Range(30, 50);
            Durability = Random.Range(20, 50);
            Class      = "Paladin";
        }
        else if (weaponTypes[typeSelect] == " Bow")
        {
            DamageStat = Random.Range(30, 45);
            Cost       = Random.Range(30, 45);
            SpeedStat  = Random.Range(30, 50);
            Durability = Random.Range(10, 30);
            Class      = "Thief";
        }


        weaponNameTextObj.GetComponent <Text>().text = weaponName;
        classText.GetComponent <Text>().text         = Class;
        damageText.GetComponent <Text>().text        = DamageStat.ToString() + " Damage";
        costText.GetComponent <Text>().text          = Cost.ToString() + " Cost";
        durabilityText.GetComponent <Text>().text    = Durability.ToString() + " Durability";
        speedText.GetComponent <Text>().text         = SpeedStat.ToString() + " Speed";
    }