예제 #1
0
 protected virtual void DoSpriteLock(Vector2 direction)
 {
     if (ExtraMath.IsEqual(direction.x, 0))
     {
         if (ExtraMath.IsEqual(direction.y, 0))
         {
             LockSprites("xyz");
         }
         else
         {
             LockSprites("xz");
         }
     }
     else
     {
         if (ExtraMath.IsEqual(direction.y, 0))
         {
             LockSprites("yz");
         }
         else
         {
             LockSprites("z");
         }
     }
 }
예제 #2
0
 void SmoothPushing()
 {
     if (ExtraMath.IsEqual(rb.velocity.x, 0f, 0.5f))
     {
         if (ExtraMath.IsEqual(rb.velocity.y, 0f, 0.5f))
         {
             base.LockSprites("xyz");
         }
         else
         {
             base.LockSprites("xz");
         }
     }
     else
     {
         if (ExtraMath.IsEqual(rb.velocity.y, 0f, 0.5f))
         {
             base.LockSprites("yz");
         }
         else
         {
             base.LockSprites("z");
         }
     }
 }
예제 #3
0
        public void Reduce()
        {
            int gratestCommonDivisor = ExtraMath.GetGreatestCommonDevisor(Numerator, Denominator);

            this.Numerator   /= gratestCommonDivisor;
            this.Denominator /= gratestCommonDivisor;
        }
예제 #4
0
    protected override IEnumerator ActionRoutine()
    {
        speakStartEvent.Invoke(_characterData, _text, parentConversation.conversationType);

        yield return(0f);

        while (true)
        {
            //set these up in playerinput
            if (_input.menuSubmit.triggered)
            {
                break;
            }
            //this doesn't f*****g work at all idiot
            if (_input.menuUp.triggered)
            {
                currentChoiceIndex--;
            }

            if (_input.menuDown.triggered)
            {
                currentChoiceIndex++;
            }

            currentChoiceIndex = ExtraMath.Modulus(currentChoiceIndex, _choiceList.Count);

            yield return(0f);
        }

        yield return(0f);

        yield return(StartCoroutine(base.ActionRoutine()));
    }
예제 #5
0
        public long Solve()
        {
            var nums = new List <long>();

            for (int i = 1; i <= 20; i++)
            {
                nums.Add(i);
            }
            return(ExtraMath.LCM(nums));
        }
예제 #6
0
        public void AssertRandomDoubleNumberIsInRange()
        {
            const double minDouble = 5.0;
            const double maxDouble = 15.0;

            for (var i = 0; i < 50; i++)
            {
                Assert.InRange(ExtraMath.RandomDoubleFromRange(minDouble, maxDouble), minDouble, maxDouble);
            }
        }
예제 #7
0
        public static Vector CalcAngles(Vector src, Vector dst)
        {
            Vector delta  = dst - src;
            Vector angles = new Vector()
            {
                X = ExtraMath.RadianToDegrees((float)Math.Atan2(-delta.Z, Math.Sqrt(delta.X * delta.X + delta.Y * delta.Y))),
                Y = ExtraMath.RadianToDegrees((float)Math.Atan2(delta.Y, delta.X)),
                Z = 0
            };

            return(angles);
        }
예제 #8
0
        private static Tuple <double, double> calculateCoord(Location origin, double brng, double arcLength)
        {
            double lat1 = ExtraMath.DegToRad(origin.Latitude);
            double lon1 = ExtraMath.DegToRad(origin.Longitude);

            double centralAngle = arcLength / earthRadius;

            double lat2 = Math.Asin(Math.Sin(lat1) * Math.Cos(centralAngle) + Math.Cos(lat1) * Math.Sin(centralAngle) * Math.Cos(ExtraMath.DegToRad(brng)));
            double lon2 = lon1 + Math.Atan2(Math.Sin(ExtraMath.DegToRad(brng)) * Math.Sin(centralAngle) * Math.Cos(lat1), Math.Cos(centralAngle) - Math.Sin(lat1) * Math.Sin(lat2));

            return(new Tuple <double, double>(ExtraMath.RadToDeg(lat2), ExtraMath.RadToDeg(lon2)));
        }
예제 #9
0
        public void NormalizeAngle()
        {
            X = ExtraMath.Clamp(X, -89, 89);

            while (Y < -180)
            {
                Y += 360;
            }

            while (Y > 180)
            {
                Y -= 360;
            }
        }
예제 #10
0
        public double this[double x, double y]
        {
            get
            {
                x *= _scaleFactor;
                y *= _scaleFactor;

                double value = 0;

                double x0, x1, y0, y1;

                /* We implement a high-pass filter by subtracting a blurred version of the noise from itself. */

                x0 = Math.Ceiling(x - _blurFactor * CutOffDistance);
                y0 = Math.Ceiling(y - _blurFactor * CutOffDistance);
                x1 = Math.Floor(x + _blurFactor * CutOffDistance);
                y1 = Math.Floor(y + _blurFactor * CutOffDistance);
                for (var xi = x0; xi <= x1; ++xi)
                {
                    var squaredDistanceX = ExtraMath.Square(x - xi);

                    for (var yi = y0; yi <= y1; ++yi)
                    {
                        var squaredDistance = ExtraMath.Square(y - yi) + squaredDistanceX;
                        value -= GetWeight(squaredDistance * _blurNormalizationFactor) * GetValue(_seedHash[xi][yi]);
                    }
                }

                value *= _blurNormalizationFactor;

                /* We implement a low-pass filter by simply only sampling the noise function at certain intervals. */

                x0 = Math.Ceiling(x - CutOffDistance);
                y0 = Math.Ceiling(y - CutOffDistance);
                x1 = Math.Floor(x + CutOffDistance);
                y1 = Math.Floor(y + CutOffDistance);
                for (var xi = x0; xi <= x1; ++xi)
                {
                    var squaredDistanceX = ExtraMath.Square(x - xi);

                    for (var yi = y0; yi <= y1; ++yi)
                    {
                        var squaredDistance = ExtraMath.Square(y - yi) + squaredDistanceX;
                        value += GetWeight(squaredDistance) * GetValue(_seedHash[xi][yi]);
                    }
                }

                return(value);
            }
        }
예제 #11
0
 /// <summary>
 /// Creates a new instance of the <see cref="ConsoleLogger"/> class with a specified output type.
 /// </summary>
 /// <param name="type"> The output type of the logger. </param>
 /// <param name="suppressConsoleResize"> Whether to suppress the console buffer from getting resized. </param>
 public ConsoleLogger(LogOutputType type = LogOutputType.ThreadTime, bool suppressConsoleResize = false)
 {
     Log.AddLogger(this);
     this.type = type;
     if (hndlr == null)
     {
         AddConsoleHandle(hndlr += OnConsoleExit);
     }
     if (!suppressConsoleResize)
     {
         BufferHeight = ExtraMath.Clamp(BufferHeight << 2, MIN_SIZE, MAX_SIZE);
         BufferWidth  = ExtraMath.Clamp(BufferWidth << 2, MIN_SIZE, MAX_SIZE);
     }
 }
예제 #12
0
        private void UpdateByValue(Item item, int value)
        {
            Logger.Log(string.Format("Updating by value={0}: name={1}, sellin={2}, startQuality={3}", value, item.Name, item.SellIn, item.Quality));
            int calculatedQuality = item.Quality + value;

            if (item.SellIn <= 0)
            {
                calculatedQuality = item.Quality + 2 * value;
            }

            item.Quality = ExtraMath.Clamp(0, calculatedQuality, 50);
            item.SellIn--;
            Logger.Log(string.Format("Updated by value={0} parameters: name={1}, sellin={2}, startQuality={3}", value, item.Name, item.SellIn, item.Quality));
        }
예제 #13
0
    protected void ReduceExternalForce()
    {
        if (Mathf.Approximately(_externalForce.x, 0f) && Mathf.Approximately(_externalForce.z, 0f))
        {
            _currentDrag = GetDrag(0f, _externalForce.y);
            _hasControl  = true;
            return;
        }
        float   vertical             = _externalForce.y;
        Vector3 lateralExternalForce = _externalForce;

        lateralExternalForce.y = 0f;
        _externalForce         = ExtraMath.ReduceVector(lateralExternalForce, Time.deltaTime * _currentDrag);
        _externalForce.y       = vertical;
    }
예제 #14
0
        private static double calculateBearing(Location A, Location B)
        {
            double lat1 = ExtraMath.DegToRad(B.Latitude);
            double lon1 = B.Longitude;
            double lat2 = ExtraMath.DegToRad(A.Latitude);
            double lon2 = A.Longitude;

            double dLon = ExtraMath.DegToRad(lon2 - lon1);

            double y = Math.Sin(dLon) * Math.Cos(lat2);
            double x = Math.Cos(lat1) * Math.Sin(lat2) - Math.Sin(lat1) * Math.Cos(lat2) * Math.Cos(dLon);

            double brng = (ExtraMath.RadToDeg(Math.Atan2(y, x)) + 360) % 360;

            return(brng);
        }
            public void UpdateAutopilot(FlightCtrlState c)
            {
                if (!(vessel.vessel.horizontalSrfSpeed > 0.1f))
                {
                    return;
                }

                if (Math.Abs(ExtraMath.AngleDelta(vessel.Heading, vessel.VelocityHeading)) <= 90)
                {
                    c.wheelSteer = (float)DirectBindingMath.Clamp(bearingProvider() / -10, -1, 1);
                }
                else
                {
                    c.wheelSteer = -(float)DirectBindingMath.Clamp(bearingProvider() / -10, -1, 1);
                }
            }
예제 #16
0
        // TODO problem 24
        public long Solve()
        {
            long seachItem = 1000000;
            var  digits    = Enumerable.Range(0, 10).ToList();
            var  str       = "";

            for (int i = 9; i > 0; i--)
            {
                var fac   = ExtraMath.Factorial(i);
                var index = (int)(seachItem / fac);
                str += digits.ElementAt(i);
                digits.RemoveAt(index);
                seachItem %= fac;
            }
            str += digits.Last();
            return(long.Parse(str));
        }
예제 #17
0
    public virtual void UpdateDimensions(Vector2 newLength)
    {
        Vector2 intDimensions = new Vector2(Mathf.Ceil(newLength.x), Mathf.Ceil(newLength.y));

        //if (!hasBeenInitialized) {
        Initialize();
        //}
        bool isVisible = (!ExtraMath.IsEqual(newLength.x, 0) && !ExtraMath.IsEqual(newLength.y, 0));

        hitBox.enabled = isVisible;
        rend.enabled   = isVisible;
        if (isVisible)
        {
            rend.size     = intDimensions;
            hitBox.offset = new Vector2(intDimensions.x / 2, dimensions.y / 2);
            hitBox.size   = newLength;
        }
        //dimensions = intDimensions;
    }
    private ViewCastInfo ViewCast(float angle)
    {
        // create and initialize a ViewCastInfo
        ViewCastInfo info      = new ViewCastInfo();
        Vector2      direction = ExtraMath.AngleToVector2(angle);

        info.Point    = _targetManager.transform.position + (Vector3)direction * _targetManager.VisionRange;
        info.Distance = _targetManager.VisionRange;
        info.Angle    = angle;
        // check if something was hit
        RaycastHit2D hit = Physics2D.Raycast(_targetManager.transform.position, direction, _targetManager.VisionRange, _targetManager.VisionLayers);

        // if something was hit, modify the ViewCastInfo
        if (hit.transform != null)
        {
            info.Hit      = true;
            info.Point    = hit.point;
            info.Distance = hit.distance;
        }
        return(info);
    }
예제 #19
0
        private void MoveMouseRelative(int dx, int dy)
        {
            var trail  = trails.GetRandomTrail();
            var matrix = ExtraMath.GetMatrix(dx, dy, trail.DX, trail.DY);
            var moves  = trail.Moves;

            var first = moves[0];
            var time  = first.Time;

            var start = User32.GetCursorPosition();

            foreach (var m in moves)
            {
                Thread.Sleep(m.Time - time);

                time = m.Time;

                var p = ExtraMath.MultiplyMatrix22ToPoint(matrix, m.X - first.X, m.Y - first.Y);

                DoMouseMoveAbsolute(start.X + p.X, start.Y + p.Y, m.Type);
            }
        }
예제 #20
0
        private void SetUpScreen(RenderInfo renderInfo)
        {
            float diagonalFactor = (float)(_uiDiagonal / Math.Sqrt(ExtraMath.Square(renderInfo.Width) + ExtraMath.Square(renderInfo.Height)));

            Width  = renderInfo.Width * diagonalFactor;
            Height = renderInfo.Height * diagonalFactor;

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();

            var modelViewMatrix = Matrix4.Zero;

            modelViewMatrix.M11 = 2.0f / Width;
            modelViewMatrix.M41 = -1.0f;
            modelViewMatrix.M22 = -2.0f / Height;
            modelViewMatrix.M42 = 1.0f;
            modelViewMatrix.M33 = 1;
            modelViewMatrix.M44 = 1;

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadMatrix(ref modelViewMatrix);
        }
예제 #21
0
        private bool TryGetNextPoint(Point currentPoint, int vertexIndex, out Point nextPoint)
        {
            Vertex chosenVertex = Vertices[vertexIndex];
            int    x            = (int)ExtraMath.MiddleValueByCompression(currentPoint.X, chosenVertex.X, chosenVertex.compressionRatio);
            int    y            = (int)ExtraMath.MiddleValueByCompression(currentPoint.Y, chosenVertex.Y, chosenVertex.compressionRatio);

            nextPoint = new Point(x, y);

            Point rotationCenter = chosenVertex.Point;

            foreach (Rule r in Rules)
            {
                rotationCenter = r.AlterCenterOfRotation(vertexIndex, chosenVertex.Point);
            }
            nextPoint = ExtraMath.RotatePointAroundOrigin(nextPoint, rotationCenter, chosenVertex.rotation);

            foreach (Rule r in Rules)
            {
                return(r.IsPointValid(nextPoint, MemoryBitmap));
            }

            return(true);
        }
예제 #22
0
파일: Program.cs 프로젝트: KubikJan7/ICSHP
        static void Main(string[] args)
        {
            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine("Conversion of decimal to binary system.");
            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine(MathConverter.DecToBin(8));


            Console.WriteLine("\n-------------------------------------------------");
            Console.WriteLine("Conversion of binary to decimal system.");
            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine(MathConverter.BinToDec("0101"));


            Console.WriteLine("\n-------------------------------------------------");
            Console.WriteLine("Conversion of decimal number to roman.");
            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine(MathConverter.DecToRoman(3269));


            Console.WriteLine("\n-------------------------------------------------");
            Console.WriteLine("Conversion of roman number to decimal.");
            Console.WriteLine("-------------------------------------------------");
            Console.WriteLine(MathConverter.RomanToDec("XLMCD"));


            Console.WriteLine("\n-------------------------------------------------");
            Console.WriteLine("Solving of a quadratic equation.");
            Console.WriteLine("-------------------------------------------------");
            ExtraMath.SolveQuadraticEquation(1, -3, -4);

            Console.WriteLine("\n-------------------------------------------------");
            Console.WriteLine("Generation of random double.");
            Console.WriteLine("-------------------------------------------------");
            ExtraMath.GenerateRndNum(new Random(), 0.56256, 10.581254);
        }
예제 #23
0
    public override void OnInspectorGUI()
    {
        List <Object> components = new List <Object>();

        Object[] assets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(target));
        for (int i = 0; i < assets.Length; i++)
        {
            if (AssetDatabase.IsSubAsset(assets[i]))
            {
                components.Add(assets[i]);
            }
        }

        components.Sort((x, y) => x.name.CompareTo(y.name));

        for (int i = 0; i < components.Count; i++)
        {
            Object componentData = components[i];

            if (componentData is CoolNoteTextData)
            {
                GUILayout.Space(16);
                CoolNoteTextData textData = (CoolNoteTextData)componentData;

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("X", GUILayout.Width(20)))
                {
                    DeleteComponent(i);
                    break;
                }
                GUILayout.EndHorizontal();

                SerializedObject serObj = new SerializedObject(textData);
                serObj.FindProperty("text").stringValue = EditorGUILayout.TextArea(serObj.FindProperty("text").stringValue, GUILayout.MinHeight(30), GUILayout.ExpandHeight(true));
                serObj.ApplyModifiedProperties();
            }
            else if (componentData is CoolNoteImageData)
            {
                GUILayout.Space(16);
                CoolNoteImageData imageData = (CoolNoteImageData)componentData;

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("E", GUILayout.Width(20)))
                {
                    _editingImage = imageData;
                }
                if (GUILayout.Button("X", GUILayout.Width(20)))
                {
                    DeleteComponent(i);
                    break;
                }
                GUILayout.EndHorizontal();

                SerializedObject serObj = new SerializedObject(imageData);

                float width  = EditorGUIUtility.currentViewWidth;
                float height = ExtraMath.Map(imageData.image.height, 0, imageData.image.width, 0, width);

                Rect rect = GUILayoutUtility.GetRect(width, height);

                GUI.DrawTexture(rect, imageData.image);

                serObj.ApplyModifiedProperties();
            }
        }

        serializedObject.ApplyModifiedProperties();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Text"))
        {
            AddTextComponent();
        }

        GUILayout.Space(10);

        if (GUILayout.Button("Add Image"))
        {
            AddImageComponent();
        }
        GUILayout.EndHorizontal();
    }
예제 #24
0
 public BigInteger Solve()
 {
     return(ExtraMath.BigCombination(40, 20));
 }
예제 #25
0
 public void Clamp()
 {
     X = ExtraMath.Clamp(X, -89, 89);
     Y = ExtraMath.Clamp(Y, -180, 180);
     Z = 0;
 }
예제 #26
0
    protected override IEnumerator ActionRoutine()
    {
        nextButtonVisible = false;
        _nextPressed      = false;
        string finalText = _text;


        if (_texto != null)
        {
            finalText = _texto;
        }

        speakStartEvent.Invoke(_characterData, finalText, parentConversation.conversationType);

        yield return(0f);

        yield return(new WaitForSeconds(0.25f));

        nextButtonVisible = true;

        float speakingDuration = 1f;


        speakingDuration = ExtraMath.Map(finalText.Length, 0, 100, 0, 5f);
        //Debug.Log("chillin "+ _input.inputSystem_Menu.confirm.onDown);


        if (parentConversation.conversationType == Conversation.ConversationType.MissionDialogue)
        {
            currentVisibleCharactersRatio = 0;

            while (currentVisibleCharactersRatio < 1)
            {
                currentVisibleCharactersRatio += (Time.deltaTime / ((float)finalText.Length)) * _charactersPerSecond;

                if (_input.menuSubmit.triggered)//_input.inputSystem_Menu.confirm.onDown)
                {
                    currentVisibleCharactersRatio = 1;
                }

                speakingDuration -= Time.deltaTime;
                yield return(0f);
            }

            currentVisibleCharactersRatio = 1;

            while (true)
            {
                speakingDuration -= Time.deltaTime;

                if (_input.menuSubmit.triggered)//_input.inputSystem_Menu.confirm.onDown)
                {
                    break;
                }

                yield return(0f);
            }
        }
        else
        {
            yield return(new WaitForSeconds(speakingDuration));
        }

        yield return(0f);



        yield return(StartCoroutine(base.ActionRoutine()));
    }
예제 #27
0
        private static IEnumerator PullRoutine(TextoSettingsData textoSettingsData)
        {
            EditorUtility.DisplayProgressBar("Pulling Textos!", "Please wait...", 0);

            string range = "A1:Z2000";

            foreach (TextoSettingsData.GoogleSheetInfo googleSheetInfo in textoSettingsData.googleSheetsInfos)
            {
                foreach (string tableID in googleSheetInfo.tableIDs)
                {
                    EditorUtility.DisplayProgressBar("Pulling Textos!", "Please wait...", ExtraMath.Map(googleSheetInfo.tableIDs.IndexOf(tableID), 0, googleSheetInfo.tableIDs.Count, 0.05f, 1));

                    string url = string.Format("https://sheets.googleapis.com/v4/spreadsheets/{0}/values/{1}!{2}?key={3}", googleSheetInfo.sheetID, tableID, range, TextoSettingsData.instance.googleAPIKey);

                    using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
                    {
                        yield return(webRequest.SendWebRequest());

                        try
                        {
                            string[] pages = url.Split('/');
                            int      page  = pages.Length - 1;

                            if (webRequest.isNetworkError)
                            {
                                Debug.Log(pages[page] + ": Error: " + webRequest.error);
                            }
                            else
                            {
                                Variant          jsonVar   = Decoder.Decode(webRequest.downloadHandler.text);
                                GoogleSheetsJSON textoJSON = new GoogleSheetsJSON();
                                jsonVar.Make(out textoJSON);

                                int           labelsRow        = 0;
                                List <string> labelsRowStrings = new List <string>(textoJSON.values[labelsRow]);

                                int uniqueIDColumn = labelsRowStrings.FindIndex(x => x.ToLower() == "line");

                                if (uniqueIDColumn < 0)
                                {
                                    uniqueIDColumn = labelsRowStrings.FindIndex(x => x.ToLower() == "uniqueid");
                                }

                                if (uniqueIDColumn >= 0)
                                {
                                    Dictionary <TextoLanguage, int> languageColumns = new Dictionary <TextoLanguage, int>();

                                    foreach (TextoLanguage language in TextoSettingsData.instance.languages)
                                    {
                                        int index = labelsRowStrings.FindIndex(x => Texto.StringToLanguage(x) == language);
                                        languageColumns.Add(language, index);
                                    }

                                    string[] paths = AssetDatabase.FindAssets("t:TextoData");

                                    List <TextoData> allTextos = new List <TextoData>();

                                    for (int i = 0; i < paths.Length; i++)
                                    {
                                        allTextos.Add(AssetDatabase.LoadAssetAtPath <TextoData>(AssetDatabase.GUIDToAssetPath(paths[i])));
                                    }

                                    for (int i = labelsRow + 1; i < textoJSON.values.Length; i++)
                                    {
                                        if (textoJSON.values.Length <= i)
                                        {
                                            continue;
                                        }

                                        if (textoJSON.values[i].Length <= uniqueIDColumn)
                                        {
                                            continue;
                                        }

                                        string uniqueID = textoJSON.values[i][uniqueIDColumn];

                                        if (!string.IsNullOrEmpty(uniqueID) && !string.IsNullOrWhiteSpace(uniqueID))
                                        {
                                            TextoData matchedData = allTextos.Find(x => x.uniqueID.ToLower() == uniqueID.ToLower());

                                            if (matchedData == null)
                                            {
                                                Debug.Log("Creating new Texto with ID: " + uniqueID);
                                                TextoData newTexto = ScriptableObject.CreateInstance <TextoData>();

                                                string parentFolderPath = TextoSettingsData.instance.folderPath;

                                                if (!AssetDatabase.IsValidFolder(parentFolderPath))
                                                {
                                                    Debug.Log(string.Format("Folder \"{0}\" doesn't exist!", parentFolderPath));
                                                    EditorUtility.ClearProgressBar();
                                                    yield break;
                                                }

                                                string folderPath = parentFolderPath + "/" + tableID;

                                                if (!AssetDatabase.IsValidFolder(folderPath))
                                                {
                                                    AssetDatabase.CreateFolder(parentFolderPath, tableID);
                                                }

                                                AssetDatabase.CreateAsset(newTexto, folderPath + "/" + uniqueID + ".asset");
                                                matchedData = newTexto;

                                                SerializedObject newSerializedObject = new SerializedObject(matchedData);
                                                newSerializedObject.FindProperty("uniqueID").stringValue = uniqueID;
                                                newSerializedObject.ApplyModifiedProperties();
                                            }

                                            SerializedObject serializedObject = new SerializedObject(matchedData);

                                            foreach (TextoLanguage language in TextoSettingsData.instance.languages)
                                            {
                                                int    languageColumn = languageColumns[language];
                                                string languageText   = "[Not found]";

                                                if (languageColumn >= 0)
                                                {
                                                    if (languageColumn < textoJSON.values[i].Length)
                                                    {
                                                        if (language == TextoLanguage.Arabic)
                                                        {
                                                            languageText = ArabicFixer.Fix(textoJSON.values[i][languageColumn]);
                                                        }
                                                        else
                                                        {
                                                            languageText = textoJSON.values[i][languageColumn];
                                                        }
                                                    }
                                                }

                                                int lineIndex = -1;

                                                for (int j = 0; j < matchedData.lines.Count; j++)
                                                {
                                                    if (matchedData.lines[j].language == language)
                                                    {
                                                        lineIndex = j;
                                                        break;
                                                    }
                                                }

                                                if (lineIndex >= 0)
                                                {
                                                    SerializedProperty lineProperty = serializedObject.FindProperty(string.Format("lines.Array.data[{0}]", lineIndex));
                                                    lineProperty.FindPropertyRelative("text").stringValue = languageText;
                                                    serializedObject.ApplyModifiedProperties();
                                                }
                                                else
                                                {
                                                    SerializedProperty linesProperty = serializedObject.FindProperty("lines");

                                                    int newIndex = matchedData.lines.Count;

                                                    linesProperty.InsertArrayElementAtIndex(newIndex);

                                                    SerializedProperty lineProperty = serializedObject.FindProperty(string.Format("lines.Array.data[{0}]", newIndex));
                                                    lineProperty.FindPropertyRelative("text").stringValue        = languageText;
                                                    lineProperty.FindPropertyRelative("language").enumValueIndex = (int)language;
                                                    serializedObject.ApplyModifiedProperties();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            EditorUtility.ClearProgressBar();
                            Debug.LogException(e);
                            yield break;
                        }
                    }
                }
            }

            EditorUtility.ClearProgressBar();
        }
예제 #28
0
 private static int CalcDistance(MouseMovementInfo a, MouseMovementInfo b)
 {
     return(ExtraMath.Distance(a.X, b.X, a.Y, b.Y));
 }
예제 #29
0
    protected override void Update()
    {
        base.Update();

        bool choiceActive = false;

        if (_currentConversation != null)
        {
            if (_currentConversation.currentConversationAction != null)
            {
                if (_currentConversation.currentConversationAction is ConAct_Choice)
                {
                    choiceActive = true;
                    ConAct_Choice choiceAction = (ConAct_Choice)(_currentConversation.currentConversationAction);
                    _speakText.maxVisibleCharacters = _speakText.text.Length;
                    for (int i = 0; i < choiceAction.choiceList.Count; i++)
                    {
                        _choiceObjects[i].SetActive(true);
                        _choiceTexts[i].text   = choiceAction.choiceList[i];
                        _choiceImages[i].color = i == choiceAction.currentChoiceIndex ? Color.yellow : Color.gray;
                    }
                }
                else if (_currentConversation.currentConversationAction is ConAct_Speak)
                {
                    ConAct_Speak speakAction = (ConAct_Speak)(_currentConversation.currentConversationAction);

                    _speakText.maxVisibleCharacters = Mathf.RoundToInt(ExtraMath.Map(speakAction.currentVisibleCharactersRatio, 0, 1, 0, _speakText.text.Length));
                    Debug.Log(_textAnimator.textInfo.characterCount);
                    if (speakAction.nextButtonVisible)
                    {
                        _nextButton.SetActive(true);
                    }
                }
                if (_speakText.maxVisibleCharacters == _speakText.text.Length && !_isTextAnimating)
                {
                    Debug.Log("animate text");
                    AnimateText();
                }
            }
        }
        if (!choiceActive)
        {
            foreach (GameObject choiceObject in _choiceObjects)
            {
                choiceObject.SetActive(false);
            }
        }
        if (_speakWindowActive)
        {
            _speakWindowActiveFrames = 2;
        }
        else
        {
            if (_speakWindowActiveFrames > 0)
            {
                _speakWindowActiveFrames--;
            }
            else
            {
                _speakObject.SetActive(false);
            }
        }
    }
예제 #30
0
 public int Solve()
 {
     return(ExtraMath.BigFactorial(100).ToString().Select(x => Int32.Parse("" + x)).Sum());
 }