Ejemplo n.º 1
0
	void Start () {
		
		// Validate MovieClipOverlayCameraBehaivour is attached to camera
		if( MovieClipOverlayCameraBehaviour.instance == null ) {
			Debug.LogError( "Failed to get MovieClipOverlayCameraBehaviour, ensure its attached to the MainCamera" );
			return;
		}
		
		// Assign stage reference
		stage = MovieClipOverlayCameraBehaviour.instance.stage;
		
		// Create menu clip
		MovieClip btn = new MovieClip( "uniSWF/Examples/Tutorial 02 - Basic button script/swf/Tut02-ButtonAsset.swf:btn_ui" );

		// Center on stage for the current screen size
		btn.x = (stage.stageWidth / 2) - (btn.srcWidth/2);  
		btn.y = (stage.stageHeight / 2) - (btn.srcHeight/2);

		// Jump to first frame and stop
		btn.gotoAndStop(1);	 

		// Inner display object such as text fields will not recieve events
		btn.mouseChildrenEnabled = false;  
		
		// Event listeners
		btn.addEventListener( MouseEvent.CLICK, onButtonClick);
		btn.addEventListener( MouseEvent.MOUSE_ENTER, onButtonEnter);
		btn.addEventListener( MouseEvent.MOUSE_LEAVE, onButtonLeave);
		
		// Add menu clip to stage
		stage.addChild(btn);
	}
Ejemplo n.º 2
0
 public PlayerSpaceView(Player model, DisplayObjectContainer parent)
     : base(model, parent)
 {
     this.player = model;
     player.ship.addEventListener(Event.CHANGE, handler);
     player.ship.addEventListener(Ships.ShipEvent.PART_CHANGE, handler);
     this.addChild(hull_view);
     hull_view.addEventListener(MouseEvent.CLICK, onClick);
     reloadHull();
 }
 public void SetButtonEvents()
 {
     SetButtonState(ButtonState.up);
     if (!mc.hasEventListener(MouseEvent.CLICK))
     {
         mc.addEventListener(MouseEvent.CLICK, btnClickCallback);
     }
     if (!mc.hasEventListener(MouseEvent.MOUSE_DOWN))
     {
         mc.addEventListener(MouseEvent.MOUSE_DOWN, OnBtnsDown);
     }
     if (!mc.hasEventListener(MouseEvent.MOUSE_ENTER))
     {
         mc.addEventListener(MouseEvent.MOUSE_ENTER, OnBtnsEnter);
     }
     if (!mc.hasEventListener(MouseEvent.MOUSE_LEAVE))
     {
         mc.addEventListener(MouseEvent.MOUSE_LEAVE, OnBtnsLeave);
     }
     if (!mc.hasEventListener(MouseEvent.MOUSE_UP))
     {
         mc.addEventListener(MouseEvent.MOUSE_UP, OnBtnsLeave);
     }
 }
Ejemplo n.º 4
0
 private void reloadHull()
 {
     if (player.ship.getHull() != null)
     {
         hull_view.removeEventListener(MouseEvent.CLICK, onClick);
         removeChild(hull_view);
         hull_view = new MovieClip();
         hull_view.addEventListener(MouseEvent.CLICK, onClick);
         hull_view.load(new string[] { "DATA\\Ships\\" + player.ship.getHull().type + ".png" });
         hull_view.width = 50;
         hull_view.moveAxisToCenter();
         hull_view.stop();
         hull_view.x = hull_view.x + 5;
         addChild(hull_view);
     }
 }
Ejemplo n.º 5
0
    void Start()
    {
        gm = GameObject.Find("GameManager").GetComponent<GameManager>();
        bm = GameObject.Find("BattleManager").GetComponent<BattleManager>();
        em = GameObject.Find("EventManager").GetComponent<EventManager>();

        // validate MovieClipOverlayCameraBehaviour ist attached to camera
        if (MovieClipOverlayCameraBehaviour.instance == null) {
            return;
        }

        // assign stage reference
        stage = MovieClipOverlayCameraBehaviour.instance.stage;

        //bottom timeline
        menu = new MovieClip ("Flash GUI/game_gui.swf:hover_menu");
        move_button = (MovieClip)menu.getChildByName ("move_btn");
        attack_button = (MovieClip)menu.getChildByName ("attack_btn");
        defend_button = (MovieClip)menu.getChildByName ("defend_btn");
        magic_button = (MovieClip)menu.getChildByName ("magic_btn");
        wait_button = (MovieClip)menu.getChildByName ("wait_btn");

        move_button.addEventListener(MouseEvent.CLICK, onMoveButton);
        attack_button.addEventListener(MouseEvent.CLICK, onAttackButton);
        defend_button.addEventListener(MouseEvent.CLICK, onDefendButton);
        magic_button.addEventListener(MouseEvent.CLICK, onSpellButton);
        wait_button.addEventListener(MouseEvent.CLICK, onWaitButton);

        //create a list and store buttons in list
        buttonList = new List<MovieClip> ();
        buttonList.Add (move_button);
        buttonList.Add (attack_button);
        buttonList.Add (defend_button);
        buttonList.Add (magic_button);
        buttonList.Add (wait_button);

        menu.x = 100;
        menu.y = 100;
        menu.scaleX = scale_factor;
        menu.scaleY = scale_factor;

        //add listeners to each button in the list and stop the animations from playing
        updateListeners (buttonList);

        stage.addChild (menu);

        menu.visible = false;

        em.UnitsReadyEvent += make_team_frame;
    }
Ejemplo n.º 6
0
	void Start ()
    {
        if (GameObject.Find("Main Camera").GetComponent<MovieClipOverlayCameraBehaviour>() == null)
        {
            return;
        }
        stage = Camera.main.GetComponent<MovieClipOverlayCameraBehaviour>().stage;

       Menu = new MovieClip("swf/MenuBar.swf:MenuBar");
 
        
        Menu.gotoAndStop(1);
        Menu.x = Screen.width;
        Menu.y = Screen.height;
        Menu.scaleX = (float)Screen.width / ScaleParameterX;
        Menu.scaleY = (float)Screen.width/ScaleParameterY;

        Name = Menu.getChildByName<TextField>("Name");
        Name.text = "";

        Level = Menu.getChildByName<TextField>("Level");
        Level.text = "";

        Score = Menu.getChildByName<TextField>("Score");
        Score.text = "Score: 0";

        Credits = Menu.getChildByName<TextField>("Credits");
        Credits.text = "Credits:0";

        Info = Menu.getChildByName<TextField>("Info");
        Info.text = "";
        
        Pause = new MovieClip("swf/PauseMute.swf:Pause");
        Pause.gotoAndStop(1);
        Pause.x = Screen.width;
        Pause.y = 0;
        Pause.scaleX = (float)Screen.width / ScaleParameterX;
        Pause.scaleY = (float)Screen.width / ScaleParameterY;
        Pause.addEventListener(MouseEvent.CLICK,OnPauseClick);



        Mute = new MovieClip("swf/PauseMute.swf:Mute");
        Mute.gotoAndStop(1);
        Mute.x = Screen.width;
        Mute.y = 0;
        Mute.scaleX = (float)Screen.width / ScaleParameterX;
        Mute.scaleY = (float)Screen.width / ScaleParameterY;
        //Mute.addEventListener(MouseEvent.CLICK, OnMuteClick);

        Create = new MovieClip("swf/MenuBar.swf:CannonCreate");
        Create.gotoAndStop(1);
        Create.x = Screen.width;
        Create.y = Screen.height;
        Create.scaleX = (float)Screen.width / ScaleParameterX;
        Create.scaleY = (float)Screen.width / ScaleParameterY;
        Create.addEventListener(MouseEvent.MOUSE_DOWN, CreationClick);


        Bonus = new MovieClip("swf/Bonus.swf:Bonus1");
        Bonus.gotoAndStop(1);
        Bonus.x = Screen.width - 90;
        Bonus.y = Screen.height / 2 + 20;
        Bonus.scaleX = (float)Screen.width / ScaleParameterX;
        Bonus.scaleY = (float)Screen.width / ScaleParameterY;


        stage.addChild(Menu);
        stage.addChild(Pause);
        stage.addChild(Mute);
        stage.addChild(Create);
        stage.addChild(Bonus);
	}