예제 #1
0
    private static bool CheckObjects(ScenarioAction action, GameObject go)
    {
        string[] array = action.m_EncodedContent.Split(new char[]
        {
            ':'
        });
        string     typeName = array[1];
        Type       type     = Type.GetType(typeName);
        MethodInfo method   = type.GetMethod(array[2]);

        ParameterInfo[] parameters = method.GetParameters();
        bool            result     = false;

        if (parameters.Length > 0)
        {
            Type   parameterType = parameters[0].ParameterType;
            string b             = array[3];
            if (parameterType.IsAssignableFrom(typeof(GameObject)) && go.name == b)
            {
                action.m_ParamO1 = go;
                result           = true;
            }
        }
        if (parameters.Length > 1)
        {
            Type   parameterType2 = parameters[1].ParameterType;
            string b2             = array[4];
            if (parameterType2.IsAssignableFrom(typeof(GameObject)) && go.name == b2)
            {
                action.m_ParamO2 = go;
                result           = true;
            }
        }
        return(result);
    }
예제 #2
0
    ScenarioAction GetScriptableObjectByName(ScenarioStep step)
    {
        ScenarioAction temp = null;

        foreach (var obj in actions)
        {
            if (obj.name == step.scriptableObjectName)
            {
                temp = Instantiate(obj) as ScenarioAction;
            }
        }
        foreach (var obj in helpactions)
        {
            if (obj.name == step.scriptableObjectName)
            {
                temp = Instantiate(obj) as ScenarioAction;
            }
        }
        foreach (var obj in states)
        {
            if (obj.name == step.scriptableObjectName)
            {
                temp = Instantiate(obj) as ScenarioAction;
            }
        }
        foreach (var obj in conditions)
        {
            if (obj.name == step.scriptableObjectName)
            {
                temp = Instantiate(obj) as ScenarioAction;
            }
        }

        return(temp);
    }
 public bool IsAvailableForUser(UserBase user, ScenarioStartupSource source, ScenarioAction action)
 {
     if (action > DenyAction)
     {
         return(true);
     }
     return(source != ScenarioStartupSource.SystemUI);
 }
 public bool IsAvailableForUser(UserBase user, ScenarioStartupSource source, ScenarioAction action)
 {
     if (action > DenyAction)
     {
         return(true);
     }
     if (user is SystemUser)
     {
         return(true);
     }
     return(UsersIds.Any(x => x.Equals(user.Id)));
 }
 public bool IsAvailableForUser(UserBase user, ScenarioStartupSource source, ScenarioAction action)
 {
     if (action > DenyAction)
     {
         return(true);
     }
     if (user is SystemUser)
     {
         return(true);
     }
     return(!GroupsIds.Any(x =>
                           Repository.Groups.First(g => g.Name.Equals(x))
                           .UsersIds.Any(z => z.Equals(user.Id))));
 }
예제 #6
0
    private void CreateConstruction()
    {
        Item item = null;

        item = ItemsManager.Get().CreateItem(this.m_ResultItemID, true, base.transform.position, base.transform.rotation);
        if (this.m_PlacingCondition == ConstructionGhost.GhostPlacingCondition.NeedFirecamp)
        {
            IFirecampAttach[] components = item.gameObject.GetComponents <IFirecampAttach>();
            foreach (IFirecampAttach firecampAttach in components)
            {
                firecampAttach.SetFirecamp(this.m_Firecamp);
            }
        }
        if (this.m_FirecampRacks.Count > 0 && ItemInfo.IsFirecamp(item.GetInfoID()))
        {
            foreach (FirecampRack firecampRack in this.m_FirecampRacks)
            {
                IFirecampAttach[] components2 = firecampRack.gameObject.GetComponents <IFirecampAttach>();
                foreach (IFirecampAttach firecampAttach2 in components2)
                {
                    firecampAttach2.SetFirecamp((Firecamp)item);
                }
            }
        }
        if (this.m_Smoker && ItemInfo.IsFirecamp(item.GetInfoID()))
        {
            IFirecampAttach[] components3 = this.m_Smoker.gameObject.GetComponents <IFirecampAttach>();
            foreach (IFirecampAttach firecampAttach3 in components3)
            {
                firecampAttach3.SetFirecamp((Firecamp)item);
            }
        }
        if (this.m_ConstructionObjectName.Length > 0)
        {
            item.gameObject.name = this.m_ConstructionObjectName;
        }
        ScenarioAction.OnItemCreated(item.gameObject);
        ScenarioCndTF.OnItemCreated(item.gameObject);
        EventsManager.OnEvent(Enums.Event.Build, 1, (int)this.m_ResultItemID);
        HUDMessages hudmessages = (HUDMessages)HUDManager.Get().GetHUD(typeof(HUDMessages));

        hudmessages.AddMessage(GreenHellGame.Instance.GetLocalization().Get(this.m_ResultItemID.ToString()) + " " + GreenHellGame.Instance.GetLocalization().Get("HUDConstruction_Created"), null, HUDMessageIcon.None, string.Empty);
        PlayerAudioModule.Get().PlayBuildCompletedSound();
        ItemsManager.Get().OnCreateItem(this.m_ResultItemID);
        item.SetLayer(item.transform, LayerMask.NameToLayer("Item"));
        foreach (IGhostObserver ghostObserver in this.m_Observers)
        {
            ghostObserver.OnCreateConstruction(this, item);
        }
    }
예제 #7
0
    public static void OnItemCreated(GameObject go)
    {
        int i = 0;

        while (i < ScenarioAction.s_NullObjects.Count)
        {
            if (ScenarioAction.CheckObjects(ScenarioAction.s_NullObjects[i], go))
            {
                ScenarioAction.s_NullObjects.RemoveAt(i);
            }
            else
            {
                i++;
            }
        }
    }
예제 #8
0
        IEnumerator StartActions()
        {
            yield return(new WaitForSeconds(startDelay));

            for (int i = 0; i < actions.Length; i++)
            {
                actions[i].Do();

                currentAction = actions[i];

                for (int sec = 0; sec < actions[i].maxTime; sec++)
                {
                    if (!currentAction.IsDoing())
                    {
                        break;
                    }

                    yield return(new WaitForSeconds(1));
                }
            }

            started = false;
        }
예제 #9
0
        /// <summary>
        /// Loads the specified project file into a ProjectFile object, optionally notifying
        /// the GUI to load the scenario file.
        /// </summary>
        public ProjectFile OpenProject(string filename, ScenarioAction action)
        {
            // TODO: Ensure that the file exists.
            StreamReader reader  = new StreamReader(new FileStream(filename, FileMode.Open));
            string       xmlText = reader.ReadToEnd();

            reader.Close();

            XmlDocument projectDoc = new XmlDocument();

            projectDoc.LoadXml(xmlText);

            // Setup the object and locate its GameDef/Template objects.
            ProjectFile    project  = new ProjectFile(projectDoc);
            Platform       platform = (Platform)Enum.Parse(typeof(Platform), project.GamePlatform);
            string         gameID   = GameDefinition.GetGameID(project.GameName, platform);
            GameDefinition def      = Prometheus.Instance.GetGameDefinitionByGameID(gameID);

            gameDefinition = def;
            foreach (ProjectTemplate template in def.ProjectTemplates)
            {
                if (template.Name == project.TemplateName)
                {
                    project.Template = template;
                }
            }

            // Locate the scenario tag.
            if (project.Templates.ContainsTemplateElement("Scenario"))
            {
                scenarioTag = project.Templates["Scenario"].Path;
            }
            else
            {
                throw new Exception("The project does not reference a scenario, which is a required element.");
            }

            // Open the DiskFileLibrary for the project.
            string          projectFolder = Path.GetDirectoryName(filename);
            DiskFileLibrary library       = new DiskFileLibrary(projectFolder + "\\Tags", project.MapName);

            // TODO: Decide which one of these is neccessary.
            project.ProjectFolder = library;
            this.projectFolder    = library;

            // Add the project to the list and register it with the Pool.
            this.filename       = filename;
            this.project        = project;
            this.project.Dirty += new EventHandler(project_Dirty);
            Prometheus.Instance.Pool.RegisterProject(def.Name, library);

            // Hey other code!  Guess what we just did!!!!!11
            OnOpenedProject();

            bool loadScenario = false;

            if (action == ScenarioAction.Load)
            {
                loadScenario = true;
            }
            else if (action == ScenarioAction.PromptUser)
            {
                CancelEventArgs e = new CancelEventArgs(false);
                if (ScenarioOpening != null)
                {
                    ScenarioOpening(this, e);
                }
                loadScenario = !e.Cancel;
            }

            if (loadScenario)
            {
                try
                {
                    TagPath path = new TagPath(project.Templates["Scenario"].Path, GameID, TagLocation.Project);
                    Prometheus.Instance.OnAddScene(path);
                }
                catch (TagAlreadyExistsException ex)
                {
                    Output.Write(OutputTypes.Warning, ex.Message);
                }
                catch (PoolException ex)
                {
                    Output.Write(OutputTypes.Warning, ex.Message);
                }
            }
            return(project);
        }
 public abstract bool IsAvailableForUser(UserBase user, ScenarioStartupSource source, ScenarioAction action);
        public ScenarioBase[] GetScenarios(UserBase user, ScenarioStartupSource source, ScenarioAction action, ValueTypeBase valueType = null, bool rightPart = false)
        {
            var actionSource = new ScenarioActionSource(user, source, ScenarioAction.ViewValue);

            return(Scenarios.Where(x =>
                                   (valueType == null || valueType.IsCompatibleWith(x.ValueType)) &&
                                   x.IsAccessAvailable(actionSource) &&
                                   (rightPart ? !(x.ValueType is ButtonValueType) : true))
                   .ToArray());
        }
 public ScenarioActionTests()
 {
     _underTest = new ScenarioAction(new Actor(), new TestAction());
 }
예제 #13
0
 public ScenarioActionSource(UserBase user, ScenarioStartupSource source, ScenarioAction action)
 {
     User   = user;
     Source = source;
     Action = action;
 }
예제 #14
0
 public ScenarioResult(ScenarioAction action, IScenario scenario = null)
 {
     Action   = action;
     Scenario = scenario;
 }
예제 #15
0
    public void Load()
    {
        while (InventoryBackpack.Get().m_Items.Count > 0)
        {
            InventoryBackpack.Get().RemoveItem(InventoryBackpack.Get().m_Items[0], false);
        }
        int i = 0;

        while (i < Item.s_AllItems.Count)
        {
            if (Item.s_AllItems[i] == null)
            {
                Item.s_AllItems.RemoveAt(i);
            }
            else
            {
                if (Item.s_AllItems[i].GetInfoID() != ItemID.Liane_ToHoldHarvest)
                {
                    UnityEngine.Object.Destroy(Item.s_AllItems[i].gameObject);
                }
                i++;
            }
        }
        Item.s_AllItems.Clear();
        this.m_ItemsToSetupAfterLoad.Clear();
        int num = SaveGame.LoadIVal("ItemsCount");

        for (int j = 0; j < num; j++)
        {
            ItemID item_id = (ItemID)SaveGame.LoadIVal("ItemID" + j);
            bool   flag    = SaveGame.LoadBVal("ItemIMReg" + j);
            Item   item    = this.CreateItem(item_id, false, Vector3.zero, Quaternion.identity);
            item.Load(j);
            if (flag)
            {
                item.ItemsManagerRegister(false);
            }
            this.m_ItemsToSetupAfterLoad.Add(item);
            ScenarioAction.OnItemCreated(item.gameObject);
            ScenarioCndTF.OnItemCreated(item.gameObject);
        }
        InventoryBackpack.Get().OnInventoryChanged();
        this.m_CreationsData.Clear();
        int num2 = SaveGame.LoadIVal("ItemCreationData");

        for (int k = 0; k < num2; k++)
        {
            ItemID key   = (ItemID)SaveGame.LoadIVal("ItemCreationDataID" + k);
            int    value = SaveGame.LoadIVal("ItemCreationDataCount" + k);
            this.m_CreationsData.Add((int)key, value);
        }
        this.m_CraftingLockedItems.Clear();
        int num3 = SaveGame.LoadIVal("CraftingLockedItems");

        for (int l = 0; l < num3; l++)
        {
            ItemID item2 = (ItemID)SaveGame.LoadIVal("CraftingLockedItem" + l);
            this.m_CraftingLockedItems.Add(item2);
        }
        this.m_WasConsumedData.Clear();
        num2 = SaveGame.LoadIVal("ItemWasConsumed");
        for (int m = 0; m < num2; m++)
        {
            this.m_WasConsumedData.Add((ItemID)SaveGame.LoadIVal("ItemWasConsumedID" + m));
        }
        this.m_WasCollectedData.Clear();
        num2 = SaveGame.LoadIVal("ItemWasCollected");
        for (int n = 0; n < num2; n++)
        {
            this.m_WasCollectedData.Add((ItemID)SaveGame.LoadIVal("ItemWasCollectedID" + n));
        }
        this.m_WasCraftedData.Clear();
        num2 = SaveGame.LoadIVal("ItemWasCrafted");
        for (int num4 = 0; num4 < num2; num4++)
        {
            this.m_WasCraftedData.Add((ItemID)SaveGame.LoadIVal("ItemWasCraftedID" + num4));
        }
        this.m_WasLiquidBoiledData.Clear();
        num2 = SaveGame.LoadIVal("WasLiquidBoiled");
        for (int num5 = 0; num5 < num2; num5++)
        {
            this.m_WasLiquidBoiledData.Add((LiquidType)SaveGame.LoadIVal("WasLiquidBoiledID" + num5));
        }
        ItemsManager.s_ItemUniqueID = SaveGame.LoadIVal("UniqueID");
        this.m_UnlockedInNotepadItems.Clear();
        int num6 = SaveGame.LoadIVal("UnlockedInNotepadItems");

        for (int num7 = 0; num7 < num6; num7++)
        {
            ItemID id = (ItemID)SaveGame.LoadIVal("UnlockedInNotepadItemID" + num7);
            this.UnlockItemInNotepad(id);
        }
    }
예제 #16
0
        public override bool IsAvailableForUser(UserBase user, ScenarioStartupSource source, ScenarioAction action)
        {
            if (source == ScenarioStartupSource.System)
            {
                return(true);
            }
            var result = true;

            foreach (var permission in Permissions)
            {
                result &= permission.IsAvailableForUser(user, source, action);
            }
            return(result);
        }