Esempio n. 1
0
    /// <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;
    }
Esempio n. 2
0
 /// <summary>
 /// Closes and resets the menu.
 /// </summary>
 public void ResetMenu()
 {
     initializing = true;
     Destroy(activeChar);
     StopCharRadiusSelect(false);
     CloseCharacterDrop();
     CloseCharacterInfo();
     CloseCharacterEdit();
     initializing = false;
     currentState = CharacterDropperState.None;
 }
Esempio n. 3
0
 /// <summary>
 /// Closes the character drop menu.
 /// </summary>
 public void CloseCharacterDrop()
 {
     if (ActiveWidgetManager.currentActive == ActiveWidgetManager.ActiveWidget.CharacterDrop)
     {
         dropCharacterSelectPanel.gameObject.SetActive(false);
         Destroy(activeChar);
         activeChar        = null;
         buttonImage.color = Color.white;
         currentState      = CharacterDropperState.SelectExisting;
         ActiveWidgetManager.DeactivateWidget(ActiveWidgetManager.ActiveWidget.CharacterDrop);
         ActiveWidgetManager.ActivateWidget(ActiveWidgetManager.ActiveWidget.WidgetConfig);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Opens the character drop menu.
 /// </summary>
 public void OpenCharacterDrop()
 {
     if (ActiveWidgetManager.currentActive == ActiveWidgetManager.ActiveWidget.WidgetConfig)
     {
         dropCharacterSelectPanel.gameObject.SetActive(true);
         modelToggleGroup.SetAllTogglesOff();
         randomToggle.isOn = true;
         activeChar        = GetCharacter();
         buttonImage.color = Color.red;
         currentState      = CharacterDropperState.DroppingNew;
         ActiveWidgetManager.DeactivateWidget(ActiveWidgetManager.ActiveWidget.WidgetConfig);
         ActiveWidgetManager.ActivateWidget(ActiveWidgetManager.ActiveWidget.CharacterDrop);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// This function is called whenever the Patrol toggle changes in the CharacterEditPanel.
 /// </summary>
 /// <param name="newValue"></param>
 public void OnPatrolChanged(bool newValue)
 {
     // If the value is turned on, we disable the mask hiding the radius select section.
     if (newValue)
     {
         radiusSelectMask.gameObject.SetActive(false);
     }
     // If the value is turned off, we enable the mask and change the state.
     else
     {
         radiusSelectMask.gameObject.SetActive(true);
         if (currentState == CharacterDropperState.CharRadiusSelect)
         {
             currentState = CharacterDropperState.EditCharacter;
         }
     }
 }
Esempio n. 6
0
    /// <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);
        }
    }
Esempio n. 7
0
    void Start()
    {
        patrolToggle.onValueChanged.AddListener(OnPatrolChanged);
        randomToggle.onValueChanged.AddListener(OnRandomChanged);
        //characterFilePath = Application.dataPath + "/FullPackage/Settings/SavedChars.characters";
        //LoadCharacters();

        if (Instance == null)
        {
            Instance = this;
        }

        radiusInput.onValueChanged.AddListener(SetRadiusProjectorFromInputValueChanged);

        ResetMenu();
        currentState = CharacterDropperState.SelectExisting;

        if (avatar == null)
        {
            Debug.Log("CharacterDropper.Avatar was null! Searching for tag: Player");
            if (GameObject.FindGameObjectWithTag("Player") != null)
            {
                Debug.Log("Found object tagged: Player");
                avatar = GameObject.FindGameObjectWithTag("Player");
            }
            else
            {
                Debug.Log("CharacterDropper.Avatar was null and no object tagged: Player");
            }
        }

        Object[] tmpArray = Resources.LoadAll("Characters/");
        foreach (Object obj in tmpArray)
        {
            loadedCharacters.Add(obj as GameObject);
            GameObject newToggle = Instantiate(Resources.Load("CustomToggle"), Vector3.zero, Quaternion.identity) as GameObject;
            newToggle.name = obj.name;
            newToggle.transform.SetParent(modelList.transform);
            newToggle.transform.SetAsLastSibling();
            newToggle.transform.Find("Label").GetComponent <Text>().text = obj.name;
            newToggle.GetComponent <Toggle>().group = modelToggleGroup;
            modelToggleGroup.RegisterToggle(newToggle.GetComponent <Toggle>());
        }
    }
Esempio n. 8
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;
    }
Esempio n. 9
0
    /// <summary>
    /// Stops the radius selection process.
    /// </summary>
    /// <param name="startMotion"></param>
    public void StopCharRadiusSelect(bool startMotion)
    {
        if (wanderToEdit != null)
        {
            wanderToEdit.localWanderRadius = radiusProjector.orthographicSize;

            if (startMotion)
            {
                wanderToEdit.SetWanderMode();
            }

            radiusInput.text = wanderToEdit.localWanderRadius.ToString("F2");
        }
        currentState = prevState;


        if (currentState == CharacterDropperState.DroppingNew)
        {
            activeChar = GetCharacter();
        }
    }