/// <summary> /// Initializes a new instance of the <see cref="NeutralState"/> class. /// </summary> /// <param name="stateContext">The class that keeps track of the current active state</param> public NeutralState(StateContext stateContext) : base(stateContext) { this.InitButton("ToggleButton", () => this.OnToggleButton()); this.InitButton("SaveButton", () => this.OnSaveButton()); this.InitButton("LoadButton", () => this.OnLoadButton()); this.InitButton("RunButton", () => this.OnRunButton()); }
/// <summary> /// Initializes a new instance of the <see cref="SaveState"/> class. /// If a save path has already been set, the class only saved the game but does not initialize /// </summary> /// <param name="stateContext">The class that keeps track of the current active state</param> /// <param name="saveOnly">Default is false, set to true if you only want to save the game and now switch state. IMPORTANT: The state will not initialize</param> public SaveState(StateContext stateContext, bool saveOnly = false) : base(stateContext) { if (saveOnly && this.StateContext.SaveFilePath != null) { this.SaveGame(SaveFile + this.StateContext.SaveFilePath + ".xml"); } else { this.InitButton("SaveButton", () => this.OnSaveButton()); this.InitButton("BackButton", () => this.OnBackButton()); this.saveStringInput = this.InitTextPane("TextInput", DateTime.Now.ToString("yyyyMMddHHmm")); } }
/// <summary> /// Initializes a new instance of the <see cref="ModifyState"/> class. /// </summary> /// <param name="stateContext">State context</param> /// <param name="gameObject">the game object to modify</param> public ModifyState(StateContext stateContext, GameObject gameObject) : base(stateContext) { this.InitButton("DeleteButton", () => this.OnDeleteButton()); this.InitButton("ConfirmButton", () => this.OnConfirmButton()); this.moveButtonPosition = this.InitButton("TranslateButton", () => this.OnTranslateButton()).transform.position; this.InitButton("RotateButton", () => this.OnRotateButton()); this.InitButton("ScaleButton", () => this.OnScaleButton()); this.copyButtonPosition = this.InitButton("CopyButton", () => this.OnCopyButton()).transform.position; this.gameObject = gameObject; this.colorRenders = gameObject.transform.GetComponentsInChildren <Renderer>(); this.ChangeOutlineRender(this.greenOutline); this.ChangeOutlineRender(Color.green); }
/// <summary> /// Initializes a new instance of the <see cref="ModifyScaleState"/> class. /// </summary> /// <param name="stateContext">The class that keeps track of the current active state</param> /// <param name="gameObject">The game object to be scaled</param> public ModifyScaleState(StateContext stateContext, GameObject gameObject) : base(stateContext) { this.gameObject = gameObject; MetaBody mb = gameObject.GetComponent <MetaBody>(); mb.useDefaultGrabSettings = false; mb.grabbable = true; mb.moveObjectOnGrab = false; mb.grabbableDistance = float.MaxValue; mb.scaleObjectOnTwoHandedGrab = true; this.InitButton("BackButton", () => this.OnBackButton()); this.InitTextPane("InfoText", "Scale"); }
/// <summary> /// Initializes a new instance of the <see cref="ModifyRotateState"/> class. /// </summary> /// <param name="stateContext">The class that keeps track of the current active state</param> /// <param name="gameObject">The object that will be rotated</param> public ModifyRotateState(StateContext stateContext, GameObject gameObject) : base(stateContext) { this.gameObject = gameObject; MetaBody mb = gameObject.GetComponent <MetaBody>(); mb.useDefaultGrabSettings = false; mb.grabbable = true; mb.grabbableDistance = float.MaxValue; mb.moveObjectOnGrab = false; mb.rotateObjectOnTwoHandedGrab = true; this.originalOrientation = gameObject.transform.localEulerAngles; this.InitButton("BackButton", () => this.OnBackButton()); this.InitTextPane("InfoText", "Rotate"); }
/// <summary> /// Initializes a new instance of the <see cref="ObjectPlacementState"/> class. The object will be scaled to 1 meter big. /// </summary> /// <param name="stateContext">State context</param> /// <param name="location">First indicated position of the placement</param> /// <param name="gameObject">The game object that has to be placed or moved</param> /// <param name="handType">The hand that is pointing</param> /// <param name="copy">Boolean if the action is to copy</param> public ObjectPlacementState(StateContext stateContext, Vector3 location, GameObject gameObject, HandType handType, bool copy = false) : base(stateContext) { this.handType = handType; this.translateModification = gameObject.GetComponent <BuildingPlane>() != null; if (this.translateModification) { this.InitTextPane("InfoText", (copy ? "Copy" : "Move")); this.previousPosition = gameObject.transform.localPosition; UnityEngine.Object.Destroy(gameObject.GetComponent <BuildingPlane>()); UnityEngine.Object.Destroy(gameObject.GetComponent <MetaBody>()); } this.gameObject = gameObject; this.InitButton("BackButton", () => this.OnBackButton()); this.gameObject.transform.localPosition = location; this.colorRenders = gameObject.transform.GetComponentsInChildren <MeshRenderer>(); this.ChangeOutlineRender(this.greenOutline); this.ChangeOutlineRender(Color.green); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigState"/> class. /// </summary> /// <param name="stateContext">State context</param> public ConfigState(StateContext stateContext) : base(stateContext) { this.InitListeners(this.InitTextPane("ConfigWindow", "Configuration")); this.InitButton("BackButton", () => this.OnBackButton()); }
/// <summary> /// Initializes a new instance of the <see cref="ObjectPlacementState"/> class. The object will be scaled to 1 meter big. /// </summary> /// <param name="stateContext">State context</param> /// <param name="location">First indicated position of the placement</param> /// <param name="gameObjectPath">Path to the wanted object to place</param> /// <param name="handType">The hand that is pointing</param> public ObjectPlacementState(StateContext stateContext, Vector3 location, string gameObjectPath, HandType handType) : this(stateContext, location, CreateObject(gameObjectPath), handType) { }
/// <summary> /// Initializes a new instance of the <see cref="AbstractState"/> class. /// </summary> /// <param name="stateContext">The class that keeps track of the current active state</param> protected AbstractState(StateContext stateContext) { this.initTimestamp = StopwatchSingleton.Time; this.StateContext = stateContext; this.buttons = new List <GameObject>(); }
/// <summary> /// Initializes a new instance of the <see cref="LoadState"/> class. /// </summary> /// <param name="stateContext">The class that keeps track of the current active state</param> public LoadState(StateContext stateContext) : base(stateContext) { this.InitButton("ConfirmButton", () => this.OnConfirmButton()); this.InitButton("BackButton", () => this.OnBackButton()); this.scollButton = this.InitLoadScrollPane(EntryHeight, FrameWidth, FrameHeight, Padding); }
/// <summary> /// Initializes a new instance of the <see cref="ObjectSelectState"/> class. /// </summary> /// <param name="stateContext">The class that keeps track of the current active state</param> public ObjectSelectState(StateContext stateContext) : base(stateContext) { this.objectSelect = this.InitObjectSelect(ColumnCount, EntryWidth, EntryHeight, Padding, FrameWidth); this.InitButton("ToggleButton", () => this.OnToggleButton()); }