/// <summary> /// Closes the character info panel. /// </summary> public void CloseCharacterInfo() { if (activeChar != null) { activeChar.GetComponent <Animator>().enabled = true; } ApplyOptions(); if (wanderToEdit != null) { wanderToEdit.poiDestination = destinationDropDown.value - 1; if (destinationDropDown.value == 0) { wanderToEdit.SetWanderMode(); } else { wanderToEdit.SetBookmarkMode(); } } SaveCharacters(); activeChar = null; wanderToEdit = null; iTween.Stop(charInfoPanel.gameObject); charInfoPanel.localScale = new Vector3(1, 1, 1); charInfoPanel.gameObject.SetActive(false); ActiveWidgetManager.DeactivateWidget(ActiveWidgetManager.ActiveWidget.CharacterDrop); currentState = CharacterDropperState.SelectExisting; }
/// <summary> /// Drops the active character at the selected location and updates its CharacterWander script. /// </summary> public void DropCharacter() { mouseDownDrop = false; activeChar.GetComponent <CapsuleCollider>().enabled = true; activeChar.GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = true; activeChar.GetComponent <CharacterWander>().enabled = true; activeChar.GetComponent <CharacterWander>().mode = (CharacterWander.WanderMode)newCharWanderSelect.value; activeChar.GetComponent <CharacterWander>().dropPoint = activeChar.transform.position; activeChar.GetComponent <CharacterWander>().poiDestination = -1; activeChar.transform.parent = charRoot.transform; ; if ((CharacterWander.WanderMode)newCharWanderSelect.value == CharacterWander.WanderMode.Patrol) { wanderToEdit = activeChar.GetComponent <CharacterWander>(); StartCharRadiusSelect(); } else { activeChar = GetCharacter(); } droppedCharacters.Add(new DroppedCharacter(activeChar.GetComponent <CharacterWander>())); SaveCharacters(); }
public DroppedCharacter(CharacterWander wanderScript) { modelName = wanderScript.gameObject.name.Substring(0, wanderScript.gameObject.name.IndexOf("(")); localWanderCenter = wanderScript.localWanderCenter; localWanderRadius = wanderScript.localWanderRadius; mode = wanderScript.mode; defaultSpeed = wanderScript.defaultSpeed; normalSpeedRadius = wanderScript.normalSpeedRadius; dropPoint = wanderScript.dropPoint; }
/// <summary> /// Starts the radius selection process. /// Changes the state to CharRadiusSelect. /// </summary> public void StartCharRadiusSelect() { prevState = currentState; currentState = CharacterDropperState.CharRadiusSelect; userSetRadius = false; if (wanderToEdit == null) { wanderToEdit = activeChar.GetComponent <CharacterWander>(); } if (activeChar != null) { wanderToEdit.localWanderCenter = activeChar.transform.position; radiusProjector.transform.position = activeChar.transform.position + new Vector3(0, 2, 0); } }
/// <summary> /// Opens the character info panel. /// </summary> /// <param name="charToOpen"></param> public void OpenCharacterInfo(GameObject charToOpen) { Destroy(activeChar); activeChar = charToOpen; mouseDownOnChar = false; wanderToEdit = activeChar.GetComponent <CharacterWander>(); activeChar.GetComponent <UnityEngine.AI.NavMeshAgent>().Stop(); wanderToEdit.CancelMovement(); activeChar.GetComponent <Animator>().enabled = false; charInfoPanel.gameObject.SetActive(true); if (wanderToEdit.mode == CharacterWander.WanderMode.Bookmark) { selectedMode = wanderToEdit.prevMode; } else { selectedMode = wanderToEdit.mode; } charInfoPanel.transform.position = UIUtilities.SetPopUpPanel(charInfoPanel); iTween.Stop(charInfoPanel.gameObject, true); charInfoPanel.localScale = new Vector3(.01f, .01f, .01f); iTween.ScaleBy(charInfoPanel.gameObject, iTween.Hash("x", 100, "y", 100, "easeType", "easeInOutExpo", "time", .5f)); UpdateCharInfoLabels(); destinationDropDown.ClearOptions(); destinationDropDown.AddOptions(new List <string>() { "None" }); destinationDropDown.AddOptions(new List <string>(POIButtonManager.originalHandler.projectPOIs.Select(e => e.buttonName).ToList())); ActiveWidgetManager.ActivateWidget(ActiveWidgetManager.ActiveWidget.CharacterDrop); currentState = CharacterDropperState.EditCharacter; }
/// <summary> /// Loads characters from file. /// </summary> public void LoadCharacters() { if (!File.Exists(characterFilePath)) { XmlIO.Save(droppedCharacters, characterFilePath); } droppedCharacters = XmlIO.Load(characterFilePath, typeof(List <DroppedCharacter>)) as List <DroppedCharacter>; foreach (DroppedCharacter character in droppedCharacters) { GameObject newChar = GameObject.Instantiate(Resources.Load("Characters/" + character.modelName), character.dropPoint, Quaternion.identity) as GameObject; newChar.transform.parent = charRoot.transform; newChar.transform.localPosition = character.dropPoint; newChar.transform.localScale = Vector3.one; CharacterWander newWander = newChar.GetComponent <CharacterWander>(); newWander.dropPoint = character.dropPoint; newWander.localWanderCenter = character.localWanderCenter; newWander.localWanderRadius = character.localWanderRadius; newWander.mode = character.mode; newWander.normalSpeedRadius = character.normalSpeedRadius; newWander.defaultSpeed = character.defaultSpeed; newWander.poiDestination = -1; } }
protected override void Initialization() { characterWander = GetComponent <CharacterWander>(); }