Beispiel #1
0
        /// <Summary>
        /// Returns the flag that the event is executed.
        /// This method is called when the key is pressed.
        /// </Summary>
        /// <param name="eventData">Event data of the position.</param>
        /// <param name="targetPos">Target position.</param>
        /// <param name="eventStartPos">Starting position of the event defined in the event parts.</param>
        bool ExecuteEventOnKeyPressed(EventMasterData eventData, Vector2Int targetPos, AriadneEventPosition eventStartPos)
        {
            bool isEventExecute = false;

            fadeManager.FadeOutKeyWait();
            if (eventData == null)
            {
                return(isEventExecute);
            }

            AriadneEventParts parts = eventProcessor.GetExecutionEventParts(eventData);

            if (parts == null)
            {
                return(isEventExecute);
            }

            if (parts.eventPos != eventStartPos)
            {
                return(isEventExecute);
            }

            if (parts.eventTrigger == AriadneEventTrigger.KeyPress)
            {
                // Execute event.
                isEventExecute = true;
                SetEventTraverse(targetPos);
                this.isExecutingEvent = true;
                SetArrowButtonState(false);
                eventProcessor.EventExecuter(parts, targetPos);
            }
            return(isEventExecute);
        }
Beispiel #2
0
        /// <Summary>
        /// Get executed flag list from event data.
        /// </Summary>
        void GetExecutedFlagList()
        {
            List <string> flagNameList = new List <string>();

            string dataType = "EventMasterData";

            string[] guidArray = MapEditorUtil.GetGuidArray(dataType);

            foreach (string guid in guidArray)
            {
                string          path      = AssetDatabase.GUIDToAssetPath(guid);
                EventMasterData eventData = AssetDatabase.LoadAssetAtPath <EventMasterData>(path);
                if (eventData == null)
                {
                    continue;
                }

                if (eventData.eventParts == null)
                {
                    continue;
                }
                foreach (AriadneEventParts parts in eventData.eventParts)
                {
                    if (parts == null)
                    {
                        continue;
                    }
                    if (parts.hasExecutedFlag && parts.executedFlagName != "")
                    {
                        flagNameList.Add(parts.executedFlagName);
                    }
                }
            }
            flagNames = flagNameList.ToArray();
        }
Beispiel #3
0
        /// <Summary>
        /// Post process of the player moving.
        /// </Summary>
        void PostMove()
        {
            isExecutingEvent = false;
            isEventReady     = false;

            // Check an event ID of target position.
            Vector2Int      ps         = PlayerPosition.playerPos;
            EventMasterData eventData  = GetEventData(ps);
            bool            isExecuted = ExecuteEventOnPostMove(eventData, ps, AriadneEventPosition.ThisPosition);

            // Check an event ID of forward position
            bool isForwardEventExecuted = false;

            if (!isExecuted)
            {
                ps = PlayerPosition.GetForwardPosition(1);
                EventMasterData eventDataForward = GetEventData(ps);
                isForwardEventExecuted = ExecuteEventOnPostMove(eventDataForward, ps, AriadneEventPosition.OneStepShortOfThis);
            }

            // When no event has been executed, set true to the move flag.
            if (!isExecuted && !isForwardEventExecuted)
            {
                isMoveOk = true;
                fadeManager.InitializeWaitFlags();
            }
        }
Beispiel #4
0
        /// <Summary>
        /// Returns the event data of target position.
        /// </Summary>
        /// <param name="targetPos">Target position.</param>
        EventMasterData GetEventData(Vector2Int targetPos)
        {
            EventMasterData eventData = null;

            if (!CheckPositionIsValid(targetPos))
            {
                return(eventData);
            }
            int index            = targetPos.x + targetPos.y * floorMapData.floorSizeHorizontal;
            int targetPosEventId = floorMapData.mapInfo[index].eventId;

            if (targetPosEventId > 0)
            {
                string path = "EventData/event_" + targetPosEventId.ToString("D5");
                eventData = (EventMasterData)Resources.Load(path);
            }
            return(eventData);
        }
Beispiel #5
0
        /// <Summary>
        /// Set treasure box open state by checking event flags.
        /// When all flags in the event are true, open the treasure box.
        /// </Summary>
        /// <param name="treasureBoxObj">The treasure box object to instantiate.</param>
        /// <param name="index">Index of the position in MapInfo list.</param>
        void SetTreasureBoxState(GameObject treasureBoxObj, int index)
        {
            TreasureAnimator treasureAnim = treasureBoxObj.GetComponent <TreasureAnimator>();

            if (treasureAnim == null)
            {
                return;
            }

            EventMasterData eventData = null;
            int             eventId   = currentFloorMapData.mapInfo[index].eventId;

            if (eventId > 0)
            {
                string path = "EventData/event_" + eventId.ToString("D5");
                eventData = (EventMasterData)Resources.Load(path);
            }
            if (eventData == null)
            {
                return;
            }

            bool isOpend            = false;
            AriadneEventParts parts = null;

            for (int i = eventData.eventParts.Count - 1; i >= 0; i--)
            {
                parts = eventData.eventParts[i];
                if (parts == null)
                {
                    continue;
                }
                if (parts.hasExecutedFlag && !string.IsNullOrEmpty(parts.executedFlagName))
                {
                    isOpend = FlagManager.CheckEventFlag(parts.executedFlagName);
                }
            }
            if (!isOpend)
            {
                return;
            }

            treasureAnim.OpenTreasureBoxImmediately();
        }
Beispiel #6
0
        /// <Summary>
        /// Returns the event parts data that matched the condition.
        /// </Summary>
        /// <param name="eventData">The event data of target position.</param>
        public AriadneEventParts GetExecutionEventParts(EventMasterData eventData)
        {
            if (eventData.eventParts == null)
            {
                return(null);
            }

            AriadneEventParts parts = null;

            // Check the condition of event parts from last index.
            for (int i = eventData.eventParts.Count - 1; i >= 0; i--)
            {
                parts = eventData.eventParts[i];
                if (CheckEventPartsCondition(parts))
                {
                    break;
                }
            }
            return(parts);
        }
Beispiel #7
0
        /// <Summary>
        /// Search event data in the project and set it to the list.
        /// </Summary>
        void SetEventMasterDataList()
        {
            eventDataList = new List <EventMasterData>();

            string dataType = "EventMasterData";

            string[] guidArray = MapEditorUtil.GetGuidArray(dataType);

            foreach (string guid in guidArray)
            {
                string          path      = AssetDatabase.GUIDToAssetPath(guid);
                EventMasterData eventData = AssetDatabase.LoadAssetAtPath <EventMasterData>(path);
                if (eventData == null)
                {
                    continue;
                }
                if (eventData.eventId > 0)
                {
                    eventDataList.Add(eventData);
                }
            }
        }
Beispiel #8
0
        /// <Summary>
        /// Returns the flag that the event is executed.
        /// This method is called after the player has moved.
        /// </Summary>
        /// <param name="eventData">Event data of the position.</param>
        /// <param name="targetPos">Target position.</param>
        /// <param name="eventStartPos">Starting position of the event defined in the event parts.</param>
        bool ExecuteEventOnPostMove(EventMasterData eventData, Vector2Int targetPos, AriadneEventPosition eventStartPos)
        {
            bool isEventExecute = false;

            if (eventData == null)
            {
                return(isEventExecute);
            }

            AriadneEventParts parts = eventProcessor.GetExecutionEventParts(eventData);

            if (parts == null)
            {
                return(isEventExecute);
            }

            if (parts.eventPos != eventStartPos)
            {
                return(isEventExecute);
            }

            if (parts.eventTrigger == AriadneEventTrigger.Auto)
            {
                // Execute event immediately.
                isEventExecute = true;
                SetEventTraverse(targetPos);
                this.isExecutingEvent = true;
                InitializeButtonPressedState();
                SetArrowButtonState(false);
                eventProcessor.EventExecuter(parts, targetPos);
            }
            else
            {
                // Set key wait flag.
                this.isEventReady = true;
                fadeManager.FadeInKeyWait();
            }
            return(isEventExecute);
        }
Beispiel #9
0
        /// <Summary>
        /// Execute event when a key is pressed.
        /// </Summary>
        void OnEventKeyPressed()
        {
            // Check an event ID of target position.
            Vector2Int      ps         = PlayerPosition.playerPos;
            EventMasterData eventData  = GetEventData(ps);
            bool            isExecuted = ExecuteEventOnKeyPressed(eventData, ps, AriadneEventPosition.ThisPosition);

            // Check an event ID of forward position
            bool isForwardEventExecuted = false;

            if (!isExecuted)
            {
                ps = PlayerPosition.GetForwardPosition(1);
                EventMasterData eventDataForward = GetEventData(ps);
                isForwardEventExecuted = ExecuteEventOnKeyPressed(eventDataForward, ps, AriadneEventPosition.OneStepShortOfThis);
            }

            // When any event has not been executed, set true to the move flag.
            if (!isExecuted && !isForwardEventExecuted)
            {
                isMoveOk = true;
            }
        }