Beispiel #1
0
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.UI.SpriteState o;
         o = new UnityEngine.UI.SpriteState();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 private void SetHost() {
     GetComponent<Image>().sprite = Enabled ? DefaultStart : GrayStart;
     SpriteState states = new SpriteState() {
         highlightedSprite = DefaultStart
     };
     GetComponent<Button>().spriteState = states;
 }
 private void SetPlayer() {
     GetComponent<Image>().sprite = GrayReady;
     SpriteState states = new SpriteState() {
         highlightedSprite = DefaultReady
     };
     GetComponent<Button>().spriteState = states;
 }
Beispiel #4
0
 /// <summary>
 /// 设置图片切换规则
 /// </summary>
 /// <param name="image"></param>
 /// <param name="button"></param>
 private void SetSpriteSwipe(Data.ImgNode image, UnityEngine.UI.Button button)
 {
     if (MatchAddress(image.Name, normalAddress))
     {
         if (image.type == ImgType.Label)
         {
             (button.targetGraphic as UnityEngine.UI.Text).text = image.text;
         }
         else
         {
             button.image.sprite = image.sprite;
         }
     }
     else if (MatchAddress(image.Name, pressedAddress))
     {
         button.transition = UnityEngine.UI.Selectable.Transition.SpriteSwap;
         UnityEngine.UI.SpriteState state = button.spriteState;
         state.pressedSprite = image.sprite;
         button.spriteState  = state;
     }
     else if (MatchAddress(image.Name, disableAddress))
     {
         button.transition = UnityEngine.UI.Selectable.Transition.SpriteSwap;
         UnityEngine.UI.SpriteState state = button.spriteState;
         state.disabledSprite = image.sprite;
         button.spriteState   = state;
     }
     else if (MatchAddress(image.Name, highlightedAddress))
     {
         button.transition = UnityEngine.UI.Selectable.Transition.SpriteSwap;
         UnityEngine.UI.SpriteState state = button.spriteState;
         state.highlightedSprite = image.sprite;
         button.spriteState      = state;
     }
 }
Beispiel #5
0
 static public int set_disabledSprite(IntPtr l)
 {
     UnityEngine.UI.SpriteState o = (UnityEngine.UI.SpriteState)checkSelf(l);
     UnityEngine.Sprite         v;
     checkType(l, 2, out v);
     o.disabledSprite = v;
     setBack(l, o);
     return(0);
 }
Beispiel #6
0
    void ChangeSprites(Sprite neutral, Sprite highlighted)
    {
        GetComponent<Image>().sprite = neutral;

        SpriteState st = new SpriteState();

        st.highlightedSprite = highlighted;
        st.pressedSprite = neutral;
    }
Beispiel #7
0
    public void OpenInventory()
    {
        inventHolder.enabled = true;
        bag.GetComponent<Image>().sprite = initBagSprites.pressedSprite;
        SpriteState openBagSpriteStates = new SpriteState();
        openBagSpriteStates.highlightedSprite = initBagSprites.pressedSprite;
        openBagSpriteStates.pressedSprite = initBagSprites.disabledSprite;

        bag.GetComponent<Button>().spriteState = openBagSpriteStates;
    }
Beispiel #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UI.ToolbarUI"/> class.
        /// </summary>
        /// <param name="script">Script.</param>
        public ToolbarUI(ToolbarScript script)
        {
            mScript = script;

            mLeftButtonSpriteState         = new SpriteState();
            mLeftButtonActiveSpriteState   = new SpriteState();
            mMiddleButtonSpriteState       = new SpriteState();
            mMiddleButtonActiveSpriteState = new SpriteState();
            mRightButtonSpriteState        = new SpriteState();
            mRightButtonActiveSpriteState  = new SpriteState();
            mPopupSpriteState              = new SpriteState();

            mScrollAreaContentTransform = null;
            mToolsTransform             = null;
            mBasePointTransform         = null;
            mPointTransform             = null;
            mPointText                  = null;
            mCoordinateSystemTransform  = null;
            mCoordinateSystemText       = null;
            mPlaybackTransform          = null;
            mPopupsTransform            = null;
            mLayersTransform            = null;
            mLayersText                 = null;
            mLayoutTransform            = null;
            mLayoutText                 = null;

            mLeftButtonSpriteState.disabledSprite            = Assets.Windows.MainWindow.Toolbar.Textures.toolLeftButton;
            mLeftButtonSpriteState.highlightedSprite         = Assets.Windows.MainWindow.Toolbar.Textures.toolLeftButton;
            mLeftButtonSpriteState.pressedSprite             = Assets.Windows.MainWindow.Toolbar.Textures.toolLeftButtonPressed;

            mLeftButtonActiveSpriteState.disabledSprite      = Assets.Windows.MainWindow.Toolbar.Textures.toolLeftButtonActive;
            mLeftButtonActiveSpriteState.highlightedSprite   = Assets.Windows.MainWindow.Toolbar.Textures.toolLeftButtonActive;
            mLeftButtonActiveSpriteState.pressedSprite       = Assets.Windows.MainWindow.Toolbar.Textures.toolLeftButtonActivePressed;

            mMiddleButtonSpriteState.disabledSprite          = Assets.Windows.MainWindow.Toolbar.Textures.toolMiddleButton;
            mMiddleButtonSpriteState.highlightedSprite       = Assets.Windows.MainWindow.Toolbar.Textures.toolMiddleButton;
            mMiddleButtonSpriteState.pressedSprite           = Assets.Windows.MainWindow.Toolbar.Textures.toolMiddleButtonPressed;

            mMiddleButtonActiveSpriteState.disabledSprite    = Assets.Windows.MainWindow.Toolbar.Textures.toolMiddleButtonActive;
            mMiddleButtonActiveSpriteState.highlightedSprite = Assets.Windows.MainWindow.Toolbar.Textures.toolMiddleButtonActive;
            mMiddleButtonActiveSpriteState.pressedSprite     = Assets.Windows.MainWindow.Toolbar.Textures.toolMiddleButtonActivePressed;

            mRightButtonSpriteState.disabledSprite           = Assets.Windows.MainWindow.Toolbar.Textures.toolRightButton;
            mRightButtonSpriteState.highlightedSprite        = Assets.Windows.MainWindow.Toolbar.Textures.toolRightButton;
            mRightButtonSpriteState.pressedSprite            = Assets.Windows.MainWindow.Toolbar.Textures.toolRightButtonPressed;

            mRightButtonActiveSpriteState.disabledSprite     = Assets.Windows.MainWindow.Toolbar.Textures.toolRightButtonActive;
            mRightButtonActiveSpriteState.highlightedSprite  = Assets.Windows.MainWindow.Toolbar.Textures.toolRightButtonActive;
            mRightButtonActiveSpriteState.pressedSprite      = Assets.Windows.MainWindow.Toolbar.Textures.toolRightButtonActivePressed;

            mPopupSpriteState.disabledSprite                 = Assets.Windows.MainWindow.Toolbar.Textures.popupButton;
            mPopupSpriteState.highlightedSprite              = Assets.Windows.MainWindow.Toolbar.Textures.popupButton;
            mPopupSpriteState.pressedSprite                  = Assets.Windows.MainWindow.Toolbar.Textures.popupButton;
        }
    private void ChangeSprite(Sprite neutral, Sprite highlight)
    {
        GetComponent<Image>().sprite = neutral;

        SpriteState st = new SpriteState();

        st.highlightedSprite = highlight;

        st.pressedSprite = neutral;

        GetComponent<Button>();
    }
Beispiel #10
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.UI.SpriteState o;
         o = new UnityEngine.UI.SpriteState();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.UI.SpriteState o;
         o = new UnityEngine.UI.SpriteState();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.UI.SpriteState o;
         o=new UnityEngine.UI.SpriteState();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.UI.SpriteState o;
         o=new UnityEngine.UI.SpriteState();
         pushValue(l,true);
         pushValue(l,o);
         return 2;
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
Beispiel #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainMenuUI"/> class.
        /// </summary>
        public MainMenuUI(MainMenuScript script)
        {
            mScript = script;

            mButtonSpriteState = new SpriteState();

            mButtonSpriteState.disabledSprite    = Assets.Windows.MainWindow.MainMenu.Textures.button;
            mButtonSpriteState.highlightedSprite = Assets.Windows.MainWindow.MainMenu.Textures.buttonHighlighted;
            mButtonSpriteState.pressedSprite     = Assets.Windows.MainWindow.MainMenu.Textures.buttonPressed;

            mScrollAreaContent          = null;
            mScrollAreaContentTransform = null;
        }
Beispiel #15
0
    static int QPYX_get_spriteState_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.UI.Selectable QPYX_obj_YXQP = (UnityEngine.UI.Selectable)QPYX_o_YXQP;
            UnityEngine.UI.SpriteState QPYX_ret_YXQP = QPYX_obj_YXQP.spriteState;
            ToLua.PushValue(L_YXQP, QPYX_ret_YXQP);
            return(1);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index spriteState on a nil value"));
        }
    }
Beispiel #16
0
    static int QPYX_set_spriteState_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.UI.Selectable QPYX_obj_YXQP = (UnityEngine.UI.Selectable)QPYX_o_YXQP;
            UnityEngine.UI.SpriteState QPYX_arg0_YXQP = StackTraits <UnityEngine.UI.SpriteState> .Check(L_YXQP, 2);

            QPYX_obj_YXQP.spriteState = QPYX_arg0_YXQP;
            return(0);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index spriteState on a nil value"));
        }
    }
    static int get_disabledSprite(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.SpriteState obj = (UnityEngine.UI.SpriteState)o;
            UnityEngine.Sprite         ret = obj.disabledSprite;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index disabledSprite on a nil value" : e.Message));
        }
    }
 static int Equals(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.UI.SpriteState obj  = (UnityEngine.UI.SpriteState)ToLua.ToObject(L, 1);
         UnityEngine.UI.SpriteState arg0 = (UnityEngine.UI.SpriteState)ToLua.CheckObject(L, 2, typeof(UnityEngine.UI.SpriteState));
         bool o = obj.Equals(arg0);
         LuaDLL.lua_pushboolean(L, o);
         ToLua.SetBack(L, 1, obj);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #19
0
    static int set_spriteState(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.Selectable  obj  = (UnityEngine.UI.Selectable)o;
            UnityEngine.UI.SpriteState arg0 = (UnityEngine.UI.SpriteState)ToLua.CheckObject(L, 2, typeof(UnityEngine.UI.SpriteState));
            obj.spriteState = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index spriteState on a nil value" : e.Message));
        }
    }
Beispiel #20
0
    static int get_spriteState(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.Selectable  obj = (UnityEngine.UI.Selectable)o;
            UnityEngine.UI.SpriteState ret = obj.spriteState;
            ToLua.PushValue(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index spriteState on a nil value"));
        }
    }
Beispiel #21
0
 public void StartGame()
 {
     if (!_started)
     {
         spawner.Spawn();
         _started = true;
         playButton.GetComponent <UnityEngine.UI.Image>().sprite = restartImage;
         UnityEngine.UI.SpriteState ss = playButton.spriteState;
         ss.pressedSprite       = restartImageP;
         playButton.spriteState = ss;
     }
     else
     {
         Scene currentScene = SceneManager.GetActiveScene();
         SceneManager.LoadScene(currentScene.name);
     }
 }
Beispiel #22
0
    static int set_spriteState(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.Selectable  obj  = (UnityEngine.UI.Selectable)o;
            UnityEngine.UI.SpriteState arg0 = StackTraits <UnityEngine.UI.SpriteState> .Check(L, 2);

            obj.spriteState = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index spriteState on a nil value"));
        }
    }
    static int set_highlightedSprite(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.SpriteState obj  = (UnityEngine.UI.SpriteState)o;
            UnityEngine.Sprite         arg0 = (UnityEngine.Sprite)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.Sprite));
            obj.highlightedSprite = arg0;
            ToLua.SetBack(L, 1, obj);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index highlightedSprite on a nil value" : e.Message));
        }
    }
Beispiel #24
0
    public override void SetData(object data)
    {
        friendItemData = data as FriendItemData;
        friend         = friendItemData.friend;
        if (friendItemData.type == 0)
        {
            item1.SetActive(true);
            item2.SetActive(false);
            recruitRewardText.text = "20";
        }
        else
        {
            item1.SetActive(false);
            item2.SetActive(true);
            head.setData(friend.name, friend.headImg, 0, friend.isVip);
            timeText.text = "上次活跃:" + friend.updateTime;
            if (friend.receiveStatus == 1)
            {
                sendBtn.interactable = true;
                sendBtn.image.sprite = sprites[1];
            }
            else if (friend.sendStatus == 0)
            {
                sendBtn.interactable = true;
                sendBtn.image.sprite = sprites[0];
            }
            else if (friend.sendStatus == 1 && friend.receiveStatus == 2)
            {
                UnityEngine.UI.SpriteState state = new UnityEngine.UI.SpriteState();
                state.disabledSprite = sprites[2];

                sendBtn.spriteState  = state;
                sendBtn.interactable = false;
            }
            else
            {
                UnityEngine.UI.SpriteState state = new UnityEngine.UI.SpriteState();
                state.disabledSprite = sprites[3];

                sendBtn.spriteState  = state;
                sendBtn.interactable = false;
            }
        }
    }
    void Update()
    {
        open = menuController.pauseMenuOpen;

        if (open)
        {
            imageObj.sprite = openedSpr;

            SpriteState state = new SpriteState();
            state.pressedSprite = openedPressedSpr;
            imageBtn.spriteState = state;
        }
        else
        {
            imageObj.sprite = closedSpr;

            SpriteState state = new SpriteState();
            state.pressedSprite = closedPressedSpr;
            imageBtn.spriteState = state;
        }
    }
Beispiel #26
0
    //Changes the sprite of a slot
    private void ChangeSprite(Sprite neutral, Sprite highlight)
    {
        //Sets the neutralsprite
        GetComponent<Image>().sprite = neutral;

        //Creates a spriteState, so that we can change the sprites of the different states
        SpriteState st = new SpriteState();
        st.highlightedSprite = highlight;
        st.pressedSprite = neutral;

        //Sets the sprite state
        GetComponent<Button>().spriteState = st;
    }
Beispiel #27
0
    private void changeSpite(Sprite neutral, Sprite highlighted)
    {
        GetComponent<Image>().sprite = neutral;

        SpriteState spriteState = new SpriteState();
        spriteState.highlightedSprite = highlighted;
        spriteState.pressedSprite = neutral;

        GetComponent<Button>().spriteState = spriteState;
    }
	public void selectCampaign(Templates.CampaignInfo camp)
	{
		States.selectedLevel=-1;
		int i;
		start_but.SetActive(false);
		for(i=0;i<missionsContainer.transform.childCount; i++)
			Destroy(missionsContainer.transform.GetChild(i).gameObject);
		States.currentCampaign=camp;
		//load load
		campaignsMenu.SetActive(false);
		missionsMenu.SetActive(true);
		((UnityEngine.UI.Text)descriptionPanel.GetComponentsInChildren<UnityEngine.UI.Text>()[0]).text=camp.name;
		((UnityEngine.UI.Text)descriptionPanel.GetComponentsInChildren<UnityEngine.UI.Text>()[1]).text=camp.desc;
		
		int currank= PlayerPrefs.GetInt("rank"+States.currentCampaign.id+"Campaign",-1);
		if(currank==-1)
		{
			rank_text.GetComponent<UnityEngine.UI.Text>().text="Rank:\n"+Templates.getInstance().getRank(States.currentCampaign.defaultRank).name;
			rank_img.GetComponent<UnityEngine.UI.Image>().overrideSprite=Templates.getInstance().getRank(States.currentCampaign.defaultRank).img;
		}
		else
		{
			rank_text.GetComponent<UnityEngine.UI.Text>().text="Rank:\n"+Templates.getInstance().getRank(currank).name;
			rank_img.GetComponent<UnityEngine.UI.Image>().overrideSprite=Templates.getInstance().getRank(currank).img;
		}
		
		int repetitions=camp.levels.Count/2;
		bool free=true;
		int stars1,stars2=0;
		for(i=0;i<repetitions;i++)
		{
			stars1=PlayerPrefs.GetInt("mission"+camp.levels[i*2]+"Stars",-1);
			stars2=PlayerPrefs.GetInt("mission"+camp.levels[i*2+1]+"Stars",-1);
			GameObject tmp=(GameObject)Instantiate(Templates.getInstance().missionBlockPrefab,Vector3.zero,Quaternion.identity);
			selectedState=new UnityEngine.UI.SpriteState();
			selectedState.disabledSprite=((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).spriteState.pressedSprite;
			selectedState.highlightedSprite=((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).spriteState.pressedSprite;
			selectedState.pressedSprite=((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).spriteState.pressedSprite;
			tmp.transform.SetParent(missionsContainer.transform);
			tmp.transform.localScale=new Vector3(1,1,1);
			
			if(stars1==-1)
			{
				if(!free)
				{
					((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).enabled=false;
					((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[0]).overrideSprite=((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).spriteState.disabledSprite;
					((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumberGrey(i*2+1)[0];
					((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumberGrey(i*2+1)[1];
			
				}
				else
				{
					free=false;
					((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumber(i*2+1)[0];
					((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumber(i*2+1)[1];
				}
			}
			else
			{
				((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumber(i*2+1)[0];
				((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumber(i*2+1)[1];
				if(stars1>=1)
				{
					Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(3).gameObject.GetComponent<UnityEngine.UI.Image>().color;
					c.a=1;
					((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(3).gameObject.GetComponent<UnityEngine.UI.Image>().color=c;
				}
				if(stars1>=2)
				{
					Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(4).gameObject.GetComponent<UnityEngine.UI.Image>().color;
					c.a=1;
					((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(4).gameObject.GetComponent<UnityEngine.UI.Image>().color=c;
				}
				if(stars1>=3)
				{
					Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(5).gameObject.GetComponent<UnityEngine.UI.Image>().color;
					c.a=1;
					((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(5).gameObject.GetComponent<UnityEngine.UI.Image>().color=c;
				}
				
			}
			
			if(stars2==-1)
			{
				if(!free)
				{
					((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).enabled=false;
					((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[0]).overrideSprite=((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).spriteState.disabledSprite;
					((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumberGrey(i*2+2)[0];
					((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumberGrey(i*2+2)[1];
				}
				else
				{
					free=false;
					((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumber(i*2+2)[0];
					((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumber(i*2+2)[1];
				}
			}
			else
			{
				((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumber(i*2+2)[0];
				((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren<UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumber(i*2+2)[1];
				if(stars1>=1)
				{
					Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(3).gameObject.GetComponent<UnityEngine.UI.Image>().color;
					c.a=1;
					((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(3).gameObject.GetComponent<UnityEngine.UI.Image>().color=c;
				}
				if(stars1>=2)
				{
					Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(4).gameObject.GetComponent<UnityEngine.UI.Image>().color;
					c.a=1;
					((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(4).gameObject.GetComponent<UnityEngine.UI.Image>().color=c;
				}
				if(stars1>=3)
				{
					Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(5).gameObject.GetComponent<UnityEngine.UI.Image>().color;
					c.a=1;
					((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(5).gameObject.GetComponent<UnityEngine.UI.Image>().color=c;
				}
			}
			
			GameObject block=tmp;
			int lev=(i*2);
			((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[0]).onClick.AddListener(() => setSelection(block,lev));
			((UnityEngine.UI.Button)tmp.GetComponentsInChildren<UnityEngine.UI.Button>()[1]).onClick.AddListener(() => setSelection(block,lev+1));
		}
	}
Beispiel #29
0
    public void ToggleInventory()
    {
        mAudio.PlayOnce ( "newItem" );
        inventHolder.enabled = !inventHolder.enabled;
        if (inventHolder.enabled)
        {
            bag.GetComponent<Image>().sprite = initBagSprites.pressedSprite;
            SpriteState openBagSpriteStates = new SpriteState();
            openBagSpriteStates.highlightedSprite = initBagSprites.pressedSprite;
            openBagSpriteStates.pressedSprite = initBagSprites.disabledSprite;

            bag.GetComponent<Button>().spriteState = openBagSpriteStates;
        }
        else
        {
            bag.GetComponent<Image>().sprite = initBagSprites.disabledSprite;
            bag.GetComponent<Button>().spriteState = initBagSprites;
        }
    }
Beispiel #30
0
 static public int get_disabledSprite(IntPtr l)
 {
     UnityEngine.UI.SpriteState o = (UnityEngine.UI.SpriteState)checkSelf(l);
     pushValue(l, o.disabledSprite);
     return(1);
 }
Beispiel #31
0
    // Use this for initialization
    void Start()
    {
        for (int i = 1; i < 8; i++)
        {
            GameObject slot = (GameObject)Instantiate(slots);
            slot.transform.SetParent( this.gameObject.transform );
            slot.name = "Slot " + i;
            slot.GetComponent<RectTransform>().localPosition = new Vector3(initSlotPosx, initSlotPosy, 0);
            slotList.Add(slot);
            initSlotPosx += 70;
        }
        inventHolder = GameObject.Find("Inventory UI").GetComponent<Canvas>();
        inventHolder.enabled = false;
        bag = GameObject.Find("Bag");
        initBagSprites = bag.GetComponent<Button>().spriteState;

        Success = GameObject.Find("Success").GetComponent<Animator>();
        Fail = GameObject.Find("Fail").GetComponent<Animator>();

        mAudio = GameObject.FindGameObjectWithTag ( "Manager" ).GetComponent<AudioManager> ();
        mChar = GameObject.FindGameObjectWithTag("Char").GetComponent<Character>();
    }
    private void Generate(int count )
    {
        var button = Instantiate( prefabDialButton );
        button.name = "button_" + (count + 1);
        button.transform.SetParent( transform );

        // Картинка
        //button.GetComponent<Image>().sprite = graphicTarget[count].sprite;
        button.GetComponent<Image>().sprite = graphicTargetAlt[count];

        var spr = new SpriteState();
        //spr.pressedSprite = graphicPressed[count].sprite;
        //spr.highlightedSprite = graphicPressed[count].sprite;
        spr.pressedSprite = graphicTargetAlt[count];
        spr.highlightedSprite = graphicPressedAlt[count];
        button.GetComponent<Button>().spriteState = spr;

        // положение на экране
        button.GetComponent<RectTransform>().localScale = new Vector3(1f,1f,1f);
        try
        {
            button.GetComponent<RectTransform>().Rotate( rotationButtons[count] );
            button.transform.localPosition = coordButtons[count];
            button.GetComponent<RectTransform>().sizeDelta = sizeButtons[count];
        } catch { print( "Положение на экране не задано" ); }
    }
Beispiel #33
0
 public void SpriteChange(Sprite neutral, Sprite highlight)
 {
     //		if (transform.parent.name != "CharacterPanel")
     //		{
         GetComponent<Image> ().sprite = neutral;
         SpriteState st = new SpriteState ();
         st.highlightedSprite = highlight;
         st.pressedSprite = neutral;
         GetComponent<Button> ().spriteState = st;
     //		}
     //		if (isEmpty && transform.parent.name == "CharacterPanel")
     //		{
     //			SpriteState st = new SpriteState ();
     //			if (name == "Head")
     //			{
     //				GetComponent<Image>().sprite = Resources.Load("HeadSprite")as Sprite;
     //				st.highlightedSprite = Resources.Load("HeadSprite")as Sprite;
     //				st.pressedSprite = Resources.Load("HeadSprite")as Sprite;
     //			}
     //			if (name == "Chest")
     //			{
     //				GetComponent<Image>().sprite = Resources.Load("ChestSprite")as Sprite;
     //				st.highlightedSprite = Resources.Load("ChestSprite")as Sprite;
     //				st.pressedSprite = Resources.Load("ChestSprite")as Sprite;
     //			}
     //			if (name == "Legs")
     //			{
     //				GetComponent<Image>().sprite = Resources.Load("LegsSprite")as Sprite;
     //				st.highlightedSprite = Resources.Load("LegsSprite")as Sprite;
     //				st.pressedSprite = Resources.Load("LegsSprite")as Sprite;
     //			}
     //			else
     //			{
     //				GetComponent<Image>().sprite = Resources.Load("BootsSprite")as Sprite;
     //				st.highlightedSprite = Resources.Load("BootsSprite")as Sprite;
     //				st.pressedSprite = Resources.Load("BootsSprite")as Sprite;
     //			}
     //			GetComponent<Button>().spriteState = st;
     //		}
 }
Beispiel #34
0
    GameObject createBtn(JToken uiObject, GameObject parent)
    {
        GameObject go = createGo(uiObject, parent);
        addImage(uiObject, go);




        go.AddComponent<Button>();
        go.GetComponent<Button>().transition = Selectable.Transition.SpriteSwap;
        string imgPath = Regex.Split(path, "Resources/")[1];
        foreach (JToken k in uiObject["child"].Children())
        {
            if((k["type"].ToString()=="idle"))
            {
                Sprite sprite = (Sprite)Resources.Load(imgPath + "/" + k["resource"], typeof(Sprite));
                go.GetComponent<Image>().sprite = sprite;
                rotateGo(k,go);
            }
            else if(k["type"].ToString()=="pressed")
            {
                Sprite sprite = (Sprite)Resources.Load(imgPath + "/" + k["resource"], typeof(Sprite));
                SpriteState sss = new SpriteState();
                //sss.disabledSprite = sprite;
                //sss.highlightedSprite = sprite;
                sss.pressedSprite = sprite;
                go.GetComponent<Button>().spriteState = sss;
            }
            
        }
        

        return go;
    }
	public void PauseGame(bool pause, bool menuPause) {
		paused = pause;
        wasMenuPaused = menuPause;
        pauseButton.GetComponent<Image>().sprite = (paused) ? playLight : pauseLight;

        SpriteState st = new SpriteState();
        st.pressedSprite = (paused) ? playDark : pauseDark;
        st.disabledSprite = disabledPauseBut;
        pauseButton.GetComponent<Button>().spriteState = st;
        Camera.main.GetComponent<AudioSource>().volume = (paused) ? 0.2f : 0.8f;
		RotateSun.pause = !RotateSun.pause;
		MonthTimer.pause = !MonthTimer.pause;
	}
    public void selectCampaign(Templates.CampaignInfo camp)
    {
        States.selectedLevel = -1;
        int i;

        start_but.SetActive(false);
        for (i = 0; i < missionsContainer.transform.childCount; i++)
        {
            Destroy(missionsContainer.transform.GetChild(i).gameObject);
        }
        States.currentCampaign = camp;
        //load load
        campaignsMenu.SetActive(false);
        missionsMenu.SetActive(true);
        ((UnityEngine.UI.Text)descriptionPanel.GetComponentsInChildren <UnityEngine.UI.Text>()[0]).text = camp.name;
        ((UnityEngine.UI.Text)descriptionPanel.GetComponentsInChildren <UnityEngine.UI.Text>()[1]).text = camp.desc;

        int currank = PlayerPrefs.GetInt("rank" + States.currentCampaign.id + "Campaign", -1);

        if (currank == -1)
        {
            rank_text.GetComponent <UnityEngine.UI.Text>().text           = "Rank:\n" + Templates.getInstance().getRank(States.currentCampaign.defaultRank).name;
            rank_img.GetComponent <UnityEngine.UI.Image>().overrideSprite = Templates.getInstance().getRank(States.currentCampaign.defaultRank).img;
        }
        else
        {
            rank_text.GetComponent <UnityEngine.UI.Text>().text           = "Rank:\n" + Templates.getInstance().getRank(currank).name;
            rank_img.GetComponent <UnityEngine.UI.Image>().overrideSprite = Templates.getInstance().getRank(currank).img;
        }

        int  repetitions = camp.levels.Count / 2;
        bool free = true;
        int  stars1, stars2 = 0;

        for (i = 0; i < repetitions; i++)
        {
            stars1 = PlayerPrefs.GetInt("mission" + camp.levels[i * 2] + "Stars", -1);
            stars2 = PlayerPrefs.GetInt("mission" + camp.levels[i * 2 + 1] + "Stars", -1);
            GameObject tmp = (GameObject)Instantiate(Templates.getInstance().missionBlockPrefab, Vector3.zero, Quaternion.identity);
            selectedState = new UnityEngine.UI.SpriteState();
            selectedState.disabledSprite    = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).spriteState.pressedSprite;
            selectedState.highlightedSprite = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).spriteState.pressedSprite;
            selectedState.pressedSprite     = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).spriteState.pressedSprite;
            tmp.transform.SetParent(missionsContainer.transform);
            tmp.transform.localScale = new Vector3(1, 1, 1);

            if (stars1 == -1)
            {
                if (!free)
                {
                    ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).enabled = false;
                    ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[0]).overrideSprite = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).spriteState.disabledSprite;
                    ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumberGrey(i * 2 + 1)[0];
                    ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumberGrey(i * 2 + 1)[1];
                }
                else
                {
                    free = false;
                    ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumber(i * 2 + 1)[0];
                    ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumber(i * 2 + 1)[1];
                }
            }
            else
            {
                ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumber(i * 2 + 1)[0];
                ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumber(i * 2 + 1)[1];
                if (stars1 >= 1)
                {
                    Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(3).gameObject.GetComponent <UnityEngine.UI.Image>().color;
                    c.a = 1;
                    ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(3).gameObject.GetComponent <UnityEngine.UI.Image>().color = c;
                }
                if (stars1 >= 2)
                {
                    Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(4).gameObject.GetComponent <UnityEngine.UI.Image>().color;
                    c.a = 1;
                    ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(4).gameObject.GetComponent <UnityEngine.UI.Image>().color = c;
                }
                if (stars1 >= 3)
                {
                    Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(5).gameObject.GetComponent <UnityEngine.UI.Image>().color;
                    c.a = 1;
                    ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.transform.GetChild(5).gameObject.GetComponent <UnityEngine.UI.Image>().color = c;
                }
            }

            if (stars2 == -1)
            {
                if (!free)
                {
                    ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).enabled = false;
                    ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[0]).overrideSprite = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).spriteState.disabledSprite;
                    ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumberGrey(i * 2 + 2)[0];
                    ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumberGrey(i * 2 + 2)[1];
                }
                else
                {
                    free = false;
                    ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumber(i * 2 + 2)[0];
                    ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumber(i * 2 + 2)[1];
                }
            }
            else
            {
                ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[1]).overrideSprite = Templates.getInstance().getNumber(i * 2 + 2)[0];
                ((UnityEngine.UI.Image)((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[2]).overrideSprite = Templates.getInstance().getNumber(i * 2 + 2)[1];
                if (stars1 >= 1)
                {
                    Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(3).gameObject.GetComponent <UnityEngine.UI.Image>().color;
                    c.a = 1;
                    ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(3).gameObject.GetComponent <UnityEngine.UI.Image>().color = c;
                }
                if (stars1 >= 2)
                {
                    Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(4).gameObject.GetComponent <UnityEngine.UI.Image>().color;
                    c.a = 1;
                    ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(4).gameObject.GetComponent <UnityEngine.UI.Image>().color = c;
                }
                if (stars1 >= 3)
                {
                    Color c = ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(5).gameObject.GetComponent <UnityEngine.UI.Image>().color;
                    c.a = 1;
                    ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.transform.GetChild(5).gameObject.GetComponent <UnityEngine.UI.Image>().color = c;
                }
            }

            GameObject block = tmp;
            int        lev   = (i * 2);
            ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).onClick.AddListener(() => setSelection(block, lev));
            ((UnityEngine.UI.Button)tmp.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).onClick.AddListener(() => setSelection(block, lev + 1));
        }
    }
//--------------------------------------------------------------------------------------------

	void setLevelButtonsClassified()
	{
		bool[] unlocks = mSavedGameManager.getCurrentGame().unlockedLevels;
		int i = 0;

		//for each button in the main level panel...
		foreach(Button b in mLevelPanel.GetComponentsInChildren<Button>())
		{
			//if the first stage for that level is locked...
			if(!unlocks[i])
			{
				//set the button's sprite to CLASSIFIED
				SpriteState ss = new SpriteState();

				//set the default state
				b.gameObject.GetComponent<Image>().sprite = levelButtonSprites[20];

				//set the different sprite states
				ss.pressedSprite = levelButtonSprites[21];
				ss.disabledSprite = levelButtonSprites[22];
				ss.highlightedSprite = levelButtonSprites[23];

				//apply the change to the button
				b.transition = Button.Transition.SpriteSwap;
				b.spriteState = ss;
			}

			//set OnClick audio based on unlock status
			b.GetComponents<AudioSource>()[1].clip = unlocks[i] ? unlockedAudio : lockedAudio;

			i += 3;
		}
	}
 public void Initialize()
 {
     SpriteState st = new SpriteState();
     if (interfaceB.isStudent)
     {
         st.highlightedSprite = bgSpriteStudent[0];
         st.pressedSprite = bgSpriteStudent[1];
         this.GetComponent<Button>().spriteState = st;
         icon.sprite = iconsStudent[0];
         title.color = InterfaceBehaviour.ClearGreen;
         desc.color = InterfaceBehaviour.ClearGreen;
     }
     else
     {
         st.highlightedSprite = bgSpriteTeacher[0];
         st.pressedSprite = bgSpriteTeacher[1];
         this.GetComponent<Button>().spriteState = st;
         icon.sprite = iconsTeacher[0];
         title.color = InterfaceBehaviour.Orange;
         desc.color = InterfaceBehaviour.Orange;
     }
     pin.GetComponent<RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f);
     icon.GetComponent<RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f);
     title.GetComponent<RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f);
     desc.GetComponent<RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f);
 }
Beispiel #39
0
    private Button buildButton(GameObject parent, string text, Color color) {
        Button button = parent.AddComponent<Button>();
        Image buttonImage = parent.AddComponent<Image>();
        buttonImage.sprite = buttonSprite;
        button.targetGraphic = buttonImage;
        //button.transition = Selectable.Transition.ColorTint;
        //ColorBlock cb = button.colors;
        //cb.normalColor = new Color(0.66f, 0.66f, 0.66f);
        //cb.highlightedColor = Color.white;
        //cb.pressedColor = new Color(0.33f, 0.33f, 0.33f);
        //cb.fadeDuration = 0.0f;
        //button.colors = cb;

        button.transition = Selectable.Transition.SpriteSwap;
        SpriteState ss = new SpriteState();
        ss.highlightedSprite = buttonHightlightSprite;
        ss.pressedSprite = buttonDownSprite;
        ss.disabledSprite = buttonDisabled;
        button.spriteState = ss;
        // if no more points left
        //button.interactable = false;

        Navigation nm = new Navigation();
        nm.mode = Navigation.Mode.None;
        button.navigation = nm;

        // add text to button
        GameObject buttonTextObj = new GameObject("text");
        Text buttonText = buttonTextObj.AddComponent<Text>();
        RectTransform trt = buttonText.rectTransform;
        trt.SetParent(button.transform, false);
        trt.anchorMin = Vector2.zero;
        trt.anchorMax = Vector2.one;
        trt.anchorMin = new Vector2(0.1f, 0.0f);
        trt.anchorMax = new Vector2(0.9f, 1.0f);
        trt.offsetMin = Vector2.zero;
        trt.offsetMax = Vector2.zero;
        buttonText.text = text;
        buttonText.font = font;
        buttonText.color = color;
        buttonText.alignment = TextAnchor.MiddleCenter;
        //text.fontSize = 40;
        buttonText.resizeTextForBestFit = true;
        buttonText.resizeTextMinSize = 10;
        buttonText.resizeTextMaxSize = 100;

        return button;
    }
    // Use this for initialization
    void Start () {
        b1 = GetComponent<Button>();
        b2_st = GetComponent<Button>().spriteState;
        if (this.gameObject.name == "ClearScores")
        {
            b1.onClick.AddListener(() => CallConfirmBox_Scores());
            GameObject text_ch = transform.GetChild(0).gameObject;
            text_ch.GetComponent<Text>().text = "Clear Scores";
        }
        else if (this.gameObject.name == "Options")
        {
            popup_options.SetActive(false);
            confirmation.SetActive(false);
            b1.onClick.AddListener(() => OptionsPopUp());


        }
        else if (this.gameObject.name == "Yes1")
        {
            b1.onClick.AddListener(() => CallClearScores());


        }
        else if (this.gameObject.name == "Yes2")
        {

            b1.onClick.AddListener(() => CallClearLevelProgress());

        }
        else if (this.gameObject.name == "No")
        {

            b1.onClick.AddListener(() => CloseConfirmBox());
        }

        else if (this.gameObject.name == "Cancel")
        {

            b1.onClick.AddListener(() => OptionsPopDown());


        }
        else if (this.gameObject.name == "Credits")
        {
            credits.SetActive(false);
            b1.onClick.AddListener(() => CallCredits());
        }
        else if (this.gameObject.name == "ExitCredits")
        {
            b1.onClick.AddListener(() => CutCredits());
        }
        else if (this.gameObject.name == "ClearLevelProgress")
        {
            b1.onClick.AddListener(() => CallConfirmBox_Progress());
            GameObject text_ch = transform.GetChild(0).gameObject;
            text_ch.GetComponent<Text>().text = "Clear Progress";
        }
        else if (this.gameObject.name == "UnlockAllLevels")
        {
            b1.onClick.AddListener(() => UnlockAllLevels());
            GameObject text_ch = transform.GetChild(0).gameObject;
            text_ch.GetComponent<Text>().text = "Unlock";
        }
        else if (this.gameObject.name == "ColorPicker")
        {
            b1.onClick.AddListener(() => CallCustomizationWindow());

        }
    }
 static int _CreateUnityEngine_UI_SpriteState(IntPtr L)
 {
     UnityEngine.UI.SpriteState obj = new UnityEngine.UI.SpriteState();
     ToLua.PushValue(L, obj);
     return(1);
 }
Beispiel #42
0
    // Use this for initialization
    void Start()
    {
        b1 = GetComponent<Button>();
        b2_st = GetComponent<Button>().spriteState;

        //b1.onClick.AddListener(() => CallCustomizationWindow());



        if (SaveScores.instance.CheckLevelStatus(i))
            {
            b1.onClick.AddListener(() => CallOnNextClick());
            gameObject.GetComponent<Image>().sprite = unlocked;
                b2_st.pressedSprite = unlocked_pressed;
                gameObject.GetComponent<Button>().spriteState = b2_st;
                //gameObject.GetComponent<Button>().spriteState.pressedSprite = unlocked_pressed;
                GameObject text_ch = transform.GetChild(0).gameObject;
                GameObject image_stars1 = transform.GetChild(1).gameObject;
                GameObject image_stars2 = transform.GetChild(2).gameObject;
                GameObject image_stars3 = transform.GetChild(3).gameObject;
                GameObject text_hs = transform.GetChild(4).gameObject;
                
                
                image_stars1.SetActive(true);
                image_stars2.SetActive(true);
                image_stars3.SetActive(true);
                text_hs.SetActive(true);
                text_hs.GetComponent<Text>().text = "High Score: " + SaveScores.instance.PrintHighScore(i);
                image_stars1.transform.localScale = new Vector3(2, 2, 2);
                image_stars2.transform.localScale = new Vector3(2, 2, 2);
                image_stars3.transform.localScale = new Vector3(2, 2, 2);
                ///////////////////////Star1//////////////////////
                if (SaveScores.instance.IsStar1(i)==1)
                {
                    image_stars1.GetComponent<Image>().sprite = gold_star;
                }
                else
                {
                    image_stars1.GetComponent<Image>().sprite = nostar;
                }
                ////////////////////Star2//////////////////////////////////
				if(SaveScores.instance.GetStarStatus(i))
				{
                if (SaveScores.instance.IsStar3(i)==3)
                {
                    image_stars3.GetComponent<Image>().sprite = gold_star;
                }
                else if (SaveScores.instance.IsStar3(i) == 2)
                {
                    image_stars3.GetComponent<Image>().sprite = silver_star;
                }
                else if (SaveScores.instance.IsStar3(i) == 1)
                {
                    image_stars3.GetComponent<Image>().sprite = bronze_star;
                }
                else if(SaveScores.instance.IsStar3(i) == 0)
                {
                    image_stars3.GetComponent<Image>().sprite = nostar;
                }
				}
				else
				{
					image_stars3.SetActive(false);
				}
                ////////////////////////Star3////////////////////////////////////
                if (SaveScores.instance.IsStar2(i) == 3)
                {
                    image_stars2.GetComponent<Image>().sprite = gold_star;
                }
                else if (SaveScores.instance.IsStar2(i) == 2)
                {
                    image_stars2.GetComponent<Image>().sprite = silver_star;
                }
                else if (SaveScores.instance.IsStar2(i) == 1)
                {
                    image_stars2.GetComponent<Image>().sprite = bronze_star;
                }
                else
                {
                    image_stars2.GetComponent<Image>().sprite = nostar;
                }

                
                text_ch.SetActive(true);
                text_ch.GetComponent<Text>().text = "" +i;
                
            }
            else
            {
                gameObject.GetComponent<Image>().sprite = locked;
                GameObject text_ch = transform.GetChild(0).gameObject;
                GameObject image_stars1 = transform.GetChild(1).gameObject;
                GameObject image_stars2 = transform.GetChild(2).gameObject;
                GameObject image_stars3 = transform.GetChild(3).gameObject;
                GameObject text_hs = transform.GetChild(4).gameObject;
                
                text_ch.SetActive(false);
                
                b1.onClick.AddListener(() => SoundManager.instance.playSFX(SoundManager.instance.clickedlockedLevel));
            

            image_stars1.SetActive(false);
                image_stars2.SetActive(false);
                image_stars3.SetActive(false);
                text_hs.SetActive(false);
            
            }
        }
//--------------------------------------------------------------------------------------------

	private void setChoiceButtonsSprites(Button b, int spriteIndex)
	{
		SpriteState ss = new SpriteState();

		//set the default state
		b.gameObject.GetComponent<Image>().sprite = buttonSprites[spriteIndex];

		//set sprite state images
		ss.pressedSprite = buttonSprites[spriteIndex + 1];
		ss.disabledSprite = buttonSprites[spriteIndex + 2];
		ss.highlightedSprite = buttonSprites[spriteIndex + 3];

		//apply change to the button
		b.transition = Button.Transition.SpriteSwap;
		b.spriteState = ss;
	}
Beispiel #44
0
    void Update()
    {
        if (selectedPlanet != null)
        {
            selectedHighlight.SetActive(true);
            selectedHighlight.transform.position = selectedPlanet.transform.position;
            selectedHighlight.transform.localScale = selectedPlanet.transform.localScale * 1.3f;

            if (selectedPlanetIsCurrentPlanet)
            {
                if (selectedPlanet.name == "Earth")
                    selectedHighlight.transform.localScale = Vector3.one * 1.7f;
                SetDescription(selectedPlanet.scripts, TextAnchor.MiddleLeft);
                selectButtonText.text = "";
                energyImage.SetActive(false);
                return;
            }
            if (selectedPlanet.isExplored)
            {
                energyImage.SetActive(false);
                selectButton.image.sprite = emigrationSpriteOn;
                SpriteState s = new SpriteState();
                s.pressedSprite = emigrationSpriteOff;
                selectButton.spriteState = s;
                selectButtonText.text = languageMgr.Translate("이주하기");
                selectButtonText.color = Color.black;
                SetDescription(selectedPlanet.scripts, TextAnchor.MiddleLeft);
            }
            else
            {
                energyImage.SetActive(true);
                selectButton.image.sprite = exploreSpriteOn;
                SpriteState s = new SpriteState();
                s.pressedSprite = exploreSpriteOff;
                selectButton.spriteState = s;
                int distance = selectedPlanet.transform.parent.GetComponent<Sector>().nowSectorTile.index - 1;
                selectButtonText.color = Color.white;
                selectButtonText.text = languageMgr.Translate("탐사하기") + "\n-" + (5f * distance).ToString();
                SetDescription(new string[] { "? ? ?", "? ? ?", "? ? ?" }, TextAnchor.MiddleCenter);
            }
        }
        else
        {
            energyImage.SetActive(false);
            selectedHighlight.SetActive(false);
        }
        population.text = dm.GetCurrentSectorData(sectorMgr.currentSector).population.ToString() + languageMgr.Translate("명");
        score.text = gm.score.ToString() + languageMgr.Translate("광년");
    }