public void UI_HandleRegister() { string username = usernameInput.text; string password = passwordInput.text; if (!Validate(username, password)) { return; } spinner.BeginLoading(); SetButtonsActive(false); APIController.UserAPI.Register(username, password) .Then(response => { spinner.CompleteLoading(); SetButtonsActive(true); Debug.Log(response); }) .Catch(e => { spinner.CompleteLoading(); SetButtonsActive(true); Debug.LogError(e.Message); }); }
public void AssemblePlants() { spinner.BeginLoading(); APIController.RoomAPI.GetRoomOfUser(PrefsController.UserID) .Then(response => { if (response._status != "OK") { Debug.LogError(response._status); } foreach (GameObject plantObject in plantObjects) { Destroy(plantObject); } Transform roomTransform = this.transform; foreach (Plant plant in response.plants) { plant.speciesID = 1; // TODO: remove GameObject go = Instantiate( plantContainerPrefab, roomTransform.TransformPoint(new Vector3(plant.positionX, plant.positionY, plant.positionZ)), roomTransform.rotation * Quaternion.Euler(plant.rotationX, plant.rotationY, plant.rotationZ), plantParentTransform ); go.GetComponent <PlantContainer>().SetPlantState(plant); plantObjects.Add(go); } spinner.CompleteLoading(); }); }
public float ShowAnimationAndReturnDuration(Transform room, string animToShow) { if (activePlant == null) { Debug.LogWarning("No active plant"); return(0f); } this.transform.SetPositionAndRotation( room.TransformPoint(new Vector3(activePlant.positionX, activePlant.positionY, activePlant.positionZ)), Quaternion.Euler(activePlant.rotationX, activePlant.rotationY, activePlant.rotationZ)); animator.SetTrigger(animToShow); ActionType type; switch (animToShow) { case "Watering": type = ActionType.USER_WATERS_PLANT; break; case "Trimming": type = ActionType.USER_TRIMS_PLANT; break; default: type = ActionType.NULL; break; } spinner.BeginLoading(); APIController.ActionAPI.AddAction(activePlant.plantID, type) .Then(response => { spinner.CompleteLoading(); }) .Catch(error => { spinner.CompleteLoading(); Debug.LogError(error); }); return(2f); }