Example #1
0
 public Quest(string questId, string description, ActionRequirement requirement, InteractiveAction completion)
 {
     _questId     = questId;
     _description = description;
     _requirement = requirement;
     _completion  = completion;
 }
        private static void InitOpenDoorAction()
        {
            ActionRequirement openActionRequirement = (GameObject owner) =>
            {
                var doorway = owner.GetComponent <LockedDoorway>();

                if (PlayerInventory.Instance.GetItems().Any(item => item.ItemID == doorway.ItemToUnlock))
                {
                    return(true);
                }
                return(false);
            };

            InteractiveAction action = (GameObject obj) =>
            {
                var doorway = obj.GetComponent <LockedDoorway>();
                PlayerInventory.Instance.RemoveItemFromInventory(doorway.ItemToUnlock);
                ProcessBarController.StartProcessWithCompletion(3f, doorway.Action.ActionImage, () =>
                                                                doorway.gameObject.SetActive(false), Color.yellow);
            };

            var openDoorAction = new ActionBase(LockedDoorway.kOpenDoorActionId, openActionRequirement, action);

            _actions.Add(LockedDoorway.kOpenDoorActionId, openDoorAction);
        }
Example #3
0
        private void AddRequirementToolstripItem(object sender, EventArgs e)
        {
            HideAllDynamicMenus();
            HideAllContextMenus();
            ActionTemplateWrapper ATW = Data[contextDataNode.Parent.Name];
            TreeNode t = contextDataNode.Nodes.Add("NewRequirement");

            t.Name = Ids.Get().ToString();

            ActionRequirement RQ = new ActionRequirement();

            RQ.Requirement = "new requirement";
            RQ.amount      = 0;
            RQ.consume     = false;

            ActionRequirementWrapper RQW = new ActionRequirementWrapper();

            RQW.ActionRequirement = RQ;

            Requirements.Add(t.Name, RQW);
            List <ActionRequirement> tempList = new List <ActionRequirement>(ATW.ActionTemplate.Requirements);

            tempList.Add(RQ);
            ATW.ActionTemplate.Requirements = tempList.ToArray();
            ShowRQ(RQW);
        }
Example #4
0
 public ActionBase(string actionID, ActionRequirement requirement, InteractiveAction action)
 {
     _id          = actionID;
     _requirement = requirement;
     _action      = action;
     _actionImage = Resources.Load <Sprite> (kActionSpritesPath + actionID);
 }
Example #5
0
        private static IEnumerable <string> GetTechnologyRequirements(uint type, byte level, IStructureBaseStats trainer)
        {
            ActionRequirementFactory.ActionRecord record =
                kernel.Get <ActionRequirementFactory>().GetActionRequirementRecord(trainer.WorkerId);

            ActionRequirement foundAction =
                record.List.FirstOrDefault(
                    action =>
                    action.Type == ActionType.TechnologyUpgradeActive &&
                    ushort.Parse(action.Parms[0]) == type &&
                    ushort.Parse(action.Parms[1]) >= level);

            if (foundAction != null)
            {
                var requirements =
                    kernel.Get <EffectRequirementFactory>()
                    .GetEffectRequirementContainer(foundAction.EffectReqId);
                foreach (var requirement in requirements)
                {
                    if (requirement.WebsiteDescription != string.Empty)
                    {
                        yield return(requirement.WebsiteDescription);
                    }
                }
            }
        }
        public void Populate(ActionRequirementWrapper RQW)
        {
            ActionRequirement RQ = RQW.ActionRequirement;

            requirementBox.Text  = RQ.Requirement;
            amountNum.Value      = RQ.amount;
            consumeCheck.Checked = RQ.consume;
            workingData          = RQ;
        }
Example #7
0
        private static IEnumerable <string> GetStructureRequirements(ushort type, byte level, IStructureBaseStats builder)
        {
            ActionRequirementFactory.ActionRecord record =
                kernel.Get <ActionRequirementFactory>().GetActionRequirementRecord(builder.WorkerId);

            ActionRequirement foundAction = null;

            foreach (var action in record.List)
            {
                if (level == 1 && action.Type == ActionType.StructureBuildActive &&
                    ushort.Parse(action.Parms[0]) == type)
                {
                    foundAction = action;
                    break;
                }

                if (level == 1 && action.Type == ActionType.StructureChangeActive &&
                    ushort.Parse(action.Parms[0]) == type)
                {
                    foundAction = action;
                    break;
                }

                if (action.Type == ActionType.StructureUpgradeActive && byte.Parse(action.Parms[0]) >= level)
                {
                    foundAction = action;
                    break;
                }
            }

            if (foundAction != null)
            {
                var requirements =
                    kernel.Get <EffectRequirementFactory>()
                    .GetEffectRequirementContainer(foundAction.EffectReqId);
                foreach (var requirement in requirements)
                {
                    if (requirement.WebsiteDescription != string.Empty)
                    {
                        yield return(requirement.WebsiteDescription);
                    }
                }
            }
        }
        private static void InitDialogueAction()
        {
            ActionRequirement openActionRequirement = (GameObject owner) =>
            {
                return(true);
            };

            InteractiveAction action = (GameObject obj) =>
            {
                var trigger = obj.GetComponent <DialogTrigger>();

                var dialogue = DialogueStorage.GetDialogueByID(trigger.DialogueID);
                DialogueDisplayer.ShowDialogue(dialogue);
            };

            var dialogueAction = new ActionBase("action.id.dialogue", openActionRequirement, action);

            _actions.Add("action.id.dialogue", dialogueAction);
        }
Example #9
0
        private static void InitQuests()
        {
            ActionRequirement req = (GameObject owner) =>
            {
                var containsitem = PlayerInventory.Instance.GetItems().Count(i => i.ItemID == "genericitem.id.toybear") > 0;
                return(containsitem);
            };

            InteractiveAction action = (GameObject obj) =>
            {
                var dialogue = DialogueStorage.GetDialogueByID("dialogue.id.thanks");
                PlayerInventory.Instance.RemoveItemFromInventory("genericitem.id.toybear");

                DialogueDisplayer.ShowDialogue(dialogue);
            };

            var newQuest = new Quest("quest.id.gettovault", "Find your way to vault", req, action);

            _quests.Add(newQuest.ID, newQuest);
        }
        private static void InitHideAction()
        {
            ActionRequirement openActionRequirement = (GameObject owner) =>
            {
                return(!PlayerQuirks.Attacked);
            };

            InteractiveAction action = (GameObject obj) =>
            {
                var doorway = obj.GetComponent <Hideout>();

                ProcessBarController.StartProcessWithCompletion(1f, doorway.Action.ActionImage, () =>
                {
                    PlayerBehaviour.CurrentPlayer.Renderer.enabled = false;
                    PlayerQuirks.Hidden = true;
                }, Color.grey);
            };

            var openDoorAction = new ActionBase(Hideout.kHideAction, openActionRequirement, action);

            _actions.Add(Hideout.kHideAction, openDoorAction);
        }
Example #11
0
        private static void InitDragAction()
        {
            var undrag = new ActionBase("action.id.undrag", (GameObject obj) => { return(true); },
                                        (GameObject obj) => { RopeDragController.Unbind(obj);
                                                              PlayerQuirks.Drags = false; });

            ActionRequirement openActionRequirement = (GameObject owner) =>
            {
                return(PlayerInventory.Instance.GetItems().Any(i => i.ItemID == "genericitem.id.rope") && !PlayerQuirks.Drags);
            };
            InteractiveAction action = (GameObject obj) =>
            {
                ProcessBarController.StartProcessWithCompletion(3f * PlayerQuirks.GetSkill(EPlayerSkills.Hiding), Resources.Load <Sprite>("Sprites/Actions/action.id.drag"), () =>
                {
                    RopeDragController.Bind(obj);
                }, Color.yellow);
            };

            var drag = new ActionBase("action.id.drag", openActionRequirement, action);

            _actions.Add(drag.ActionID, drag);
            _actions.Add(undrag.ActionID, undrag);
        }
Example #12
0
    public ConversationAction(JSONNode actionJSON)
    {
        string JSONtype = actionJSON["action"];

        switch (JSONtype)
        {
        case "remove-item":
            type = ActionType.RemoveItem;
            break;

        case "add-item":
            type = ActionType.AddItem;
            break;

        case "replace-responses":
            type = ActionType.ReplaceResponses;
            break;

        case "walk-to":
            type = ActionType.WalkTo;
            break;

        case "run-conversation":
            type = ActionType.RunConversation;
            break;

        case "set-flag":
            type = ActionType.SetFlag;
            break;

        case "say":
            type = ActionType.Say;
            break;

        default:
            type = ActionType.AddItem;
            break;
        }

        objects = ConversationLoader.JSONToStringArray(actionJSON, "objects");

        var requirementsJSON = actionJSON["requirements"];

        if (requirementsJSON == null)
        {
            requirements = null;
        }
        else
        {
            requirements = new ActionRequirement[requirementsJSON.Count];
            for (int i = 0; i < requirementsJSON.Count; i++)
            {
                requirements[i] = new ActionRequirement(requirementsJSON[i]);
            }
        }

        var actionsJSON = actionJSON["actions"];

        if (actionsJSON == null)
        {
            nextActions = null;
        }
        else
        {
            nextActions = new ConversationAction[actionsJSON.Count];
            for (int i = 0; i < actionsJSON.Count; i++)
            {
                nextActions[i] = new ConversationAction(actionsJSON[i]);
            }
        }
    }
Example #13
0
        public void Init(string filename)
        {
            dict.Add(0, new ActionRecord {
                Id = 0, List = new List <ActionRequirement>()
            });

            using (var reader = new CsvReader(new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))))
            {
                String[] toks;

                var col = new Dictionary <string, int>();
                for (int i = 0; i < reader.Columns.Length; ++i)
                {
                    col.Add(reader.Columns[i], i);
                }

                while ((toks = reader.ReadRow()) != null)
                {
                    if (toks[0].Length <= 0)
                    {
                        continue;
                    }
                    int lvl   = int.Parse(toks[col["Level"]]);
                    int type  = int.Parse(toks[col["Type"]]);
                    int index = type * 100 + lvl;

                    if (dict.Any(x => x.Key > index && x.Key < type * 100 + 99))
                    {
                        throw new Exception("Action out of sequence, newer lvl is found!");
                    }

                    int lastLvl = dict.Keys.LastOrDefault(x => x <= index && x > type * 100);

                    ActionRecord record;
                    if (lastLvl == 0)
                    {
                        record = new ActionRecord {
                            List = new List <ActionRequirement>(), Id = index
                        };
                        dict[index] = record;
                    }
                    else if (lastLvl == index)
                    {
                        record = dict[index];
                    }
                    else
                    {
                        ActionRecord lastActionRecord = dict[lastLvl];
                        record = new ActionRecord {
                            List = new List <ActionRequirement>(), Id = index
                        };
                        record.List.AddRange(lastActionRecord.List);
                        dict[index] = record;
                    }

                    byte actionIndex;
                    if ((actionIndex = byte.Parse(toks[col["Index"]])) > 0)
                    {
                        // Create action and set basic options
                        ActionRequirement actionReq = new ActionRequirement
                        {
                            Index = actionIndex,
                            Type  = (ActionType)Enum.Parse(typeof(ActionType), (toks[col["Action"]] + "_active").ToCamelCase(), true),
                        };

                        // Set action options
                        if (toks[col["Option"]].Length > 0)
                        {
                            foreach (var opt in toks[col["Option"]].Split('|'))
                            {
                                actionReq.Option |= (ActionOption)Enum.Parse(typeof(ActionOption), opt, true);
                            }
                        }

                        // Set action params
                        actionReq.Parms = new string[5];
                        for (int i = 6; i < 11; ++i)
                        {
                            actionReq.Parms[i - 6] = toks[i].Contains("=") ? toks[i].Split('=')[1] : toks[i];
                        }

                        // Set effect requirements
                        uint effectReqId;
                        if (Config.actions_ignore_requirements)
                        {
                            actionReq.EffectReqId = 0;
                        }
                        else
                        {
                            actionReq.EffectReqId = uint.TryParse(toks[col["EffectReq"]], out effectReqId) ? effectReqId : 0;
                        }
                        if (toks[col["EffectReqInherit"]].Length > 0)
                        {
                            actionReq.EffectReqInherit = (EffectInheritance)Enum.Parse(typeof(EffectInheritance), toks[col["EffectReqInherit"]], true);
                        }
                        else
                        {
                            actionReq.EffectReqInherit = EffectInheritance.All;
                        }
                        if (record.List.Any(x => x.Index == actionIndex))
                        {
                            record.List.RemoveAll(x => x.Index == actionIndex);
                        }

                        record.List.Add(actionReq);
                    }
                }
            }
        }