Inheritance: exSpriteBase
Example #1
0
 void Start()
 {
     mSprite = (exSprite)GetComponent<exSprite>();
     mIsActive = false;
     mIsStartup = false;
     mAI = (SkillAI)gameObject.AddComponent("SkillAI");
 }
        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);
        }
    // 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;
        }
    }
    ///////////////////////////////////////////////////////////////////////////////
    // functions
    ///////////////////////////////////////////////////////////////////////////////

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

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

        sprite = GetComponent<exSprite>();
        lastColor = sprite.color;
        lastWidth = sprite.width;
        lastHeight = sprite.height;
    }
Example #5
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;
    }
Example #6
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);
    }
    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);
        }
    }
Example #8
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();
     }
 }
    // ------------------------------------------------------------------ 
    // 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;
        }
    }
 /// <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;
 }
Example #12
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 void Awake()
 {
     headIcon = transform.Find("head_icon").GetComponent<exSprite>();
     userName = transform.Find("name").GetComponent<exSpriteFont>();
     score = transform.Find("score").GetComponent<exSpriteFont>();
 }
Example #13
0
 // Use this for initialization
 void Start()
 {
     mSprite = (exSprite)GetComponent<exSprite>();
 }
Example #14
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;
            }
        }
    }
Example #15
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];
        }
    }
Example #16
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;
            }
        }
    }
Example #17
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];
        }
    }
Example #18
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 void Awake()
 {
     challengeMng = Stage.instance.challengeMng;
     spBullet = GetComponent<exSprite>();
 }
Example #19
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);
        }
    }
Example #20
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 protected new void OnEnable()
 {
     base.OnEnable();
     if ( target != editSprite ) {
         editSprite = target as exSprite;
     }
 }
 // Use this for initialization
 void Start()
 {
     myTransform = transform;
     spriteObj = GetComponent<exSprite>();
     spriteAnimation = GetComponent<exSpriteAnimation>();
 }
Example #22
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_;
         }
     }
 }
Example #23
0
 // ------------------------------------------------------------------
 // Desc:
 // ------------------------------------------------------------------
 void Awake()
 {
     spPowerUp = GetComponent<exSprite>();
 }
Example #24
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>();
    }
Example #25
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;
             }
         }
     }
 }
Example #26
0
 void Awake()
 {
     cover = (exSprite)this.gameObject.GetComponent<exSprite>();
 }
Example #27
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>();
    }
Example #28
0
    ///////////////////////////////////////////////////////////////////////////////
    //
    ///////////////////////////////////////////////////////////////////////////////
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    protected new void Awake()
    {
        base.Awake();

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

        UpdateBar ();
    }
Example #29
0
 void Awake()
 {
     shipSprite = GetComponent<exSprite>();
 }
Example #30
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);
    }