Exemplo n.º 1
0
 // private constructor as per XSingleton
 private XWorld()
 {
     mBroadcaster_WorldRegenerated = new XBroadcaster <WorldRegenerated>();
     mGen      = new XWorldGen();
     mMapType  = XWorldGen.eMapType.Default;
     mGenSet   = mGen.GetTuningSet(mMapType);
     mMapScale = 2;
 }
Exemplo n.º 2
0
        private void ProcessInput()
        {
            bool generate_map    = false;
            bool resize_map      = false;
            bool change_map_type = false;

            var key_enumerator = mListenter_KeyUp.CreateEnumerator();

            while (key_enumerator.MoveNext())
            {
                if (key_enumerator.GetCurrent().mKey == Microsoft.Xna.Framework.Input.Keys.W)
                {
                    generate_map = true;
                }
                else if (key_enumerator.GetCurrent().mKey == Microsoft.Xna.Framework.Input.Keys.T)
                {
                    change_map_type = true;
                }
                else if (key_enumerator.GetCurrent().mKey == Microsoft.Xna.Framework.Input.Keys.S)
                {
                    resize_map = true;
                }
            }

            var button_enumerator = mListener_Button.CreateEnumerator();

            while (button_enumerator.MoveNext())
            {
                if (button_enumerator.GetCurrent().mID == mRegnerateMapButton.GetID())
                {
                    generate_map = true;
                }
                else if (button_enumerator.GetCurrent().mID == mMapTypeButton.GetID())
                {
                    change_map_type = true;
                }
                else if (button_enumerator.GetCurrent().mID == mMapSizeButton.GetID())
                {
                    resize_map = true;
                }
            }

            if (change_map_type)
            {
                // loop through map types
                mMapType     = (XWorldGen.eMapType)(((int)mMapType + 1) % (int)XWorldGen.eMapType.Num);
                mGenSet      = mGen.GetTuningSet(mMapType);
                generate_map = true;
            }

            if (resize_map)
            {
                ++mMapScale;
                generate_map = true;

                if (mMapScale > mGen.GetMaxMapScale())
                {
                    mMapScale = 1;
                }
            }

            if (generate_map)
            {
                XSimpleDraw simple_draw = XSimpleDraw.Instance(xeSimpleDrawType.WorldSpace_Persistent_Map);
                simple_draw.CancelPrimitives();
                mRendered = false;
                Generate();

                WorldRegenerated world_regenerated = new WorldRegenerated();
                mBroadcaster_WorldRegenerated.Post(world_regenerated);
            }
        }