Ejemplo n.º 1
0
 public PineObject(float r, float h, int trunkHeight, TreeConfig config)
 {
     _r           = r;
     _h           = h;
     _trunkHeight = trunkHeight;
     _config      = config;
 }
Ejemplo n.º 2
0
                public TreeConfigChance(JSONNode node, ref double summedChance, double modifier)
                {
                    tree = treeStorage[node["tree"].GetAs <string>()];
                    double num = node["chance"].GetAs <double>() * modifier;

                    chance        = num + summedChance;
                    summedChance += num;
                }
Ejemplo n.º 3
0
        public static void ExportXML(TreeConfig _bTree, string _name)
        {
            XmlSerializer writer = new XmlSerializer(typeof(TreeConfig));
            StreamWriter  file   = new StreamWriter(exportConfigPath + _name + ".xml");

            writer.Serialize(file, _bTree);
            file.Close();
        }
Ejemplo n.º 4
0
        public static void ExportBinary(TreeConfig _bTree, string _name)
        {
            FileStream      fs = new FileStream(exportConfigPath + _name + ".btree", FileMode.OpenOrCreate);
            BinaryFormatter binaryFormatter = new BinaryFormatter();

            binaryFormatter.Serialize(fs, _bTree);
            fs.Close();
        }
Ejemplo n.º 5
0
 public ModelConfig()
 {
     CustomForms = new Dictionary <string, CustomForm>();
     FormConfig  = new FormConfig();
     GridConfig  = new GridConfig();
     KeyField    = new KeyField();
     TreeConfig  = new TreeConfig();
 }
        public static BTreeEditorTreeConfig CreateEditorTreeConfigFromRootEditorNode(BTreeNodeDesigner _rootEditorNode)
        {
            TreeConfig            _treeConfig       = BTreeNodeFactory.CreateConfigFromBTreeRoot(_rootEditorNode.m_EditorNode.m_Node);
            BTreeEditorTreeConfig _treeEditorConfig = new BTreeEditorTreeConfig(_treeConfig);
            int index = 0;

            CreateEditorNodeConfigFromRootEditorNode(_rootEditorNode, ref _treeEditorConfig.m_EditorNodes, ref index);

            return(_treeEditorConfig);
        }
Ejemplo n.º 7
0
 public BTEditorTreeConfig(TreeConfig _config)
 {
     mNodes       = _config.mNodes;
     mName        = _config.mName;
     mEditorNodes = new BTEditorNodeConfig[mNodes.Length];
     for (int i = 0; i < mEditorNodes.Length; i++)
     {
         mEditorNodes[i] = new BTEditorNodeConfig(mNodes[i]);
     }
     mIsEnterNode = false;
 }
 public BTreeEditorTreeConfig(TreeConfig _config)
 {
     m_Nodes       = _config.m_Nodes;
     m_Name        = _config.m_Name;
     m_EditorNodes = new BTreeEditorNodeConfig[m_Nodes.Length];
     for (int i = 0; i < m_EditorNodes.Length; i++)
     {
         m_EditorNodes[i] = new BTreeEditorNodeConfig(m_Nodes[i]);
     }
     m_IsEnterNode = false;
 }
        private string BuildItemName(TreeConfig tree, bool prot = false)
        {
            var nameBuilder = new StringBuilder();

            nameBuilder.Append($"{UniFormat(tree.Env)} {UniFormat(tree.Type)}, Variant {UniFormat(tree.Variant)}");
            if (prot)
            {
                nameBuilder.Append(" (protected)");
            }

            return(nameBuilder.ToString());
        }
Ejemplo n.º 10
0
        public void ExportBinaryBTree()
        {
            if (mGraphDesigner == null || mGraphDesigner.mRootNode == null)
            {
                EditorUtility.DisplayDialog("Export Error", "未创建根节点", "ok");
                return;
            }
            Debugger.Log("exportBtree");
            TreeConfig _treeConfig = BTEditorNodeFactory.CreateTreeConfigFromBTreeGraphDesigner(mGraphDesigner);
            string     name        = mGraphDesigner.mRootNode.NodeName;

            BTEditorSerialization.ExportBinary(_treeConfig, name);
            EditorUtility.DisplayDialog("Export", "导出行为树配置成功:" + name, "ok");
        }
Ejemplo n.º 11
0
        protected TreeData GetRandomizedTreeValues(TreeConfig config)
        {
            var stainDiaMod    = (int)Random.Range(config.StainDiaMod[0], config.StainDiaMod[1]);
            var stainHeightMod = (int)Random.Range(config.StainHeightMod[0], config.StainHeightMod[1]);
            var topMod         = (int)Random.Range(config.TreeTopMod[0], config.TreeTopMod[1]);

            return(new TreeData
            {
                TreeTopDia = config.TreeTopDia + topMod,
                TreeTopHeight = config.TreeTopHeight + topMod,
                TreeStainDia = config.TreeStainDia + stainDiaMod,
                TreeStainHeight = config.TreeStainHeight + stainHeightMod,
            });
        }
Ejemplo n.º 12
0
 public override void Entry(IModHelper helper)
 {
     instance = this;
     config   = helper.ReadConfig <TreeConfig>() ?? new TreeConfig();
     tryLoadAPIs(helper);
     try
     {
         hInstance = HarmonyInstance.Create("jpan.mine_changes");
         TreeHooks.addTrans(this, hInstance);
     }
     catch (Exception ex)
     {
         Monitor.Log("Could not patch one of the Hooks: " + ex, LogLevel.Error);
     }
 }
Ejemplo n.º 13
0
        public void ExportXMLBTree()
        {
            if (mGraphDesigner == null || mGraphDesigner.mRootNode == null)
            {
                EditorUtility.DisplayDialog("Export Error", "未创建根节点", "ok");
                return;
            }
            string text = EditorUtility.SaveFilePanel("Save Behavior Tree", BTEditorSerialization.exportConfigPath, mGraphDesigner.mRootNode.NodeName, "xml");

            if (text.Length != 0 && Application.dataPath.Length < text.Length)
            {
                Debugger.Log("exportBtree");
                TreeConfig _treeConfig = BTEditorNodeFactory.CreateTreeConfigFromBTreeGraphDesigner(mGraphDesigner);

                BTEditorSerialization.ExportXML(_treeConfig, System.IO.Path.GetFileNameWithoutExtension(text));
                EditorUtility.DisplayDialog("Export", "导出行为树配置成功:" + text, "ok");
            }
        }
Ejemplo n.º 14
0
        private void Initialize(TreeConfig config, Vector3 position)
        {
            var voxels = new Dictionary <VoxelMaterial, List <Vector3> >();
            var data   = GetRandomizedTreeValues(config);

            Position = position;
            var strainVoxels = GenerateStrain(data);

            voxels.Add(MaterialRegistry.Instance.GetMaterialFromName(config.StainMaterial), strainVoxels);

            var topOfStain    = new Vector3(-data.TreeTopDia / 2f + (data.TreeStainDia) / 2f, data.TreeStainHeight, -data.TreeTopDia / 2f + (data.TreeStainDia) / 2f);
            var treeTopVoxels = GenerateTreeTop(topOfStain, data);

            voxels.Add(MaterialRegistry.Instance.GetMaterialFromName(config.LeafMaterial), treeTopVoxels);

            Multiblock = Multiblock.InstantiateVoxels(position, voxels, "Tree");
            Multiblock.EnableWind(1);
        }
Ejemplo n.º 15
0
 private void resetProject()
 {
     tvModel.Nodes.Clear();
     _settings          = null;
     _TreeConfiguration = null;
 }
Ejemplo n.º 16
0
    public static void build()
    {
        string saveFile = "Upgrade/TreeNode";

        TreeConfig config = new TreeConfig();

        //first value in the list is level, second is increment
        //first four elements of tower are the same

        //sub-elements are
        //pre-requisite number
        //increment, increment multiplier
        //gold cost, gold cost multiplier
        //pre-requisite_(num) number, pre-requisite_(num) level

        //array length is 6 + resource cost * 2. resource cost is in pair
        //pre-requisite * 2. pre-requisite is in pair

        //pre-requisite number is in the form of a in index


        config.trees = new Dictionary <int, float[][]>
        {
            {
                //utility
                0, new float[][]
                {
                    new float[] { 0, 2.2f, 0.5f, 3000f, 2, 5f },                            //inGame_life
                    new float[] { 1, 1.5f, 0.4f, 900f, 1.5f, 0, 3 }                         //inGame_gold
                }
            },

            {
                //general upgrade
                1, new float[][]
                {
                    new float[] { 0, 0.02f, 0.04f, 60f, 0.08f },                                 //general_damage
                    new float[] { 0, 0.02f, 0.04f, 60f, 0.08f },                                 //general_range
                    new float[] { 0, 0.02f, 0.04f, 60f, 0.08f },                                 //general_atk_speed
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 5 }                            //general_effect
                }
            },

            {
                //first tower
                2, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },                                 //damage
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },                                 //range
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },                                 //atk_speed
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }                                  //effect
                }
            },

            {
                //second tower
                3, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }
                }
            },
            {
                //third tower
                4, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }
                }
            },
            {
                //fourth tower
                5, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }
                }
            },
            {
                //fifth tower
                6, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }
                }
            },
            {
                //sixth tower
                7, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }
                }
            }
            ,
            {
                //sixth tower
                8, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }
                }
            }
            ,
            {
                //sixth tower
                9, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }
                }
            }
            ,
            {
                //sixth tower
                10, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }
                }
            }
            ,
            {
                //sixth tower
                11, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }
                }
            }
            ,
            {
                //sixth tower
                12, new float[][]
                {
                    new float[] { 0, 0, 0, 5f, 0 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 0, 1 },
                    new float[] { 1, 0.02f, 0.04f, 60f, 0.08f, 1, 5 }
                }
            }
        };

        //ConfigSaver.saveTextFile<TreeConfig>(saveFile, config);
    }
Ejemplo n.º 17
0
 public RandomizedTree(TreeConfig config, Vector3 position)
 {
     Initialize(config, position);
 }