Beispiel #1
0
        //
        protected override void OnAttach()
        {
            base.OnAttach();

            EngineApp.Instance.KeysAndMouseButtonUpAll();

            //hudControl
            hudControl = ControlDeclarationManager.Instance.CreateControl( "Gui\\RTSHUD.gui" );
            Controls.Add( hudControl );

            ( (EButton)hudControl.Controls[ "Menu" ] ).Click += delegate( EButton sender )
            {
                Controls.Add( new MenuWindow() );
            };

            ( (EButton)hudControl.Controls[ "Exit" ] ).Click += delegate( EButton sender )
            {
                string mapName = "Maps\\Vietheroes\\Map.map";
                string spawnPointName = "SpawnPoint_FromRTSDemo";
                GameWorld.Instance.SetShouldChangeMap( mapName, spawnPointName, null );
            };

            ( (EButton)hudControl.Controls[ "Help" ] ).Click += delegate( EButton sender )
            {
                hudControl.Controls[ "HelpWindow" ].Visible = !hudControl.Controls[ "HelpWindow" ].Visible;
            };

            ( (EButton)hudControl.Controls[ "HelpWindow" ].Controls[ "Close" ] ).Click += delegate( EButton sender )
            {
                hudControl.Controls[ "HelpWindow" ].Visible = false;
            };

            ( (EButton)hudControl.Controls[ "DebugPath" ] ).Click += delegate( EButton sender )
            {
                mapDrawPathMotionMap = !mapDrawPathMotionMap;
            };

            InitControlPanelButtons();
            UpdateControlPanel();

            //set playerFaction
            if( RTSFactionManager.Instance != null && RTSFactionManager.Instance.Factions.Count != 0 )
                playerFaction = RTSFactionManager.Instance.Factions[ 0 ].FactionType;

            //minimap
            minimapControl = hudControl.Controls[ "Minimap" ];
            string textureName = Map.Instance.GetSourceMapVirtualFileDirectory() + "\\Minimap\\Minimap";
            Texture minimapTexture = TextureManager.Instance.Load( textureName, Texture.Type.Type2D, 0 );
            minimapControl.BackTexture = minimapTexture;
            minimapControl.RenderUI += new RenderUIDelegate( Minimap_RenderUI );

            //set camera position
            foreach( Entity entity in Map.Instance.Children )
            {
                SpawnPoint spawnPoint = entity as SpawnPoint;
                if( spawnPoint == null )
                    continue;
                cameraPosition = spawnPoint.Position.ToVec2();
                break;
            }

            //World serialized data
            if( World.Instance.GetCustomSerializationValue( "cameraDistance" ) != null )
                cameraDistance = (float)World.Instance.GetCustomSerializationValue( "cameraDistance" );
            if( World.Instance.GetCustomSerializationValue( "cameraDirection" ) != null )
                cameraDirection = (SphereDir)World.Instance.GetCustomSerializationValue( "cameraDirection" );
            if( World.Instance.GetCustomSerializationValue( "cameraPosition" ) != null )
                cameraPosition = (Vec2)World.Instance.GetCustomSerializationValue( "cameraPosition" );
            for( int n = 0; ; n++ )
            {
                Unit unit = World.Instance.GetCustomSerializationValue(
                    "selectedUnit" + n.ToString() ) as Unit;
                if( unit == null )
                    break;
                SetEntitySelected( unit, true );
            }

            ResetTime();
        }
        //

        protected override void OnAttach()
        {
            base.OnAttach();

            EngineApp.Instance.KeysAndMouseButtonUpAll();

            //hudControl
            hudControl = ControlDeclarationManager.Instance.CreateControl("Maps\\RTSDemo\\Gui\\HUD.gui");
            Controls.Add(hudControl);

            ((Button)hudControl.Controls["Menu"]).Click += delegate(Button sender)
            {
                Controls.Add(new MenuWindow());
            };

            ((Button)hudControl.Controls["Exit"]).Click += delegate(Button sender)
            {
                GameWorld.Instance.NeedChangeMap("Maps\\MainDemo\\Map.map", "Teleporter_Maps", null);
            };

            ((Button)hudControl.Controls["Help"]).Click += delegate(Button sender)
            {
                hudControl.Controls["HelpWindow"].Visible = !hudControl.Controls["HelpWindow"].Visible;
            };

            ((Button)hudControl.Controls["HelpWindow"].Controls["Close"]).Click += delegate(Button sender)
            {
                hudControl.Controls["HelpWindow"].Visible = false;
            };

            ((Button)hudControl.Controls["DebugPath"]).Click += delegate(Button sender)
            {
                mapDrawPathMotionMap = !mapDrawPathMotionMap;
            };

            cameraDistanceScrollBar = hudControl.Controls["CameraDistance"] as ScrollBar;
            if (cameraDistanceScrollBar != null)
            {
                cameraDistanceScrollBar.ValueRange = cameraDistanceRange;
                cameraDistanceScrollBar.ValueChange += cameraDistanceScrollBar_ValueChange;
            }

            cameraHeightScrollBar = hudControl.Controls["CameraHeight"] as ScrollBar;
            if (cameraHeightScrollBar != null)
            {
                cameraHeightScrollBar.ValueRange = cameraAngleRange;
                cameraHeightScrollBar.ValueChange += cameraHeightScrollBar_ValueChange;
            }

            InitControlPanelButtons();
            UpdateControlPanel();

            //set playerFaction
            if (RTSFactionManager.Instance != null && RTSFactionManager.Instance.Factions.Count != 0)
                playerFaction = RTSFactionManager.Instance.Factions[0].FactionType;

            //minimap
            minimapControl = hudControl.Controls["Minimap"];
            string textureName = Map.Instance.GetSourceMapVirtualFileDirectory() + "\\Minimap\\Minimap";
            Texture minimapTexture = TextureManager.Instance.Load(textureName, Texture.Type.Type2D, 0);
            minimapControl.BackTexture = minimapTexture;
            minimapControl.RenderUI += new RenderUIDelegate(Minimap_RenderUI);

            //set camera position
            foreach (Entity entity in Map.Instance.Children)
            {
                SpawnPoint spawnPoint = entity as SpawnPoint;
                if (spawnPoint == null)
                    continue;
                cameraPosition = spawnPoint.Position.ToVec2();
                break;
            }

            //World serialized data
            if (World.Instance.GetCustomSerializationValue("cameraDistance") != null)
                cameraDistance = (float)World.Instance.GetCustomSerializationValue("cameraDistance");
            if (World.Instance.GetCustomSerializationValue("cameraDirection") != null)
                cameraDirection = (SphereDir)World.Instance.GetCustomSerializationValue("cameraDirection");
            if (World.Instance.GetCustomSerializationValue("cameraPosition") != null)
                cameraPosition = (Vec2)World.Instance.GetCustomSerializationValue("cameraPosition");
            for (int n = 0; ; n++)
            {
                Unit unit = World.Instance.GetCustomSerializationValue(
                    "selectedUnit" + n.ToString()) as Unit;
                if (unit == null)
                    break;
                SetEntitySelected(unit, true);
            }

            ResetTime();

            //render scene for loading resources
            EngineApp.Instance.RenderScene();

            EngineApp.Instance.MousePosition = new Vec2(.5f, .5f);

            UpdateCameraScrollBars();
        }
Beispiel #3
0
public Faction(FactionType n, System.Single atk, System.Single def, System.Single prod, System.Single res)
	{JustEntered = false;
 frame = World.frame;
		UnityFaction = new UnityFaction();
		Research = res;
		Production = prod;
		FactionType = n;
		Defense = def;
		Attack = atk;
		
}
        public BadFactionPlayer()
        {
            // Initialise the bad faction's characters
            foragerAI = null;
            forager = null;
            builderAI = null;
            builder = null;
            hiveAI = null;
            hive = null;
            barrackAI = null;
            barrack = null;
            depotAI = null;
            depot = null;

            // Set the computer's faction
            if (RTSFactionManager.Instance != null && RTSFactionManager.Instance.Factions.Count != 1)
                badFaction = RTSFactionManager.Instance.Factions[1].FactionType;

            // Initialise the opening strategy
            openingStrategy = OpeningStrategy().GetEnumerator();
            strategyIterator = 0;
            foragerStrategy = ForagerStrategy().GetEnumerator();
            foragerIterator = 0;
            // Initalise the first action
            currentAction = Action.Null;
        }