Beispiel #1
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 #2
0
        /// <Summary>
        /// Treasure box opening process.
        /// </Summary>
        /// <param name="treasureObj">The treasure box object to animate.</param>
        /// <param name="eventParts">The event parts data.</param>
        IEnumerator TreasureAnimation(GameObject treasureObj, AriadneEventParts eventParts)
        {
            // Get the TreasureAnimator component.
            TreasureAnimator treasureAnim = treasureObj.GetComponent <TreasureAnimator>();

            if (treasureAnim != null)
            {
                // Send treasure open message.
                treasureAnim.OpenTreasureBox();

                // Wait until the treasure box is opened.
                yield return(new WaitForSeconds(treasureAnimTime));

                // Show item message.
                SetTreasureItem(eventParts);
            }
            else
            {
                AnimatorWarning(treasureObj);
            }
        }