コード例 #1
0
        public GridSystem(Room room, int cellsX, Vector2 position, int? GridWidth = null, int? GridHeight = null)
        {
            linesToDraw = new List<Rectangle>();
            this.position = position;
            this.room = room;

            this.gridWidth = GridWidth ?? room.worldWidth;
            this.gridHeight = GridHeight ?? room.worldHeight;
            this.cellsX = cellsX;

            //this.cellReach = cellReach;
            cellWidth = (int)Math.Ceiling((double)gridWidth / (double)cellsX);
            cellHeight = cellWidth;
            this.cellsY = (gridHeight - 1)/ cellHeight + 1;
            //cellheight = gridheight / cellsY;
            grid = new List<Collider>[cellsX, cellsY];
            for (int i = 0; i < cellsX; i++)
            {
                for (int j = 0; j < cellsY; j++)
                {
                    grid[i, j] = new List<Collider>();
                }
            }

            //
            arrayGrid = new IndexArray<Collider>[cellsX][];
            for(int i = 0; i < cellsX; i++)
            {
                arrayGrid[i] = new IndexArray<Collider>[cellsY];
                for(int j = 0; j < cellsY; j++)
                {
                    arrayGrid[i][j] = new IndexArray<Collider>(100);
                }
            }
            bucketBags = new IndexArray<IndexArray<Collider>>[cellsX][];
            for (int i = 0; i < cellsX; i++)
            {
                bucketBags[i] = new IndexArray<IndexArray<Collider>>[cellsY];
                for (int j = 0; j < cellsY; j++)
                {
                    bucketBags[i][j] = new IndexArray<IndexArray<Collider>>(20);
                }
            }
            //
            distToOffsets = GenerateReachOffsetsDictionary();

            //Stopwatch stopwatch = new Stopwatch();
            //stopwatch.Start();
            int generateReach = gridWidth / 3;
            //GenerateAllReachOffsetsPerCoord(generateReach); //takes a shitload of time.. but only for the temproom?
            //stopwatch.Stop();
            //string taken = stopwatch.Elapsed.ToString();
            //Console.WriteLine("gridsystem generation time taken: " + taken);

            bucketLists = new List<List<Collider>>[cellsX, cellsY];

            ///new attempt
            GenerateReachOffsetsArray();
        }
コード例 #2
0
 public Level(Room room, int cellsX, int cellsY, int cellWidth, int? cellHeight = null)
 {
     this.room = room;
     this.cellsX = cellsX;
     this.cellsY = cellsY;
     this.cellWidth = cellWidth;
     this.cellHeight = cellHeight ?? cellWidth;
 }
コード例 #3
0
        //public static Dictionary<string, bool> timerStarteds = new Dictionary<string, bool>();
        public Testing()
        {
            room = OrbIt.game.room;

            Redirector.PopulateDelegatesAll();
            redirector = new Redirector();

            //obints.CollectionChanged += (s, e) => { };
        }
コード例 #4
0
        public Formation(Link link,
                            Formation form,
                            bool InitializeFormation = true)
        {
            this.room = OrbIt.game.room;
            this.link = link;
            //this.FormationType = FormationType;
            this.Uninhabited = form.Uninhabited;
            this.UpdateFrequency = form.UpdateFrequency;
            this.NearestNValue = form.NearestNValue;
            this.AffectionSets = new Dictionary<Node, ObservableHashSet<Node>>();

            if (InitializeFormation) UpdateFormation();
        }
コード例 #5
0
        public Formation(   Link link, 
                            formationtype FormationType = formationtype.AllToAll,
                            bool Uninhabited = false,
                            int UpdateFrequency = -1,
                            int NearestNValue = 1,
                            bool InitializeFormation = true)
        {
            this.room = OrbIt.game.room;
            this.link = link;
            //this.FormationType = FormationType;
            this.Uninhabited = Uninhabited;
            this.UpdateFrequency = UpdateFrequency;
            this.NearestNValue = NearestNValue;
            this.AffectionSets = new Dictionary<Node, ObservableHashSet<Node>>();

            if (InitializeFormation) UpdateFormation();
        }
コード例 #6
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;
                }
            }
        }
コード例 #7
0
        public RoomPanel(Sidebar sidebar, Control parent, Room room, bool interactive, int Top = 0, int Padding = 5)
        {
            this.Padding = Padding;
            panel = new Panel(sidebar.manager);
            panel.Init();
            panel.Top = Top;
            panel.Left = Padding;
            panel.Width = room.worldWidth;
            panel.Height = room.worldHeight;

            //roomPanel.Left = (parent.Width - roomPanel.Width)/2;

            int col = 30;

            panel.Color = new Color(col, col, col);
            panel.BevelBorder = BevelBorder.All;
            panel.BevelStyle = BevelStyle.Flat;
            panel.BevelColor = Color.Black;

            parent.Add(panel);
            panel.ClientArea.Draw += (s, e) =>
            {

                e.Renderer.Draw(room.roomRenderTarget, e.Rectangle, Color.White);

            };

            refreshAction = refresh;

            parent.VisibleChanged += (s, e) => {
                if (parent.Visible)
                    OrbIt.OnUpdate += refreshAction;
                else
                    OrbIt.OnUpdate -= refreshAction;
            };

            panel.Click += (s, e) =>
            {
                Point innerpos = (e as MouseEventArgs).Position;
                //room.spawnNode(innerpos.X, innerpos.Y);
                Utils.notImplementedException();
            };
        }
コード例 #8
0
        public CollisionManager(Room room)
        {
            this.room = room;
            CollisionSetCircle = new HashSet<Collider>();
            CollisionSetPolygon = new HashSet<Collider>();
            colIterations = 1;

            collideAction = (c1, c2) =>
            {
                if (c1.parent == c2.parent) return;
                if (c1 is Body)
                {
                    Body b = (Body)c1;

                    if (gridsystemCollision.alreadyVisited.Contains(c2)) return;
                    if (c2 is Body)
                    {
                        Body bb = (Body)c2;
                        //if (!b.exclusionList.Contains(bb))
                        b.CheckCollisionBody(bb);
                    }
                    else
                    {
                        b.CheckCollisionCollider(c2);
                    }
                }
                else
                {
                    if (gridsystemCollision.alreadyVisited.Contains(c2)) return;
                    if (c2 is Body)
                    {
                        Body bb = (Body)c2;
                        //if (!c1.exclusionList.Contains(bb))
                        c1.CheckCollisionBody(bb);
                    }
                }
            };

            gridsystemCollision = new GridSystem(room, room.gridsystemAffect.cellsX, new Vector2(0, room.worldHeight - OrbIt.ScreenHeight), room.worldWidth, OrbIt.ScreenHeight);
        }
コード例 #9
0
        protected override void Initialize()
        {
            Assets.LoadAssets(Content);
            base.Initialize();
            base.MainWindow.TransparentClientArea = true;
            room = new Room(this, ScreenWidth, ScreenHeight-40);
            setResolution(prefWindowedResolution, false);

            globalGameMode = new GlobalGameMode(this);
            frameRateCounter = new FrameRateCounter(this);

            Player.CreatePlayers(room);
            ui = UserInterface.Start();
            ui.Initialize();
            room.attatchToSidebar(ui);
            GlobalKeyBinds(ui);
        }
コード例 #10
0
 public void Draw(Room room, Vector2 position, Color color)
 {
     room.camera.AddPermanentDraw(texture, position, color * alpha, scale, rotation, 20);
 }
コード例 #11
0
 public Formation()
 {
     //..
     this.room = OrbIt.game.room;
     this.AffectionSets = new Dictionary<Node, ObservableHashSet<Node>>();
 }
コード例 #12
0
 public Gametype()
 {
     room = OrbIt.game.room;
     players = new HashSet<Player>();
 }
コード例 #13
0
 public void DrawGrid(Room room, Color color)
 {
     room.camera.drawGrid(linesToDraw, color);
     linesToDraw = new List<Rectangle>();
 }
コード例 #14
0
 public RoomGroups(Room room)
 {
     this.room = room;
 }
コード例 #15
0
        public ThreadedCamera(Room room, float zoom = 0.5f, Vector2? pos = null)
        {
            this.room = room;
            this.batch = new SpriteBatch(OrbIt.game.GraphicsDevice);
            this.zoom = zoom;
            this.pos = pos ?? new Vector2(room.gridsystemAffect.position.X + room.gridsystemAffect.gridWidth / 2, 10 + room.gridsystemAffect.position.Y + room.gridsystemAffect.gridHeight / 2);
            _worker = new Thread(Work);
            _worker.Name = "CameraThread";
            _worker.IsBackground = true;
            _worker.Start();

            //Game1.ui.keyManager.addProcessKeyAction("screenshot", KeyCodes.PrintScreen, OnPress: delegate { TakeScreenshot = true; });
        }
コード例 #16
0
 public static void MakeBullet(Room room)
 {
     Dictionary<dynamic, dynamic> props = new Dictionary<dynamic, dynamic>()
     {
         { nodeE.radius, 5f},
         { typeof(Laser), true},
         { typeof(ColorChanger), true},
         { typeof(Lifetime), true},
     };
     bulletNode = new Node(room, props);
     bulletNode.Comp<Collision>().isSolid = false;
     bulletNode.body.isSolid = true;
     bulletNode.body.restitution = 1f;
     bulletNode.Comp<ColorChanger>().colormode = ColorChanger.ColorMode.hueShifter;
     bulletNode.Comp<Lifetime>().timeUntilDeath.enabled = true;
     bulletNode.Comp<Laser>().thickness = 5f;
     bulletNode.Comp<Laser>().laserLength = 20;
     bulletNode.Comp<Movement>().randInitialVel.enabled = false;
     bulletNode.group = room.groups.bullets;
 }
コード例 #17
0
        public void MakeBigTony(Room room)
        {
            //if (bigtony != null)
            //{
            //    return;
            //}
            Dictionary<dynamic, dynamic> tonyProps = new Dictionary<dynamic, dynamic>()
            {
                { nodeE.position, new Vector2(room.worldWidth/2,room.worldHeight/2) },
                { nodeE.texture, textures.blackorb },
                { typeof(PhaseOrb), true },
            };
            Node tony = new Node(room, tonyProps);
            room.scheduler.doEveryXMilliseconds(delegate
            {
                if (OrbIt.soundEnabled) Scheduler.end.Play(0.3f, -0.5f, 0f);
                int rad = 100;
                for (int i = 0; i < 10; i++)
                {
                    int rx = Utils.random.Next(rad * 2) - rad;
                    int ry = Utils.random.Next(rad * 2) - rad;
                    //room.spawnNode(room.worldWidth / 2 + rx, room.worldHeight / 2 + ry);

                }
            }, 2000);
            //tony.body.pos = new Vector2(room.worldWidth / 2, room.worldHeight / 2);
            tony.body.radius = 64;
            tony.body.mass = tonymass;
            tony.body.velocity *= 100;
            tony.name = "bigTony";
            tony.body.texture = textures.blackorb;
            tony.Comp<Queuer>().queuecount = 100;

            bigtony = tony;

            EventHandler updateScores = null;
            updateScores = (ooo, eee) =>
            {
                foreach (var p in room.players)
                {
                    if (p.node == bigtony)
                    {
                        p.node.meta.score += OrbIt.gametime.ElapsedGameTime.Milliseconds;
                        if (p.node.meta.score >= maxScore)
                        {
                            p.node.body.radius += 500;
                            p.node.body.mass += 100;
                            foreach (var pp in room.players)
                            {
                                //pp.node.body.ClearHandlers();
                                //pp.nodeCollision.body.ClearHandlers();
                                pp.node.collision.AllHandlersEnabled = false;
                            }
                            if (OrbIt.soundEnabled) Scheduler.fanfare.Play();
                            bigtony.OnAffectOthers -= updateScores;
                        }
                    }
                }
            };
            bigtony.OnAffectOthers += updateScores;

                room.masterGroup.fullSet.Add(bigtony); //#bigtony
        }