Ejemplo n.º 1
1
	// Use this for initialization
	void Start ()
    {
        uiSprite = thumbImgaeObject.GetComponent<UI2DSprite>();
        uiLabelName = placeNameObject.GetComponent<UILabel>();
        uiLabelInfo = placeInfoObject.GetComponent<UILabel>();
        spr = Resources.LoadAll<Sprite>("Background");
	}
    private void UpdateSprite()
    {
        if (this.mUnitySprite == null && this.mNguiSprite == null)
        {
            this.mUnitySprite = base.GetComponent <SpriteRenderer>();
            this.mNguiSprite  = base.GetComponent <UI2DSprite>();
            if (this.mUnitySprite == null && this.mNguiSprite == null)
            {
                base.enabled = false;
                return;
            }
        }
        float num = (!this.ignoreTimeScale) ? Time.time : RealTime.time;

        if (this.framerate != 0)
        {
            this.mUpdate = num + Mathf.Abs(1f / (float)this.framerate);
        }
        if (this.mUnitySprite != null)
        {
            this.mUnitySprite.sprite = this.frames[this.mIndex];
        }
        else if (this.mNguiSprite != null)
        {
            this.mNguiSprite.nextSprite = this.frames[this.mIndex];
        }
    }
Ejemplo n.º 3
0
    public void Initialize(string _strName)
    {
        SetCharacter(_strName);

        if (m_spriteChara == null)
        {
            m_spriteChara = GetComponent <UI2DSprite> ();
        }
        m_spriteChara.sprite2D = m_sprIdleList [0];

        if (m_button == null)
        {
            m_button = GetComponent <ButtonBase> ();
        }

        m_eStep    = STEP.LOADING;
        m_eStepPre = STEP.MAX;
        m_Config.LoadResources("csv/config_chara");
        if (_strName.Equals("") || _strName.Equals(CsvKvs.READ_ERROR_STRING))
        {
            Debug.Log("empty");
            gameObject.SetActive(false);
        }
        else
        {
            Debug.Log("fill");
            gameObject.SetActive(true);
        }
        return;
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 单一渐变背景图
    /// </summary>
    /// <param name="effect">特效</param>
    /// <param name="callback">回调</param>
    //private IEnumerator TransBackGround(NewImageEffect effect, Action callback)
    //{
    //    UI2DSprite ui = bgSprite;
    //    UI2DSprite trans = backTransSprite;
    //    //将trans淡出同时淡入原ui
    //    float t = 0;
    //    float origin = trans.alpha;
    //    float final = 0;
    //    Debug.Log(effect.time);
    //    while (t < 1)
    //    {
    //        t = Mathf.MoveTowards(t, 1, 1 / effect.time * Time.deltaTime);
    //        trans.alpha = origin + t * (final - origin);
    //        ui.alpha = t;
    //        yield return null;
    //    }
    //    if (transList.ContainsKey(-1)) transList.Remove(-1);
    //    callback();
    //}

    /// <summary>
    /// 单一渐变图层(-1为背景层)
    /// </summary>
    /// <param name="effect">特效</param>
    /// <param name="callback">回调</param>
    private IEnumerator TransByDepth(NewImageEffect effect, Action callback)
    {
        UI2DSprite ui    = GetSpriteByDepth(effect.depth);
        UI2DSprite trans = GetTransByDepth(effect.depth);
        //将trans淡出同时淡入原ui
        float t      = 0;
        float origin = trans.alpha;
        float final  = 0;

        while (t < 1)
        {
            t           = Mathf.MoveTowards(t, 1, 1 / effect.time * Time.deltaTime);
            trans.alpha = origin + t * (final - origin);
            ui.alpha    = t;
            yield return(null);
        }
        //删除trans
        if (effect.depth != -1)
        {
            GameObject.Destroy(trans.gameObject);
        }
        if (transList.ContainsKey(effect.depth))
        {
            transList.Remove(effect.depth);
        }

        callback();
    }
Ejemplo n.º 5
0
 // Use this for initialization
 void Start()
 {
     fixedHeight = transform.root.GetComponent <UIRoot> ().manualHeight;
     sprite      = GetComponent <UI2DSprite> ();
     iniAlpha    = sprite.color.a;
     spriteSide  = sprite.width;
 }
Ejemplo n.º 6
0
    public void SaveImageInfo()
    {
        //储存当前的背景
        Dictionary <int, SpriteState> charaDic = new Dictionary <int, SpriteState>();

        //和立绘信息
        foreach (Transform child in fgPanel.transform)
        {
            //int depth = Convert.ToInt32(child.name.Substring(6, child.name.Length - 6));
            int        depth  = Convert.ToInt32(child.name.Substring(6));
            UI2DSprite ui     = child.GetComponent <UI2DSprite>();
            string     sprite = ui.sprite2D == null ? "" : ui.sprite2D.name;
            charaDic.Add(depth, new SpriteState(sprite, child.localPosition, ui.alpha));
        }
        if (bgSprite.sprite2D == null)
        {
            dm.gameData.bgSprite = string.Empty;
        }
        else
        {
            dm.gameData.bgSprite = bgSprite.sprite2D.name;
        }

        dm.gameData.fgSprites = charaDic;
    }
Ejemplo n.º 7
0
    private Vector3 SetDefaultPos(UI2DSprite ui, string pstr)
    {
        int x;

        switch (pstr)
        {
        case "left":
            x = -320;
            break;

        case "middle":
            x = 0;
            break;

        case "right":
            x = 320;
            break;

        default:
            x = 0;
            break;
        }
        int y = -540 + ui.height / 2;

        return(new Vector3(x, y));
    }
Ejemplo n.º 8
0
    static void ReplaceTo2DSprite()
    {
        // 取得所有選取對象.
        Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.Unfiltered);

        //遍历所有的游戏对象
        foreach (Object obj in SelectedAsset)
        {
            GameObject pGObj = (GameObject)obj;

            SpriteRenderer[] pRenderer = pGObj.GetComponentsInChildren <SpriteRenderer>();

            foreach (SpriteRenderer pRender in pRenderer)
            {
                pRender.gameObject.transform.localScale = Vector3.one;
                UI2DSprite pSprite = pRender.gameObject.AddComponent <UI2DSprite>();
                pSprite.sprite2D = pRender.sprite;
                pSprite.depth    = pRender.sortingOrder;
                pSprite.color    = pRender.color;
                pSprite.MakePixelPerfect();
            }
        }
        //刷新编辑器
        AssetDatabase.Refresh();
    }
Ejemplo n.º 9
0
    public bool LoadMaterial(UI2DSprite uiSprite, string fileName)
    {
        if (uiSprite == null || string.IsNullOrEmpty(fileName))
        {
            return(false);
        }
        Material mat;
        int      result = SetMaterialResource(uiSprite, fileName, out mat);

        if (result == 0)
        {
            uiSprite.material = null;
            return(false);
        }

        if (result == 2)
        {
            uiSprite.material = GameObject.Instantiate(mat);
            AddOrSetInstanceMaterialMap(uiSprite.GetInstanceID(), uiSprite.material);
        }
        else if (result == 1)
        {
            if (uiSprite.material == null)
            {
                mat = GetInstanceMaterialMap(uiSprite.GetInstanceID());
                uiSprite.material = mat;
            }
        }

        return(mat != null);
    }
Ejemplo n.º 10
0
    private void ImageSet(NewImageEffect effect, bool isSprite, bool isAlpha, bool isPos)
    {
        //决定操作对象
        UI2DSprite ui = bgSprite;

        if (effect.target == NewImageEffect.ImageType.Fore)
        {
            ui = GetSpriteByDepth(effect.depth);
        }
        ui.shader = Shader.Find("Unity/Transparent Colored");
        if (isSprite)
        {
            ui.sprite2D = LoadBackground(effect.state.spriteName);
            if (effect.target == NewImageEffect.ImageType.Fore)
            {
                ui.sprite2D = LoadCharacter(effect.state.spriteName);
                ui.MakePixelPerfect();
            }
        }
        if (isAlpha)
        {
            ui.alpha = effect.state.spriteAlpha;
        }
        if (isPos)
        {
            ui.transform.localPosition = string.IsNullOrEmpty(effect.defaultpos) ? effect.state.GetPosition() : SetDefaultPos(ui, effect.defaultpos);
        }
    }
Ejemplo n.º 11
0
        /// <summary>
        /// 淡出并移除背景
        /// </summary>
        /// <param name="time">淡出时间</param>
        public static Queue <ImageEffect> FadeOutBackground(float time)
        {
            AnimationBuilder builder = new AnimationBuilder();
            UI2DSprite       ui      = EffectBuilder.backgroundSprite;

            return(builder.BeginWith(EffectBuilder.FadeOut(ui, time)).Then(EffectBuilder.RemoveSprite(ui)).Get());
        }
Ejemplo n.º 12
0
        public static Queue <ImageEffect> ChangeSprite(UI2DSprite uiSprite, Sprite sprite)
        {
            AnimationBuilder builder = new AnimationBuilder();

            return(builder.BeginWith(EffectBuilder.ChangeSprite(uiSprite, sprite
                                                                )).Get());
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 移除背景
        /// </summary>
        public static Queue <ImageEffect> RemoveBackground()
        {
            AnimationBuilder builder = new AnimationBuilder();
            UI2DSprite       ui      = EffectBuilder.backgroundSprite;

            return(builder.BeginWith(EffectBuilder.ChangeSprite(ui, null)).Get());
        }
Ejemplo n.º 14
0
 void Awake()
 {
     _MySprite = GetComponent <UI2DSprite>();
     _Eating   = false;
     _NowTime  = 0.0f;
     _MaxTime  = Random.Range(1.0f, 2.5f);
 }
Ejemplo n.º 15
0
    private void SetEvidence()
    {
        //初始化[证据]列表
        eviNameList = DataManager.GetInstance().GetInTurnVar <List <string> >("持有证据");
        eviGrid.transform.DestroyChildren();
        foreach (string eviName in eviNameList)
        {
            if (!eviDic.ContainsKey(eviName))
            {
                return;
            }
            Evidence   evi    = eviDic[eviName];
            GameObject eviBtn = Resources.Load("Prefab/EvidenceContainer") as GameObject;
            eviBtn = NGUITools.AddChild(eviGrid, eviBtn);

            EvidenceButton script = eviBtn.GetComponent <EvidenceButton>();
            script.current = evi;
            script.SetUIManager(this);

            UILabel enl = eviBtn.transform.Find("EvidenceName_Label").GetComponent <UILabel>();
            enl.text = evi.name;

            UI2DSprite eis = eviBtn.transform.Find("EvidenceIcon_Sprite").GetComponent <UI2DSprite>();
            eis.sprite2D = Resources.Load <Sprite>(evi.iconPath);
        }
        eviGrid.GetComponent <UIGrid>().Reposition();
    }
    void OnEnable()
    {
        if (_sprite == null && gameObject.GetComponent <UI2DSprite>() != null)
        {
            _sprite = this.gameObject.GetComponent <UI2DSprite>();
        }

        if (defaultMaterial == null)
        {
            defaultMaterial = new Material(Shader.Find("Sprites/Default"));
        }

        if (ForceMaterial == null)
        {
            ActiveChange           = true;
            tempMaterial           = new Material(Shader.Find(shader));
            tempMaterial.hideFlags = HideFlags.None;
            if (_sprite != null)
            {
                _sprite.material = tempMaterial;
            }
        }
        else
        {
            ForceMaterial.shader    = Shader.Find(shader);
            ForceMaterial.hideFlags = HideFlags.None;
            if (_sprite != null)
            {
                _sprite.material = ForceMaterial;
            }
        }
    }
Ejemplo n.º 17
0
    public static UIRect getGameObjectRect(GameObject obj)
    {
        UIPanel panel = obj.GetComponent <UIPanel>();

        if (panel != null)
        {
            return(panel);
        }
        UILabel label = obj.GetComponent <UILabel>();

        if (label != null)
        {
            return(label);
        }
        UITexture texture = obj.GetComponent <UITexture>();

        if (texture != null)
        {
            return(texture);
        }
        UISprite sprite = obj.GetComponent <UISprite>();

        if (sprite != null)
        {
            return(sprite);
        }
        UI2DSprite sprite2D = obj.GetComponent <UI2DSprite>();

        if (sprite2D != null)
        {
            return(sprite2D);
        }
        return(null);
    }
Ejemplo n.º 18
0
    public bool LoadShaderAsync(UI2DSprite uiSprite, string fileName, int loadPriority = 0)
    {
        if (uiSprite == null || string.IsNullOrEmpty(fileName))
        {
            return(false);
        }
        var mgr = BaseResLoaderAsyncMgr.GetInstance();

        if (mgr != null)
        {
            ulong id;
            int   rk = ReMake(fileName, uiSprite, BaseResLoaderAsyncType.UI2DSpriteShader, false, out id);
            if (rk < 0)
            {
                return(false);
            }
            if (rk == 0)
            {
                return(true);
            }

            return(mgr.LoadShaderAsync(fileName, this, id, loadPriority));
        }
        return(false);
    }
Ejemplo n.º 19
0
 public static void SetSpriteFillAmount(UI2DSprite sprite, float p)
 {
     if (sprite)
     {
         sprite.fillAmount = p;
     }
 }
Ejemplo n.º 20
0
    /// <summary>
    /// Cache the sprite we'll be working with.
    /// </summary>

    protected override void OnInit()
    {
        base.OnInit();
        mSprite   = (mWidget as UISprite);
        mSprite2D = (mWidget as UI2DSprite);
        if (mSprite != null)
        {
            mNormalSprite = mSprite.spriteName;
        }
        if (mSprite2D != null)
        {
            mNormalSprite2D = mSprite2D.sprite2D;
        }
        //if (buttonSound == null)
        //{
        //    buttonSound = gameObject.GetComponent<UIButtonSoundPlayer>();
        //    if (buttonSound == null)
        //    {
        //        buttonSound = gameObject.AddComponent<UIButtonSoundPlayer>();
        //    }
        //    //버튼 이벤트로 사운드가 자동 재생되도록 하는 이벤트를 붙여주는데 기존에 이미 추가가 되었다면.
        //    //중복된 이벤트는 제거해주고 없으면 붙여준다.
        //    EventDelegate newDelegate = new EventDelegate(buttonSound, "Play");

        //    if (this.onClick.Contains(newDelegate) == false)
        //    {
        //        this.onClick.Add(newDelegate);
        //    }

        //}
    }
Ejemplo n.º 21
0
 public static void Set2dSpriteColor(UI2DSprite sprite, Color c)
 {
     if (sprite)
     {
         sprite.color = c;
     }
 }
Ejemplo n.º 22
0
    private void AssignObject()
    {
        animator       = gameObject.GetComponent <Animator>();
        spriteRenderer = Master.GetChildByName(gameObject, "Sprite").GetComponent <SpriteRenderer>();
        boxCollider2D  = gameObject.GetComponent <BoxCollider2D>();

        GameObject pf_general = Master.GetGameObjectInPrefabs("Characters/Units/General");

        general = NGUITools.AddChild(gameObject, pf_general);

        normalSpawnBullet  = Master.GetChildByName(gameObject, "NormalSpawnBullet").transform;
        upgradeSpawnBullet = Master.GetChildByName(gameObject, "UpgradeSpawnBullet").transform;
        healthShootBar     = Master.GetChildByName(gameObject, "HealthShootBar");
        healthBar          = Master.GetChildByName(gameObject, "HealthBar").GetComponent <UISlider>();
        shootBar           = Master.GetChildByName(gameObject, "ShootBar").GetComponent <UISlider>();
        reloadAlert        = Master.GetChildByName(gameObject, "ReloadAlert");
        upgradeAlert       = Master.GetChildByName(gameObject, "UpgradeAlert");
        upgradeBar         = Master.GetChildByName(gameObject, "UpgradeBar").GetComponent <UISlider>();
        priceUpgrade       = Master.GetChildByName(gameObject, "PriceLabelUpgrade").GetComponent <UILabel>();
        freezeEffect       = Master.GetChildByName(gameObject, "FreezeEffect").GetComponent <UI2DSprite>();

        healthShootBar.gameObject.SetActive(false);
        reloadAlert.SetActive(false);
        upgradeAlert.SetActive(false);
        upgradeBar.gameObject.SetActive(false);
        freezeEffect.gameObject.SetActive(false);
    }
Ejemplo n.º 23
0
    void AssignObject()
    {
        GameObject pf_general = Master.GetGameObjectInPrefabs("Characters/Enemies/General");

        general = NGUITools.AddChild(gameObject, pf_general);
        if (isSpineAnim)
        {
            if (anim == null)
            {
                anim = transform.GetComponent <SkeletonAnimation> ();
            }
            transform.localScale = new Vector3(33f, 33f, 33f);
            Master.GetChildByName(gameObject, "Sprite").gameObject.SetActive(false);
        }
        else
        {
            animator = gameObject.GetComponent <Animator> ();
        }
//    spriteRenderer = Master.GetChildByName (gameObject, "Sprite").GetComponent<SpriteRenderer> ();
        weapon = Master.GetChildByName(gameObject, weaponName).gameObject;


        freezeEffect = Master.GetChildByName(gameObject, "FreezeEffect").GetComponent <UI2DSprite> ();
        freezeEffect.gameObject.SetActive(false);

        weapon.SetActive(false);
        healthBar       = Master.GetChildByName(gameObject, "HealthBar").GetComponent <UISlider> ();
        critical        = Master.GetGameObjectInPrefabs("Critical");
        healthBar.value = 1;
        healthBar.gameObject.SetActive(false);
    }
    private void UpdateSprite()
    {
        if (mUnitySprite == null && mNguiSprite == null)
        {
            mUnitySprite = this.GetComponent <SpriteRenderer>();
            mNguiSprite  = this.GetComponent <UI2DSprite>();
            if (mUnitySprite == null && mNguiSprite == null)
            {
                this.set_enabled(false);
                return;
            }
        }
        float num = (!ignoreTimeScale) ? Time.get_time() : RealTime.time;

        if (framerate != 0)
        {
            mUpdate = num + Mathf.Abs(1f / (float)framerate);
        }
        if (mUnitySprite != null)
        {
            mUnitySprite.set_sprite(frames[mIndex]);
        }
        else if (mNguiSprite != null)
        {
            mNguiSprite.nextSprite = frames[mIndex];
        }
    }
Ejemplo n.º 25
0
        public GameObject CreateMask(GameObject parent, float maskAlpha, string name = MASK_NAME)
        {
            //Create Mask GameObject
            GameObject maskClip = NGUITools.AddChild(parent, true);

            maskClip.name = MASK_NAME;

            //Create UI2DSprite
            UI2DSprite tx      = maskClip.AddComponent <UI2DSprite>();
            Texture2D  texture = new Texture2D(1, 1);

            texture.SetPixel(0, 0, Color.black);
            texture.Apply();
            tx.sprite2D = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
            tx.type     = UIBasicSprite.Type.Sliced;
            tx.alpha    = maskAlpha;
            UIWidget widget = tx;

            //Create BoxCollider and Widget Size
            BoxCollider box = maskClip.AddComponent <BoxCollider>();

            box.isTrigger = true;
            widget.depth  = -1;
            widget.autoResizeBoxCollider = true;
            Vector2 size = FUtil.GetCurrentScreenSize();

            widget.width  = (int)size.x;
            widget.height = (int)size.y;

            return(maskClip);
        }
Ejemplo n.º 26
0
    protected override bool OnShaderLoaded(Shader target, UnityEngine.Object obj, BaseResLoaderAsyncType asyncType, bool isMatInst, string resName, string tag)
    {
        bool ret = base.OnShaderLoaded(target, obj, asyncType, isMatInst, resName, tag);

        if (!ret)
        {
            switch (asyncType)
            {
            case BaseResLoaderAsyncType.UITextureShader:
                UITexture ui1 = obj as UITexture;
                ui1.shader = target;
                break;

            case BaseResLoaderAsyncType.UI2DSpriteShader:
                UI2DSprite ui2 = obj as UI2DSprite;
                ui2.shader = target;
                break;

            default:
                return(false);
            }

            SetResource <Shader>(obj, target, resName, tag);
            return(true);
        }
        return(false);
    }
Ejemplo n.º 27
0
    public void setStats(LevelStat levelStat)
    {
        labelFruit      = fruitLabel.GetComponent <UILabel> ();
        labelCoins      = coinLabel.GetComponent <UILabel> ();
        labelFruit.text = levelStat.collectedFruits.Count + "/" + levelStat.maxFruits;
        labelCoins.text = "+" + levelStat.collectedCoins;

        List <Crystal.Color> crystalColors = levelStat.collectedCrystals;

        for (int i = 0; i < crystalColors.Count; i++)
        {
            Transform  child  = crystalParent.transform.GetChild(i);
            UI2DSprite sprite = child.gameObject.GetComponent <UI2DSprite> ();
            switch (crystalColors [i])
            {
            case Crystal.Color.Blue:
                sprite.sprite2D = CrystalController.current.crystalBlueSprite;
                break;

            case Crystal.Color.Green:
                sprite.sprite2D = CrystalController.current.crystalGreenSprite;
                break;

            case Crystal.Color.Red:
                sprite.sprite2D = CrystalController.current.crystalRedSprite;
                break;
            }
        }

        HeroController.lastRabit.enabled = false;
    }
Ejemplo n.º 28
0
    /// <summary>
    /// Immediately update the visible sprite.
    /// </summary>

    void UpdateSprite()
    {
        if (mUnitySprite == null && mNguiSprite == null)
        {
            mUnitySprite = GetComponent <UnityEngine.SpriteRenderer>();
            mNguiSprite  = GetComponent <UI2DSprite>();

            if (mUnitySprite == null && mNguiSprite == null)
            {
                enabled = false;
                return;
            }
        }

        float time = ignoreTimeScale ? RealTime.time : Time.time;

        if (framerate != 0)
        {
            mUpdate = time + Mathf.Abs(1f / framerate);
        }

        if (mUnitySprite != null)
        {
            mUnitySprite.sprite = frames[frameIndex];
        }
        else if (mNguiSprite != null)
        {
            mNguiSprite.nextSprite = frames[frameIndex];
        }
    }
Ejemplo n.º 29
0
    void OnDestroy()
    {
        if (this.gameObject.GetComponent <UI2DSprite>() != null)
        {
            if (_sprite == null)
            {
                _sprite = this.gameObject.GetComponent <UI2DSprite>();
            }
        }
        if ((Application.isPlaying == false) && (Application.isEditor == true))
        {
            if (tempMaterial != null)
            {
                DestroyImmediate(tempMaterial);
            }

            if (gameObject.activeSelf && defaultMaterial != null)
            {
                if (this.gameObject.GetComponent <UI2DSprite>() != null)
                {
                    _sprite.material           = defaultMaterial;
                    _sprite.material.hideFlags = HideFlags.None;
                }
            }
        }
    }
Ejemplo n.º 30
0
 void Start()
 {
     _Play              = true;
     _MySprite          = GetComponent <UI2DSprite>();
     _NowFrame          = 0;
     _MySprite.sprite2D = _Sprites[_NowFrame];
 }
Ejemplo n.º 31
0
    /// <summary>
    /// Immediately update the visible sprite.
    /// </summary>

    void UpdateSprite()
    {
        if (mUnitySprite == null && mNguiSprite == null)
        {
            mUnitySprite = GetComponent <UnityEngine.SpriteRenderer>();
            mNguiSprite  = GetComponent <UI2DSprite>();

            if (mUnitySprite == null && mNguiSprite == null)
            {
                enabled = false;
                return;
            }
        }

        float time = ignoreTimeScale ? RealTime.time : Time.time;

        if (framerate != 0)
        {
            mUpdate = time + Mathf.Abs(1f / framerate);
        }

        mIndex = Mathf.Clamp(mIndex, 0, animations[currentAnimation].frames.Length - 1);

        if (mUnitySprite != null)
        {
            mUnitySprite.sprite = animations[currentAnimation].frames[mIndex];
        }
        else if (mNguiSprite != null)
        {
            mNguiSprite.nextSprite = animations[currentAnimation].frames[mIndex];;
        }
    }
Ejemplo n.º 32
0
	// Use this for initialization
	void Start ()
    {
        root = GameObject.Find("UI Root");
        mm = root.transform.Find("Map_Panel").gameObject.GetComponent<MapManager>();
        uiSprite = thumbImgaeObject.GetComponent<UI2DSprite>();
        uiLabelName = placeNameObject.GetComponent<UILabel>();
        uiLabelInfo = placeInfoObject.GetComponent<UILabel>();
        spr = Resources.LoadAll<Sprite>("Background");
	}
Ejemplo n.º 33
0
	// Use this for initialization
    void Awake() 
    {
        uiManager = GameObject.FindGameObjectWithTag("UI").GetComponent<UIManager>();
        skillSprite = transform.FindChild("CoolDownContainer").GetComponent<UI2DSprite>();
        skillLevel = transform.FindChild("LevelContainer").GetComponent<SkillLevelContainer>();
        skillCost = transform.FindChild("CostCell").GetComponent<CostContainer>();
        skillCoolDown = transform.FindChild("CoolDownContainer").GetComponent<CoolDownContainer>();
        description = transform.FindChild("Description").GetComponent<UILabel>();
        mapManager = GameObject.FindGameObjectWithTag("Map").GetComponent<MapManager>();
	}
Ejemplo n.º 34
0
	public static void SetAnimations()
	{		
		currentSprite =  Selection.activeGameObject.GetComponent<UI2DSprite>();
		currentAnimation = Selection.activeGameObject.GetComponent<UI2DSpriteAnimation>();
		
		if( currentSprite == null || currentAnimation == null )
		{
			Debug.Log("Sprite ou animacao nula");
			 return;
		} 
		
		string spriteSheetPath = AssetDatabase.GetAssetPath( currentSprite.sprite2D );
		Sprite[] sprites = AssetDatabase.LoadAllAssetsAtPath(spriteSheetPath).OfType<Sprite>().ToArray();
		
		currentAnimation.AddNewAnimation( "newAnimation", sprites );
			
	}
Ejemplo n.º 35
0
	public void Initialize(Sprite sprite, InventoryPower power, int boardIndex){
		keyLabel = GetComponentInChildren<UILabel>();
		keyLabel.enabled = true;
		keyLabel.text = boardIndex.ToString();
		ActivationKey = boardIndex.ToString();

		associatedPower = power;
		powerIcon = GetComponent<UI2DSprite>();
		powerIcon.sprite2D = sprite;

		if(boardIndex == 1)
		{
			activationButton = InputControlType.LeftBumper;
		}
		else 
		{
			activationButton = InputControlType.RightBumper;
		}
	}
Ejemplo n.º 36
0
	public override void Start() {
		base.Start();
		currentHealth = maxHealth;
		matchManager = GameObject.FindGameObjectWithTag("MatchManager").GetComponent<MatchManager>();
		damageOverlayImage = GameObject.FindGameObjectWithTag("DamageOverlay").GetComponent<UI2DSprite>();
		matchData = spaceship.GetComponent<SpaceshipMatchData>();

		if (damageOverlayImage == null) {
			Debug.Log("No UI2DSprite tagged with 'DamageOverlay' was found in the scene!");
		}
		Color indicatorColor = enemyIndicator.renderer.material.GetColor("_TintColor");
		indicatorColor.a = 0.0f;
		enemyIndicator.renderer.material.SetColor("_Tint", indicatorColor);
	
		/* Make local copy of material so multiple of the same ships don't reference the same one. */
		Material electricFieldCopy = Instantiate(electricField) as Material;
		electricField = electricFieldCopy;
		spaceshipShell.renderer.material = electricFieldCopy;
		spaceshipShell.GetComponent<ScrollUVLinear>().materialToScroll = electricFieldCopy;
	}
Ejemplo n.º 37
0
	// Use this for initialization
	void Start () 
	{
		instance = this;

		frozen = transform.FindChild ("Frozen").GetComponent<UI2DSprite> ();
		damage = transform.FindChild ("Damage").GetComponent<UI2DSprite> ();
		invencibility = transform.FindChild ("Invencibility").GetComponent<UI2DSprite> ();
		blank = transform.FindChild ("Blank").GetComponent<UISprite> ();
		shield = transform.FindChild("Shield").GetComponent<UI2DSprite>();

		myAudioSource = GetComponent<AudioSource>();

		frozen.enabled = false;
		damage.enabled = false;
		invencibility.enabled = false;
		blank.enabled = false;
		shield.enabled = false;

		GameController.OnReset += Reset;
	}
Ejemplo n.º 38
0
	/// <summary>
	/// Immediately update the visible sprite.
	/// </summary>

	void UpdateSprite ()
	{
		if (mUnitySprite == null && mNguiSprite == null)
		{
			mUnitySprite = GetComponent<UnityEngine.SpriteRenderer>();
			mNguiSprite = GetComponent<UI2DSprite>();

			if (mUnitySprite == null && mNguiSprite == null)
			{
				enabled = false;
				return;
			}
		}

		float time = ignoreTimeScale ? RealTime.time : Time.time;
		if (framerate != 0) mUpdate = time + Mathf.Abs(1f / framerate);

		if (mUnitySprite != null)
		{
			mUnitySprite.sprite = frames[mIndex];
		}
		else if (mNguiSprite != null)
		{
			mNguiSprite.nextSprite = frames[mIndex];
		}
	}
Ejemplo n.º 39
0
	// Use this for initialization
	void Start () {
		currentWeaponSprite = GetComponent<UI2DSprite>();
	}
Ejemplo n.º 40
0
	/// <summary>
	/// Cache the sprite we'll be working with.
	/// </summary>

	protected override void OnInit ()
	{
		base.OnInit();
		mSprite = (mWidget as UISprite);
		mSprite2D = (mWidget as UI2DSprite);
		if (mSprite != null) mNormalSprite = mSprite.spriteName;
		if (mSprite2D != null) mNormalSprite2D = mSprite2D.sprite2D;
	}
Ejemplo n.º 41
0
	private void initLabels() {

		driverTitle = this.transform.FindChild("DriverTitle").GetComponent<UILabel>();
		this.faceSprite = this.gameObject.GetComponentInChildren<UI2DSprite>();
		
	}
Ejemplo n.º 42
0
 private void UpdateSprite()
 {
     if (this.mUnitySprite == null && this.mNguiSprite == null)
     {
         this.mUnitySprite = base.GetComponent<SpriteRenderer>();
         this.mNguiSprite = base.GetComponent<UI2DSprite>();
         if (this.mUnitySprite == null && this.mNguiSprite == null)
         {
             base.enabled = false;
             return;
         }
     }
     float num = (!this.ignoreTimeScale) ? Time.time : RealTime.time;
     if (this.framerate != 0)
     {
         this.mUpdate = num + Mathf.Abs(1f / (float)this.framerate);
     }
     if (this.mUnitySprite != null)
     {
         this.mUnitySprite.sprite = this.frames[this.mIndex];
     }
     else if (this.mNguiSprite != null)
     {
         this.mNguiSprite.nextSprite = this.frames[this.mIndex];
     }
 }
Ejemplo n.º 43
0
	/// <summary>
	/// Cache the sprite we'll be working with.
	/// </summary>

	protected override void OnInit ()
	{
		base.OnInit();
		mSprite = (mWidget as UISprite);
		mSprite2D = (mWidget as UI2DSprite);
		if (mSprite != null) mNormalSprite = mSprite.spriteName;
		if (mSprite2D != null) mNormalSprite2D = mSprite2D.sprite2D;
        
        if(gameObject.GetComponent<SoundButtonClick>() == null)
            gameObject.AddComponent<SoundButtonClick>();
	}
Ejemplo n.º 44
0
	void Start ()
	{
		mUnitySprite = GetComponent<UnityEngine.SpriteRenderer>();
		mNguiSprite = GetComponent<UI2DSprite>();
		if (framerate > 0) mUpdate = (ignoreTimeScale ? RealTime.time : Time.time) + 1f / framerate;
	}
Ejemplo n.º 45
0
	public void SetSprite( UI2DSprite spt )
	{
		mSprite = spt;
	}
Ejemplo n.º 46
0
	protected override void OnEnable ()
	{
		base.OnEnable();
		mSprite = target as UI2DSprite;
	}
Ejemplo n.º 47
0
 protected override void OnInit()
 {
     base.OnInit();
     this.mSprite = (this.mWidget as UISprite);
     this.mSprite2D = (this.mWidget as UI2DSprite);
     if (this.mSprite != null)
     {
         this.mNormalSprite = this.mSprite.spriteName;
     }
     if (this.mSprite2D != null)
     {
         this.mNormalSprite2D = this.mSprite2D.sprite2D;
     }
 }
Ejemplo n.º 48
0
	/// <summary>
	/// Immediately update the visible sprite.
	/// </summary>

	void UpdateSprite ()
	{
		if (mUnitySprite == null && mNguiSprite == null)
		{
			mUnitySprite = GetComponent<UnityEngine.SpriteRenderer>();
			mNguiSprite = GetComponent<UI2DSprite>();

			if (mUnitySprite == null && mNguiSprite == null)
			{
				enabled = false;
				return;
			}
		}

		float time = ignoreTimeScale ? RealTime.time : Time.time;
		if (framerate != 0) mUpdate = time + Mathf.Abs(1f / framerate);
		
		mIndex = Mathf.Clamp( mIndex, 0, animations[currentAnimation].frames.Length-1 );

		if (mUnitySprite != null)
		{
			mUnitySprite.sprite = animations[currentAnimation].frames[mIndex];
		}
		else if (mNguiSprite != null)
		{
			
			mNguiSprite.nextSprite = animations[currentAnimation].frames[mIndex];;
		}
	}
Ejemplo n.º 49
0
	// Use this for initialization
	void Start () {
		energybarSprite = GetComponent<UI2DSprite>();
		initialScale = this.transform.localScale;
		currentScale = initialScale;
	}
Ejemplo n.º 50
0
 // Use this for initialization
 void Start()
 {
     cdMask = GetComponent<UI2DSprite>();
 }
Ejemplo n.º 51
0
		// Use this for initialization
		void Start () {
            spr = GetComponent<UI2DSprite>();
		}
Ejemplo n.º 52
0
		public void initLabels() {
			UI2DSprite[] uis = this.GetComponentsInChildren<UI2DSprite>();
			for(int i = 0;i<uis.Length;i++) {
				if(uis[i].name=="LogoSprite") {
					this.companySprite = uis[i];
				}
			}
			companyTitle = initLabel("SponsorTitle");
			sponsorDescription = initLabel("SponsorDescription");
			contractLength = initLabel("ContractLengthValue");
			contractValue = initLabel("SponsorOfferValue");
			this.sponsorInterest = initLabel("InterestValue");
			this.positionLabel = initLabel("AdPositionValue");
			
			
	}
Ejemplo n.º 53
0
	// Use this for initialization
	void Awake () {
        sprite = GetComponent<UI2DSprite>();
        uiManager = GameObject.FindWithTag("UI").GetComponent<UIManager>();
        label = transform.FindChild("Label").GetComponent<UILabel>();
	}