Esempio n. 1
0
        public virtual void PrewarmAfterCreate()
        {
            BasePrecondition basePrecondition = ParsePrecondition(m_preconditionString);

            if (basePrecondition != null && basePrecondition is PartyCheckPrecondition && !(this is SetEnabledInteraction))
            {
                Int32 requiredTokenID = ((PartyCheckPrecondition)basePrecondition).RequiredTokenID;
                if (requiredTokenID > 0)
                {
                    LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.ANNOUNCE_NEEDED_TOKEN, new TokenEventArgs(requiredTokenID));
                }
            }
        }
Esempio n. 2
0
 public virtual void Execute()
 {
     m_precondition = ParsePrecondition(m_preconditionString);
     if (m_precondition != null)
     {
         m_stateMachine.ChangeState(1);
         LegacyLogic.Instance.EventManager.RegisterEvent(EEventType.PRECONDITION_EVALUATED, new EventHandler(Validate));
         m_precondition.Trigger();
     }
     else
     {
         StartExecution();
     }
 }
        private void UpdateName(InteractiveObject p_interactiveObject)
        {
            Boolean flag = false;
            IEnumerable <InteractiveObjectTooltipStaticData> iterator = StaticDataHandler.GetIterator <InteractiveObjectTooltipStaticData>(EDataType.INTERACTIVE_OBJECT_TOOLTIPS);
            KeyCode keyCode = KeyConfigManager.KeyBindings[EHotkeyType.INTERACT].Key1;

            if (keyCode == KeyCode.None)
            {
                keyCode = KeyConfigManager.KeyBindings[EHotkeyType.INTERACT].AltKey1;
            }
            String text = m_actionColorHex + "[" + LocaManager.GetText("OPTIONS_INPUT_KEYNAME_" + keyCode.ToString().ToUpper()) + "][-]";

            if (!String.IsNullOrEmpty(p_interactiveObject.Prefab))
            {
                String directoryName = Path.GetDirectoryName(p_interactiveObject.Prefab);
                foreach (InteractiveObjectTooltipStaticData interactiveObjectTooltipStaticData in iterator)
                {
                    if (interactiveObjectTooltipStaticData.PrefabFolder == directoryName || interactiveObjectTooltipStaticData.PrefabFolder == p_interactiveObject.Prefab)
                    {
                        m_label.text = LocaManager.GetText(interactiveObjectTooltipStaticData.LocaKey, text);
                        flag         = true;
                        break;
                    }
                }
            }
            if (p_interactiveObject is Button)
            {
                if (!flag)
                {
                    m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_BUTTON", text);
                }
                return;
            }
            if (p_interactiveObject is Lever)
            {
                if (!flag)
                {
                    m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_LEVER", text);
                }
                return;
            }
            if (!(p_interactiveObject is Barrel))
            {
                if (p_interactiveObject is Container)
                {
                    Container container = p_interactiveObject as Container;
                    if (!container.IsEmpty())
                    {
                        if (!flag)
                        {
                            m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_CONTAINER", text);
                        }
                    }
                    else
                    {
                        foreach (SpawnCommand spawnCommand in container.Commands)
                        {
                            if (spawnCommand.Type == EInteraction.CHANGE_ATTRIBUTE)
                            {
                                m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_CONTAINER", text);
                                return;
                            }
                        }
                        m_label.text = String.Empty;
                    }
                    return;
                }
                if (p_interactiveObject is Door)
                {
                    if (LegacyLogic.Instance.WorldManager.Party.SelectedInteractiveObject == null || p_interactiveObject.IsSecret)
                    {
                        m_label.text = String.Empty;
                        return;
                    }
                    if (((Door)p_interactiveObject).State == EInteractiveObjectState.DOOR_OPEN)
                    {
                        m_label.text = String.Empty;
                    }
                    else
                    {
                        m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_DOOR", text);
                    }
                    return;
                }
                else
                {
                    if (p_interactiveObject is Sign)
                    {
                        if (!flag)
                        {
                            m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_SIGN", text);
                        }
                        return;
                    }
                    if (p_interactiveObject is Entrance)
                    {
                        if (flag)
                        {
                            return;
                        }
                        Entrance entrance = (Entrance)p_interactiveObject;
                        String   text2    = entrance.MinimapTooltipLocaKey;
                        if (!String.IsNullOrEmpty(text2))
                        {
                            text2        = LocaManager.GetText(entrance.MinimapTooltipLocaKey);
                            m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_ENTRANCE", text, text2);
                            return;
                        }
                        text2 = null;
                        foreach (SpawnCommand spawnCommand2 in entrance.Commands)
                        {
                            if (spawnCommand2.Type == EInteraction.USE_ENTRANCE)
                            {
                                String[] array = spawnCommand2.Extra.Split(new Char[]
                                {
                                    ','
                                });
                                text2 = array[0].Replace(".xml", String.Empty);
                                break;
                            }
                        }
                        if (text2 != null)
                        {
                            GridInfo gridInfo = LegacyLogic.Instance.MapLoader.FindGridInfo(text2);
                            if (gridInfo != null)
                            {
                                text2 = LocaManager.GetText(gridInfo.LocationLocaName);
                                if (LegacyLogic.Instance.MapLoader.Grid.Type == EMapType.DUNGEON)
                                {
                                    text2 = text2.Replace("@", ", ");
                                }
                                else if (text2.LastIndexOf('@') != -1)
                                {
                                    text2 = text2.Remove(text2.LastIndexOf('@'));
                                }
                                m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_ENTRANCE", text, text2);
                                return;
                            }
                            Debug.LogError("Grid Info not found " + text2);
                        }
                    }
                    else if (p_interactiveObject is NpcContainer)
                    {
                        NpcContainer npcContainer = (NpcContainer)p_interactiveObject;
                        if (!npcContainer.IsEnabled)
                        {
                            m_label.text = String.Empty;
                            return;
                        }
                        String minimapTooltipLocaKey = npcContainer.MinimapTooltipLocaKey;
                        if (!String.IsNullOrEmpty(npcContainer.IndoorScene))
                        {
                            if (!String.IsNullOrEmpty(minimapTooltipLocaKey))
                            {
                                String text3 = LocaManager.GetText(minimapTooltipLocaKey);
                                m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_BUILDING_DEFAULT", text, text3);
                                return;
                            }
                            foreach (InteractiveObjectTooltipStaticData interactiveObjectTooltipStaticData2 in iterator)
                            {
                                if (interactiveObjectTooltipStaticData2.PrefabFolder == npcContainer.IndoorScene)
                                {
                                    m_label.text = LocaManager.GetText(interactiveObjectTooltipStaticData2.LocaKey, text);
                                    return;
                                }
                            }
                            m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_INDOOR_CONTEXT", text);
                            return;
                        }
                        else
                        {
                            if (!npcContainer.Npcs[0].IsEnabled)
                            {
                                m_label.text = String.Empty;
                                return;
                            }
                            foreach (SpawnCommand spawnCommand3 in npcContainer.Commands)
                            {
                                if (spawnCommand3.Type == EInteraction.START_DEFINED_DIALOG && !String.IsNullOrEmpty(spawnCommand3.Precondition) && spawnCommand3.Precondition.StartsWith("PARTY_CHECK"))
                                {
                                    BasePrecondition basePrecondition = BaseInteraction.ParsePrecondition(spawnCommand3.Precondition);
                                    if (basePrecondition is PartyCheckPrecondition && !((PartyCheckPrecondition)basePrecondition).Evaluate())
                                    {
                                        m_label.text = String.Empty;
                                        return;
                                    }
                                }
                            }
                            if (flag)
                            {
                                return;
                            }
                            if (!String.IsNullOrEmpty(minimapTooltipLocaKey))
                            {
                                m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_NPC", text, minimapTooltipLocaKey);
                                return;
                            }
                            if (npcContainer.Npcs[0].StaticID != 224 && npcContainer.Npcs[0].StaticID != 225)
                            {
                                String text4 = LocaManager.GetText(npcContainer.Npcs[0].StaticData.NameKey);
                                m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_NPC", text, text4);
                                return;
                            }
                        }
                    }
                    else if (p_interactiveObject is RechargingObject)
                    {
                        RechargingObject rechargingObject = (RechargingObject)p_interactiveObject;
                        if (rechargingObject.IsFountain())
                        {
                            m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_FOUNTAIN", text);
                        }
                        else if (rechargingObject.IsCrystal())
                        {
                            m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_CRYSTAL", text);
                        }
                        else
                        {
                            m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_STATUE", text);
                        }
                        return;
                    }
                    m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_FALLBACK", text);
                }
                return;
            }
            Barrel barrel = p_interactiveObject as Barrel;

            if (barrel.State == EInteractiveObjectState.BARREL_EMPTY)
            {
                m_label.text = String.Empty;
                return;
            }
            if (barrel.State == EInteractiveObjectState.BARREL_OPEN)
            {
                m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_FALLBACK", text);
                return;
            }
            m_label.text = LocaManager.GetText("INTERACT_TOOLTIP_BARREL", text);
        }
Esempio n. 4
0
        protected internal static BasePrecondition ParsePrecondition(String p_precondition)
        {
            if (p_precondition == "NONE" || p_precondition == String.Empty)
            {
                return(null);
            }
            String[] array = p_precondition.Split(new Char[]
            {
                ','
            });
            if (array[0] == "NONE")
            {
                return(null);
            }
            BasePrecondition      basePrecondition      = null;
            String                maintext              = String.Empty;
            String                successText           = String.Empty;
            String                failText              = String.Empty;
            String                text                  = String.Empty;
            EPotionTarget         attribute             = EPotionTarget.NONE;
            Int32                 requiredValue         = 0;
            EPreconditionDecision epreconditionDecision = (EPreconditionDecision)Enum.Parse(typeof(EPreconditionDecision), array[1]);

            maintext = array[2];
            if (epreconditionDecision == EPreconditionDecision.TEXT_INPUT && array.Length > 5)
            {
                text = array[5];
            }
            if (epreconditionDecision == EPreconditionDecision.WHO_WILL && array.Length > 5)
            {
                attribute     = (EPotionTarget)Enum.Parse(typeof(EPotionTarget), array[5]);
                requiredValue = Convert.ToInt32(array[6]);
            }
            if (array[0] == "PLAIN")
            {
                basePrecondition = new PlainPrecondition();
            }
            else
            {
                successText = array[3];
                failText    = array[4];
            }
            if (array[0] == "SELECT_CHARACTER")
            {
                basePrecondition = new SelectCharacterPrecondition();
            }
            if (array[0] == "TEST")
            {
                if (array.Length != 7)
                {
                    throw new FormatException(String.Concat(new Object[]
                    {
                        "Could not parse precondition params ",
                        p_precondition,
                        " because it contains ",
                        array.Length,
                        " arguments instead of ",
                        7
                    }));
                }
                basePrecondition = new TestPrecondition
                {
                    Attribute     = attribute,
                    RequiredValue = requiredValue,
                    SuccessText   = successText,
                    FailText      = failText
                };
            }
            if (array[0] == "CHALLENGE")
            {
                if (array.Length != 8 && array.Length != 7)
                {
                    throw new FormatException(String.Concat(new Object[]
                    {
                        "Could not parse precondition params ",
                        p_precondition,
                        " because it contains ",
                        array.Length,
                        " arguments instead of ",
                        8
                    }));
                }
                if (array.Length == 8)
                {
                    basePrecondition = new ChallengePrecondition
                    {
                        Attribute     = attribute,
                        RequiredValue = requiredValue,
                        SuccessText   = successText,
                        FailText      = failText,
                        Damage        = Convert.ToInt32(array[7])
                    };
                }
                else
                {
                    basePrecondition = new ChallengePrecondition
                    {
                        Attribute     = attribute,
                        RequiredValue = requiredValue,
                        SuccessText   = successText,
                        FailText      = failText,
                        Damage        = 0
                    };
                }
            }
            if (array[0] == "SECRET_CHALLENGE")
            {
                if (array.Length != 8)
                {
                    throw new FormatException(String.Concat(new Object[]
                    {
                        "Could not parse precondition params ",
                        p_precondition,
                        " because it contains ",
                        array.Length,
                        " arguments instead of ",
                        8
                    }));
                }
                basePrecondition = new SecretChallengePrecondition
                {
                    Attribute     = attribute,
                    RequiredValue = requiredValue,
                    SuccessText   = successText,
                    FailText      = failText,
                    Damage        = Convert.ToInt32(array[7])
                };
            }
            if (array[0] == "DISARM_TRAP")
            {
                if (array.Length != 7)
                {
                    throw new FormatException(String.Concat(new Object[]
                    {
                        "Could not parse precondition params ",
                        p_precondition,
                        " because it contains ",
                        array.Length,
                        " arguments instead of ",
                        7
                    }));
                }
                basePrecondition = new DisarmTrapPrecondition
                {
                    Attribute     = attribute,
                    RequiredValue = requiredValue,
                    SuccessText   = successText,
                    FailText      = failText
                };
            }
            if (array[0] == "INPUT")
            {
                if (array.Length != 6)
                {
                    throw new FormatException(String.Concat(new Object[]
                    {
                        "Could not parse precondition params ",
                        p_precondition,
                        " because it contains ",
                        array.Length,
                        " arguments instead of ",
                        6
                    }));
                }
                basePrecondition = new InputPrecondition
                {
                    WantedInput = text,
                    SuccessText = successText,
                    FailText    = failText
                };
            }
            if (array[0] == "UNLOCK_KEY")
            {
                if (array.Length != 6)
                {
                    throw new FormatException(String.Concat(new Object[]
                    {
                        "Could not parse precondition params ",
                        p_precondition,
                        " because it contains ",
                        array.Length,
                        " arguments instead of ",
                        6
                    }));
                }
                Int32 wantedPrivilege = 0;
                if (text != String.Empty)
                {
                    wantedPrivilege = Int32.Parse(text, CultureInfo.InvariantCulture.NumberFormat);
                }
                basePrecondition = new UnlockKeyPrecondition
                {
                    WantedPrivilege = wantedPrivilege,
                    SuccessText     = successText,
                    FailText        = failText
                };
            }
            if (array[0] == "PARTY_CHECK")
            {
                if (array.Length != 13 && array.Length != 10 && array.Length != 9 && array.Length != 8)
                {
                    throw new FormatException(String.Concat(new Object[]
                    {
                        "Could not parse precondition params ",
                        p_precondition,
                        " because it contains ",
                        array.Length,
                        " arguments instead of ",
                        13
                    }));
                }
                if (array.Length > 5)
                {
                    basePrecondition = new PartyCheckPrecondition
                    {
                        SuccessText               = successText,
                        FailText                  = failText,
                        RequiredTokenID           = Convert.ToInt32(array[5]),
                        RequiredBlessingID        = Convert.ToInt32(array[6]),
                        RequiredActiveQuestStepID = Convert.ToInt32(array[7])
                    };
                    if (array.Length > 8)
                    {
                        ((PartyCheckPrecondition)basePrecondition).RequiredFinishedQuestStepID = Convert.ToInt32(array[8]);
                    }
                    if (array.Length > 9)
                    {
                        ((PartyCheckPrecondition)basePrecondition).RequiredHirelingID = Convert.ToInt32(array[9]);
                    }
                    if (array.Length > 12)
                    {
                        ((PartyCheckPrecondition)basePrecondition).RequiredInactiveQuestStepID = Convert.ToInt32(array[10]);
                        ((PartyCheckPrecondition)basePrecondition).WithoutHirelingID           = Convert.ToInt32(array[11]);
                        ((PartyCheckPrecondition)basePrecondition).WithoutTokenID = Convert.ToInt32(array[12]);
                    }
                }
                else
                {
                    basePrecondition = new PartyCheckPrecondition
                    {
                        SuccessText = successText,
                        FailText    = failText
                    };
                }
            }
            basePrecondition.Decision = epreconditionDecision;
            basePrecondition.Maintext = maintext;
            return(basePrecondition);
        }
Esempio n. 5
0
 public PreconditionGUIEventArgs(BasePrecondition p_condition)
 {
     m_condition = p_condition;
 }