コード例 #1
0
    public Vector3 CenterOfActivity()
    {
        float timeGate = 20.0f;

        float   sumWeights  = 0.0f;
        Vector3 sumPosition = new Vector3(0.0f, 0.0f, 0.0f);

        float ct = Time.time;

        foreach (GeneratorObject obj in Objects.Values)
        {
            LGenerator lgen = obj.LGen;
            float      dt   = ct - lgen.LastTimeTouched;
            if (dt <= timeGate)
            {
                float weight = timeGate - dt;
                sumWeights += weight;
                sumPosition = sumPosition + (lgen.Bounds.center * weight);
            }
        }

        if (sumWeights <= 5.0f)
        {
            sumWeights = 5.0f;
        }

        return(sumPosition / sumWeights);
    }
コード例 #2
0
        private void HashTestOthers(IArgon2ParametersBuilder a_Argon2ParametersBuilder,
                                    Argon2Version a_Version, Int32 a_Iterations, Int32 a_Memory, Int32 a_Parallelism,
                                    string a_Password, string a_Salt, string a_PasswordRef, Int32 a_OutputLength)
        {
            IPBKDF_Argon2 LGenerator;

            byte[]            LSalt, LPassword;
            string            LActual;
            IArgon2Parameters LArgon2Parameter;

            LSalt     = Converters.ConvertStringToBytes(a_Salt, Encoding.ASCII);
            LPassword = Converters.ConvertStringToBytes(a_Password, Encoding.ASCII);

            a_Argon2ParametersBuilder.WithVersion(a_Version).WithIterations(a_Iterations)
            .WithMemoryPowOfTwo(a_Memory).WithParallelism(a_Parallelism).WithSalt(LSalt);

            //
            // Set the password.
            //
            LArgon2Parameter = a_Argon2ParametersBuilder.Build();
            a_Argon2ParametersBuilder.Clear();

            LGenerator = HashFactory.KDF.PBKDF_Argon2.CreatePBKDF_Argon2(LPassword, LArgon2Parameter);

            LActual = Converters.ConvertBytesToHexString(LGenerator.GetBytes(a_OutputLength), false);

            LArgon2Parameter.Clear();
            LGenerator.Clear();

            Assert.AreEqual(a_PasswordRef, LActual,
                            String.Format("Expected {0} but got {1}.", a_PasswordRef, LActual));
        } //
コード例 #3
0
        private void HashTestFromInternetDraft(IArgon2ParametersBuilder a_Argon2ParametersBuilder,
                                               Argon2Version a_Version, Int32 a_Iterations, Int32 a_MemoryAsKB, Int32 a_Parallelism,
                                               string a_Additional, string a_Secret, string a_Salt, string a_Password, string a_PasswordRef,
                                               Int32 a_OutputLength)
        {
            IPBKDF_Argon2 LGenerator;
            string        LActual;

            byte[]            LAdditional, LSecret, LSalt, LPassword;
            IArgon2Parameters LArgon2Parameter;

            LAdditional = Converters.ConvertHexStringToBytes(a_Additional);
            LSecret     = Converters.ConvertHexStringToBytes(a_Secret);
            LSalt       = Converters.ConvertHexStringToBytes(a_Salt);
            LPassword   = Converters.ConvertHexStringToBytes(a_Password);

            a_Argon2ParametersBuilder.WithVersion(a_Version).WithIterations(a_Iterations)
            .WithMemoryAsKB(a_MemoryAsKB).WithParallelism(a_Parallelism)
            .WithAdditional(LAdditional).WithSecret(LSecret).WithSalt(LSalt);

            //
            // Set the password.
            //
            LArgon2Parameter = (IArgon2Parameters)a_Argon2ParametersBuilder.Build();
            a_Argon2ParametersBuilder.Clear();

            LGenerator = HashFactory.KDF.PBKDF_Argon2.CreatePBKDF_Argon2(LPassword, LArgon2Parameter);

            LActual = Converters.ConvertBytesToHexString(LGenerator.GetBytes(a_OutputLength), false);

            LArgon2Parameter.Clear();
            LGenerator.Clear();

            Assert.AreEqual(a_PasswordRef, LActual,
                            String.Format("Expected {0} but got {1}.", a_PasswordRef, LActual));
        } //
コード例 #4
0
 public GeneratorObject(GameObject obj, string shape)
 {
     Obj   = obj;
     Shape = shape;
     LGen  = obj.GetComponent <LGenerator>();
 }