Esempio n. 1
0
        public virtual void Mouse(MouseState state, MouseState oldState)
        {
            // apply world mouse updating
            this.WorldMouseTestUtility.Update(state);


            this.MouseWorldPosition = GameInstance.ConvertScreenToWorld(state.X, state.Y);

            //if (state.LeftButton == ButtonState.Released && oldState.LeftButton == ButtonState.Pressed)
            //    MouseUp();
            //else if (state.LeftButton == ButtonState.Pressed && oldState.LeftButton == ButtonState.Released)
            //    MouseDown(this.MouseWorldPosition);

            if (this.World.HibernationEnabled)
            {
                if (state.RightButton == ButtonState.Pressed)
                {
                    // get first independent active area
                    //var activeArea = this.World.HibernationManager.ActiveAreas.FirstOrDefault(aa => aa.AreaType == ActiveAreaType.Independent) as IndependentActiveArea;

                    if (this.MouseActiveArea == null)
                    {
                        // init and add
                        this.MouseActiveArea = new IndependentActiveArea();
                        this.MouseActiveArea.SetRadius(IndependentActiveAreaRadius);
                        this.World.HibernationManager.ActiveAreas.Add(this.MouseActiveArea);
                    }

                    // set it to match current click position
                    this.MouseActiveArea.SetPosition(this.MouseWorldPosition);
                }
            }

            //MouseMove(this.MouseWorldPosition);
        }
Esempio n. 2
0
        public override void Initialize()
        {
            const int WorldSideSize = 2000;

            this.World = WorldPerformanceTestSetup.CreateWorld(WorldSideSize); // 2km

            // add an interest area ever X meters
            const int AAradius = 100;
            const int AAmargin = 250;

            for (var x = -WorldSideSize / 2 + AAmargin; x < WorldSideSize / 2 - AAmargin / 2; x += AAmargin)
            {
                for (var y = -WorldSideSize / 2 + AAmargin; y < WorldSideSize / 2 - AAmargin / 2; y += AAmargin)
                {
                    // init and add
                    var activeArea = new IndependentActiveArea();
                    activeArea.SetPosition(new Vector2(x, y));
                    activeArea.SetRadius(AAradius);
                    this.World.HibernationManager.ActiveAreas.Add(activeArea);
                }
            }


            // sets up debug drawing
            base.Initialize();

            // automatically enable additional performance info
            this.DebugView.AppendFlags(Diagnostics.DebugViewFlags.PerformanceGraph);
            this.DebugView.AppendFlags(Diagnostics.DebugViewFlags.DebugPanel);
            this.DebugView.AppendFlags(Diagnostics.DebugViewFlags.AABB);
            this.DebugView.Enabled = true;

            // set zoom to show a meaningful part of the world
            //this.GameInstance.ViewZoom = 0.09f;
        }