コード例 #1
0
        protected sealed override void PrepareProto()
        {
            if (this.Tier < TechConstants.MinTier)
            {
                throw new Exception(
                          $"Tier out of range: {this.Tier} - min tier is {TechConstants.MinTier}");
            }

            if (this.Tier > TechConstants.MaxTier)
            {
                throw new Exception(
                          $"Tier out of range: {this.Tier} - max tier is {TechConstants.MaxTier}");
            }

            this.AllNodes = FindProtoEntities <TechNode>()
                            .Where(n => n.Group == this)
                            .OrderBy(n => n.HierarchyLevel)
                            .ThenBy(n => n.Order)
                            .ThenBy(n => n.Name)
                            .ToList();

            var rootNodes = new List <TechNode>();

            foreach (var protoTechNode in this.AllNodes)
            {
                if (protoTechNode.RequiredNode == null)
                {
                    rootNodes.Add(protoTechNode);
                }
            }

            this.RootNodes = rootNodes;

            //if (this.AllNodes.Count == 0)
            //{
            //    throw new Exception("No nodes inside tech group");
            //}

            this.LearningPointsPrice = this.CalculateLearningPointsPrice();

            var requirements = new Requirements();

            this.PrepareTechGroup(requirements);
            if (this.LearningPointsPrice > 0)
            {
                requirements.Insert(0, new TechGroupRequirementLearningPoints(this.LearningPointsPrice));
            }

            this.GroupRequirements = requirements;
        }
コード例 #2
0
ファイル: TechGroup.cs プロジェクト: johndragon/CryoFall
        protected sealed override void PrepareProto()
        {
            if (this.Tier < TechConstants.MinTier)
            {
                throw new Exception(
                          $"Tier out of range: {this.Tier} - min tier is {TechConstants.MinTier}");
            }

            if (this.Tier > TechConstants.MaxTier)
            {
                throw new Exception(
                          $"Tier out of range: {this.Tier} - max tier is {TechConstants.MaxTier}");
            }

            this.SharedRebuildAllNodes();

            var rootNodes = new List <TechNode>();

            foreach (var protoTechNode in this.Nodes)
            {
                if (protoTechNode.RequiredNode == null)
                {
                    rootNodes.Add(protoTechNode);
                }
            }

            this.RootNodes           = rootNodes;
            this.LearningPointsPrice = this.CalculateLearningPointsPrice();

            var requirements = new Requirements();

            this.PrepareTechGroup(requirements);
            if (this.LearningPointsPrice > 0)
            {
                requirements.Insert(0, new TechGroupRequirementLearningPoints(this.LearningPointsPrice));
            }

            this.GroupRequirements = requirements;

            if (IsClient)
            {
                PveSystem.ClientIsPvEChanged += this.SharedRebuildAllNodes;
            }
        }
コード例 #3
0
        public void AddSibling()
        {
            {
                // Instanciate a new requirement
                RequirementModel requirementItem = new RequirementModel
                {
                    ID                 = Guid.NewGuid(),
                    Project_ID         = Globals.Project_ID,
                    ArticleNo          = "xxx",
                    ArticleHeader      = "New Article",
                    Version            = "",
                    IsChanged          = false,
                    IsNew              = true,
                    RequirementType_ID = TypeViewModelLocator.GetTypeVM().GetTypeGroupID("Requirement"),
                    ChildRequirements  = new TD.ObservableItemCollection <RequirementModel>()
                };

                // If no item has been selected, put the object in the root of the tree
                if (SelectedItem == null)
                {
                    requirementItem.Parent_ID = null;//
                    Requirements.Add(requirementItem);
                }
                // If the selected item is in the root, put the new object in the root also
                else if (SelectedItem.Parent_ID == null)
                {
                    requirementItem.Parent_ID = null;
                    Requirements.Insert(Requirements.IndexOf(SelectedItem) + 1, requirementItem);
                }
                // Otherwise het the parent object and add the new object as a child
                else
                {
                    RequirementModel parentItem = GetRequirement(SelectedItem.Parent_ID);
                    requirementItem.Parent_ID = SelectedItem.Parent_ID;
                    parentItem.ChildRequirements.Insert(parentItem.ChildRequirements.IndexOf(SelectedItem) + 1, requirementItem);
                }

                IsChanged = true;
            }
        }
コード例 #4
0
        public void MoveSelection(TreeListViewRow destination)
        {
            if (destination != null)
            {
                RequirementModel destinationItem = (destination.DataContext) as RequirementModel;
                try
                {
                    // Setup a private collection with the selected items only. This is because the SelectedItems that are part of the view model collection
                    // will change as soon as we start removing and adding objects
                    TD.ObservableItemCollection <RequirementModel> selectedItems = new TD.ObservableItemCollection <RequirementModel>();
                    foreach (RequirementModel item in SelectedItems)
                    {
                        selectedItems.Add(item);
                    }

                    foreach (RequirementModel item in selectedItems)
                    {
                        // find the original parent of the object that's moved
                        RequirementModel parentSourceItem = GetRequirement(item.Parent_ID);

                        // If the parent is in the root level
                        if (parentSourceItem == null)
                        {
                            // Remove the item in the root level
                            Requirements.Remove(item);
                        }
                        else
                        {
                            // Otherwise remove the item from the child collection
                            parentSourceItem.ChildRequirements.Remove(item);
                        }

                        TreeListViewDropPosition relativeDropPosition = (TreeListViewDropPosition)destination.GetValue(RadTreeListView.DropPositionProperty);

                        // If put on top of destination
                        if (relativeDropPosition == TreeListViewDropPosition.Inside)
                        {
                            // the Parent_ID of the item will become the ID of the destination
                            item.Parent_ID = destinationItem.ID;
                            destinationItem.ChildRequirements.Add(item);
                        }
                        // If put before or after the destination
                        else
                        {
                            // if the desitination is in the root collection
                            if (destinationItem.Parent_ID == null)
                            {
                                // The parent_ID of the item will also be null
                                item.Parent_ID = null;
                                Requirements.Insert(Requirements.IndexOf(destinationItem), item);
                            }
                            else
                            {
                                // otherwise the Parent_ID of the item will be the same as that of the destination item
                                item.Parent_ID = destinationItem.Parent_ID;
                                // find the Parent of the destination item
                                parentSourceItem = GetRequirement(destinationItem.Parent_ID);
                                // Insert the item above the destination item in the ChildObject collection of the parent of the destination
                                if (relativeDropPosition == TreeListViewDropPosition.Before)
                                {
                                    parentSourceItem.ChildRequirements.Insert(parentSourceItem.ChildRequirements.IndexOf(destinationItem), item);
                                }
                                else
                                {
                                    parentSourceItem.ChildRequirements.Insert(parentSourceItem.ChildRequirements.IndexOf(destinationItem) + 1, item);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    RadWindow.Alert(ex.Message);
                }
            }
        }
コード例 #5
0
ファイル: TechGroup.cs プロジェクト: jashking/CryoFall
        private static void SharedRebuildAllNodes()
        {
            if (Api.IsClient &&
                !PveSystem.ClientIsPveFlagReceived)
            {
                AvailableTechGroups = new TechGroup[0];
                return;
            }

            var isPvE = PveSystem.SharedIsPve(false);

            var allTechGroups = Api.FindProtoEntities <TechGroup>();

            foreach (var techGroup in allTechGroups)
            {
                SetupTimeGate(techGroup);

                techGroup.Nodes = techGroup.IsAvailable
                                      ? (IReadOnlyList <TechNode>)LazyAllNodesWithoutFiltering
                                  .Value
                                  .Where(n => n.Group == techGroup &&
                                         n.IsAvailable)
                                  .OrderBy(n => n.HierarchyLevel)
                                  .ThenBy(n => n.Order)
                                  .ThenBy(n => n.ShortId)
                                  .ToList()
                                      : new TechNode[0];

                var rootNodes = new List <TechNode>();
                foreach (var node in techGroup.Nodes)
                {
                    node.SharedResetCachedLearningPointsPrice();

                    if (node.IsRootNode)
                    {
                        rootNodes.Add(node);
                    }
                }

                techGroup.RootNodes = rootNodes;

                var requirements = new Requirements();
                techGroup.PrepareTechGroup(requirements);
                if (techGroup.LearningPointsPrice > 0)
                {
                    requirements.Insert(0, new TechGroupRequirementLearningPoints(techGroup.LearningPointsPrice));
                }

                if (!PveSystem.SharedIsPve(clientLogErrorIfDataIsNotYetAvailable: false) &&
                    techGroup.TimeGatePvP > 0)
                {
                    requirements.Add(new TechGroupRequirementTimeGate(techGroup.TimeGatePvP));
                }

                techGroup.GroupRequirements = requirements;

                Api.SafeInvoke(techGroup.NodesChanged);
            }

            AvailableTechGroups = allTechGroups.Where(t => t.IsAvailable).ToArray();
            Api.SafeInvoke(AvailableTechGroupsChanged);

            void SetupTimeGate(TechGroup techGroup)
            {
                if (isPvE)
                {
                    techGroup.TimeGatePvP = 0;
                    return;
                }

                if (techGroup.IsPrimary)
                {
                    techGroup.TimeGatePvP = techGroup.Tier switch
                    {
                        TechTier.Tier3 => TechConstants.PvpTechTimeGameTier3Basic,
                        TechTier.Tier4 => TechConstants.PvpTechTimeGameTier4Basic,
                        TechTier.Tier5 => TechConstants.PvpTechTimeGameTier5Basic,
                        _ => 0
                    };
                }
                else
                {
                    techGroup.TimeGatePvP = techGroup.Tier switch
                    {
                        TechTier.Tier3 => TechConstants.PvpTechTimeGameTier3Specialized,
                        TechTier.Tier4 => TechConstants.PvpTechTimeGameTier4Specialized,
                        TechTier.Tier5 => TechConstants.PvpTechTimeGameTier5Specialized,
                        _ => 0
                    };
                }
            }
        }