/// <summary> /// This Method set the position from which the user has to drag objects inside the arena /// </summary> public void SetDragAndDropPositions() { this.checkAlreadyPlacedObjects(); // This in case positions have been already assigned if (this.arePositionAlreadyAssigned) { foreach (ObjectSliceCouple couple in this.objectSliceCouples) { if (!couple.isPlaced) { couple.arenaObject.transform.position = couple.dragAndDropPosition; couple.arenaObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } } } else { Dictionary <int, Vector3Ser> positions = ArenaObjectsRetriever.RetrievePositions(false); List <Vector3Ser> positionValues = this.ShufflePositionDictionary(positions); for (int i = 0; i < this.arenaObjects.Count; i++) { float x = positionValues[i].x; float y = positionValues[i].y; float z = positionValues[i].z; ((GameObject)this.arenaObjects[i]).transform.position = new Vector3(x, y, z); ((GameObject)this.arenaObjects[i]).transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); foreach (ObjectSliceCouple couple in this.objectSliceCouples) { if (couple.arenaObject == (GameObject)this.arenaObjects[i]) { couple.dragAndDropPosition = ((GameObject)this.arenaObjects[i]).transform.position; } } } this.arePositionAlreadyAssigned = true; } }
/// <summary> /// This method set the initial position of each object for each slice and it takes into account also the different cases in which slices have /// to be considered together and the object is moved a bit from is natural position (just to have a better distribution of the space). /// </summary> public void SetArenaPositions() { // If positions have been already assigned we simply recover them if (this.arePositionAlreadyAssigned) { foreach (ObjectSliceCouple couple in this.objectSliceCouples) { couple.arenaObject.transform.position = couple.arenaPosition; couple.arenaObject.transform.localScale = new Vector3(1f, 1f, 1f); } } else { Dictionary <int, Vector3Ser> positions = ArenaObjectsRetriever.RetrievePositions(true); ArrayList adjacents = ArenaSetup.singleton.GetDoubleSlices(); this.SetZeroPosition(); int currentSliceIndex = 1; int adjacentSliceIndex = 0; int objectIndex = 0; for (int i = 0; i < this.objectSliceCouples.Count; i++) { if (adjacents.Count != 0) { if (((ObjectSliceCouple)this.objectSliceCouples[i]).slice == ((Slice)adjacents[adjacentSliceIndex]).slice) { float x = (positions[currentSliceIndex].x + positions[currentSliceIndex + 1].x) / 3; float y = (positions[currentSliceIndex].y + positions[currentSliceIndex + 1].y) / 3; float z = (positions[currentSliceIndex].z + positions[currentSliceIndex + 1].z) / 3; ((GameObject)this.arenaObjects[objectIndex]).transform.position = new Vector3(x, y, z); ((ObjectSliceCouple)this.objectSliceCouples[i]).arenaPosition = new Vector3(x, y, z); ((ObjectSliceCouple)this.objectSliceCouples[i + 1]).arenaPosition = new Vector3(x, y, z); currentSliceIndex += 2; adjacentSliceIndex += 2; i++; } else { float x = positions[currentSliceIndex].x; float y = positions[currentSliceIndex].y; float z = positions[currentSliceIndex].z; ((GameObject)this.arenaObjects[objectIndex]).transform.position += new Vector3(x, y, z); if (Game1Parameters.Difficulty <= 4) { ((GameObject)this.arenaObjects[objectIndex]).transform.position /= 1.5f; } if (Game1Parameters.Difficulty > 4 && Game1Parameters.Difficulty <= 8 && currentSliceIndex > 4) { ((GameObject)this.arenaObjects[objectIndex]).transform.position /= 1.2f; } ((ObjectSliceCouple)this.objectSliceCouples[i]).arenaPosition = ((GameObject)this.arenaObjects[objectIndex]).transform.position; currentSliceIndex++; } } else { float x = positions[currentSliceIndex].x; float y = positions[currentSliceIndex].y; float z = positions[currentSliceIndex].z; ((GameObject)this.arenaObjects[objectIndex]).transform.position += new Vector3(x, y, z); if (Game1Parameters.Difficulty <= 4) { ((GameObject)this.arenaObjects[objectIndex]).transform.position /= 1.5f; } if (Game1Parameters.Difficulty > 4 && Game1Parameters.Difficulty <= 8 && currentSliceIndex > 4) { ((GameObject)this.arenaObjects[objectIndex]).transform.position /= 1.2f; } ((ObjectSliceCouple)this.objectSliceCouples[i]).arenaPosition = ((GameObject)this.arenaObjects[objectIndex]).transform.position; currentSliceIndex++; } objectIndex++; } } }