public void Grow() { switch (TreeGrowthState) { case TreeGrowthState.Seed: TreeGrowthState = TreeGrowthState.Sprout; break; case TreeGrowthState.Sprout: TreeGrowthState = TreeGrowthState.Sapling; break; case TreeGrowthState.Sapling: TreeGrowthState = TreeGrowthState.Mature; break; case TreeGrowthState.Mature: TreeGrowthState = TreeGrowthState.Snag; break; case TreeGrowthState.Snag: TreeGrowthState = TreeGrowthState.Seed; break; } }
public void UpdateTreeWindForceOnGrow(GameObject tree) { TreeGrowthState treeGrowthState = tree.GetComponentInChildren <Tree>().TreeGrowthState; if (treeGrowthState == TreeGrowthState.Mature || treeGrowthState == TreeGrowthState.Snag) { UpdateTreeWindForce(tree); } }
private void UpdateTreeWindForce(GameObject tree) { TreeGrowthState treeGrowthState = tree.GetComponentInChildren <Tree>().TreeGrowthState; if (tree.activeSelf && (treeGrowthState == TreeGrowthState.Mature || treeGrowthState == TreeGrowthState.Snag)) { //módulo de forceOverTime das animações de folhas caindo var particleSystemForceOverTimeModule = tree.GetComponentInChildren <ParticleSystem>().forceOverLifetime; particleSystemForceOverTimeModule.x = WindForce; particleSystemForceOverTimeModule.y = 0; particleSystemForceOverTimeModule.z = 0; //balanço dos galhos das árvores var material = tree.GetComponentInChildren <MeshRenderer>().materials[1]; material.SetFloat("_tree_sway_speed", WindForce * 0.3f); } }