void Recompose() { // check for CSV load if (PLAYDATE_RecipeLoaderSingleton.recipeDict == null) { return; } print("//1. Get objects to recompose and tag them"); //1. Get objects to recompose List <recipeItem> objsToRecompose = GetObjectsToRecomposeAndTag(); print("//2. Choose recipe"); List <recipeItem> chosenRecipe = ChooseThingsToRecomposeFromRecipe(objsToRecompose); //obj to use, obj to destroy (needed alternatives), obj leftover = recomposition(gobjs); print("//2.5.. Calculate recomposition object with algorithm"); recomposeChoice thisChoice = calculateChoice(chosenRecipe); print("//3. Destroy objects, create new object."); if (DestroyAndCreate(thisChoice) > 0) { print("DestroyAndCreate successful!"); } }
recomposeChoice calculateChoice(List <recipeItem> cr) { List <recipeItem> oCreated, oUsed, oNeeded, oDestroy; oCreated = new List <recipeItem>(); oUsed = new List <recipeItem>(); oNeeded = new List <recipeItem>(); oDestroy = new List <recipeItem>(); //test oCreated.Add(new recipeItem("log", 1)); oCreated.Add(new recipeItem("treeB", 6)); recomposeChoice ourChoice = new recomposeChoice(oCreated, oUsed, oNeeded, oDestroy); return(ourChoice); }
int DestroyAndCreate(recomposeChoice ch) { // DESTROY OBJECTS // out of tagged objects, // find appropriate number of used objects and destroy them (random order) // find appropriate number of needed objecs and destroy them (TODO MAYBE) // LEAVE THE LEFTOVER ALONE! // CREATE OBJECTS Vector3 thisPos = this.gameObject.transform.position; foreach (recipeItem ri in ch.objsCreated) { VRTK.Examples.PLAYDATE_DecomposeThing.InstantiatePrefab(ri.makeName, ri.makeCount, thisPos); } return(1); }