示例#1
0
        private static void UpdateGUIFrame(Item item, Character character)
        {
            if (frame == null)
            {
                return;
            }

            bool unfixedFound = false;

            foreach (GUIComponent child in frame.children)
            {
                FixRequirement requirement = child.UserData as FixRequirement;
                if (requirement == null)
                {
                    continue;
                }

                if (requirement.Fixed)
                {
                    child.Color = Color.LightGreen * 0.3f;
                    child.GetChild <GUITickBox>().Selected = true;
                }
                else
                {
                    bool canBeFixed = requirement.CanBeFixed(character, child);
                    unfixedFound = true;
                    //child.GetChild<GUITickBox>().Selected = canBeFixed;
                    GUITickBox tickBox = child.GetChild <GUITickBox>();
                    if (tickBox.Selected)
                    {
                        tickBox.Selected  = canBeFixed;
                        requirement.Fixed = canBeFixed;
                    }
                    child.Color = Color.Red * 0.2f;
                    //tickBox.State = GUIComponent.ComponentState.None;
                }
            }
            if (!unfixedFound)
            {
                item.Condition = 100.0f;
                frame          = null;
            }
        }
示例#2
0
        private static bool FixButtonPressed(GUIButton button, object obj)
        {
            FixRequirement requirement = obj as FixRequirement;

            if (requirement == null)
            {
                return(true);
            }

            Item item = frame.UserData as Item;

            if (item == null)
            {
                return(true);
            }

            if (!requirement.CanBeFixed(Character.Controlled, button.Parent))
            {
                return(true);
            }

            if (GameMain.Client != null)
            {
                GameMain.Client.CreateEntityEvent(item, new object[] { NetEntityEvent.Type.Repair, item.FixRequirements.IndexOf(requirement) });
            }
            else if (GameMain.Server != null)
            {
                GameMain.Server.CreateEntityEvent(item, new object[] { NetEntityEvent.Type.Status });
                requirement.Fixed = true;
            }
            else
            {
                requirement.Fixed = true;
            }

            return(true);
        }