Beispiel #1
0
 /**
  * <summary>Registers a Hotspot, so that it can be updated</summary>
  * <param name = "_object">The Hotspot to register</param>
  */
 public void Register(Hotspot _object)
 {
     if (!hotspots.Contains(_object))
     {
         hotspots.Add(_object);
     }
 }
Beispiel #2
0
 /**
  * <summary>Triggers the OnEnableInteractionMenus event</summary>
  * <param name = "hotspot">The Hotspot for which Interaction menus were turned on for. Null if invItem is not.</param>
  * <param name = "invItem">The Inventory item for which Interaction menus were turned on for.  Null if hotspot is not.</param>
  */
 public void Call_OnEnableInteractionMenus(Hotspot hotspot, InvItem invItem)
 {
     if (OnEnableInteractionMenus != null)
     {
         OnEnableInteractionMenus(hotspot, invItem);
     }
 }
Beispiel #3
0
 /**
  * <summary>Unregisters a Hotspot, so that it is no longer updated</summary>
  * <param name = "_object">The Hotspot to unregister</param>
  */
 public void Unregister(Hotspot _object)
 {
     if (hotspots.Contains(_object))
     {
         hotspots.Remove(_object);
     }
 }
Beispiel #4
0
        public override void LoadData(string stringData)
        {
            HotspotData data = Serializer.LoadScriptData <HotspotData> (stringData);

            if (data == null)
            {
                return;
            }

            if (data.isOn)
            {
                gameObject.layer = LayerMask.NameToLayer(KickStarter.settingsManager.hotspotLayer);
            }
            else
            {
                gameObject.layer = LayerMask.NameToLayer(KickStarter.settingsManager.deactivatedLayer);
            }

            if (GetComponent <Hotspot>())
            {
                Hotspot _hotspot = GetComponent <Hotspot>();

                StringToButtonStates(_hotspot, data.buttonStates);

                if (data.hotspotName != "")
                {
                    _hotspot.SetName(data.hotspotName, data.displayLineID);
                }
            }
        }
Beispiel #5
0
        public string GetFullLabel(Hotspot _hotspot, int _language)
        {
            if (_hotspot == null)
            {
                return(string.Empty);
            }

            if (_hotspot.lookButton == this)
            {
                string prefix = KickStarter.cursorManager.GetLabelFromID(KickStarter.cursorManager.lookCursor_ID, _language);
                return(AdvGame.CombineLanguageString(prefix,
                                                     _hotspot.GetName(_language),
                                                     _language));
            }
            else if (_hotspot.useButtons.Contains(this))
            {
                string prefix = KickStarter.cursorManager.GetLabelFromID(iconID, _language);
                return(AdvGame.CombineLanguageString(prefix,
                                                     _hotspot.GetName(_language),
                                                     _language));
            }
            else if (_hotspot.invButtons.Contains(this))
            {
                InvItem item   = KickStarter.runtimeInventory.GetItem(invID);
                string  prefix = KickStarter.runtimeInventory.GetHotspotPrefixLabel(item, item.GetLabel(_language), _language);
                return(AdvGame.CombineLanguageString(prefix,
                                                     _hotspot.GetName(_language),
                                                     _language));
            }

            return(string.Empty);
        }
        public MatchingInvInteractionData(Hotspot hotspot)
        {
            invInstances          = new List <InvInstance> ();
            invInteractionIndices = new List <int>();
            selectItemModes       = new List <SelectItemMode>();

            for (int i = 0; i < hotspot.invButtons.Count; i++)
            {
                Button button = hotspot.invButtons[i];
                if (button.isDisabled)
                {
                    continue;
                }

                foreach (InvInstance invInstance in KickStarter.runtimeInventory.PlayerInvCollection.InvInstances)
                {
                    if (InvInstance.IsValid(invInstance) && invInstance.ItemID == button.invID && !button.isDisabled)
                    {
                        invInteractionIndices.Add(i);
                        selectItemModes.Add(button.selectItemMode);
                        invInstances.Add(invInstance);
                        break;
                    }
                }
            }
        }
Beispiel #7
0
        public override string SaveData()
        {
            HotspotData hotspotData = new HotspotData();

            hotspotData.objectID = constantID;

            if (gameObject.layer == LayerMask.NameToLayer(KickStarter.settingsManager.hotspotLayer))
            {
                hotspotData.isOn = true;
            }
            else
            {
                hotspotData.isOn = false;
            }

            if (GetComponent <Hotspot>())
            {
                Hotspot _hotspot = GetComponent <Hotspot>();
                hotspotData.buttonStates = ButtonStatesToString(_hotspot);

                hotspotData.hotspotName   = _hotspot.GetName(0);
                hotspotData.displayLineID = _hotspot.displayLineID;
            }

            return(Serializer.SaveScriptData <HotspotData> (hotspotData));
        }
        private void ShowHotspotGUI()
        {
            GUILayout.BeginVertical("Button");

            GUILayout.Label("Hotspots: " + sceneHotspots.Length + " found");
            if (GUILayout.Button("Select next"))
            {
                SetNextHotspot();
            }

            if (selectedHotspot != null)
            {
                GUILayout.Label("Selected Hotspot: " + selectedHotspot.GetName(0));

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Deselect"))
                {
                    selectedHotspot = null;
                    KickStarter.playerInteraction.SetActiveHotspot(null);
                }
                if (GUILayout.Button("Use"))
                {
                    selectedHotspot.RunUseInteraction();
                }
                if (GUILayout.Button("Examine"))
                {
                    selectedHotspot.RunExamineInteraction();
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
        }
Beispiel #9
0
        /**
         * Detects Hotspots in its vicinity. This is public so that it can be called by StateHandler every frame.
         */
        public void _Update()
        {
            if (nearestHotspot && nearestHotspot.gameObject.layer == LayerMask.NameToLayer(AdvGame.GetReferences().settingsManager.deactivatedLayer))
            {
                nearestHotspot = null;
            }

            if (KickStarter.stateHandler != null && KickStarter.stateHandler.gameState == GameState.Normal)
            {
                try
                {
                    if (KickStarter.playerInput.InputGetButtonDown("CycleHotspotsLeft"))
                    {
                        CycleHotspots(false);
                    }
                    else if (KickStarter.playerInput.InputGetButtonDown("CycleHotspotsRight"))
                    {
                        CycleHotspots(true);
                    }
                    else if (KickStarter.playerInput.InputGetAxis("CycleHotspots") > 0.1f)
                    {
                        CycleHotspots(true);
                    }
                    else if (KickStarter.playerInput.InputGetAxis("CycleHotspots") < -0.1f)
                    {
                        CycleHotspots(false);
                    }
                }
                catch {}
            }
        }
        public override void AssignValues(List <ActionParameter> parameters)
        {
            if (isPlayer)
            {
                runtimeChar = KickStarter.player;
            }
            else
            {
                runtimeChar = AssignFile <Char> (parameters, charToMoveParameterID, charToMoveID, charToMove);
            }

            Hotspot markerHotspot = AssignFile <Hotspot> (parameters, markerParameterID, markerID, null);

            if (markerHotspot != null && markerHotspot.walkToMarker != null)
            {
                runtimeMarker = markerHotspot.walkToMarker;
            }
            else
            {
                runtimeMarker = AssignFile <Marker> (parameters, markerParameterID, markerID, marker);
            }

            maxTime       = AssignFloat(parameters, maxTimeParameterID, maxTime);
            isFacingAfter = false;
        }
Beispiel #11
0
 /**
  * <summary>Checks if a specific Hotspot is within its volume.</summary>
  * <param name = "hotspot">The Hotspot to check for</param>
  * <returns>True if the Hotspot is within the Collider volume</returns>
  */
 public bool IsHotspotInTrigger(Hotspot hotspot)
 {
     if (hotspots.Contains(hotspot))
     {
         return(true);
     }
     return(false);
 }
        /**
         * <summary>Creates a new instance of the 'Hotspot: Enable or disable' Action</summary>
         * <param name = "hotspotToAffect">The Hotspot to affect</param>
         * <param name = "changeToMake">The type of change to make</param>
         * <returns>The generated Action</returns>
         */
        public static ActionHotspotEnable CreateNew(Hotspot hotspotToAffect, ChangeType changeToMake)
        {
            ActionHotspotEnable newAction = (ActionHotspotEnable)CreateInstance <ActionHotspotEnable>();

            newAction.hotspot    = hotspotToAffect;
            newAction.changeType = changeToMake;
            return(newAction);
        }
        /**
         * <summary>Creates a new instance of the 'Hotspot: Check interaction enabled' Action</summary>
         * <param name = "hotspotToCheck">The Hotspot to check</param>
         * <param name = "interactionType">The interaction type to check</param>
         * <param name = "index">The index number of the interaction to check within the given interactionType</param>
         * <returns>The generated Action</returns>
         */
        public static ActionInteractionCheck CreateNew(Hotspot hotspotToCheck, InteractionType interactionType, int index)
        {
            ActionInteractionCheck newAction = (ActionInteractionCheck)CreateInstance <ActionInteractionCheck>();

            newAction.hotspot         = hotspotToCheck;
            newAction.interactionType = interactionType;
            newAction.number          = index;
            return(newAction);
        }
Beispiel #14
0
        private void OnSelectHotspot(Hotspot hotspot)
        {
            /**
             * Whenever a Hotspot is selected, begin the countdown.
             */

            hoverHotspot         = hotspot;
            hotspotHoverDuration = hoverDuration;
        }
Beispiel #15
0
        private void OnDeselectHotspot(Hotspot hotspot)
        {
            /**
             * Whenever a Hotspot is deselected, end the countdown.
             */

            hoverHotspot         = null;
            hotspotHoverDuration = 0f;
        }
        /**
         * <summary>Creates a new instance of the 'Hotspot: Rename' Action</summary>
         * <param name = "hotspotToRename">The Hotspot to rename</param>
         * <param name = "newName">If Hotspot's new name</param>
         * <param name = "translationID">The new name's translation ID number, as generated by the Speech Manager</param>
         * <returns>The generated Action</returns>
         */
        public static ActionRename CreateNew(Hotspot hotspotToRename, string newName, int translationID = -1)
        {
            ActionRename newAction = (ActionRename)CreateInstance <ActionRename>();

            newAction.hotspot = hotspotToRename;
            newAction.newName = newName;
            newAction.lineID  = translationID;
            return(newAction);
        }
Beispiel #17
0
        private void ShowContextIcons()
        {
            Hotspot hotspot = KickStarter.playerInteraction.GetActiveHotspot();

            if (hotspot == null)
            {
                return;
            }

            if (hotspot.HasContextUse())
            {
                if (!hotspot.HasContextLook())
                {
                    DrawIcon(KickStarter.cursorManager.GetCursorIconFromID(hotspot.GetFirstUseButton().iconID), false);
                    return;
                }
                else
                {
                    Button _button = hotspot.GetFirstUseButton();

                    if (hotspot.HasContextUse() && hotspot.HasContextLook() && CanDisplayIconsSideBySide())
                    {
                        CursorIcon icon = KickStarter.cursorManager.GetCursorIconFromID(_button.iconID);
                        DrawIcon(new Vector2(-icon.size * Screen.width / 2f, 0f), icon, false);
                    }
                    else if (CanCycleContextSensitiveMode() && contextCycleExamine && hotspot.HasContextLook())
                    {
                        CursorIcon lookIcon = KickStarter.cursorManager.GetCursorIconFromID(KickStarter.cursorManager.lookCursor_ID);
                        DrawIcon(Vector2.zero, lookIcon, true);
                    }
                    else
                    {
                        DrawIcon(KickStarter.cursorManager.GetCursorIconFromID(_button.iconID), false);
                    }
                }
            }

            if (hotspot.HasContextLook() &&
                (!hotspot.HasContextUse() ||
                 (hotspot.HasContextUse() && CanDisplayIconsSideBySide())))
            {
                if (KickStarter.cursorManager.cursorIcons.Count > 0)
                {
                    CursorIcon icon = KickStarter.cursorManager.GetCursorIconFromID(KickStarter.cursorManager.lookCursor_ID);

                    if (hotspot.HasContextUse() && hotspot.HasContextLook() && CanDisplayIconsSideBySide())
                    {
                        DrawIcon(new Vector2(icon.size * Screen.width / 2f, 0f), icon, true);
                    }
                    else
                    {
                        DrawIcon(icon, true);
                    }
                }
            }
        }
 private void DoChange(Hotspot _hotspot)
 {
     if (changeType == ChangeType.Enable)
     {
         _hotspot.TurnOn();
     }
     else
     {
         _hotspot.TurnOff();
     }
 }
 private void DoChange(Hotspot _hotspot)
 {
     if (changeType == ChangeType.Enable)
     {
         _hotspot.TurnOn ();
     }
     else
     {
         _hotspot.TurnOff ();
     }
 }
        /**
         * <summary>Creates a new instance of the 'Hotspot: Change interaction' Action</summary>
         * <param name = "hotspot">The Hotspot to affect</param>
         * <param name = "changeType">What kind of change to make</param>
         * <param name = "interactionType">The type of Hotspot interaction to affect</param>
         * <param name = "interactionIndex">The index number of the interactions to affect</param>
         * <returns>The generated Action</returns>
         */
        public static ActionInteraction CreateNew(Hotspot hotspot, ChangeType changeType, InteractionType interactionType, int interactionIndex = 0)
        {
            ActionInteraction newAction = (ActionInteraction)CreateInstance <ActionInteraction>();

            newAction.hotspot         = hotspot;
            newAction.interactionType = interactionType;
            newAction.changeType      = changeType;
            newAction.number          = interactionIndex;

            return(newAction);
        }
Beispiel #21
0
        /**
         * <summary>Unregisters a Hotspot, so that it is no longer updated</summary>
         * <param name = "_object">The Hotspot to unregister</param>
         */
        public void Unregister(Hotspot _object)
        {
            if (hotspots.Contains(_object))
            {
                hotspots.Remove(_object);

                if (KickStarter.eventManager)
                {
                    KickStarter.eventManager.Call_OnRegisterHotspot(_object, false);
                }
            }
        }
Beispiel #22
0
        /**
         * <summary>Registers a Hotspot, so that it can be updated</summary>
         * <param name = "_object">The Hotspot to register</param>
         */
        public void Register(Hotspot _object)
        {
            if (!hotspots.Contains(_object))
            {
                hotspots.Add(_object);

                if (KickStarter.eventManager)
                {
                    KickStarter.eventManager.Call_OnRegisterHotspot(_object, true);
                }
            }
        }
Beispiel #23
0
        /**
         * <summary>Triggers the OnDoubleClickHotspot event, regardless of the Hotspot's doubleClickingHotspot variable.</summary>
         * <param name = "hotspot">The Hotspot that was double-clicked.</param>
         */
        public void Call_OnDoubleClickHotspot(Hotspot hotspot)
        {
            if (hotspot == null)
            {
                return;
            }

            if (OnDoubleClickHotspot != null)
            {
                OnDoubleClickHotspot(hotspot);
            }
        }
Beispiel #24
0
        /**
         * <summary>Triggers the OnHotspotInteract event.</summary>
         * <param name = "hotspot">The Hotspot the was interacted with</param>
         * <param name = "button">The specific Button on the Hotspot that was interacted with. This will be null if the interaction is unhandled.</param>
         */
        public void Call_OnInteractHotspot(Hotspot hotspot, AC.Button button)
        {
            if (hotspot == null)
            {
                return;
            }

            if (OnHotspotInteract != null)
            {
                OnHotspotInteract(hotspot, button);
            }
        }
Beispiel #25
0
        /**
         * <summary>Generates a label that represents the name of the parameter's value, if appropriate<summary>
         * <returns>A label that represents the name of the parameter's value<summary>
         */
        public string GetLabel()
        {
            switch (parameterType)
            {
            case ParameterType.GameObject:
                if (gameObject != null)
                {
                    Hotspot _hotspot = gameObject.GetComponent <Hotspot>();
                    if (_hotspot)
                    {
                        return(_hotspot.GetName(Options.GetLanguage()));
                    }

                    Char _char = gameObject.GetComponent <Char>();
                    if (_char)
                    {
                        return(_char.GetName(Options.GetLanguage()));
                    }

                    return(gameObject.name);
                }
                return(string.Empty);

            case ParameterType.InventoryItem:
                InvItem invItem = KickStarter.inventoryManager.GetItem(intValue);
                if (invItem != null)
                {
                    return(invItem.GetLabel(Options.GetLanguage()));
                }
                return(GetSaveData());

            case ParameterType.GlobalVariable:
                GVar gVar = KickStarter.variablesManager.GetVariable(intValue);
                if (gVar != null)
                {
                    return(gVar.label);
                }
                return(GetSaveData());

            case ParameterType.LocalVariable:
                GVar lVar = LocalVariables.GetVariable(intValue);
                if (lVar != null)
                {
                    return(lVar.label);
                }
                return(GetSaveData());

            default:
                return(GetSaveData());
            }
        }
Beispiel #26
0
        private void ShowContextIcons()
        {
            Hotspot hotspot = KickStarter.playerInteraction.GetActiveHotspot();

            if (hotspot == null)
            {
                return;
            }

            if (hotspot.HasContextUse())
            {
                if (!hotspot.HasContextLook())
                {
                    DrawIcon(KickStarter.cursorManager.GetCursorIconFromID(hotspot.GetFirstUseButton().iconID), false);
                    return;
                }
                else
                {
                    Button _button = hotspot.GetFirstUseButton();

                    if (hotspot.HasContextUse() && hotspot.HasContextLook() && KickStarter.cursorManager.lookUseCursorAction == LookUseCursorAction.DisplayBothSideBySide)
                    {
                        CursorIcon icon = KickStarter.cursorManager.GetCursorIconFromID(_button.iconID);
                        DrawIcon(new Vector2(-icon.size * Screen.width / 2f, 0f), icon, false);
                    }
                    else
                    {
                        DrawIcon(KickStarter.cursorManager.GetCursorIconFromID(_button.iconID), false);
                    }
                }
            }

            if (hotspot.HasContextLook() &&
                (!hotspot.HasContextUse() ||
                 (hotspot.HasContextUse() && KickStarter.cursorManager.lookUseCursorAction == LookUseCursorAction.DisplayBothSideBySide)))
            {
                if (KickStarter.cursorManager.cursorIcons.Count > 0)
                {
                    CursorIcon icon = KickStarter.cursorManager.GetCursorIconFromID(KickStarter.cursorManager.lookCursor_ID);

                    if (hotspot.HasContextUse() && hotspot.HasContextLook() && KickStarter.cursorManager.lookUseCursorAction == LookUseCursorAction.DisplayBothSideBySide)
                    {
                        DrawIcon(new Vector2(icon.size * Screen.width / 2f, 0f), icon, true);
                    }
                    else
                    {
                        DrawIcon(icon, true);
                    }
                }
            }
        }
Beispiel #27
0
        private string ButtonStatesToString(Hotspot hotspot)
        {
            System.Text.StringBuilder stateString = new System.Text.StringBuilder();

            if (KickStarter.settingsManager == null || KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
            {
                // Single-use and Look interaction
                if (hotspot.provideLookInteraction)
                {
                    stateString.Append(GetButtonDisabledValue(hotspot.lookButton));
                }
                else
                {
                    stateString.Append("0");
                }
            }

            stateString.Append("|");

            // Multi-use interactions
            if (hotspot.provideUseInteraction)
            {
                foreach (AC.Button button in hotspot.useButtons)
                {
                    stateString.Append(GetButtonDisabledValue(button));

                    if (hotspot.useButtons.IndexOf(button) < hotspot.useButtons.Count - 1)
                    {
                        stateString.Append(",");
                    }
                }
            }

            stateString.Append("|");

            // Inventory interactions
            if (hotspot.provideInvInteraction)
            {
                foreach (AC.Button button in hotspot.invButtons)
                {
                    stateString.Append(GetButtonDisabledValue(button));

                    if (hotspot.invButtons.IndexOf(button) < hotspot.invButtons.Count - 1)
                    {
                        stateString.Append(",");
                    }
                }
            }

            return(stateString.ToString());
        }
Beispiel #28
0
        /**
         * <summary>Gets the currently-active Hotspot.</summary>
         * <returns>The currently active Hotspot.</returns>
         */
        public Hotspot GetSelected()
        {
            if (hotspots.Count > 0)
            {
                if (AdvGame.GetReferences().settingsManager.hotspotsInVicinity == HotspotsInVicinity.NearestOnly)
                {
                    if (selected >= 0 && hotspots.Count > selected)
                    {
                        if (IsLayerCorrect(hotspots[selected].gameObject.layer))
                        {
                            return(nearestHotspot);
                        }
                        else
                        {
                            nearestHotspot = null;
                            hotspots.Remove(nearestHotspot);
                            hotspots = KickStarter.eventManager.Call_OnModifyHotspotDetectorCollection(this, hotspots);
                        }
                    }
                }
                else if (AdvGame.GetReferences().settingsManager.hotspotsInVicinity == HotspotsInVicinity.CycleMultiple)
                {
                    if (selected >= hotspots.Count)
                    {
                        selected = hotspots.Count - 1;
                    }
                    else if (selected < 0)
                    {
                        selected = 0;
                    }

                    if (IsLayerCorrect(hotspots[selected].gameObject.layer))
                    {
                        return(hotspots [selected]);
                    }
                    else
                    {
                        if (nearestHotspot == hotspots [selected])
                        {
                            nearestHotspot = null;
                        }

                        hotspots.RemoveAt(selected);
                        hotspots = KickStarter.eventManager.Call_OnModifyHotspotDetectorCollection(this, hotspots);
                    }
                }
            }

            return(null);
        }
Beispiel #29
0
        private void StringToButtonStates(Hotspot hotspot, string stateString)
        {
            if (string.IsNullOrEmpty(stateString))
            {
                return;
            }

            string[] typesArray = stateString.Split(SaveSystem.pipe[0]);

            if (KickStarter.settingsManager == null || KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
            {
                // Look interactions
                if (hotspot.provideLookInteraction && hotspot.lookButton != null)
                {
                    hotspot.SetButtonState(hotspot.lookButton, !SetButtonDisabledValue(typesArray [0]));
                }
            }

            if (hotspot.provideUseInteraction && hotspot.useButtons.Count > 0)
            {
                string[] usesArray = typesArray[1].Split(","[0]);

                for (int i = 0; i < usesArray.Length; i++)
                {
                    if (hotspot.useButtons.Count < i + 1)
                    {
                        break;
                    }

                    hotspot.SetButtonState(hotspot.useButtons[i], !SetButtonDisabledValue(usesArray [i]));
                }
            }

            // Inventory interactions
            if (hotspot.provideInvInteraction && typesArray.Length > 2 && hotspot.invButtons.Count > 0)
            {
                string[] invArray = typesArray[2].Split(","[0]);

                for (int i = 0; i < invArray.Length; i++)
                {
                    if (hotspot.invButtons.Count < i + 1)
                    {
                        break;
                    }

                    hotspot.SetButtonState(hotspot.invButtons[i], !SetButtonDisabledValue(invArray [i]));
                }
            }
        }
Beispiel #30
0
        /**
         * <summary>Gets the currently-active Hotspot.</summary>
         * <returns>The currently active Hotspot.</returns>
         */
        public Hotspot GetSelected()
        {
            if (hotspots.Count > 0)
            {
                if (AdvGame.GetReferences().settingsManager.hotspotsInVicinity == HotspotsInVicinity.NearestOnly)
                {
                    if (hotspots.Count > selected)
                    {
                        if (hotspots[selected].gameObject.layer == LayerMask.NameToLayer(AdvGame.GetReferences().settingsManager.hotspotLayer))
                        {
                            return(nearestHotspot);
                        }
                        else
                        {
                            nearestHotspot = null;
                            hotspots.Remove(nearestHotspot);
                        }
                    }
                }
                else if (AdvGame.GetReferences().settingsManager.hotspotsInVicinity == HotspotsInVicinity.CycleMultiple)
                {
                    if (selected >= hotspots.Count)
                    {
                        selected = hotspots.Count - 1;
                    }
                    else if (selected < 0)
                    {
                        selected = 0;
                    }

                    if (hotspots [selected].gameObject.layer == LayerMask.NameToLayer(AdvGame.GetReferences().settingsManager.hotspotLayer))
                    {
                        return(hotspots [selected]);
                    }
                    else
                    {
                        if (nearestHotspot == hotspots [selected])
                        {
                            nearestHotspot = null;
                        }

                        hotspots.RemoveAt(selected);
                    }
                }
            }

            return(null);
        }
		private void StringToButtonStates (Hotspot hotspot, string stateString)
		{
			if (stateString.Length == 0)
			{
				return;
			}

			string[] typesArray = stateString.Split ("|"[0]);
			
			if (AdvGame.GetReferences ().settingsManager == null || AdvGame.GetReferences ().settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
			{
				// Look interactions
				if (hotspot.provideLookInteraction && hotspot.lookButton != null)
				{
					hotspot.lookButton.isDisabled = SetButtonDisabledValue (typesArray [0]);
				}
			}

			if (hotspot.provideUseInteraction)
			{
				string[] usesArray = typesArray[1].Split (","[0]);
				
				for (int i=0; i<usesArray.Length; i++)
				{
					if (hotspot.useButtons.Count < i+1)
					{
						break;
					}
					hotspot.useButtons[i].isDisabled = SetButtonDisabledValue (usesArray [i]);
				}
			}

			// Inventory interactions
			if (hotspot.provideInvInteraction && typesArray.Length > 2)
			{
				string[] invArray = typesArray[2].Split (","[0]);
				
				for (int i=0; i<invArray.Length; i++)
				{
					if (hotspot.invButtons.Count < i+1)
					{
						break;
					}
					
					hotspot.invButtons[i].isDisabled = SetButtonDisabledValue (invArray [i]);
				}
			}
		}
Beispiel #32
0
        /**
         * <summary>Triggers either the OnHotspotSelect or OnHotspotDeselect event.</summary>
         * <param name = "hotspot">The Hotspot that was affected</param>
         * <param name = "wasSelected">If True, the OnHotspotSelect event will be triggered. If False, the OnHotspotDeselect Event will be triggered.</param>
         */
        public void Call_OnChangeHotspot(Hotspot hotspot, bool wasSelected)
        {
            if (hotspot == null)
            {
                return;
            }

            if (wasSelected && OnHotspotSelect != null)
            {
                OnHotspotSelect(hotspot);
            }
            else if (!wasSelected && OnHotspotDeselect != null)
            {
                OnHotspotDeselect(hotspot);
            }
        }
Beispiel #33
0
        public Hotspot GetSelected()
        {
            if (hotspots.Count > 0)
            {
                if (AdvGame.GetReferences ().settingsManager.hotspotsInVicinity == HotspotsInVicinity.NearestOnly)
                {
                    if (hotspots [selected].gameObject.layer == LayerMask.NameToLayer (AdvGame.GetReferences ().settingsManager.hotspotLayer))
                    {
                        return nearestHotspot;
                    }
                    else
                    {
                        nearestHotspot = null;
                        hotspots.Remove (nearestHotspot);
                    }
                }
                else if (AdvGame.GetReferences ().settingsManager.hotspotsInVicinity == HotspotsInVicinity.CycleMultiple)
                {
                    if (selected >= hotspots.Count)
                    {
                        selected = hotspots.Count - 1;
                    }
                    else if (selected < 0)
                    {
                        selected = 0;
                    }

                    if (hotspots [selected].gameObject.layer == LayerMask.NameToLayer (AdvGame.GetReferences ().settingsManager.hotspotLayer))
                    {
                        return hotspots [selected];
                    }
                    else
                    {
                        if (nearestHotspot == hotspots [selected])
                        {
                            nearestHotspot = null;
                        }

                        hotspots.RemoveAt (selected);
                    }
                }
            }

            return null;
        }
		override public void ShowGUI (List<ActionParameter> parameters)
		{
			parameterID = Action.ChooseParameterGUI ("Hotspot to rename:", parameters, parameterID, ParameterType.GameObject);
			if (parameterID >= 0)
			{
				constantID = 0;
				hotspot = null;
			}
			else
			{
				hotspot = (Hotspot) EditorGUILayout.ObjectField ("Hotspot to rename:", hotspot, typeof (Hotspot), true);
				
				constantID = FieldToID <Hotspot> (hotspot, constantID);
				hotspot = IDToField <Hotspot> (hotspot, constantID, false);
			}
			
			newName = EditorGUILayout.TextField ("New label:", newName);
			
			AfterRunningOption ();
		}
		override public void ShowGUI (List<ActionParameter> parameters)
		{
			parameterID = Action.ChooseParameterGUI ("Hotspot to affect:", parameters, parameterID, ParameterType.GameObject);
			if (parameterID >= 0)
			{
				constantID = 0;
				hotspot = null;
			}
			else
			{
				hotspot = (Hotspot) EditorGUILayout.ObjectField ("Hotspot to affect:", hotspot, typeof (Hotspot), true);
				
				constantID = FieldToID <Hotspot> (hotspot, constantID);
				hotspot = IDToField <Hotspot> (hotspot, constantID, false);
			}

			changeType = (ChangeType) EditorGUILayout.EnumPopup ("Change to make:", changeType);

			AfterRunningOption ();
		}
		private void ExtractHotspot (Hotspot hotspot, bool onlySeekNew)
		{
			if (hotspot.interactionSource == InteractionSource.AssetFile)
			{
				if (hotspot.useButton.IsButtonModified () && hotspot.useButton.assetFile)
				{
					ProcessActionList (hotspot.useButton.assetFile.actions, onlySeekNew, true);
					EditorUtility.SetDirty (hotspot.useButton.assetFile);
				}

				if (hotspot.lookButton.assetFile)
				{
					ProcessActionList (hotspot.lookButton.assetFile.actions, onlySeekNew, true);
					EditorUtility.SetDirty (hotspot.lookButton.assetFile);
				}

				foreach (Button _button in hotspot.useButtons)
				{
					if (_button.assetFile)
					{
						ProcessActionList (_button.assetFile.actions, onlySeekNew, true);
						EditorUtility.SetDirty (_button.assetFile);
					}
				}

				foreach (Button _button in hotspot.invButtons)
				{
					if (_button.assetFile)
					{
						ProcessActionList (_button.assetFile.actions, onlySeekNew, true);
						EditorUtility.SetDirty (_button.assetFile);
					}
				}
			}

			string hotspotName = hotspot.name;
			if (hotspot.hotspotName != "")
			{
				hotspotName = hotspot.hotspotName;
			}

			if (onlySeekNew && hotspot.lineID == -1)
			{
				// Assign a new ID on creation
				SpeechLine newLine;
				newLine = new SpeechLine (GetIDArray(), EditorApplication.currentScene, hotspotName, languages.Count - 1, AC_TextType.Hotspot);
				hotspot.lineID = newLine.lineID;
				lines.Add (newLine);
			}
			
			else if (!onlySeekNew && hotspot.lineID > -1)
			{
				// Already has an ID, so don't replace
				lines.Add (new SpeechLine (hotspot.lineID, EditorApplication.currentScene, hotspotName, languages.Count - 1, AC_TextType.Hotspot));
			}
		}
		private IEnumerator UseObject (int selectedItemID)
		{
			bool doRun = false;
			if (playerInput.hotspotMovingTo == hotspot)
			{
				doRun = true;
			}

			if (playerInput != null && playerInput.runLock == PlayerMoveLock.AlwaysWalk)
			{
				doRun = false;
			}
			
			if (KickStarter.player)
			{
				if (button != null && !button.isBlocking && (button.playerAction == PlayerAction.WalkToMarker || button.playerAction == PlayerAction.WalkTo) && settingsManager.movementMethod != MovementMethod.UltimateFPS)
				{
					stateHandler.gameState = GameState.Normal;
					playerInput.hotspotMovingTo = hotspot;
				}
				else
				{
					stateHandler.gameState = GameState.Cutscene;
					playerInput.hotspotMovingTo = null;
				}
			}
			
			Hotspot _hotspot = hotspot;
			hotspot.Deselect ();
			hotspot = null;
			
			if (KickStarter.player)
			{
				if (button != null && button.playerAction != PlayerAction.DoNothing)
				{
					Vector3 lookVector = Vector3.zero;
					Vector3 targetPos = _hotspot.transform.position;
					
					if (settingsManager.ActInScreenSpace ())
					{
						lookVector = AdvGame.GetScreenDirection (KickStarter.player.transform.position, _hotspot.transform.position);
					}
					else
					{
						lookVector = targetPos - KickStarter.player.transform.position;
						lookVector.y = 0;
					}
					
					KickStarter.player.SetLookDirection (lookVector, false);
					
					if (button.playerAction == PlayerAction.TurnToFace)
					{
						while (KickStarter.player.IsTurning ())
						{
							yield return new WaitForFixedUpdate ();			
						}
					}
					
					if (button.playerAction == PlayerAction.WalkToMarker && _hotspot.walkToMarker)
					{
						if (Vector3.Distance (KickStarter.player.transform.position, _hotspot.walkToMarker.transform.position) > (1.05f - settingsManager.destinationAccuracy))
						{
							if (GetComponent <NavigationManager>())
							{
								Vector3[] pointArray;
								Vector3 targetPosition = _hotspot.walkToMarker.transform.position;
								
								if (settingsManager.ActInScreenSpace ())
								{
									targetPosition = AdvGame.GetScreenNavMesh (targetPosition);
								}
								
								pointArray = GetComponent <NavigationManager>().navigationEngine.GetPointsArray (KickStarter.player.transform.position, targetPosition);
								KickStarter.player.MoveAlongPoints (pointArray, doRun);
								targetPos = pointArray [pointArray.Length - 1];
							}
							
							while (KickStarter.player.activePath)
							{
								yield return new WaitForFixedUpdate ();
							}
						}
						
						if (button.faceAfter)
						{
							lookVector = _hotspot.walkToMarker.transform.forward;
							lookVector.y = 0;
							KickStarter.player.Halt ();
							KickStarter.player.SetLookDirection (lookVector, false);
							
							while (KickStarter.player.IsTurning ())
							{
								yield return new WaitForFixedUpdate ();			
							}
						}
					}
					
					else if (lookVector.magnitude > 2f && button.playerAction == PlayerAction.WalkTo)
					{
						if (GetComponent <NavigationManager>())
						{
							Vector3[] pointArray;
							Vector3 targetPosition = _hotspot.transform.position;
							if (_hotspot.walkToMarker)
							{
								targetPosition = _hotspot.walkToMarker.transform.position;
							}

							if (settingsManager.ActInScreenSpace ())
							{
								targetPosition = AdvGame.GetScreenNavMesh (targetPosition);
							}
							
							pointArray = GetComponent <NavigationManager>().navigationEngine.GetPointsArray (KickStarter.player.transform.position, targetPosition);
							KickStarter.player.MoveAlongPoints (pointArray, doRun);
							targetPos = pointArray [pointArray.Length - 1];
						}
						
						if (button.setProximity)
						{
							button.proximity = Mathf.Max (button.proximity, 1f);
							targetPos.y = KickStarter.player.transform.position.y;
							
							while (Vector3.Distance (KickStarter.player.transform.position, targetPos) > button.proximity && KickStarter.player.activePath)
							{
								yield return new WaitForFixedUpdate ();
							}
						}
						else
						{
							yield return new WaitForSeconds (0.6f);
						}
						
						if (button.faceAfter)
						{
							if (settingsManager.ActInScreenSpace ())
							{
								lookVector = AdvGame.GetScreenDirection (KickStarter.player.transform.position, _hotspot.transform.position);
							}
							else
							{
								lookVector = _hotspot.transform.position - KickStarter.player.transform.position;
								lookVector.y = 0;
							}
							
							KickStarter.player.Halt ();
							KickStarter.player.SetLookDirection (lookVector, false);
							
							while (KickStarter.player.IsTurning ())
							{
								yield return new WaitForFixedUpdate ();			
							}
						}
					}
				}
				else
				{
					KickStarter.player.charState = CharState.Decelerate;
				}
				
				KickStarter.player.EndPath ();
				playerInput.hotspotMovingTo = null;
				yield return new WaitForSeconds (0.1f);
				KickStarter.player.EndPath ();
				playerInput.hotspotMovingTo = null;
			}

			_hotspot.Deselect ();
			hotspot = null;

			if (KickStarter.player)
			{
				KickStarter.player.ClearHeadTurnTarget (HeadFacing.Hotspot, false);
			}

			if (button == null)
			{
				// Unhandled event
				if (selectedItemID >= 0 && runtimeInventory.GetItem (selectedItemID) != null && runtimeInventory.GetItem (selectedItemID).unhandledActionList)
				{
					ActionListAsset unhandledActionList = runtimeInventory.GetItem (selectedItemID).unhandledActionList;
					runtimeInventory.SetNull ();
					AdvGame.RunActionListAsset (unhandledActionList);	
				}
				else if (selectedItemID >= 0 && runtimeInventory.unhandledHotspot)
				{
					runtimeInventory.SetNull ();
					AdvGame.RunActionListAsset (runtimeInventory.unhandledHotspot);	
				}
				else
				{
					stateHandler.gameState = GameState.Normal;
					if (settingsManager.inventoryDragDrop)
					{
						runtimeInventory.SetNull ();
					}
				}
			}
			else
			{
				runtimeInventory.SetNull ();

				if (_hotspot.interactionSource == InteractionSource.AssetFile)
				{
					AdvGame.RunActionListAsset (button.assetFile);
				}
				else if (_hotspot.interactionSource == InteractionSource.CustomScript)
				{
					if (button.customScriptObject != null && button.customScriptFunction != "")
					{
						button.customScriptObject.SendMessage (button.customScriptFunction);
					}
				}
				else if (_hotspot.interactionSource == InteractionSource.InScene)
				{
					if (button.interaction)
					{
						button.interaction.Interact ();
					}
					else
					{
						stateHandler.gameState = GameState.Normal;
					}
				}
			}

			button = null;
		}
		private void ChooseHotspotThenInteractionClick_Process (bool doubleTap)
		{
			Hotspot newHotspot = CheckForHotspots ();

			if (hotspot != null && newHotspot == null)
			{
				DisableHotspot (false);
			}
			else if (newHotspot != null)
			{
				if (newHotspot.IsSingleInteraction ())
				{
					ContextSensitiveClick ();
					return;
				}
				
				if (playerInput.mouseState == MouseState.HeldDown && playerInput.dragState == DragState.Player)
				{
					// Disable hotspots while dragging player
					DisableHotspot (false);
				}
				else
				{
					bool clickedNew = false;
					if (newHotspot != hotspot)
					{
						clickedNew = true;

						if (hotspot)
						{
							hotspot.Deselect ();
							playerMenus.DisableHotspotMenus ();
						}
						hotspot = newHotspot;
						hotspot.Select ();

						playerMenus.SetInteractionMenus (false);
					}

					if (hotspot)
					{
						if (playerInput.mouseState == MouseState.SingleClick ||
						    (settingsManager.inventoryDragDrop && IsDroppingInventory ()) ||
						    (settingsManager.MouseOverForInteractionMenu () && runtimeInventory.hoverItem == null && clickedNew && !IsDroppingInventory ()))
						{
							if (runtimeInventory.selectedItem != null && settingsManager.inventoryInteractions == InventoryInteractions.Single)
							{
								if (!settingsManager.inventoryDragDrop && clickedNew && doubleTap)
								{
									return;
								} 
								else
								{
									HandleInteraction ();
								}
							}
							else if (playerMenus)
							{
								if (playerInput.interactionMenuIsOn && settingsManager.SelectInteractionMethod () == SelectInteractions.CyclingMenuAndClickingHotspot)
								{
									ClickHotspotToInteract ();
									return;
								}

								if (clickedNew && doubleTap)
								{
									return;
								}

								if (KickStarter.player)
								{
									KickStarter.player.Halt ();
								}

								playerInput.hotspotMovingTo = null;
								StopInteraction ();
								runtimeInventory.SetNull ();
								playerMenus.SetInteractionMenus (true);
							}
						}
						else if (playerInput.mouseState == MouseState.RightClick)
						{
							hotspot.Deselect ();
						}
					}
				}
			}
		}
Beispiel #39
0
        public void _Update()
        {
            if (nearestHotspot && nearestHotspot.gameObject.layer == LayerMask.NameToLayer (AdvGame.GetReferences ().settingsManager.deactivatedLayer))
            {
                nearestHotspot = null;
            }

            if (KickStarter.stateHandler != null && KickStarter.stateHandler.gameState == GameState.Normal)
            {
                try
                {
                    if (KickStarter.playerInput.InputGetButtonDown ("CycleHotspotsLeft"))
                    {
                        CycleHotspots (false);
                    }
                    else if (KickStarter.playerInput.InputGetButtonDown ("CycleHotspotsRight"))
                    {
                        CycleHotspots (true);
                    }
                    else if (KickStarter.playerInput.InputGetAxis ("CycleHotspots") > 0.1f)
                    {
                        CycleHotspots (true);
                    }
                    else if (KickStarter.playerInput.InputGetAxis ("CycleHotspots") < -0.1f)
                    {
                        CycleHotspots (false);
                    }
                }
                catch {}
            }
        }
Beispiel #40
0
        private void ExtractHotspot(Hotspot hotspot, bool onlySeekNew)
        {
            if (hotspot.interactionSource == InteractionSource.AssetFile)
            {
                ProcessActionListAsset (hotspot.useButton.assetFile, onlySeekNew);
                ProcessActionListAsset (hotspot.lookButton.assetFile, onlySeekNew);
                ProcessActionListAsset (hotspot.unhandledInvButton.assetFile, onlySeekNew);

                foreach (Button _button in hotspot.useButtons)
                {
                    ProcessActionListAsset (_button.assetFile, onlySeekNew);
                }

                foreach (Button _button in hotspot.invButtons)
                {
                    ProcessActionListAsset (_button.assetFile, onlySeekNew);
                }
            }

            string hotspotName = hotspot.name;
            if (hotspot.hotspotName != "")
            {
                hotspotName = hotspot.hotspotName;
            }

            if (onlySeekNew && hotspot.lineID == -1)
            {
                // Assign a new ID on creation
                SpeechLine newLine = new SpeechLine (GetIDArray(), UnityVersionHandler.GetCurrentSceneName (), hotspotName, languages.Count - 1, AC_TextType.Hotspot);

                hotspot.lineID = newLine.lineID;
                lines.Add (newLine);
            }

            else if (!onlySeekNew && hotspot.lineID > -1)
            {
                // Already has an ID, so don't replace
                SpeechLine existingLine = new SpeechLine (hotspot.lineID, UnityVersionHandler.GetCurrentSceneName (), hotspotName, languages.Count - 1, AC_TextType.Hotspot);

                int lineID = SmartAddLine (existingLine);
                if (lineID >= 0) hotspot.lineID = lineID;
            }
        }
		private void OnEnable ()
		{
			_target = (Hotspot) target;
		}
Beispiel #42
0
        private void OnTriggerStay2D(Collider2D other)
        {
            if (other.GetComponent <Hotspot>() && other.gameObject.layer == LayerMask.NameToLayer (AdvGame.GetReferences ().settingsManager.hotspotLayer))
            {
                if (nearestHotspot == null || (Vector3.Distance (transform.position, other.transform.position) <= Vector3.Distance (transform.position, nearestHotspot.transform.position)))
                {
                    nearestHotspot = other.GetComponent <Hotspot>();
                }

                foreach (Hotspot hotspot in hotspots)
                {
                    if (hotspot == other.GetComponent <Hotspot>())
                    {
                        return;
                    }
                }
                hotspots.Add (other.GetComponent <Hotspot>());
            }
        }
Beispiel #43
0
 void Start()
 {
     Random.seed = System.DateTime.Now.Millisecond;
     DontDestroyOnLoad (this.gameObject);
     this.renderer = GetComponent<SpriteRenderer> ();
     this.hotspot = GetComponent<AC.Hotspot> ();
     this.collider2d = GetComponent<BoxCollider2D> ();
     SetActive (false);
 }
Beispiel #44
0
        private IEnumerator UseObject(int selectedItemID)
        {
            bool doRun = false;
            bool doSnap = false;
            if (hotspotMovingTo == hotspot && KickStarter.playerInput.LastClickWasDouble ())
            {
                if (hotspotMovingTo.doubleClickingHotspot == DoubleClickingHotspot.TriggersInteractionInstantly)
                {
                    doSnap = true;
                }
                else
                {
                    doRun = true;
                }
            }

            if (KickStarter.playerInput != null && KickStarter.playerInput.runLock == PlayerMoveLock.AlwaysWalk)
            {
                doRun = false;
            }

            if (KickStarter.player)
            {
                if (button != null && !button.isBlocking && (button.playerAction == PlayerAction.WalkToMarker || button.playerAction == PlayerAction.WalkTo))
                {
                    KickStarter.stateHandler.gameState = GameState.Normal;
                    hotspotMovingTo = hotspot;
                }
                else
                {
                    if (button != null && button.playerAction != PlayerAction.DoNothing)
                    {
                        inPreInteractionCutscene = true;
                        KickStarter.stateHandler.gameState = GameState.Cutscene;
                    }
                    else
                    {
                        KickStarter.stateHandler.gameState = GameState.Normal;
                    }
                    hotspotMovingTo = null;
                }
            }

            Hotspot _hotspot = hotspot;
            if (KickStarter.player == null || inPreInteractionCutscene || (button != null && button.playerAction == PlayerAction.DoNothing))
            {
                DeselectHotspot ();
            }

            if (KickStarter.player)
            {
                if (button != null && button.playerAction != PlayerAction.DoNothing)
                {
                    Vector3 lookVector = Vector3.zero;
                    Vector3 targetPos = _hotspot.transform.position;

                    if (KickStarter.settingsManager.ActInScreenSpace ())
                    {
                        lookVector = AdvGame.GetScreenDirection (KickStarter.player.transform.position, _hotspot.transform.position);
                    }
                    else
                    {
                        lookVector = targetPos - KickStarter.player.transform.position;
                        lookVector.y = 0;
                    }

                    KickStarter.player.SetLookDirection (lookVector, false);

                    if (button.playerAction == PlayerAction.TurnToFace)
                    {
                        while (KickStarter.player.IsTurning ())
                        {
                            yield return new WaitForFixedUpdate ();
                        }
                    }

                    if (button.playerAction == PlayerAction.WalkToMarker && _hotspot.walkToMarker)
                    {
                        if (Vector3.Distance (KickStarter.player.transform.position, _hotspot.walkToMarker.transform.position) > KickStarter.settingsManager.GetDestinationThreshold ())
                        {
                            if (KickStarter.navigationManager)
                            {
                                Vector3[] pointArray;
                                Vector3 targetPosition = _hotspot.walkToMarker.transform.position;

                                if (KickStarter.settingsManager.ActInScreenSpace ())
                                {
                                    targetPosition = AdvGame.GetScreenNavMesh (targetPosition);
                                }

                                pointArray = KickStarter.navigationManager.navigationEngine.GetPointsArray (KickStarter.player.transform.position, targetPosition, KickStarter.player);
                                KickStarter.player.MoveAlongPoints (pointArray, doRun);
                                targetPos = pointArray [pointArray.Length - 1];
                            }

                            while (KickStarter.player.GetPath ())
                            {
                                if (doSnap)
                                {
                                    KickStarter.player.Teleport (targetPos);
                                    break;
                                }
                                yield return new WaitForFixedUpdate ();
                            }
                        }

                        if (button.faceAfter)
                        {
                            lookVector = _hotspot.walkToMarker.transform.forward;
                            lookVector.y = 0;
                            KickStarter.player.EndPath ();
                            KickStarter.player.SetLookDirection (lookVector, false);

                            while (KickStarter.player.IsTurning ())
                            {
                                if (doSnap)
                                {
                                    KickStarter.player.SetLookDirection (lookVector, true);
                                    break;
                                }
                                yield return new WaitForFixedUpdate ();
                            }
                        }
                    }

                    else if (button.playerAction == PlayerAction.WalkTo)
                    {
                        float dist = Vector3.Distance (KickStarter.player.transform.position, targetPos);
                        if (_hotspot.walkToMarker)
                        {
                            dist = Vector3.Distance (KickStarter.player.transform.position, _hotspot.walkToMarker.transform.position);
                        }

                        if ((button.setProximity && dist > button.proximity) ||
                            (!button.setProximity && dist > 2f))
                        {
                            if (KickStarter.navigationManager)
                            {
                                Vector3[] pointArray;
                                Vector3 targetPosition = _hotspot.transform.position;
                                if (_hotspot.walkToMarker)
                                {
                                    targetPosition = _hotspot.walkToMarker.transform.position;
                                }

                                if (KickStarter.settingsManager.ActInScreenSpace ())
                                {
                                    targetPosition = AdvGame.GetScreenNavMesh (targetPosition);
                                }

                                pointArray = KickStarter.navigationManager.navigationEngine.GetPointsArray (KickStarter.player.transform.position, targetPosition, KickStarter.player);
                                KickStarter.player.MoveAlongPoints (pointArray, doRun);
                                targetPos = pointArray [pointArray.Length - 1];
                            }

                            if (button.setProximity)
                            {
                                button.proximity = Mathf.Max (button.proximity, 1f);
                                targetPos.y = KickStarter.player.transform.position.y;

                                while (Vector3.Distance (KickStarter.player.transform.position, targetPos) > button.proximity && KickStarter.player.GetPath ())
                                {
                                    if (doSnap)
                                    {
                                        break;
                                    }
                                    yield return new WaitForFixedUpdate ();
                                }
                            }
                            else
                            {
                                if (!doSnap)
                                {
                                    yield return new WaitForSeconds (0.6f);
                                }
                            }
                        }

                        if (button.faceAfter)
                        {
                            if (KickStarter.settingsManager.ActInScreenSpace ())
                            {
                                lookVector = AdvGame.GetScreenDirection (KickStarter.player.transform.position, _hotspot.transform.position);
                            }
                            else
                            {
                                lookVector = _hotspot.transform.position - KickStarter.player.transform.position;
                                lookVector.y = 0;
                            }

                            KickStarter.player.EndPath ();
                            KickStarter.player.SetLookDirection (lookVector, false);

                            while (KickStarter.player.IsTurning ())
                            {
                                if (doSnap)
                                {
                                    KickStarter.player.SetLookDirection (lookVector, true);
                                }
                                yield return new WaitForFixedUpdate ();
                            }
                        }
                    }
                }
                else
                {
                    KickStarter.player.charState = CharState.Decelerate;
                }

                KickStarter.player.EndPath ();
                hotspotMovingTo = null;
            //	yield return new WaitForSeconds (0.1f);
            //	KickStarter.player.EndPath ();
                hotspotMovingTo = null;
            }

            DeselectHotspot ();
            inPreInteractionCutscene = false;
            KickStarter.playerMenus.SetInteractionMenus (false);

            if (KickStarter.player)
            {
                KickStarter.player.ClearHeadTurnTarget (false, HeadFacing.Hotspot);
            }

            if (button == null)
            {
                // Unhandled event
                if (selectedItemID >= 0 && KickStarter.runtimeInventory.GetItem (selectedItemID) != null && KickStarter.runtimeInventory.GetItem (selectedItemID).unhandledActionList)
                {
                    ActionListAsset unhandledActionList = KickStarter.runtimeInventory.GetItem (selectedItemID).unhandledActionList;
                    KickStarter.runtimeInventory.SetNull ();
                    AdvGame.RunActionListAsset (unhandledActionList);
                }
                else if (selectedItemID >= 0 && KickStarter.runtimeInventory.unhandledGive && KickStarter.runtimeInventory.IsGivingItem ())
                {
                    KickStarter.runtimeInventory.SetNull ();
                    AdvGame.RunActionListAsset (KickStarter.runtimeInventory.unhandledGive);
                }
                else if (selectedItemID >= 0 && KickStarter.runtimeInventory.unhandledHotspot && !KickStarter.runtimeInventory.IsGivingItem ())
                {
                    KickStarter.runtimeInventory.SetNull ();
                    AdvGame.RunActionListAsset (KickStarter.runtimeInventory.unhandledHotspot);
                }
                else
                {
                    KickStarter.stateHandler.gameState = GameState.Normal;
                    if (KickStarter.settingsManager.inventoryDragDrop)
                    {
                        KickStarter.runtimeInventory.SetNull ();
                    }
                }
            }
            else
            {
                KickStarter.runtimeInventory.SetNull ();

                if (_hotspot.interactionSource == InteractionSource.AssetFile)
                {
                    AdvGame.RunActionListAsset (button.assetFile);
                }
                else if (_hotspot.interactionSource == InteractionSource.CustomScript)
                {
                    if (button.customScriptObject != null && button.customScriptFunction != "")
                    {
                        button.customScriptObject.SendMessage (button.customScriptFunction);
                    }
                }
                else if (_hotspot.interactionSource == InteractionSource.InScene)
                {
                    if (button.interaction)
                    {
                        button.interaction.Interact ();
                    }
                    else
                    {
                        KickStarter.stateHandler.gameState = GameState.Normal;
                    }
                }
            }

            button = null;
        }
Beispiel #45
0
 public bool IsHotspotInTrigger(Hotspot hotspot)
 {
     if (hotspots.Contains (hotspot))
     {
         return true;
     }
     return false;
 }
        /**
         * <summary>Handles the clicking of a Hotspot, and runs the appropriate interaction based on the current cursor and inventory.</summary>
         * <param name = "_interactionType">The type of interaction to run (Use, Examine, Inventory)</param>
         * <param name = "selectedCursorID">The ID number of the current cursor, if _interactionType = InteractionType.Use</param>
         * <param name = "selectedItemID">The ID number of the current inventory item (see InvItem), if _interactionType = InteractionType.Inventory</param>
         * <param name = "clickedHotspot">The Hotspot that was clicked on</param>
         */
        public void ClickButton(InteractionType _interactionType, int selectedCursorID, int selectedItemID, Hotspot clickedHotspot = null)
        {
            inPreInteractionCutscene = false;
            StopCoroutine ("UseObject");

            if (clickedHotspot != null)
            {
                hotspot = clickedHotspot;
            }

            if (KickStarter.player)
            {
                KickStarter.player.EndPath ();
            }

            if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && KickStarter.settingsManager.selectInteractions == SelectInteractions.CyclingCursorAndClickingHotspot)
            {
                if (KickStarter.settingsManager.autoCycleWhenInteract)
                {
                    SetNextInteraction ();
                }
                else
                {
                    ResetInteractionIndex ();
                }
            }
            else if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot && KickStarter.settingsManager.autoCycleWhenInteract)
            {
                KickStarter.playerCursor.ResetSelectedCursor ();
            }

            KickStarter.playerInput.ResetMouseClick ();
            KickStarter.playerInput.ResetClick ();
            button = null;

            if (_interactionType == InteractionType.Use)
            {
                if (selectedCursorID == -1)
                {
                    button = hotspot.GetFirstUseButton ();
                }
                else
                {
                    foreach (Button _button in hotspot.useButtons)
                    {
                        if (_button.iconID == selectedCursorID && !_button.isDisabled)
                        {
                            button = _button;
                            break;
                        }
                    }

                    if (button == null && KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                    {
                        AdvGame.RunActionListAsset (KickStarter.cursorManager.GetUnhandledInteraction (selectedCursorID));
                        KickStarter.runtimeInventory.SetNull ();
                        KickStarter.player.ClearHeadTurnTarget (false, HeadFacing.Hotspot);
                        return;
                    }
                }
            }
            else if (_interactionType == InteractionType.Examine)
            {
                button = hotspot.lookButton;
            }
            else if (_interactionType == InteractionType.Inventory && selectedItemID >= 0)
            {
                foreach (Button invButton in hotspot.invButtons)
                {
                    if (invButton.invID == selectedItemID && !invButton.isDisabled)
                    {
                        if ((KickStarter.runtimeInventory.IsGivingItem () && invButton.selectItemMode == SelectItemMode.Give) ||
                            (!KickStarter.runtimeInventory.IsGivingItem () && invButton.selectItemMode == SelectItemMode.Use))
                        {
                            button = invButton;
                            break;
                        }
                    }
                }
            }

            if (button != null && button.isDisabled)
            {
                button = null;

                if (_interactionType != InteractionType.Inventory)
                {
                    KickStarter.player.ClearHeadTurnTarget (false, HeadFacing.Hotspot);
                    return;
                }
            }

            StartCoroutine ("UseObject", selectedItemID);
        }
 /**
  * Cancels the interaction process, that involves the Player prefab moving towards the Hotspot before the Interaction itself is run.
  */
 public void StopMovingToHotspot()
 {
     hotspotMovingTo = null;
     KickStarter.player.EndPath ();
     KickStarter.player.ClearHeadTurnTarget (false, HeadFacing.Hotspot);
     StopInteraction ();
 }
		override public void AssignValues ()
		{
			hotspot = AssignFile <Hotspot> (constantID, hotspot);
		}
Beispiel #49
0
        private void OnTriggerExit2D(Collider2D other)
        {
            if (other.GetComponent <Hotspot>())
            {
                Hotspot _hotspot = other.GetComponent <Hotspot>();

                if (nearestHotspot == _hotspot)
                {
                    nearestHotspot = null;
                }

                if (IsHotspotInTrigger (_hotspot))
                {
                    hotspots.Remove (_hotspot);
                }

                if (_hotspot.highlight != null)
                {
                    _hotspot.highlight.HighlightOff ();
                }
            }
        }
		private string ButtonStatesToString (Hotspot hotspot)
		{
			System.Text.StringBuilder stateString = new System.Text.StringBuilder ();
			
			if (AdvGame.GetReferences ().settingsManager == null || AdvGame.GetReferences ().settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
			{
				// Single-use and Look interaction
				if (hotspot.provideLookInteraction)
				{
					stateString.Append (GetButtonDisabledValue (hotspot.lookButton));
				}
				else
				{
					stateString.Append ("0");
				}
			}

			stateString.Append ("|");

			// Multi-use interactions
			if (hotspot.provideUseInteraction)
			{
				foreach (AC.Button button in hotspot.useButtons)
				{
					stateString.Append (GetButtonDisabledValue (button));
					
					if (hotspot.useButtons.IndexOf (button) < hotspot.useButtons.Count-1)
					{
						stateString.Append (",");
					}
				}
			}
				
			stateString.Append ("|");

			// Inventory interactions
			if (hotspot.provideInvInteraction)
			{
				foreach (AC.Button button in hotspot.invButtons)
				{
					stateString.Append (GetButtonDisabledValue (button));
					
					if (hotspot.invButtons.IndexOf (button) < hotspot.invButtons.Count-1)
					{
						stateString.Append (",");
					}
				}
			}
			
			return stateString.ToString ();
		}
		private void ContextSensitiveClick_Process (bool doubleTap, Hotspot newHotspot)
		{
			if (hotspot != null && newHotspot == null)
			{
				DisableHotspot (false);
			}
			else if (newHotspot != null)
			{
				if (playerInput.mouseState == MouseState.HeldDown && playerInput.dragState == DragState.Player)
				{
					// Disable hotspots while dragging player
					DisableHotspot (false); 
				}
				else if (newHotspot != hotspot)
				{
					DisableHotspot (false); 
					
					hotspot = newHotspot;
					hotspot.Select ();

					if (settingsManager.SelectInteractionMethod () == SelectInteractions.CyclingCursorAndClickingHotspot)
					{
						runtimeInventory.MatchInteractions ();

						if (settingsManager.autoCycleWhenInteract)
						{
							RestoreHotspotInteraction ();
						}
						else
						{
							ResetInteractionIndex ();
						}
					}
				}
				else if (hotspot != null && doubleTap)
				{
					// Still work if not clicking on the active Hotspot
					HandleInteraction ();
				}
			}
		}
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            if (AdvGame.GetReferences () && AdvGame.GetReferences ().settingsManager)
            {
                parameterID = Action.ChooseParameterGUI ("Hotspot to checl:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    hotspot = null;
                }
                else
                {
                    hotspot = (Hotspot) EditorGUILayout.ObjectField ("Hotspot to check:", hotspot, typeof (Hotspot), true);

                    constantID = FieldToID <Hotspot> (hotspot, constantID);
                    hotspot = IDToField <Hotspot> (hotspot, constantID, false);
                }

                interactionType = (InteractionType) EditorGUILayout.EnumPopup ("Interaction to check:", interactionType);

                if ((!isAssetFile && hotspot != null) || isAssetFile)
                {
                    if (interactionType == InteractionType.Use)
                    {
                        if (isAssetFile)
                        {
                            number = EditorGUILayout.IntField ("Use interaction:", number);
                        }
                        else if (AdvGame.GetReferences ().cursorManager)
                        {
                            // Multiple use interactions
                            List<string> labelList = new List<string>();

                            foreach (AC.Button button in hotspot.useButtons)
                            {
                                labelList.Add (hotspot.useButtons.IndexOf (button) + ": " + AdvGame.GetReferences ().cursorManager.GetLabelFromID (button.iconID, 0));
                            }

                            number = EditorGUILayout.Popup ("Use interaction:", number, labelList.ToArray ());
                        }
                        else
                        {
                            EditorGUILayout.HelpBox ("A Cursor Manager is required.", MessageType.Warning);
                        }
                    }
                    else if (interactionType == InteractionType.Inventory)
                    {
                        if (isAssetFile)
                        {
                            number = EditorGUILayout.IntField ("Inventory interaction:", number);
                        }
                        else if (AdvGame.GetReferences ().inventoryManager)
                        {
                            List<string> labelList = new List<string>();

                            foreach (AC.Button button in hotspot.invButtons)
                            {
                                labelList.Add (hotspot.invButtons.IndexOf (button) + ": " + AdvGame.GetReferences ().inventoryManager.GetLabel (button.invID));
                            }

                            number = EditorGUILayout.Popup ("Inventory interaction:", number, labelList.ToArray ());
                        }
                        else
                        {
                            EditorGUILayout.HelpBox ("An Inventory Manager is required.", MessageType.Warning);
                        }
                    }
                }
            }
            else
            {
                EditorGUILayout.HelpBox ("A Settings Manager is required for this Action.", MessageType.Warning);
            }

            AfterRunningOption ();
        }
 public override void AssignValues(List<ActionParameter> parameters)
 {
     hotspot = AssignFile <Hotspot> (parameters, parameterID, constantID, hotspot);
 }
		public void DisableHotspot (bool isInstant)
		{
			if (hotspot)
			{
				if (isInstant)
				{
					hotspot.DeselectInstant ();
				}
				else
				{
					hotspot.Deselect ();
				}
				hotspot = null;
			}
		}