Inheritance: exSpriteBase
示例#1
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    void Init()
    {
        if (nameToState == null)
        {
            initialized = false;
        }

        if (initialized == false)
        {
            initialized = true;

            sprite       = GetComponent <exSprite>();
            defaultAtlas = sprite.atlas;
            defaultIndex = sprite.index;

            nameToState = new Dictionary <string, exSpriteAnimState> ();
            for (int i = 0; i < animations.Count; ++i)
            {
                exSpriteAnimState state = new exSpriteAnimState(animations[i]);
                nameToState[state.name] = state;
            }

            if (defaultAnimation != null)
            {
                curAnimation = nameToState[defaultAnimation.name];
            }
        }
    }
    // Update notes states
    void UpdateNotes()
    {
        // Game over check
        if (common.gameOver)
        {
            return;
        }

        // Iterate through each active node
        foreach (NotesScript note in notes)
        {
            float timeDiff = common.GetTimeDiff(note);
            common.CheckAutoPlay(note, timeDiff);
            common.UpdateNoteState(note, timeDiff);

            // Update tapbox size
            exSprite sprite = note.tapbox.gameObject.GetComponent <exSprite>();
            if (timeDiff > 0)               // Before tapbox
            {
                float multiplier = timeDiff / CommonScript.TIME_ONSCREEN;
                sprite.scale = tapboxSize * (1 + multiplier);
            }
            else
            {
                sprite.scale = tapboxSize;
            }
        }
    }
示例#3
0
    ///////////////////////////////////////////////////////////////////////////////
    // Panel
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    static void CreatePanelObject(bool _useSprite)
    {
        // create panel object
        GameObject panelGO = new GameObject("Panel");
        exUIPanel  panel   = panelGO.AddComponent <exUIPanel>();

        // create Background
        if (_useSprite)
        {
            GameObject backgroundGO = new GameObject("Background");
            exSprite   background   = backgroundGO.AddComponent <exSprite>();
            panel.background = background;
            backgroundGO.transform.parent = panelGO.transform;
        }
        else
        {
            GameObject     backgroundGO = new GameObject("Background");
            exSpriteBorder background   = backgroundGO.AddComponent <exSpriteBorder>();
            panel.background = background;
            backgroundGO.transform.parent = panelGO.transform;
        }

        panel.width  = 100.0f;
        panel.height = 100.0f;

        //
        Selection.activeObject = panelGO;
    }
        public override void OnEnter()
        {
            // Get the target of the animation
            TargetGameObject = Fsm.GetOwnerDefaultTarget(gameObject);

            // If there is no target
            if (TargetGameObject == null && AnimationName != null)
            {
                Finish();
                return;
            }
            exanimation = TargetGameObject.GetComponent<exSpriteAnimation>();
            exsprite = TargetGameObject.GetComponent<exSprite>();
            exsprite.trimTexture = trimTexture.Value;
            exsprite.useTextureOffset = useTextureOffset.Value;
            if (color.Value != Color.white)
            {
                exsprite.color = color.Value;
            }else
            {
                exsprite.color = exsprite.color;
            }
            exsprite.enabled = true;
            exanimation.Stop();
            exanimation.Play(AnimationName.Value);
        }
示例#5
0
    ///////////////////////////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////////////////////////

    public static void SetBarSize(exSprite _bar,
                                  float _barSize,
                                  float _progress,
                                  Direction _direction)
    {
        if (_bar != null)
        {
            if (_direction == Direction.Horizontal)
            {
                if (_bar.spriteType == exSpriteType.Sliced)
                {
                    float progressWidth = _progress * (_barSize - _bar.leftBorderSize - _bar.rightBorderSize);
                    _bar.width = progressWidth + _bar.leftBorderSize + _bar.rightBorderSize;
                }
                else
                {
                    _bar.width = _progress * _barSize;
                }
            }
            else
            {
                if (_bar.spriteType == exSpriteType.Sliced)
                {
                    float progressHeight = _progress * (_barSize - _bar.topBorderSize - _bar.bottomBorderSize);
                    _bar.height = progressHeight + _bar.topBorderSize + _bar.bottomBorderSize;
                }
                else
                {
                    _bar.height = _progress * _barSize;
                }
            }
        }
    }
示例#6
0
 void Start()
 {
     mSprite = (exSprite)GetComponent<exSprite>();
     mIsActive = false;
     mIsStartup = false;
     mAI = (SkillAI)gameObject.AddComponent("SkillAI");
 }
示例#7
0
        public static exSprite NewSlicedSprite(GameObject _go, exTextureInfo _info,
                                               int _left, int _right, int _top, int _bottom,
                                               int _width, int _height, Color _color,
                                               bool _borderOnly)
        {
            exSprite sprite = _go.GetComponent <exSprite>();

            if (sprite == null)
            {
                sprite = _go.AddComponent <exSprite>();
            }
            if (sprite.shader == null)
            {
                sprite.shader = Shader.Find("ex2D/Alpha Blended");
            }
            sprite.spriteType  = exSpriteType.Sliced;
            sprite.textureInfo = _info;

            sprite.borderOnly       = _borderOnly;
            sprite.customBorderSize = true;
            sprite.leftBorderSize   = _left;
            sprite.rightBorderSize  = _right;
            sprite.topBorderSize    = _top;
            sprite.bottomBorderSize = _bottom;

            sprite.customSize = true;
            sprite.width      = _width;
            sprite.height     = _height;

            sprite.color = _color;

            return(sprite);
        }
    // Use this for initialization
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
        LM = (LevelManager)FindObjectOfType(typeof(LevelManager));

        Debug.Log("Starting #" + nHumans);
        myTransform = transform;
        spriteObj = GetComponent<exSprite>();
        spriteAnimation = GetComponent<exSpriteAnimation>();
        // Determine if I should be an alien.
        if (nAliens < maxAliens) {
            float pAlien = 0;
            if (nHumans >= nHandlers - maxAliens) {
                pAlien = 1;
            }
            else {
                pAlien = Random.Range(0, nHandlers);
            }
            if (pAlien <= 1 || nHumans >= nHandlers ) {
                Debug.Log("Human "+ nHumans + " Is an ALIEN!");
                isAlien = true;
                nAliens++;
                nHumans++;
            }
            else {
                Debug.Log("Human "+ nHumans + " Is a HUMAN!");
                nHumans++;
            }
        }
        //EventManager.instance.AddListener(this, "Oso_clicked");
        if (isAlien) {
            audio.pitch = 1.75f;
        }
    }
示例#9
0
    ///////////////////////////////////////////////////////////////////////////////
    // Internal Functions
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    void Init()
    {
        bool initialized = (nameToState != null);

        if (initialized == false)
        {
            sprite_            = GetComponent <exSprite>();
            defaultTextureInfo = sprite_.textureInfo;

            nameToState = new Dictionary <string, exSpriteAnimationState>();
            for (int i = 0; i < animations.Count; ++i)
            {
                exSpriteAnimationClip clip = animations[i];
                if (clip != null)
                {
                    exSpriteAnimationState state = new exSpriteAnimationState(clip);
                    nameToState[state.name] = state;
                    if (ReferenceEquals(defaultAnimation, clip))
                    {
                        curAnimation   = state;
                        lastFrameIndex = -1;
                    }
                }
            }
            exDebug.Assert(defaultAnimation == null || defaultAnimation == nameToState[defaultAnimation.name].clip);
        }
    }
示例#10
0
    static public EZJointTween Play(GameObject bone, GameObject joint, exSprite sprite, EZSkew skew, JsonSkeletalObj[] datas, float speed, int n, float time)
    {
        int temp = 0;

        for (int m = 0; m < n + 1; ++m)
        {
            temp += datas[m].d;
        }

        float duration = temp * speed - time;

        if (duration < 0)
        {
            duration = 0;
        }
        EZJointTween comp = EZTweener.Begin <EZJointTween>(joint, duration);

        comp.sprite_ = sprite;
        comp.skew_   = skew;
        comp._joint  = joint;
        comp._bone   = bone;
        comp._datas  = datas;
        comp._speed  = speed;
        comp._n      = n;
        comp.setup();
        comp.onFinished = EZJointTween.OnFinished_;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            EZJointTween.OnFinished_(comp);
        }
        return(comp);
    }
示例#11
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    protected new void LateUpdate()
    {
        base.LateUpdate();
        if (sprite == null)
        {
            sprite = GetComponent <exSprite>();
            if (sprite == null)
            {
                Debug.LogError("Can't find exSprite Component in GameObject " + gameObject.name);
                return;
            }
        }

        if (lastColor != sprite.color)
        {
            lastColor           = sprite.color;
            sprite.updateFlags |= exPlane.UpdateFlags.Color;
        }
        if (lastWidth != sprite.width)
        {
            lastWidth           = sprite.width;
            sprite.updateFlags |= exPlane.UpdateFlags.Vertex;
        }
        if (lastHeight != sprite.height)
        {
            lastHeight          = sprite.height;
            sprite.updateFlags |= exPlane.UpdateFlags.Vertex;
        }
    }
示例#12
0
    // Use this for initialization
    void Start()
    {
        warCtrl = GameObject.FindWithTag("GameController").GetComponent <WarSceneController>();
        rwCrt   = GameObject.Find("RangedWeapons").GetComponent <RangedWeaponCreator>();

        sprite = GetComponent <exSprite>();
        anim   = GetComponent <exSpriteAnimation>();

        if (soliderType == 3 || soliderType == 4 || soliderType == 5)
        {
            timeCoolDown = 1;
        }
        else
        {
            timeCoolDown = 0.5f;
        }

        manPosMaxX    = WarSceneController.manPosMaxX;
        manPosMaxY    = WarSceneController.manPosMaxY;
        locationStepX = WarSceneController.locationStepX;
        locationStepY = WarSceneController.locationStepY;
        CheckLocationState();

        hitDistance1 = (int)(hitDistance / locationStepX);
    }
示例#13
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------ 
    // Desc: 
    // ------------------------------------------------------------------ 

    protected new void Awake () {
        base.Awake();

        sprite = GetComponent<exSprite>();
        lastColor = sprite.color;
        lastWidth = sprite.width;
        lastHeight = sprite.height;
    }
示例#14
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    protected new void OnEnable()
    {
        base.OnEnable();
        if (target != editSprite)
        {
            editSprite = target as exSprite;
        }
    }
示例#15
0
    public SpriteTrailSprite createSpriteTrailSprite(exSprite pExSprite)
    {
        SpriteTrailSprite sprite = (GameObject.Instantiate(ApplicationFactory.instance.m_emptyExSpritePrefab) as GameObject).GetComponent <SpriteTrailSprite>();

        sprite.init(pExSprite);

        return(sprite);
    }
示例#16
0
 // Use this for initialization
 void Start()
 {
     enabled      = false;
     timeTick     = 0;
     sprite       = transform.GetChild(0).GetComponent <exSprite>();
     sprite.color = new Color(0, 0, 0, 0);
     sprite.gameObject.SetActive(false);
 }
示例#17
0
    // Remove completed notes, add new ones
    void UpdateNotesList()
    {
        // Game over check
        if (common.gameOver)
        {
            return;
        }

        // Remove completed notes, assumes sequential removal
        while (notes.Count > 0 && notes.First.Value.state == NotesScript.NotesState.REMOVE)
        {
            Destroy(notes.First.Value.gameObject);
            notes.RemoveFirst();
        }

        // Add new notes
        while (notesIterator.hasNext())
        {
            // If in the look-ahead range
            if (notesIterator.nextTime() - common.musicTime < CommonScript.TIME_LOOKAHEAD)
            {
                GameObject  notesObject = (GameObject)Instantiate(notesPrefab);
                NotesScript note        = notesObject.GetComponent <NotesScript>();
                notesIterator.next(note);
                // Set note's position
                Vector3 position;
                float   timePoint  = note.time % CommonScript.TIME_SCROLL;
                float   multiplier = timePoint / CommonScript.TIME_SCROLL;
                switch (note.column)
                {
                case 0: position = notesPositionInit_0 - notesPositionDelta_0 * multiplier; break;

                case 1: position = notesPositionInit_1 - notesPositionDelta_1 * multiplier; break;

                case 2: position = notesPositionInit_2 - notesPositionDelta_2 * multiplier; break;

                case 3: position = notesPositionInit_3 - notesPositionDelta_3 * multiplier; break;

                default: position = new Vector3(0, 0, 0); break;                         // Error
                }
                notesObject.transform.position = position;
                exSprite sprite = notesObject.GetComponent <exSprite>();
                sprite.color = new Color(1, 1, 1, 0);
                notes.AddLast(new LinkedListNode <NotesScript>(note));
            }
            else
            {
                break;
            }
        }

        // Check game done
        if (notes.Count == 0 && !notesIterator.hasNext())
        {
            slider.gameObject.active = false;
            common.OnGameOver();
        }
    }
示例#18
0
    public void init(exSprite pExSprite)
    {
        //Cache and init ex sprite component
        exSprite = GetComponent <exSprite>();
        exSprite.SetSprite(pExSprite.atlas, pExSprite.index);

        renderer.enabled  = false;
        renderer.material = m_alphaMaterial;
    }
示例#19
0
    public void SetTexture(int index)
    {
        if (mSprite == null)
            mSprite = (exSprite)GetComponent<exSprite>();

        Debug.Log(mSprite);
        Debug.Log (mSprite.atlas);
        mSprite.SetSprite(mSprite.atlas, index, false);
    }
示例#20
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    protected new void Awake()
    {
        base.Awake();

        sprite     = GetComponent <exSprite>();
        lastColor  = sprite.color;
        lastWidth  = sprite.width;
        lastHeight = sprite.height;
    }
示例#21
0
    void Awake()
    {
        exSprite = GetComponent<exSprite>();

        //default to player team
        team = new Team();
        team.id = GameManager.teams[0].id;
        team.color = GameManager.teams[0].color;
    }
示例#22
0
    public void InitArmyInfo(ArmyInfo ai)
    {
        armyInfo          = ai;
        armyInfo.armyCtrl = GetComponent <ArmyController>();

        SetArmyKingFlag();

        if (armyInfo.cityTo != -1)
        {
            if (pathfinding == null)
            {
                pathfinding = GameObject.FindWithTag("Pathfinding").GetComponent <MyPathfinding>();
            }
            SetRoute(pathfinding.GetRoute(armyInfo.pos, armyInfo.cityTo));
        }

        state    = (ArmyState)armyInfo.state;
        timeTick = armyInfo.timeTick;

        if (state == ArmyState.Garrison)
        {
            exSprite          moveSprite = GetComponent <exSprite>();
            exSpriteAnimation moveAnim   = GetComponent <exSpriteAnimation>();
            moveAnim.Stop();

            int frame = armyInfo.direction;
            if (frame == -1)
            {
                frame = 0;
            }
            moveAnim.SetFrame("ArmyGarrison", frame);

            Vector3 pos = flagPos[3 + frame];
            if (!armyInfo.isFlipped)
            {
                pos.x = -pos.x;
            }
            else
            {
                isHFlipped = true;
                moveSprite.HFlip();

                exSprite    flagSprite = flagCtrl.GetComponent <exSprite>();
                BoxCollider flagCol    = flagCtrl.GetComponent <BoxCollider>();
                flagSprite.HFlip();
                flagCol.center = new Vector3(-flagCol.center.x, flagCol.center.y, flagCol.center.z);
            }

            flagCtrl.localPosition = pos;
        }
        else
        {
            CalcDirection();
        }
    }
示例#23
0
    // Setup tapboxes and touch input
    void SetupTapboxes()
    {
        //tapboxes = new List<TapboxScript>();
        GameObject sliderObject = (GameObject)Instantiate(tapboxPrefab);

        slider = sliderObject.GetComponent <TapboxScript>();
        exSprite sprite = sliderObject.GetComponent <exSprite>();

        sprite.scale        = new Vector2(SLIDER_WIDTH, SLIDER_HEIGHT);
        sprite.color        = new Color(1, 1, 1, 0.75f);
        sliderPositionDelta = sliderPositionInit - sliderPositionEnd;
    }
示例#24
0
    // Initialize a tapbox
    TapboxScript InitTapbox(int column, Vector3 position)
    {
        GameObject   tapboxObject = (GameObject)Instantiate(tapboxPrefab);
        TapboxScript tapbox       = tapboxObject.GetComponent <TapboxScript>();

        tapbox.Setup(column);
        tapboxObject.transform.position = position;
        exSprite sprite = tapboxObject.GetComponent <exSprite>();

        sprite.scale = gridScale;
        return(tapbox);
    }
示例#25
0
    public void UpdateNoteState(NotesScript note, float timeDiff)
    {
        // Update alpha
        exSprite sprite = note.gameObject.GetComponent <exSprite>();

        if (timeDiff > TIME_ONSCREEN_OPAQ)
        {
            sprite.color = new Color(1, 1, 1, 1 - (timeDiff - TIME_ONSCREEN_OPAQ) / (TIME_LOOKAHEAD - TIME_ONSCREEN_OPAQ));
        }
        else
        {
            sprite.color = new Color(1, 1, 1, 1);
        }

        // We assume notes don't skip states (e.g. from DISABLE to MISS)
        switch (note.state)
        {
        case NotesScript.NotesState.DISABLE:
            if (timeDiff <= TIME_ACTIVE)
            {
                note.state = NotesScript.NotesState.ACTIVE;
            }
            break;

        case NotesScript.NotesState.ACTIVE:
            if (timeDiff <= TIME_MISS)
            {
                OnNoteMiss(note);
            }
            break;

        case NotesScript.NotesState.HIT:
            float hitTimeDiff = note.time_hit - musicTime;
            if (hitTimeDiff <= TIME_REMOVE)
            {
                note.state = NotesScript.NotesState.REMOVE;
            }
            break;

        case NotesScript.NotesState.MISS:
            // TODO
            if (timeDiff <= TIME_MISS + TIME_REMOVE)
            {
                note.state = NotesScript.NotesState.REMOVE;
            }
            break;

        case NotesScript.NotesState.REMOVE:
        default:
            break;
        }
    }
    void Start()
    {
        RUIManager.instance.registerRUISpriteButton(gameObject);

        sp = transform.GetComponent<exSprite> ();
        currentState = states.Normal;
        int idx = sp.index;
        NormalState = sp.atlas.elements [idx].name;

        if (ClickState == null || ClickState == "") {
            Debug.LogWarning ("Click State NOT SET: " + name);
        }
    }
示例#27
0
    public void init(Player pPlayer, Transform pTransform, Board pBoard)
    {
        m_transform = pTransform;
        m_board     = pBoard;

        m_player = pPlayer;

        m_sprite = GetComponent <exSprite>();

        m_playerAnimation = GetComponent <PlayerAnimation>();

        //Set idle animation
        m_playerAnimation.playAnimation(m_player.team.ID + (m_player.isGK ? "_gk_" : "_player_") + PlayerAnimationIds.Idle);
    }
示例#28
0
    ///////////////////////////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    protected new void Awake()
    {
        base.Awake();

        // handle scroll bar
        Transform transBar = transform.Find("__bar");

        if (transBar)
        {
            bar = transBar.GetComponent <exSprite>();
        }

        UpdateBar();
    }
示例#29
0
 ///////////////////////////////////////////////////////////////////////////////
 // functions
 ///////////////////////////////////////////////////////////////////////////////
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 public static void UpdateAtlas( exSprite _sprite, 
                                  exAtlasDB.ElementInfo _elInfo )
 {
     // get atlas and index from textureGUID
     if ( _elInfo != null ) {
         if ( _elInfo.guidAtlas != exEditorHelper.AssetToGUID(_sprite.atlas) ||
              _elInfo.indexInAtlas != _sprite.index )
         {
             _sprite.SetSprite( exEditorHelper.LoadAssetFromGUID<exAtlas>(_elInfo.guidAtlas),
                                _elInfo.indexInAtlas );
         }
     }
     else {
         _sprite.Clear();
     }
 }
示例#30
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public static void UpdateAtlas(exSprite _sprite,
                                   exAtlasDB.ElementInfo _elInfo)
    {
        // get atlas and index from textureGUID
        if (_elInfo != null)
        {
            if (_elInfo.guidAtlas != exEditorHelper.AssetToGUID(_sprite.atlas) ||
                _elInfo.indexInAtlas != _sprite.index)
            {
                _sprite.SetSprite(exEditorHelper.LoadAssetFromGUID <exAtlas>(_elInfo.guidAtlas),
                                  _elInfo.indexInAtlas);
            }
        }
        else
        {
            _sprite.Clear();
        }
    }
示例#31
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public static void SetSize(exSpriteBase _sp, float _newWidth, float _newHeight)
    {
        exSprite spriteBG = _sp as exSprite;

        if (spriteBG)
        {
            spriteBG.width  = _newWidth;
            spriteBG.height = _newHeight;
        }
        else
        {
            exSpriteBorder borderBG = _sp as exSpriteBorder;
            if (borderBG)
            {
                borderBG.width  = _newWidth;
                borderBG.height = _newHeight;
            }
        }
    }
示例#32
0
    // Setup tapboxes and touch input
    void SetupTapboxes()
    {
        //tapboxes = new List<TapboxScript>();
        GameObject sliderObject_0 = (GameObject)Instantiate(tapboxPrefab);

        slider_0 = sliderObject_0.GetComponent <TapboxScript>();
        exSprite sprite_0 = sliderObject_0.GetComponent <exSprite>();

        sprite_0.scale        = sliderSizeInit;
        sprite_0.color        = new Color(1, 1, 1, 0.75f);
        sliderPositionDelta_0 = sliderPositionInit_0 - sliderPositionEnd_0;

        GameObject sliderObject_1 = (GameObject)Instantiate(tapboxPrefab);

        slider_1 = sliderObject_1.GetComponent <TapboxScript>();
        exSprite sprite_1 = sliderObject_1.GetComponent <exSprite>();

        sprite_1.scale        = sliderSizeInit;
        sprite_1.color        = new Color(1, 1, 1, 0.75f);
        sliderPositionDelta_1 = sliderPositionInit_1 - sliderPositionEnd_1;

        GameObject sliderObject_2 = (GameObject)Instantiate(tapboxPrefab);

        slider_2 = sliderObject_2.GetComponent <TapboxScript>();
        exSprite sprite_2 = sliderObject_2.GetComponent <exSprite>();

        sprite_2.scale = sliderSizeInit;
        sprite_2.color = new Color(1, 1, 1, 0.75f);
        sliderObject_2.transform.Rotate(new Vector3(0, 0, 90f));
        sliderPositionDelta_2 = sliderPositionInit_2 - sliderPositionEnd_2;

        GameObject sliderObject_3 = (GameObject)Instantiate(tapboxPrefab);

        slider_3 = sliderObject_3.GetComponent <TapboxScript>();
        exSprite sprite_3 = sliderObject_3.GetComponent <exSprite>();

        sprite_3.scale = sliderSizeInit;
        sprite_3.color = new Color(1, 1, 1, 0.75f);
        sliderObject_3.transform.Rotate(new Vector3(0, 0, 90f));
        sliderPositionDelta_3 = sliderPositionInit_3 - sliderPositionEnd_3;

        sliderSizeDelta = sliderSizeInit - sliderSizeEnd;
    }
示例#33
0
    // Update notes states
    void UpdateNotes()
    {
        // Game over check
        if (common.gameOver)
        {
            return;
        }

        // Iterate through each active node
        foreach (NotesScript note in notes)
        {
            float timeDiff = common.GetTimeDiff(note);
            common.CheckAutoPlay(note, timeDiff);
            common.UpdateNoteState(note, timeDiff);

            // Update size
            exSprite sprite = note.gameObject.GetComponent <exSprite>();
            if (timeDiff > 0)               // Before tapbox
            {
                float multiplier = 1 - timeDiff / CommonScript.TIME_ONSCREEN;
                if (multiplier <= 0f)
                {
                    // Don't draw
                    note.gameObject.active = false;
                }
                else
                {
                    sprite.scale = gridScale * multiplier;
                    // Draw
                    note.gameObject.active = true;
                }
            }
            else
            {
                sprite.scale           = gridScale;
                note.gameObject.active = true;
            }
        }
    }
示例#34
0
    // Use this for initialization
    void Start()
    {
        // Disable rendering of all child items
        foreach (Component component in this.GetComponentsInChildren <Component>())
        {
            if (component.gameObject.renderer != null)
            {
                component.gameObject.renderer.enabled = false;
            }
        }

        fadeTimerStart = 0;
        fadeDone       = true;

        submitButton       = GameObject.Find("SubmitButton").GetComponent <exSprite>();
        submitLabel        = GameObject.Find("SubmitLabel").GetComponent <exSpriteFont>();
        submitButtonActive = false;

        // Disable the submit button to avoid collisions
        submitButton.gameObject.active = false;

        common = (CommonScript)GameObject.Find("Common").GetComponent <CommonScript>();
    }
示例#35
0
    // ------------------------------------------------------------------ 
    // Desc: 
    // ------------------------------------------------------------------ 

    protected new void Update () {
        base.Update();
        if ( sprite == null ) {
            sprite = GetComponent<exSprite>();
            if ( sprite == null ) {
                Debug.LogError("Can't find exSprite Component in GameObject " + gameObject.name);
                return;
            }
        }

        if ( lastColor != sprite.color ) {
            lastColor = sprite.color;
            sprite.updateFlags |= exPlane.UpdateFlags.Color;
        }
        if ( lastWidth != sprite.width ) {
            lastWidth = sprite.width;
            sprite.updateFlags |= exPlane.UpdateFlags.Vertex;
        }
        if ( lastHeight != sprite.height ) {
            lastHeight = sprite.height;
            sprite.updateFlags |= exPlane.UpdateFlags.Vertex;
        }
    }
示例#36
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    void Init()
    {
        if (initialized == false)
        {
            initialized = true;

            sprite       = GetComponent <exSprite>();
            defaultAtlas = sprite.atlas;
            defaultIndex = sprite.index;

            nameToState = new Dictionary <string, exSpriteAnimState> ();
            foreach (exSpriteAnimClip clip in animations)
            {
                exSpriteAnimState state = new exSpriteAnimState(clip);
                nameToState[state.name] = state;
            }

            if (defaultAnimation != null)
            {
                curAnimation = nameToState[defaultAnimation.name];
            }
        }
    }
示例#37
0
    ///////////////////////////////////////////////////////////////////////////////
    // Button
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    static void CreateButtonObject(bool _useSprite)
    {
        // create button object
        GameObject buttonGO = new GameObject("Button");
        exUIButton button   = buttonGO.AddComponent <exUIButton>();

        // create Background
        if (_useSprite)
        {
            GameObject backgroundGO = new GameObject("Background");
            exSprite   background   = backgroundGO.AddComponent <exSprite>();
            button.background             = background;
            backgroundGO.transform.parent = buttonGO.transform;
        }
        else
        {
            GameObject     backgroundGO = new GameObject("Background");
            exSpriteBorder background   = backgroundGO.AddComponent <exSpriteBorder>();
            button.background             = background;
            backgroundGO.transform.parent = buttonGO.transform;
        }

        // create Font
        GameObject   fontGO = new GameObject("Font");
        exSpriteFont font   = fontGO.AddComponent <exSpriteFont>();

        font.text               = "";
        button.font             = font;
        fontGO.transform.parent = buttonGO.transform;

        button.width  = 50.0f;
        button.height = 20.0f;

        //
        Selection.activeObject = buttonGO;
    }
    // Use this for initialization
    void Start()
    {
        fade = GameObject.Find("Fade").GetComponent <FadeScript>();
        fade.FadeIn();

        descriptionCloseButton = GameObject.Find("DescriptionCloseButton");
        difficultyLabel        = GameObject.Find("DifficultyLabel").GetComponent <exSpriteFont>();

        difficultyLabel.text = NotesData.DIFFICULTY_LEVEL;

        musicSrc = (AudioSource)this.gameObject.GetComponent <AudioSource>();
        musicSrc.Play();

        for (int i = 0; i < ModeLauncherScript.modesDone.Length; i++)
        {
            string   name   = string.Format("Checkbox_{0}", i + 1);
            exSprite sprite = GameObject.Find(name).GetComponent <exSprite>();
            sprite.renderer.enabled = ModeLauncherScript.modesDone[i];
        }
        if (ModeLauncherScript.descriptionViewed)
        {
            CloseDescription();
        }
    }
示例#39
0
        public static exSprite NewSimpleSprite(GameObject _go, exTextureInfo _info,
                                               int _width, int _height, Color _color)
        {
            exSprite sprite = _go.GetComponent <exSprite>();

            if (sprite == null)
            {
                sprite = _go.AddComponent <exSprite>();
            }
            if (sprite.shader == null)
            {
                sprite.shader = Shader.Find("ex2D/Alpha Blended");
            }
            sprite.spriteType  = exSpriteType.Simple;
            sprite.textureInfo = _info;

            sprite.customSize = true;
            sprite.width      = _width;
            sprite.height     = _height;

            sprite.color = _color;

            return(sprite);
        }
示例#40
0
文件: Bullet.cs 项目: nantas/Danmaku
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 void Awake()
 {
     challengeMng = Stage.instance.challengeMng;
     spBullet = GetComponent<exSprite>();
 }
 // Use this for initialization
 void Start()
 {
     myTransform = transform;
     spriteObj = GetComponent<exSprite>();
     spriteAnimation = GetComponent<exSpriteAnimation>();
 }
示例#42
0
    ///////////////////////////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////////////////////////
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    protected new void Awake()
    {
        base.Awake();

        // handle scroll bar
        Transform transBar = transform.Find("__bar");
        if ( transBar ) {
            bar = transBar.GetComponent<exSprite>();
            if ( bar ) {
                bar.customSize = true;
                bar.anchor = Anchor.TopLeft;
            }

            //
            exUIButton btnBar = transBar.GetComponent<exUIButton>();
            if ( btnBar ) {
                btnBar.grabMouseOrTouch = true;

                btnBar.AddEventListener ( "onPressDown",
                                          delegate ( exUIEvent _event ) {
                                              if ( dragging )
                                                  return;

                                              exUIPointEvent pointEvent = _event as exUIPointEvent;
                                              if ( pointEvent.isTouch || pointEvent.GetMouseButton(0) ) {
                                                  dragging = true;
                                                  draggingID = pointEvent.mainPoint.id;

                                                  exUIMng.inst.SetFocus(this);
                                              }
                                          } );

                btnBar.AddEventListener ( "onPressUp",
                                          delegate ( exUIEvent _event ) {
                                              exUIPointEvent pointEvent = _event as exUIPointEvent;
                                              if ( ( pointEvent.isTouch || pointEvent.GetMouseButton(0) ) && pointEvent.pointInfos[0].id == draggingID ) {
                                                  if ( dragging ) {
                                                      dragging = false;
                                                      draggingID = -1;
                                                  }
                                              }
                                          } );

                btnBar.AddEventListener ( "onHoverMove",
                                          delegate ( exUIEvent _event ) {
                                              if ( scrollView ) {
                                                  exUIPointEvent pointEvent = _event as exUIPointEvent;
                                                  for ( int i = 0; i < pointEvent.pointInfos.Length; ++i ) {
                                                      exUIPointInfo point = pointEvent.pointInfos[i];
                                                      if ( dragging && ( pointEvent.isTouch || pointEvent.GetMouseButton(0) ) && point.id == draggingID  ) {
                                                          Vector2 delta = point.worldDelta;
                                                          delta.y = -delta.y;
                                                          scrollView.Scroll (delta/ratio);
                                                      }
                                                  }
                                              }
                                          } );
            }
        }

        // handle background
        background = GetComponent<exSprite>();
        if ( background ) {
            scrollStart = transBar ? transBar.localPosition : Vector3.zero;

            if ( background.spriteType == exSpriteType.Sliced ) {
                if ( direction == Direction.Horizontal ) {
                    scrollStart.x = background.leftBorderSize;
                }
                else {
                    scrollStart.y = background.topBorderSize;
                }
            }
        }

        // handle scroll view
        if ( scrollView ) {
            scrollView.AddEventListener ( "onContentResized",
                                          delegate ( exUIEvent _event ) {
                                              UpdateScrollBarRatio ();
                                              UpdateScrollBar ();
                                          } );
            scrollView.AddEventListener ( "onScroll",
                                          delegate ( exUIEvent _event ) {
                                              if ( direction == Direction.Horizontal ) {
                                                  scrollOffset = scrollView.scrollOffset.x * ratio;
                                              }
                                              else {
                                                  scrollOffset = scrollView.scrollOffset.y * ratio;
                                              }
                                              UpdateScrollBar ();

                                              //
                                              if ( scrollView.showCondition == exUIScrollView.ShowCondition.WhenDragging ) {
                                                  activeSelf = true;
                                              }
                                          } );
            scrollView.AddEventListener ( "onScrollFinished",
                                          delegate ( exUIEvent _event ) {
                                              if ( scrollView.showCondition == exUIScrollView.ShowCondition.WhenDragging ) {
                                                  cooldownTimer = cooldown;
                                                  isCoolingDown = true;
                                              }
                                          } );
            UpdateScrollBarRatio ();
            UpdateScrollBar ();

            // handle scrollbar effect
            if ( scrollView.showCondition == exUIScrollView.ShowCondition.WhenDragging ) {
                //
                exUIEffect effect = GetComponent<exUIEffect>();
                if ( effect == null ) {
                    effect = gameObject.AddComponent<exUIEffect>();

                    if ( background != null ) {
                        effect.AddEffect_Color( background,
                                                EffectEventType.Deactive,
                                                exEase.Type.Linear,
                                                new Color( background.color.r, background.color.g, background.color.b, 0.0f ),
                                                0.5f );
                    }

                    if ( bar != null ) {
                        effect.AddEffect_Color( bar,
                                                EffectEventType.Deactive,
                                                exEase.Type.Linear,
                                                new Color( bar.color.r, bar.color.g, bar.color.b, 0.0f ),
                                                0.5f );
                    }
                }

                //
                if ( background ) {
                    Color tmpColor = background.color;
                    tmpColor.a = 0.0f;
                    background.color = tmpColor;
                }

                //
                if ( bar ) {
                    Color tmpColor = bar.color;
                    tmpColor.a = 0.0f;
                    bar.color = tmpColor;
                }

                //
                active_ = false;
            }
        }
    }
示例#43
0
文件: PowerUp.cs 项目: nantas/Danmaku
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 void Awake()
 {
     spPowerUp = GetComponent<exSprite>();
 }
 /// <summary>
 /// Gets the atlas from sprite.
 /// </summary>
 /// <returns>
 /// The atlas from sprite.
 /// </returns>
 /// <param name='sprite'>
 /// Sprite.
 /// </param>
 private static exAtlas GetAtlasFromSprite(exSprite sprite)
 {
     return sprite.atlas;
 }
 /// <summary>
 /// Change the sprite image from another image in the same (or different atlas), using the specific index
 /// </summary>
 /// <param name='sprite'>
 /// Sprite. exSprite to be changed
 /// </param>
 /// <param name='atlas'>
 /// Atlas. exAtlas (may be the same atlas or a new one)
 /// </param>
 /// <param name='index'>
 /// Index. int (the identifier of the new Sprite)
 /// </param> 
 private static void ChangeSprite(exSprite sprite, exAtlas atlas, int index)
 {
     float width = sprite.width;
     float height = sprite.height;
     sprite.SetSprite(atlas,index,false);
     sprite.height = height;
     sprite.width = width;
 }
示例#46
0
 ///////////////////////////////////////////////////////////////////////////////
 //
 ///////////////////////////////////////////////////////////////////////////////
 public static void SetBarSize( exSprite _bar, 
                                 float _barSize, 
                                 float _progress, 
                                 Direction _direction )
 {
     if ( _bar != null ) {
         if ( _direction == Direction.Horizontal ) {
             if ( _bar.spriteType == exSpriteType.Sliced ) {
                 float progressWidth = _progress * (_barSize-_bar.leftBorderSize-_bar.rightBorderSize);
                 _bar.width = progressWidth + _bar.leftBorderSize + _bar.rightBorderSize;
             }
             else {
                 _bar.width = _progress * _barSize;
             }
         }
         else {
             if ( _bar.spriteType == exSpriteType.Sliced ) {
                 float progressHeight = _progress * (_barSize-_bar.topBorderSize-_bar.bottomBorderSize);
                 _bar.height = progressHeight + _bar.topBorderSize + _bar.bottomBorderSize;
             }
             else {
                 _bar.height = _progress * _barSize;
             }
         }
     }
 }
示例#47
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 protected new void OnEnable()
 {
     base.OnEnable();
     if ( target != editSprite ) {
         editSprite = target as exSprite;
     }
 }
示例#48
0
    // Use this for initialization
    void Start()
    {
        // Disable rendering of all child items
        foreach (Component component in this.GetComponentsInChildren<Component>()) {
            if (component.gameObject.renderer != null) {
                component.gameObject.renderer.enabled = false;
            }
        }

        fadeTimerStart = 0;
        fadeDone = true;

        submitButton = GameObject.Find("SubmitButton").GetComponent<exSprite>();
        submitLabel = GameObject.Find("SubmitLabel").GetComponent<exSpriteFont>();
        submitButtonActive = false;

        // Disable the submit button to avoid collisions
        submitButton.gameObject.active = false;

        common = (CommonScript)GameObject.Find("Common").GetComponent<CommonScript>();
    }
示例#49
0
 void Awake()
 {
     shipSprite = GetComponent<exSprite>();
 }
示例#50
0
    void Start()
    {
        //Object access
        pSys = GameObject.FindGameObjectWithTag("BackgroundEffect").GetComponent<ParticleSystem>();
        screenEdge = GameObject.FindGameObjectWithTag("Top").GetComponent<Collider>().bounds.min.x;
        score = GameObject.FindGameObjectWithTag("Score").GetComponent<RunnerScoring>();
        recognizer = GameObject.FindGameObjectWithTag("Recognizer").GetComponent<TapDetector>();
        rCollision = gameObject.GetComponent<RunnerCollision>();
        pSys = GameObject.FindGameObjectWithTag("BackgroundEffect").GetComponent<ParticleSystem>();
        fadeScreen = GameObject.FindGameObjectWithTag("FadeScreen").GetComponent<RedSpriteFade>();
        myCamera = GameObject.FindGameObjectWithTag ("MainCamera");
        myTransform = transform;

        //Start variables
        startPosition = myTransform.position;
        gravityButton = false;
        recognizer.setOnStart(true);
        setState (State.respawn);

        //Camera effects
        shakeAmount = 1.5f;
        fadeScreen.setRenderer(false);

            //Red UI frames
            change1 = false;
            change2 = false;
            change3 = false;
            change4 = false;
            change5 = false;

        //Animation variables
        flip = GetComponent<exSprite>();
    }
示例#51
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    void InitSprite( exSprite _sprite )
    {
        if ( _sprite.shader == null )
            _sprite.shader = Shader.Find("ex2D/Alpha Blended");

        if ( _sprite.textureInfo != null ) {
            if ( _sprite.textureInfo.isDiced ) {
                _sprite.spriteType = exSpriteType.Diced;
                _sprite.customSize = false;
            }
            else if ( _sprite.textureInfo.hasBorder ) {
                _sprite.spriteType = exSpriteType.Sliced;
                _sprite.customSize = true;
                _sprite.width = _sprite.textureInfo.width;
                _sprite.height = _sprite.textureInfo.height;
            }
        }
    }
示例#52
0
 void Awake()
 {
     cover = (exSprite)this.gameObject.GetComponent<exSprite>();
 }
示例#53
0
    ///////////////////////////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////////////////////////
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    protected new void Awake()
    {
        base.Awake();

        // handle scroll bar
        Transform transBar = transform.Find("__bar");
        if ( transBar ) {
            bar = transBar.GetComponent<exSprite>();
        }

        UpdateBar ();
    }
示例#54
0
 // Use this for initialization
 void Start()
 {
     mSprite = (exSprite)GetComponent<exSprite>();
 }
示例#55
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 void Awake()
 {
     headIcon = transform.Find("head_icon").GetComponent<exSprite>();
     userName = transform.Find("name").GetComponent<exSpriteFont>();
     score = transform.Find("score").GetComponent<exSpriteFont>();
 }
示例#56
0
    void Start()
    {
        myTransform = transform;
        spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent<SpawnObstacles>();
        myCollider = gameObject.GetComponent<SphereCollider>();
        topBorder = GameObject.FindGameObjectWithTag("Top");
        bottomBorder = GameObject.FindGameObjectWithTag("Bottom");
        doOnce = false;

        //Add to volume control
        if(PlayerPrefs.HasKey("volumeFX"))
        {
            if(GetComponent<AudioSource>() != null)
            {
                AudioSource audio = GetComponent<AudioSource>();
                audio.volume = (float)PlayerPrefs.GetInt("volumeFX")/10;
            }
        }

        flip = GetComponent<exSprite>();

        //Offsets will use opposite border max/min because this object has a spehere colider, not a box collider
        if(Random.Range(0, 100) > 50)
        {
            offsetY = (topBorder.collider.bounds.max.y - gameObject.collider.bounds.size.y/1.5f);
            flip.VFlip();
            myCollider.center = -myCollider.center;
            Destroy(myTransform.FindChild("Buzzparticlebot").gameObject);

        }

        else
        {
            offsetY = (bottomBorder.collider.bounds.min.y + gameObject.collider.bounds.size.y/1.5f);
            Destroy(myTransform.FindChild("Buzzparticletop").gameObject);
        }

        myTransform.position = new Vector3(myTransform.position.x, offsetY, 0.0f);
    }
示例#57
0
    ///////////////////////////////////////////////////////////////////////////////
    // Internal Functions
    ///////////////////////////////////////////////////////////////////////////////
        
    // ------------------------------------------------------------------ 
    // Desc: 
    // ------------------------------------------------------------------ 

    void Init () {
        bool initialized = (nameToState != null);
        if (initialized == false) {
            sprite_ = GetComponent<exSprite>();
            defaultTextureInfo = sprite_.textureInfo;

            nameToState = new Dictionary<string, exSpriteAnimationState>();
            for (int i = 0; i < animations.Count; ++i) {
                exSpriteAnimationClip clip = animations[i];
                if (clip != null) {
                    exSpriteAnimationState state = new exSpriteAnimationState(clip);
                    nameToState[state.name] = state;
                    if (ReferenceEquals(defaultAnimation, clip)) {
                        curAnimation = state;
                        lastFrameIndex = -1;
                    }
                }
            }
            exDebug.Assert(defaultAnimation == null || defaultAnimation == nameToState[defaultAnimation.name].clip);
        }
    }
示例#58
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////

    // ------------------------------------------------------------------ 
    // Desc: 
    // ------------------------------------------------------------------ 

    void Init () {
        if ( initialized == false ) {
            initialized = true;

            sprite = GetComponent<exSprite>();
            defaultAtlas = sprite.atlas;
            defaultIndex = sprite.index;

            nameToState = new Dictionary<string,exSpriteAnimState> ();
            foreach ( exSpriteAnimClip clip in animations ) {
                exSpriteAnimState state = new exSpriteAnimState(clip);
                nameToState[state.name] = state;
            }

            if ( defaultAnimation != null )
                curAnimation = nameToState[defaultAnimation.name];
        }
    }
示例#59
0
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    void Init()
    {
        if ( nameToState == null ) {
            initialized = false;
        }

        if ( initialized == false ) {
            initialized = true;

            sprite = GetComponent<exSprite>();
            defaultAtlas = sprite.atlas;
            defaultIndex = sprite.index;

            nameToState = new Dictionary<string,exSpriteAnimState> ();
            for ( int i = 0; i < animations.Count; ++i ) {
                exSpriteAnimState state = new exSpriteAnimState(animations[i]);
                nameToState[state.name] = state;
            }

            if ( defaultAnimation != null )
                curAnimation = nameToState[defaultAnimation.name];
        }
    }
示例#60
0
 ///////////////////////////////////////////////////////////////////////////////
 // functions
 ///////////////////////////////////////////////////////////////////////////////
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 void Awake()
 {
     if ( renderType == RenderType.Clipping ) {
         clipPlane = GetComponent<exClipping>();
         if (isHorizontal) {
             total = clipPlane.width;
             clipPlane.width = total * ratio_;
         } else {
             total = clipPlane.height;
             clipPlane.height = total * ratio_;
         }
     }
     else if ( renderType == RenderType.Sprite ) {
         sprite = GetComponent<exSprite>();
         if (isHorizontal) {
             total = sprite.width;
             sprite.width = total * ratio_;
         } else {
             total = sprite.height;
             sprite.height = total * ratio_;
         }
     }
     else {
         border = GetComponent<exSpriteBorder>();
         if (isHorizontal) {
             total = border.width;
             border.width = total * ratio_;
         } else {
             total = border.height;
             border.height = total * ratio_;
         }
     }
 }