/// <summary>
        /// Get result the calculate operation.
        /// </summary>
        /// <param name="sourceData"></param>
        /// <returns></returns>
        public IOperation <double> GetOperation(IData <double> sourceData)
        {
            switch (sourceData.Operation)
            {
            case "+":
                return(new Add(sourceData.X, sourceData.Y));

            case "-":
                return(new Subtract(sourceData.X, sourceData.Y));

            case "/":
                return(new Divide(sourceData.X, sourceData.Y));

            case "%":
                return(new Remain(sourceData.X, sourceData.Y));

            case "*":
                return(new Multiply(sourceData.X, sourceData.Y));

            case "^":
                return(new Pow(sourceData.X, sourceData.Y));

            case "sqrt":
                return(new Sqrt(sourceData.X));

            case "log10":
                return(new Log10(sourceData.X));

            default:
                Revise.NullReferenceException(Resource.OperationNotDefined);
                return(null);
            }
        }
Exemple #2
0
        private Data GetData()
        {
            if (_inputParsedData.Length > 3 || _inputParsedData.Length < 2)
            {
                Revise.ArgumentException(Resource.InvalidNumberOfArguments);
            }

            if (_inputParsedData.Length == 3)
            {
                if (!double.TryParse(_inputParsedData[0], out double x))
                {
                    x = double.NaN;
                }

                if (!double.TryParse(_inputParsedData[2], out double y))
                {
                    y = double.NaN;
                }

                string operation = _inputParsedData[1];
                return(new Data(x, y, operation));
            }
            else
            {
                if (!double.TryParse(_inputParsedData[1], out double x))
                {
                    x = double.NaN;
                }

                string operation = _inputParsedData[0];
                return(new Data(x, double.NaN, operation));
            }
        }
Exemple #3
0
        /// <summary>
        /// Calculates the divide of two double numbers
        /// </summary>
        /// <returns>X / Y</returns>
        public double Operate()
        {
            if (Y == 0)
            {
                Revise.DivideByZeroException(Resource.DivideByZero);
            }

            return(X / Y);
        }
Exemple #4
0
        /// <summary>
        /// Calculates the Log10 of two double numbers
        /// </summary>
        /// <returns>Log10(X)</returns>
        public double Operate()
        {
            double result = Math.Log10(X);

            if (double.IsNaN(result))
            {
                Revise.ArgumentException(Resource.ValueOfXLessThanZero, nameof(X));
            }

            return(result);
        }
Exemple #5
0
        /// <summary>
        /// Calculates the sum of two double numbers
        /// </summary>
        /// <returns>X + Y</returns>
        public double Operate()
        {
            double result = X + Y;

            if (double.IsInfinity(result))
            {
                Revise.ArgumentException(Resource.OutOfRange, nameof(result));
            }

            return(result);
        }
        /// <summary>
        /// Checking X, Y values.
        /// </summary>
        private void СheckXY()
        {
            StringBuilder error = new StringBuilder();

            if (double.IsNaN(X))
            {
                AddError(Resource.UnableX);
            }

            if (double.IsNaN(Y))
            {
                AddError(Resource.UnableY);
            }

            if (double.IsInfinity(X))
            {
                AddError(Resource.OutOfRangeX);
            }

            if (double.IsInfinity(Y))
            {
                AddError(Resource.OutOfRangeY);
            }

            if (error.Length > 0)
            {
                Revise.ArgumentException(GetResultErrors());
            }

            #region Helpers
            void AddError(string message)
            {
                if (error.Length > 0)
                {
                    error.Append(GetNewLine());
                }
                error.AppendFormat(message);
            }

            string GetNewLine()
            {
                return(Environment.NewLine);
            }

            string GetResultErrors()
            {
                return(string.Format("{0}{1}{2}", Resource.UnableCompleteOperation, GetNewLine(), error.ToString()));
            }

            #endregion
        }
Exemple #7
0
    static Terrain ImportTerrain(string planet, string map, Revise.Files.ZON.ZoneFile zon, int x, int y)
    {
        var blockName = x.ToString() + "_" + y.ToString();
        var basePath = rootPath + "3DDATA/MAPS/" + planet + "/" + map + "/" + blockName;
        float blockX = (x - 32) * 160;
        float blockY = (32 - y) * 160;

        Object.DestroyImmediate(GameObject.Find(blockName));

        var ifo = new Revise.Files.IFO.MapDataFile();
        ifo.Load(basePath + ".IFO");

        for (int i = 0; i < ifo.Objects.Count; ++i)
        {
            var obj = ifo.Objects[i];
            ImportObject("JUNON_JDT_DECO", x, y, "DECO", i, obj);
        }

        for (int i = 0; i < ifo.Buildings.Count; ++i)
        {
            var obj = ifo.Buildings[i];
            ImportObject("JUNON_JDT_CNST", x, y, "CNST", i, obj);
        }

        for (int i = 0; i < ifo.Animations.Count; ++i)
        {
            //var obj = ifo.Animations[i];
            Debug.LogWarning("Got unexpected animation object.");
        }

        for (int i = 0; i < ifo.Sounds.Count; ++i) {
            var snd = ifo.Sounds[i];
            var sndName = "SND_" + snd.ObjectID.ToString() + " (" + blockName + "_" + i.ToString() + ")";

            var a = new GameObject();

            //var s = a.AddComponent<AudioSource>();
            //TODO: Need to link to audio after copy in prestage

            a.transform.localPosition = ifotruPosition(snd.Position);
            a.transform.localRotation = rtuRotation(snd.Rotation);
            a.transform.localScale = rtuScale(snd.Scale);
            a.name = sndName;
            a.isStatic = true;
        }

        var tex = ImportPlanMap(planet, map, x, y);

        var him = new Revise.Files.HIM.HeightmapFile();
        him.Load(basePath + ".HIM");

        float[,] heights = new float[65,65];
        float heightMin = him.Heights[0, 0];
        float heightMax = him.Heights[0, 0];
        for (int ix = 0; ix < 65; ++ix)
        {
            for (int iy = 0; iy < 65; ++iy)
            {
                if (him.Heights[ix, iy] < heightMin)
                {
                    heightMin = him.Heights[ix, iy];
                }
                if (him.Heights[ix, iy] > heightMax)
                {
                    heightMax = him.Heights[ix, iy];
                }
            }
        }
        float heightBase = heightMin;
        float heightDelta = heightMax - heightMin;
        for (int ix = 0; ix < 65; ++ix)
        {
            for (int iy = 0; iy < 65; ++iy)
            {
                heights[ix, iy] = (him.Heights[64 - ix, iy] - heightBase) / heightDelta;
            }
        }

        var til = new Revise.Files.TIL.TileFile();
        til.Load(basePath + ".TIL");

        /*
        for (int ix = 0; ix < til.Width; ++ix) {
            for (int iy = 0; iy < til.Height; ++iy) {
                var t = til[ix, iy].Tile;
                Debug.Log(
                    til[ix, iy].Brush.ToString() + "," +
                    til[ix, iy].TileSet.ToString() + "," +
                    til[ix, iy].TileIndex.ToString() + "," +
                    til[ix, iy].Tile.ToString());
                Debug.Log(
                    zon.Tiles[t].Layer1.ToString() + "," +
                    zon.Tiles[t].Offset1.ToString() + "," +
                    zon.Tiles[t].Layer2.ToString() + "," +
                    zon.Tiles[t].Offset2.ToString() + "," +
                    zon.Tiles[t].TileType.ToString() + "," +
                    zon.Tiles[t].TileType.ToString() + "," +
                    zon.Tiles[t].Rotation.ToString());
                Debug.Log(zon.Textures[zon.Tiles[t].Layer1 + zon.Tiles[t].Offset1]);
                Debug.Log(zon.Textures[zon.Tiles[t].Layer2 + zon.Tiles[t].Offset2]);
            }
        }
        */

        var td = new TerrainData();
        td.size = new Vector3(80, heightDelta/100, 80);
        td.heightmapResolution = 65;
        td.SetHeights(0, 0, heights);
        var ts = new SplatPrototype[1];
        ts[0] = new SplatPrototype();
        ts[0].texture = tex;
        ts[0].tileSize = new Vector2(160, 160);
        td.splatPrototypes = ts;

        var ter = Terrain.CreateTerrainGameObject(td).GetComponent<Terrain>();
        ter.name = blockName;

        ter.transform.localPosition = new Vector3(blockX, heightBase/100, blockY);
        return ter;
    }
Exemple #8
0
    static void ImportObject(string set, int x, int y, string prefix, int i, Revise.Files.IFO.Blocks.MapBlock obj)
    {
        var blockName = x.ToString() + "_" + y.ToString();
        string mdlBasePath = "Assets/ROSEMdls/" + set + "/";
        var mdlName = prefix + "_" + obj.ObjectID.ToString() + " (" + blockName + "_" + i.ToString() + ")";

        Object.DestroyImmediate(GameObject.Find(mdlName));

        // Temporarily disable objects while working on Terrain!
        //return;

        var mdlBaseName = mdlBasePath + "Model_" + obj.ObjectID.ToString();
        var mdlPath = mdlBaseName + ".asset";
        RoseMapObjectData modata = Resources.LoadAssetAtPath(mdlPath, typeof(RoseMapObjectData)) as RoseMapObjectData;

        if (!modata)
        {
            Debug.Log("Failed to find map model - " + mdlPath);
            return;
        }

        var go = new GameObject();
        var mo = go.AddComponent<RoseMapObject>();
        mo.data = modata;
        mo.UpdateModels();

        go.transform.localPosition = ifotruPosition(obj.Position);
        go.transform.localRotation = rtuRotation(obj.Rotation);
        go.transform.localScale = rtuScale(obj.Scale);
        go.isStatic = true;
        go.name = mdlName;
    }
Exemple #9
0
    static void ImportMap(string planet, string map, Revise.Files.ZON.ZoneFile zon)
    {
        for (var i = 0; i < zon.Textures.Count; ++i) {
            var tex = zon.Textures[i];
        }

        for (var i = 0; i < zon.Tiles.Count; ++i) {
            var tile = zon.Tiles[i];
            Debug.Log(
                i.ToString() + ": " +
                tile.TileType.ToString() + "," +
                tile.Layer1.ToString() + "," +
                tile.Layer2.ToString() + "," +
                tile.Offset1.ToString() + "," +
                tile.Offset2.ToString() + "," +
                tile.Rotation.ToString());
            Debug.Log(zon.Textures[tile.Offset1 + tile.Layer1]);
            Debug.Log(zon.Textures[tile.Offset2 + tile.Layer2]);
        }
    }