コード例 #1
0
 public EditNodeWindow(Sidebar sidebar, Group group)
     : this(sidebar, ViewType.Group)
 {
     titlePanelEditNode.lblTitle.Text = "Edit Group";
     lblName.Text = "Group Name:";
     txtName.Text = group.Name;
 }
コード例 #2
0
 public LevelSave(Group group, int levelWidth, int levelHeight, string name)
 {
     Diodes = new List<DiodeData>();
     foreach (var n in group.room.masterGroup.fullSet)
     {
         if (n.HasComp<Diode>())
         {
             Diodes.Add(new DiodeData(n.Comp<Diode>()));
         }
     }
     this.levelHeight = levelHeight;
     this.levelWidth = levelWidth;
     this.name = name;
     polygonVertices = new List<float[]>();
     polygonPositions = new List<float[]>();
     foreach(Node n in group.fullSet)
     {
         if (n.body.shape is Polygon)
         {
             Polygon p = (Polygon)n.body.shape;
             float[] verts = new float[p.vertexCount * 2];
             for(int i = 0; i < p.vertexCount; i++)
             {
                 verts[i * 2] = p.vertices[i].X;
                 verts[(i * 2) + 1] = p.vertices[i].Y;
             }
             polygonVertices.Add(verts);
             polygonPositions.Add(new float[]{n.body.pos.X, n.body.pos.Y});
             //cover angle?
         }
     }
 }
コード例 #3
0
        //, Control under)
        public LoadLevelWindow(Sidebar sidebar)
        {
            previouslyPaused = sidebar.ui.IsPaused;
            sidebar.ui.IsPaused = true;
            sidebar.master.Visible = false;
            Control par = sidebar.tbcViews.TabPages[0];
            UserInterface.GameInputDisabled = true;
            this.manager = sidebar.manager;
            this.sidebar = sidebar;
            tomShaneSidebar = new TomShaneSidebar(manager);
            tomShaneSidebar.Init();
            tomShaneSidebar.Left = sidebar.master.Left;
            tomShaneSidebar.Width = par.Width;
            tomShaneSidebar.Top = 20;
            tomShaneSidebar.Height = par.Height + 15;
            tomShaneSidebar.BevelBorder = BevelBorder.All;
            tomShaneSidebar.BevelColor = Color.Black;
            tomShaneSidebar.Left = LeftPadding;
            tomShaneSidebar.Text = "Load Level";
            tomShaneSidebar.BackColor = new Color(30, 60, 30);
            manager.Add(tomShaneSidebar);

            wallGroup = sidebar.room.groups.walls;
            foreach(Node n in wallGroup.entities)
            {
                previousWallNodes.Add(n);
            }

            TitlePanel titlePanelAddComponent = new TitlePanel(sidebar, tomShaneSidebar, "Load Level", false);
            //titlePanelAddComponent.btnBack.Click += Close;
            HeightCounter += titlePanelAddComponent.Height;

            normalView = new NormalView(sidebar, tomShaneSidebar, 0, 100, Height: 350);
            normalView.Width -= 15;
            PopulateLevelSaves();

            normalView.OnSelectionChanged += normalView_OnSelectionChanged;

            btnLoad = new Button(manager);
            btnLoad.Init();
            tomShaneSidebar.Add(btnLoad);
            btnLoad.Text = "Load";
            btnLoad.Top = 500;
            btnLoad.Left = LeftPadding * 4;
            btnLoad.Width = 70;
            btnLoad.Click += btnLoad_Click;

            btnCancel = new Button(manager);
            btnCancel.Init();
            tomShaneSidebar.Add(btnCancel);
            btnCancel.Text = "Cancel";
            btnCancel.Top = 500;
            btnCancel.Left = btnLoad.Left + btnLoad.Width + 50;
            btnCancel.Width = 70;
            btnCancel.Click += btnCancel_Click;
        }
コード例 #4
0
        public Group(Room room, Node defaultNode = null, Group parentGroup = null, string Name = "", bool Spawnable = true, ObservableHashSet<Node> entities = null)
        {
            if (parentGroup != null) room = parentGroup.room;
            this.room = room ?? OrbIt.game.room;

            GroupId = -1;
            this.defaultNode = defaultNode ?? this.room.defaultNode;
            this.entities = entities ?? new ObservableHashSet<Node>();
            this.inherited = new ObservableHashSet<Node>();
            this.fullSet = new ObservableHashSet<Node>();
            if (entities != null)
            {
                foreach (Node e in entities)
                {
                    fullSet.Add(e);
                }
            }
            this.parentGroup = parentGroup;
            //this.groupState = groupState;
            this.Spawnable = Spawnable;
            this.childGroups = new Dictionary<string, Group>();
            this.entities.CollectionChanged += entities_CollectionChanged;
            this.inherited.CollectionChanged += entities_CollectionChanged;

            if (Name.Equals(""))
            {
                this.GroupId = GroupNumber;
                Name = "Group" + GroupNumber; //maybe a check that the name is unique
                GroupNumber++;
            }
            this.Name = Name;

            groupPath = new List<Group>();

            if (parentGroup != null)
            {
                parentGroup.AddGroup(this.Name, this);
                Group g = parentGroup;

                while (g != null)
                {
                    groupPath.Add(g);
                    g = g.parentGroup;
                }
            }
        }
コード例 #5
0
        public PlayerView(Sidebar sidebar, Control parent, int Left, int Top)
            : base(sidebar, parent, Left, Top, false)
        {
            playerGroup = sidebar.room.groups.player;

            btnEditAllPlayers = new Button(manager);
            btnEditAllPlayers.Init();
            btnEditAllPlayers.Parent = parent;
            btnEditAllPlayers.Text = "Edit All Players";
            btnEditAllPlayers.Width = 150;
            btnEditAllPlayers.Left = parent.Width / 2 - btnEditAllPlayers.Width / 2;
            btnEditAllPlayers.Top = Top + VertPadding * 2;
            HeightCounter +=  btnEditAllPlayers.Height * 2;
            btnEditAllPlayers.Click += (s, e) =>
            {
                editGroupWindow = new EditNodeWindow(sidebar, "All Players", room.groups.player.Name, ViewType.Group);
                editGroupWindow.componentView.SwitchGroup(room.groups.player);
                //editGroupWindow.componentView.SwitchNode(n, false);

            };

            lblPlayers = new Label(manager);
            lblPlayers.Init();
            lblPlayers.Parent = parent;
            lblPlayers.Text = "Players";
            lblPlayers.Width = 150;
            lblPlayers.Left = LeftPadding;
            lblPlayers.TextColor = Color.Black;
            lblPlayers.Top = HeightCounter;
            HeightCounter += lblPlayers.Height + VertPadding;
            Width = parent.Width - LeftPadding * 4;

            base.Initialize();

            insView = new InspectorView(sidebar, parent, Left, HeightCounter);
            insView.GroupSync = true;
            insView.Height = 120;
            insView.Width = Width;
            this.ItemCreator += ItemCreatorDelegate;

            InitializePlayers();
        }
コード例 #6
0
        public void AssignColor(Group activegroup, Node newNode)
        {
            if (Group.IntToColor.ContainsKey(activegroup.GroupId))
            {
                newNode.body.color = Group.IntToColor[activegroup.GroupId];
            }
            else
            {
                int Enumsize = Enum.GetValues(typeof(System.Drawing.KnownColor)).Length;

                //int rand = Utils.random.Next(size - 1);
                int index = 0;
                foreach (char c in activegroup.Name.ToCharArray().ToList())
                {
                    index += (int)c;
                }
                index = index % (Enumsize - 1);

                System.Drawing.Color syscolor = System.Drawing.Color.FromKnownColor((System.Drawing.KnownColor)index);
                Color xnacol = new Color(syscolor.R, syscolor.G, syscolor.B, syscolor.A);
                newNode.body.color = xnacol;
            }
        }
コード例 #7
0
 public void MakePresetGroups()
 {
     var infos = Component.compInfos;
     int runenum = 0;
     foreach(Type t in infos.Keys)
     {
         Info info = infos[t];
         if ((info.compType & mtypes.essential) == mtypes.essential) continue;
         if ((info.compType & mtypes.exclusiveLinker) == mtypes.exclusiveLinker) continue;
         if ((info.compType & mtypes.item) == mtypes.item) continue;
         if (info.userLevel == UserLevel.Developer || info.userLevel == UserLevel.Advanced) continue;
         if (t == typeof(Lifetime)) continue;
         if (t == typeof(Rune)) continue;
         Node nodeDef = defaultNode.CreateClone(this);
         nodeDef.SetColor(Utils.randomColor());
         nodeDef.addComponent(t, true);
         nodeDef.addComponent(typeof(Rune), true);
         nodeDef.Comp<Rune>().runeTexture = (textures)runenum++;
         Group presetgroup = new Group(this, nodeDef, groups.preset, t.ToString().LastWord('.') + " Group");
     }
 }
コード例 #8
0
        public static void SaveLevel(Group group, int levelWidth, int levelHeight, string name)
        {
            if (name.Equals("")) return;
            name = name.Trim();
            //string filename = "Presets//Nodes//" + name + ".xml";
            string filename = Assets.levelsFilepath + "/" + name + ".xml";
            Action completeSave = delegate
            {
                LevelSave levelSave = new LevelSave(group, levelWidth, levelHeight, name);
                OrbIt.game.serializer = new Polenter.Serialization.SharpSerializer();
                OrbIt.game.serializer.Serialize(levelSave, filename);
                //Assets.NodePresets.Add(serializenode);
            };

            if (File.Exists(filename))
            { //we must be overwriting, therefore don't update the live presetList
                PopUp.Prompt("OverWrite?", "O/W?", delegate(bool c, object a) { if (c) { completeSave(); PopUp.Toast("Level '" + name + "' was overwritten."); } return true; });
            }
            else { PopUp.Toast("Level Saved as " + name); completeSave(); }
        }
コード例 #9
0
        public Node CreateNode()
        {
            Vector2 pos = UserInterface.WorldMousePos;

            //new node(s)
            Dictionary<dynamic, dynamic> userP = new Dictionary<dynamic, dynamic>() {
                                { nodeE.position, pos },
            };
            HashSet<Type> comps = new HashSet<Type>() { typeof(BasicDraw), typeof(Movement), typeof(Lifetime)};
            List<Type> allComps = new List<Type>();
            foreach (Type c in Component.compTypes)
            {
                allComps.Add(c);
            }

            int total = allComps.Count - comps.Count;

            Random random = Utils.random;
            int compsToAdd = random.Next(total);

            int a = 21 * 21;
            int randLog = random.Next(a);
            int root = (int)Math.Ceiling(Math.Sqrt(randLog));
            root = 21 - root;
            compsToAdd = root;

            //System.Console.WriteLine(compsToAdd + " " + root);

            int counter = 0;
            while (compsToAdd > 0)
            {
                if (counter++ > allComps.Count) break;
                int compNum = random.Next(allComps.Count - 1);
                Type newcomp = allComps[compNum];
                if (comps.Contains(newcomp))
                {
                    continue;
                }
                comps.Add(newcomp);
                compsToAdd--;
            }

            foreach (Type c in comps)
            {
                userP.Add(c, true);
            }

            Node n = room.spawnNode(userP, blank: true, lifetime: 5000);
            if (n != null)
            {
                //savedDicts.Enqueue(userP);
                savedNodes.Enqueue(n);
                Group p = room.masterGroup.childGroups["Link Groups"];
                Group g = new Group(room, n, p, n.name);
                //p.AddGroup(g.Name, g);
                OrbIt.ui.sidebar.UpdateGroupComboBoxes();
                savedGroups.Enqueue(g);
            }
            return n;
            //ListBox lst = Game1.ui.sidebar.lstMain;
            //Node newNode = (Node)lst.Items.ElementAt(lst.ItemIndex + 1);
            //System.Console.WriteLine(newNode.name);
        }
コード例 #10
0
        private Node SpawnNodeHelper(Node newNode, Action<Node> afterSpawnAction = null, Group g = null, int lifetime = -1)
        {
            //newNode.addComponent(comp.itempayload, true);
            newNode.OnSpawn();
            if (afterSpawnAction != null) afterSpawnAction(newNode);
            if (lifetime != -1)
            {
                newNode.addComponent<Lifetime>(true);
                newNode.Comp<Lifetime>().timeUntilDeath.value = lifetime;
                newNode.Comp<Lifetime>().timeUntilDeath.enabled = true;
            }

            g.IncludeEntity(newNode);
            newNode.spawned = true;
            return newNode;
        }
コード例 #11
0
        public CreateGroupWindow(Sidebar sidebar)
        {
            this.sidebar = sidebar;
            this.manager = sidebar.manager;
            sidebar.CreatingGroup = true;
            //sidebar.ui.game.SwitchToTempRoom();
            //temproom = sidebar.ui.game.tempRoom;
            //tempgroup = g;// sidebar.ActiveGroup;//temproom.groups.generalGroups.childGroups.ElementAt(0).Value;

            neoSidebar = new NeoSidebar(manager);
            neoSidebar.Init();
            int tomtom = 5;
            neoSidebar.ClientArea.BackColor = UserInterface.TomDark;
            neoSidebar.BackColor = Color.Black;
            neoSidebar.BevelBorder = BevelBorder.All;
            Margins tomtomtomtom = new Margins(tomtom, tomtom, tomtom, tomtom);
            neoSidebar.ClientMargins = tomtomtomtom;

            neoSidebar.Left = sidebar.master.Left;
            neoSidebar.Width = sidebar.Width;
            neoSidebar.Top = 0;
            neoSidebar.Height = OrbIt.ScreenHeight;
            //poop.Text = "Create Group";
            //poop.Closed += delegate { UserInterface.GameInputDisabled = false; sidebar.CreatingGroup = false; sidebar.ui.game.SwitchToMainRoom(); sidebar.groupsView.createGroupWindow = null; };
            //window.ShowModal();
            manager.Add(neoSidebar);

            int width = 120;
            int offset = neoSidebar.Width - width - 20;

            TitlePanel titlePanelCreateGroup = new TitlePanel(sidebar, neoSidebar, "Create Group", true);
            titlePanelCreateGroup.btnBack.Click += (s, e) => Close();

            HeightCounter += titlePanelCreateGroup.Height;

            Label lblName = new Label(manager);
            lblName.Init();
            lblName.Parent = neoSidebar;
            lblName.Left = LeftPadding;
            lblName.Top = HeightCounter;
            lblName.Width = width;
            lblName.Text = "Group Name:";

            TextBox txtName = new TextBox(manager);
            txtName.Init();
            txtName.Parent = neoSidebar;
            txtName.Top = HeightCounter;
            txtName.Width = width;
            txtName.Left = offset;
            HeightCounter += txtName.Height + LeftPadding;

            Button btnRandomName = new Button(manager);
            btnRandomName.Init();
            btnRandomName.Parent = neoSidebar;
            btnRandomName.Top = HeightCounter;
            btnRandomName.Width = txtName.Width;
            btnRandomName.Left = offset;
            btnRandomName.Text = "Random Name";
            HeightCounter += txtName.Height + LeftPadding;
            btnRandomName.Click += (s, e) =>
            {
                txtName.Text = Utils.RandomName();
            };

            RadioButton rdEmpty = new RadioButton(manager);
            rdEmpty.Init();
            rdEmpty.Parent = neoSidebar;
            rdEmpty.Top = HeightCounter;
            rdEmpty.Left = LeftPadding;
            rdEmpty.Text = "Default";
            rdEmpty.Checked = true;
            HeightCounter += rdEmpty.Height + LeftPadding;

            RadioButton rdExisting = new RadioButton(manager);
            rdExisting.Init();
            rdExisting.Parent = neoSidebar;
            rdExisting.Top = HeightCounter;
            rdExisting.Left = LeftPadding;
            rdExisting.Text = "Existing";
            rdExisting.Checked = false;
            rdExisting.Width = width;

            ComboBox cbExisting = new ComboBox(manager);
            cbExisting.Init();
            cbExisting.Parent = neoSidebar;
            cbExisting.Top = HeightCounter;
            cbExisting.Width = width;
            cbExisting.Left = offset;
            foreach(Group gg in sidebar.game.room.groups.general.childGroups.Values)
            {
                cbExisting.Items.Add(gg);
            }
            cbExisting.ItemIndex = 0;
            cbExisting.Enabled = false;
            HeightCounter += cbExisting.Height + LeftPadding;

            RadioButton rdTemplate = new RadioButton(manager);
            rdTemplate.Init();
            rdTemplate.Parent = neoSidebar;
            rdTemplate.Top = HeightCounter;
            rdTemplate.Left = LeftPadding;
            rdTemplate.Text = "Template";
            rdTemplate.Checked = false;
            rdTemplate.Width = width;

            ComboBox cbTemplate = new ComboBox(manager);
            cbTemplate.Init();
            cbTemplate.Parent = neoSidebar;
            cbTemplate.Top = HeightCounter;
            cbTemplate.Width = width;
            cbTemplate.Left = offset;
            foreach (Node n in Assets.NodePresets)
            {
                cbTemplate.Items.Add(n);
            }
            if (Assets.NodePresets.Count > 0) cbTemplate.ItemIndex = 0;
            cbTemplate.Enabled = false;
            HeightCounter += cbTemplate.Height + LeftPadding;

            componentView = new ComponentView(sidebar, neoSidebar, 0, HeightCounter, ViewType.Group);
            componentView.Height = 150;
            componentView.Width = neoSidebar.Width - LeftPadding * 4;

            neoSidebar.Width += 100;
            neoSidebar.Width -= 100;
            tempgroup = new Group(sidebar.room, sidebar.room.defaultNode.CreateClone(sidebar.room), null, "tempgroup", false);

            SetGroup(sidebar.room.defaultNode);

            rdEmpty.Click += (s, e) =>
            {
                cbExisting.Enabled = false;
                cbTemplate.Enabled = false;
                SetGroup(sidebar.room.defaultNode);
            };
            rdExisting.Click += (s, e) =>
            {
                cbExisting.Enabled = true;
                cbTemplate.Enabled = false;
                ComboUpdate(cbExisting);
            };
            cbExisting.ItemIndexChanged += (s, e) =>
            {
                ComboUpdate(cbExisting);
            };
            rdTemplate.Click += (s, e) =>
            {
                cbExisting.Enabled = false;
                cbTemplate.Enabled = true;
                ComboUpdate(cbTemplate);
            };
            cbTemplate.ItemIndexChanged += (s, e) =>
            {
                ComboUpdate(cbTemplate);
            };

            btnCreateGroup = new Button(manager);
            btnCreateGroup.Init();
            btnCreateGroup.Parent = neoSidebar;
            btnCreateGroup.Top = componentView.bottomArea.Top + componentView.bottomArea.Height + LeftPadding * 2;
            btnCreateGroup.Text = "Create Group";
            btnCreateGroup.Width = width;
            btnCreateGroup.Left = neoSidebar.Width / 2 - btnCreateGroup.Width / 2;

            btnCreateGroup.Click += (s, e) =>
            {
                if (String.IsNullOrWhiteSpace(txtName.Text))
                    PopUp.Toast("Please enter a group name.");
                else if(sidebar.game.room.groups.general.childGroups.Keys.Contains(txtName.Text))
                    PopUp.Toast("Group already exists.");
                else{

                    OrbIt.game.room = sidebar.game.room;
                    Node newNode = tempgroup.defaultNode.CreateClone(sidebar.game.room);
                    newNode.body.color = ColorChanger.randomColorHue();
                    newNode.basicdraw.UpdateColor();
                    Group newGroup = new Group(sidebar.game.room, newNode, sidebar.game.room.groups.general, txtName.Text.Trim());
                    newNode.name = txtName.Text.Trim();
                    newNode.group = newGroup;
                    sidebar.groupsView.UpdateGroups();
                    foreach(DetailedItem item in sidebar.groupsView.viewItems)
                    {
                        if (item.obj == newGroup)
                        {
                            sidebar.groupsView.SelectItem(item);
                            break;
                        }
                    }
                    Close();
                }
            };
        }
コード例 #12
0
        public void SyncTitleNumber(Group group = null)
        {
            if (group == null)
            {
                group = GetActiveGroup();
                if (group == null) return;
            }

            int count = group == null ? 0 : group.entities.Count;
            title1.Text = group.Name + " : " + count;
        }
コード例 #13
0
 public override void OnSpawn()
 {
     currentGroup = room.groups.general.childGroups.ElementAt(0).Value;
 }
コード例 #14
0
        /*
        public Group FindGroup(string name)
        {
            if (name.Equals(Name)) return this;

            foreach (string s in childGroups.Keys.ToList())
            {
                if (name.Equals(s)) return childGroups[s];
            }
            if (parentGroup != null) return parentGroup;
            return this;
        }
        */
        public void AddGroup(string name, Group group)
        {
            if (childGroups.ContainsKey(name))
            {
                return;
                //throw new SystemException("Error: One of the childGroups with the same key was already present in this Group.");
            }
            childGroups.Add(name, group);
            group.parentGroup = this;
            foreach(Node n in group.fullSet)
            {
                inherited.Add(n);
            }
        }
コード例 #15
0
 public void SwitchGroup(Group g)
 {
     if (g == null) return;
     activeGroup = g;
     if (insView != null) insView.activeGroup = g;
     SwitchNode(g.defaultNode, true);
 }
コード例 #16
0
        public GroupsView(Sidebar sidebar, Control parent, int Left, int Top, Group parentGroup)
            : base(sidebar, parent, Left, Top, false)
        {
            Height += 50;
            this.parentGroup = parentGroup;
            HeightCounter = Top + 45;
            lblGroupLabel = new Label(manager);
            lblGroupLabel.Init();
            lblGroupLabel.Parent = parent;
            lblGroupLabel.Left = LeftPadding;
            lblGroupLabel.Top = 10;// HeightCounter;
            lblGroupLabel.Width = sidebar.Width / 2;
            lblGroupLabel.Text = "";
            lblGroupLabel.TextColor = Color.Black;
            //HeightCounter += lblGroupLabel.Height + LeftPadding;

            ItemCreator += ItemCreatorDelegate;

            Initialize();

            btnCreateGroup = new Button(manager);
            btnCreateGroup.Init();
            btnCreateGroup.Parent = parent;
            btnCreateGroup.Top = HeightCounter;
            btnCreateGroup.Text = "Create Group";
            btnCreateGroup.Height = (int)(btnCreateGroup.Height * 1.5);
            btnCreateGroup.Width = (parent.Width - LeftPadding * 2) / 2;
            btnCreateGroup.Left = LeftPadding;//parent.Width / 2 - btnCreateGroup.Width / 2;
            btnCreateGroup.Click += (s, e) =>
            {
                createGroupWindow = new CreateGroupWindow(sidebar);
            };
            Margins m = btnCreateGroup.ClientMargins;
            btnCreateGroup.ClientMargins = new Margins(m.Left, 1, m.Right, 1);

            btnEmptyGroup = new Button(manager);
            btnEmptyGroup.Init();
            btnEmptyGroup.Parent = parent;
            btnEmptyGroup.Top = HeightCounter;
            btnEmptyGroup.Text = "Empty Group";
            btnEmptyGroup.Height = (int)(btnEmptyGroup.Height * 1.5);
            btnEmptyGroup.Width = btnCreateGroup.Width;
            btnEmptyGroup.Left = parent.Width - LeftPadding * 2 - btnEmptyGroup.Width;//parent.Width / 2 - btnCreateGroup.Width / 2;
            btnEmptyGroup.Click += (s, e) =>
            {
                sidebar.btnRemoveAllNodes_Click(null, null);
            };
            Margins m2 = btnEmptyGroup.ClientMargins;
            btnEmptyGroup.ClientMargins = new Margins(m2.Left, 1, m2.Right, 1);

            HeightCounter += btnCreateGroup.Height + LeftPadding;

            btnEmptyAll = new Button(manager);
            btnEmptyAll.Init();
            btnEmptyAll.Parent = parent;
            btnEmptyAll.Top = HeightCounter;
            btnEmptyAll.Text = "Empty All Groups";
            //btnEmptyAll.Height = (int)(btnEmptyGroup.Height * 1.5);
            btnEmptyAll.Width = parent.Width / 2;
            btnEmptyAll.Left = parent.Width / 2 - btnEmptyAll.Width / 2;//parent.Width / 2 - btnCreateGroup.Width / 2;
            btnEmptyAll.Click += (s, e) =>
            {
                EmptyAllGroups();
            };
        }
コード例 #17
0
 public void CreateNewItem(Group g)
 {
     int top = 0;
     if (viewItems.Count > 0)
     {
         top = (viewItems[0].itemHeight - 4) * viewItems.Count;
     }
     DetailedItem detailedItem = new DetailedItem(manager, this, g, backPanel, top, LeftPadding);
     base.CreateItem(detailedItem);
 }
コード例 #18
0
        public void ApplyToAllNodes(Group group)
        {
            if (group == null) return;
            List<InspectorInfo> itemspath = new List<InspectorInfo>();
            InspectorInfo item = (InspectorInfo)InsBox.Items.ElementAt(InsBox.ItemIndex);
            object value = item.GetValue();

            BuildItemsPath(item, itemspath);

            group.ForEachAllSets(delegate(Node n)
            {
                if (n == itemspath.ElementAt(0).obj) return;
                InspectorInfo temp = new InspectorInfo(null, n, sidebar);
                int count = 0;
                foreach (InspectorInfo pathitem in itemspath)
                {
                    if (temp.obj.GetType() != pathitem.obj.GetType())
                    {
                        Console.WriteLine("The paths did not match while applying to all. {0} != {1}", temp.obj.GetType(), pathitem.obj.GetType());
                        break;
                    }
                    if (count == itemspath.Count - 1) //last item
                    {
                        if (pathitem.membertype == member_type.dictentry)
                        {
                            dynamic dict = temp.parentItem.obj;
                            dynamic key = pathitem.key;
                            if (!dict.ContainsKey(key)) break;
                            if (dict[key] is Component)
                            {
                                dict[key].active = ((Component)value).active;
                            }
                            else if (temp.IsPanelType())
                            {
                                dict[key] = value;
                            }
                        }
                        else
                        {
                            if (value is Component)
                            {
                                ((Component)temp.obj).active = ((Component)value).active;
                            }
                            else if (temp.IsPanelType())
                            {
                                temp.fpinfo.SetValue(value, temp.parentItem.obj);
                            }
                        }
                    }
                    else
                    {
                        InspectorInfo next = itemspath.ElementAt(count + 1);
                        if (next.membertype == member_type.dictentry)
                        {
                            dynamic dict = temp.obj;
                            dynamic key = next.key;
                            if (!dict.ContainsKey(key)) break;
                            temp = new InspectorInfo(null, temp, dict[key], key);
                        }
                        else
                        {
                            temp = new InspectorInfo(null, temp, next.fpinfo.GetValue(temp.obj), next.fpinfo.propertyInfo);
                        }
                    }
                    count++;
                }
            });
        }
コード例 #19
0
 public Node spawnNode(Node newNode, Action<Node> afterSpawnAction = null, int lifetime = -1, Group g = null)
 {
     Group spawngroup = g ?? OrbIt.ui.sidebar.GetActiveGroup();
     if (spawngroup == null || !spawngroup.Spawnable) return null;
     //newNode.name = "bullet" + Node.nodeCounter;
     return SpawnNodeHelper(newNode, afterSpawnAction, spawngroup, lifetime);
 }
コード例 #20
0
        public override void PlayerControl(Input input)
        {
            if (fireMode == mode.SingleFire)
            {
                if (input.BtnDown(InputButtons.RightTrigger_Mouse1))
                {
                    if (!input.oldInputState.IsButtonDown(InputButtons.RightTrigger_Mouse1))
                    {
                        FireNode(input.GetRightStick());
                    }
                    else if (steerNode && lastFired != null)
                    {
                        lastFired.body.velocity = VMath.VectorRotateLerp(lastFired.body.velocity, input.GetRightStick(), 0.02f);
                    }
                }
            }
            else if (fireMode == mode.AutoFire)
            {
                if (input.BtnDown(InputButtons.RightTrigger_Mouse1))
                {
                    if (shootingDelayCount++ % shootingDelay == 0)
                    {
                        FireNode(input.GetRightStick());
                    }
                }
            }

            if (input.BtnClicked(InputButtons.RightBumper_E))
            {
                if (room.groups.general.childGroups.Values.Count < 2) return;
                bool next = false;
                var tempGroup = room.groups.general.childGroups;
                for (int i = 0; i < tempGroup.Values.Count; i++)
                {
                    Group g = tempGroup.Values.ElementAt(i);
                    if (next)
                    {
                        currentGroup = g;
                        break;
                    }
                    if (g == currentGroup)
                    {
                        if (i == tempGroup.Values.Count - 1)
                        {
                            currentGroup = tempGroup.Values.ElementAt(0);
                            break;
                        }
                        next = true;
                    }
                }
            }
        }
コード例 #21
0
        public Room(OrbIt game, int worldWidth, int worldHeight, bool Groups = true)
        {
            groups = new RoomGroups(this);
            AllActiveLinks = new ObservableHashSet<Link>();
            AllInactiveLinks = new ObservableHashSet<Link>();

            this.worldWidth = worldWidth;
            this.worldHeight = worldHeight;

            scheduler = new Scheduler();
            borderColor = Color.DarkGray;

            // grid System
            gridsystemAffect = new GridSystem(this, 40, new Vector2(0, worldHeight - OrbIt.ScreenHeight), worldWidth, OrbIt.ScreenHeight);
            collisionManager = new CollisionManager(this);
            //gridsystemAffect = new GridSystem(this, 40, new Vector2(0, worldHeight - OrbIt.Height), worldWidth, OrbIt.Height);
            level = new Level(this, 40, 40, gridsystemAffect.cellWidth, gridsystemAffect.cellHeight);
            roomRenderTarget = new RenderTarget2D(game.GraphicsDevice, OrbIt.ScreenWidth, OrbIt.ScreenHeight);
            //gridsystemCollision = new GridSystem(this, gridsystemAffect.cellsX, new Vector2(0, worldHeight - OrbIt.Height), worldWidth, OrbIt.Height);
            camera = new ThreadedCamera(this, 1f);
            DrawLinks = true;
            scheduler = new Scheduler();

            players = new HashSet<Player>();

            #region ///Default User props///
            Dictionary<dynamic, dynamic> userPr = new Dictionary<dynamic, dynamic>() {
                { nodeE.position, new Vector2(0, 0) },
                { nodeE.texture, textures.blackorb },
            };
            #endregion

            defaultNode = new Node(this, userPr);
            defaultNode.name = "master";
            //defaultNode.IsDefault = true;

            foreach(Component c in defaultNode.comps.Values)
            {
                c.AfterCloning();
            }

            Node firstdefault = new Node(this, ShapeType.Circle);
            //firstdefault.addComponent(comp.itempayload, true);
            Node.cloneNode(defaultNode, firstdefault);
            firstdefault.name = "[G0]0";
            //firstdefault.IsDefault = true;

            masterGroup = new Group(this, defaultNode, null, defaultNode.name, false);
            if (Groups)
            {
                new Group(this, defaultNode, masterGroup, "General Groups", false);
                new Group(this, defaultNode, masterGroup, "Preset Groups", false);
                new Group(this, defaultNode.CreateClone(this), masterGroup, "Player Group", true);
                new Group(this, defaultNode, masterGroup, "Item Group", false);
                new Group(this, defaultNode, masterGroup, "Link Groups", false);
                new Group(this, defaultNode.CreateClone(this), masterGroup, "Bullet Group", true);
                new Group(this, defaultNode, masterGroup, "Wall Group", true);
                new Group(this, firstdefault, groups.general, "Group1");
            }

            Dictionary<dynamic, dynamic> userPropsTarget = new Dictionary<dynamic, dynamic>() {
                    { typeof(ColorChanger), true },
                    { nodeE.texture, textures.ring }
            };

            targetNodeGraphic = new Node(this,userPropsTarget);

            targetNodeGraphic.name = "TargetNodeGraphic";

            //MakeWalls(WallWidth);

            MakePresetGroups();
            MakeItemGroups();
        }
コード例 #22
0
        void ConvertIntoList_Click(object sender, EventArgs e)
        {
            Node n = (Node)lstMain.Items.ElementAt(lstMain.ItemIndex);
            if (n == room.targetNode)
            {
                room.targetNode = null;
            }

            Node newdefault = n.CreateClone(n.room);
            //Node.cloneNode(n, newdefault);
            newdefault.body.velocity = new Vector2(0, 0);
            Group g = new Group(room, newdefault, room.masterGroup.childGroups["General Groups"]);
            newdefault.name = g.Name;
            //room.masterGroup.childGroups["General Groups"].AddGroup(g.Name, g);
            //room.masterGroup.UpdateComboBox();
            UpdateGroupComboBoxes();

            Group active = GetActiveGroup();
            if (active == null) return;
            //active.fullSet.Remove(n);
            active.DeleteEntity(n);

            //g.fullSet.Add(n);

            int index = cbListPicker.Items.IndexOf(newdefault.name);
            cbListPicker.ItemIndex = index;
            //cmbListPicker.Refresh();
            //cmbListPicker.ItemIndex = 0;
        }
コード例 #23
0
 public Node spawnNode(Group group, Dictionary<dynamic, dynamic> userProperties = null)
 {
     if (group == null) return null;
     Node newNode = group.defaultNode.CreateClone(this);
     newNode.group = group;
     newNode.name = group.Name + Node.nodeCounter;
     if (userProperties != null) newNode.acceptUserProps(userProperties);
     return SpawnNodeHelper(newNode, null, group, -1);
 }