コード例 #1
0
ファイル: DrawDungeonWall.cs プロジェクト: lavumi/DungeonRPG
        /// <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();
        }
コード例 #2
0
ファイル: EventProcessor.cs プロジェクト: lavumi/DungeonRPG
        /// <Summary>
        /// Returns that event parts condition is matched.
        /// </Summary>
        /// <param name="parts">The event parts to check the condition.</param>
        bool CheckEventPartsCondition(AriadneEventParts parts)
        {
            bool isMatched = false;

            switch (parts.startCondition)
            {
            case AriadneEventCondition.Flag:
                isMatched = FlagManager.CheckEventFlag(parts.startFlagName);
                break;

            case AriadneEventCondition.Item:
                isMatched = ItemManager.CheckEventConditionItem(parts.startItemId, parts.comparisonOperator, parts.startNum);
                break;

            case AriadneEventCondition.Money:
                isMatched = ItemManager.CheckEventConditionMoney(parts.comparisonOperator, parts.startNum);
                break;

            case AriadneEventCondition.NoCondition:
                isMatched = true;
                break;
            }
            return(isMatched);
        }