Example #1
0
    void Update()
    {
        // if not static geometry always execute
        // if static - execute only in editor

        if (isStaticGeometry && !Application.isEditor)
        {
            return;
        }

        int level = (int)(-transform.position.y * 100 + transform.position.z * 49);

        if (useSpriteRenderer)
        {
            spriteRenderer = spriteRenderer ?? GetComponent <SpriteRenderer>();
            spriteRenderer.sortingOrder = level;
        }
        else
        {
            sortingGroup = sortingGroup ?? GetComponent <SortingGroup>();
            sortingGroup.sortingOrder = level;
        }

        // Debug.Log("IsometricSorting " + this + " order: " + level);
    }
 public void SetChildrenShouldRunWithoutRaise(bool?shouldRun)
 {
     foreach (var ex in SortingGroup.Select(sg => sg as IExcludable))
     {
         ex.SetChildrenShouldRunWithoutRaise(shouldRun);
     }
 }
Example #3
0
 private void Awake()
 {
     rb            = GetComponent <Rigidbody2D>();
     sgroup        = GetComponent <SortingGroup>();
     spriteBoundsY = GetComponent <SpriteRenderer>().bounds.extents.y * 0.5f;
     CreateStaticCollider();
 }
 public override void Start()
 {
     base.Start();
     group    = GetComponent <SortingGroup>();
     renderer = this.gameObject.GetComponentInChildren <SpriteRenderer>();
     target   = enemyManager.Drill;
 }
Example #5
0
        private void refreshSortingGroup()
        {
            SortingGroup sortinggroup = this.GetComponent <SortingGroup>();

            sortinggroup.enabled = false;
            sortinggroup.enabled = true;
        }
        private void Awake()
        {
            _poolObject = GetComponent <AntPoolObject>();
            var availComponents = AntEffectEngine.AvailableComponents;

            _components      = new IComponent[availComponents.Length];
            _componentsCount = _components.Length;
            for (int i = 0, n = availComponents.Length; i < n; i++)
            {
                ConstructorInfo constructor = availComponents[i].GetConstructor(Type.EmptyTypes);
                var             comp        = (IComponent)constructor.Invoke(null);
                if (comp != null)
                {
                    comp.Initialize(this);
                    _components[i] = comp;
                }
            }

            _sortingGroup    = GetComponent <SortingGroup>();
            _hasSortingGroup = (_sortingGroup != null);
            if (!_hasSortingGroup)
            {
                _spriteRenderer    = GetComponent <SpriteRenderer>();
                _hasSpriteRenderer = (_spriteRenderer != null);
            }
        }
    private void Start()
    {
        if (target == null)
        {
            target = transform;
        }

        sortingGroup   = GetComponent <SortingGroup>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        if (!sortingGroup && !spriteRenderer)
        {
            Debug.LogErrorFormat("IsometricObjectStatic: {0} does not have a SortingGroup nor SpriteRenderer", gameObject.name);
        }

        float order = (-target.position.y + targetOffset) * Constants.MapInfo.PixelPerUnit;

        if (sortingGroup)
        {
            sortingGroup.sortingOrder = (int)order;
        }
        else
        {
            spriteRenderer.sortingOrder = (int)order;
        }
    }
 public override void Start()
 {
     base.Start();
     group     = GetComponent <SortingGroup>();
     renderer  = this.gameObject.GetComponentInChildren <SpriteRenderer>();
     canAttack = true;
 }
    private void Awake()
    {
        startPosition    = transform.position;
        animator         = GetComponent <Animator>();
        rectTransfrom    = GetComponent <RectTransform>();
        startRect        = rectTransfrom.rect;
        startRect.center = startPosition;
        m_MainCamera     = Camera.main;
        //Shouldn't use string comparation for performance purpose
        //graphics = transform.Find("Graphics");
        //The best way is to use public reference, but we do this for now (might be refactor later)
        m_Mask           = transform.GetComponentInChildren <SpriteMask>();
        m_Graphics       = m_Mask.transform.parent;
        m_OriginalScale  = m_Graphics.localScale;
        m_MouseDownScale = new Vector3(m_OriginalScale.x + 1, m_OriginalScale.y + 1, 1);

        //Collect all colliders except CompositeCollider2D
        Collider2D[] colliders = GetComponentsInChildren <Collider2D>();
        for (int i = 0; i < colliders.Length; i++)
        {
            if (colliders[i] is CompositeCollider2D)
            {
                continue;
            }
            m_Colliders.Add(colliders[i]);
        }

        m_ObjectsSortingGroup = GetComponentInChildren <SortingGroup>();
    }
        static bool Prefix(DecalControllerBehaviour __instance, ref bool ___dirty, ref int ___originalSortingLayer, ref SpriteMask ___spriteMask)
        {
            ___dirty = true;
            string    text      = __instance.DecalDescriptor.name + " container";
            Transform transform = __instance.transform.Find(text);

            if (transform)
            {
                __instance.decalHolder = transform.gameObject;
            }
            else
            {
                __instance.decalHolder = new GameObject(text);
            }
            __instance.decalHolder.transform.SetParent(__instance.transform);
            __instance.decalHolder.transform.localPosition = Vector3.zero;
            __instance.decalHolder.transform.localScale    = Vector3.one;
            __instance.decalHolder.AddComponent <Optout>();
            SpriteRenderer component = __instance.GetComponent <SpriteRenderer>();

            if (component == null)
            {
                component = __instance.GetComponentInChildren <SpriteRenderer>();
            }
            __instance.decalHolder.transform.rotation = component.transform.rotation;
            ___originalSortingLayer = component.sortingLayerID;
            SortingGroup sortingGroup = __instance.decalHolder.AddComponent <SortingGroup>();

            sortingGroup.sortingLayerID = ___originalSortingLayer;
            sortingGroup.sortingOrder   = 1;
            ___spriteMask              = __instance.decalHolder.AddComponent <SpriteMask>();
            ___spriteMask.sprite       = component.sprite;
            ___spriteMask.sortingOrder = 1;
            return(false);
        }
Example #11
0
        private void Start()
        {
            _sortingGroup    = GetComponent <SortingGroup>();
            _targetTransform = OrientationTarget.GetComponent <Transform>();

            FindBounds(GetComponentsInChildren <SpriteRenderer>().ToList());
        }
Example #12
0
        protected void Awake()
        {
            if (KickStarter.settingsManager != null && KickStarter.settingsManager.IsInLoadingScene())
            {
                return;
            }

            sortingGroup = GetComponentInChildren <SortingGroup>();

            if (sortingGroup == null)
            {
                renderers = GetComponentsInChildren <Renderer>(true);

                _renderer = GetComponent <Renderer>();
                if (_renderer == null && !affectChildren)
                {
                    ACDebug.LogWarning("FollowSortingMap on " + gameObject.name + " must be attached alongside a Renderer component.");
                }
            }

            if (GetComponent <Char>() != null && Application.isPlaying)
            {
                ACDebug.LogWarning("The 'Follow Sorting Map' component attached to the character '" + gameObject.name + " is on the character's root - it should instead be placed on their sprite child.  To prevent movement locking, the Follow Sorting Map has been disabled.", this);
                enabled = false;
            }

            SetOriginalDepth();
        }
Example #13
0
 public override void Awake()
 {
     base.Awake();
     sortingGroup = GetComponent <SortingGroup> ();
     type         = FlashUtils.ClassType.MovieClip;
     FlashManager.getInstance().movieClipCount++;
 }
Example #14
0
 // Use this for initialization
 void Start()
 {
     _sortingGroup = GetComponent <SortingGroup>();
     _anchor       = _anchor == null ? transform : _anchor;
     _sortingGroup.sortingOrder = GetSortingForTransform(_anchor);
     enabled = Dynamic;
 }
Example #15
0
    void SetRenderingOrder(SortingGroup sortingGroup, ref int orderIndex)
    {
        switch (sortingGroup.sortingMode)
        {
        case SortingMode.Isometric:
            SortIsometric(sortingGroup);
            break;

        case SortingMode.Hierarchy:
            SortHierarchy(sortingGroup);
            break;
        }

        foreach (var rendererInfo in sortingGroup.rendererInfos)
        {
            if (rendererInfo.renderer)
            {
                rendererInfo.renderer.sortingLayerID = sortingLayerID;
                rendererInfo.renderer.sortingOrder   = orderIndex--;
            }

            if (rendererInfo.sortingGroup != null)
            {
                SetRenderingOrder(rendererInfo.sortingGroup, ref orderIndex);
            }
        }
    }
Example #16
0
    void Awake()
    {
        //find all
        root = transform.Find("MaoRoot").GetComponent <SpriteRenderer>();
        body = transform.Find("MaoBody").GetComponent <SpriteRenderer>();
        skin = transform.Find("MaoSkin").GetComponent <SpriteRenderer>();

        //init root
        root.enabled = false;

        //init body
        maoBody = body.gameObject.AddComponent <BaseMaoBody>();
        maoBody.onMouseDownEvent += OnBodySelected;
        maoBody.onMouseDragEvent += OnBodyDrag;
        maoBody.onMouseUpEvent   += OnBodyUnselected;
        recordBodyScale           = body.transform.localScale;

        //init skin
        SetSkinScale(0f);
        recordSkinScale = skin.transform.localScale;

        //init mao
        recordRotation = transform.eulerAngles;
        sortingGroup   = GetComponent <SortingGroup>();
        sortingGroup.sortingLayerName = LAYER_MAO;
    }
 public void PlacedOn(SortingGroup other)
 {
     if (CanBePlacedOnThings)
     {
         surfaceSortingGroup = other;
     }
 }
Example #18
0
    private void Awake()
    {
        unit  = GetComponent <Unit>();
        group = GetComponent <SortingGroup>();

        unit.OnArmsChanged          += Unit_OnArmsChanged;
        unit.OnBodyChanged          += Unit_OnBodyChanged;
        unit.OnHelmetChanged        += Unit_OnHelmetChanged;
        unit.OnLegsChanged          += Unit_OnLegsChanged;
        unit.OnShieldChanged        += Unit_OnShieldChanged;
        unit.OnWeaponChanged        += Unit_OnWeaponChanged;
        unit.OnChargingValueChanged += Unit_OnChargingValueChanged;

        unit.OnUnitFallDown += Unit_OnUnitFallDown;
        unit.OnUnitStandUp  += Unit_OnUnitStandUp;

        unit.OnUnitDeath += Death;

        unit.OnRunValueChanged += Unit_OnRunValueChanged;
        unit.AfterInitiate     += Unit_AfterInitiate;

        Unit_OnArmsChanged(unit.Arms);
        Unit_OnLegsChanged(unit.Legs);

        underlayerOutline.Alpha = 0.3f;
    }
Example #19
0
    private void Awake()
    {
        SortingGroup sortingGroup = GetComponent <SortingGroup>();
        int          oldOrder     = sortingGroup.sortingOrder;

        sortingGroup.sortingOrder = oldOrder + 1;
        sortingGroup.sortingOrder = oldOrder;
    }
 // Use this for initialization
 void Start()
 {
     parent       = transform.root.root.root;
     parentscript = parent.GetComponent <movementctrl>();
     sprite       = GetComponentsInChildren <SpriteRenderer>();
     spritecount  = sprite.Length;
     sortinggroup = transform.parent.GetComponent <SortingGroup>();
 }
Example #21
0
 // Use this for initialization
 void Start()
 {
     rb           = GetComponent <Rigidbody2D>();
     enemy        = GameObject.FindGameObjectWithTag("Enemy");
     hp           = transform.GetChild(0).gameObject.GetComponent <HpConfig>();
     target       = GameObject.FindGameObjectWithTag("Player").transform;
     sortingGroup = GetComponent <SortingGroup>();
 }
    public override void Start()
    {
        base.Start();
        group = GetComponent <SortingGroup>();

        InvokeRepeating("MiteMove", timeBetweenWriggles, timeBetweenWriggles);
        renderer = gameObject.GetComponentInChildren <SpriteRenderer>();
    }
Example #23
0
    private void Reset()
    {
        if (sortingGroup == null)
        {
            sortingGroup = GetComponent <SortingGroup>();
        }

        //sortingGroup.sortingLayerName = SortingLayerName.VisibleParticles;
    }
Example #24
0
    // Use this for initialization
    void Start()
    {
        m_SortingGroup = GetComponent <SortingGroup>();

        if (!m_SortingGroup)
        {
            Debug.LogWarning("You forgot to add the \"Sorting Group\" component to the gameObject : " + gameObject.name);
        }
    }
Example #25
0
 void ClearCache(bool allow_to_create_components)
 {
     _meshFilter   = SwfUtils.GetComponent <MeshFilter>  (gameObject, allow_to_create_components);
     _meshRenderer = SwfUtils.GetComponent <MeshRenderer>(gameObject, allow_to_create_components);
     _sortingGroup = SwfUtils.GetComponent <SortingGroup>(gameObject, allow_to_create_components);
     _dirtyMesh    = true;
     _curSequence  = null;
     _curPropBlock = null;
 }
Example #26
0
 // Use this for initialization
 void Start()
 {
     sortingGroup = GetComponent <SortingGroup>();
     SetVisuals();
     //var sprites = GetComponentsInChildren<SpriteRenderer>();
     //Debug.Log(sprites.Length);
     //foreach (SpriteRenderer sprite in sprites)
     //    sprite.color = color;
 }
Example #27
0
    private void OnValidate()
    {
        if (sortingGroup == null)
        {
            sortingGroup = GetComponent <SortingGroup>();
        }

        UpdateOrder();
    }
Example #28
0
    IEnumerator Freeze(float duration)
    {
        isBusy = true;

        bool         firstToFreeze       = (frozenStatus == 0);
        bool         createdSortingGroup = false;
        GameObject   iceBlockInstance    = null;
        SortingGroup sGroup = null;

        //actor not already frozen; freeze it
        if (firstToFreeze)
        {
            //create iceblock object
            iceBlockInstance = Instantiate(iceBlockPrefab, transform);
            iceBlockInstance.GetComponent <SpriteMask>().sprite = spriteRenderer.sprite;
            sGroup = GetComponent <SortingGroup>();
            createdSortingGroup = (sGroup == null);
            if (createdSortingGroup)
            {
                sGroup = gameObject.AddComponent <SortingGroup>();
            }

            //freeze actor
            animator.enabled = false;
            lockAI          += 1;
        }

        frozenStatus += 1;
        yield return(new WaitForSeconds(duration));

        frozenStatus -= 1;

        //we froze in the first place, so we're responsible for cleaning up
        if (firstToFreeze)
        {
            //wait for other freeze effects to end
            while (frozenStatus > 0)
            {
                yield return(null);
            }

            if (this != null)
            {
                //unfreeze actor
                animator.enabled = true;
                lockAI          -= 1;

                //destroy iceblock
                if (createdSortingGroup)                 //don't want to delete this if the actor already had one
                {
                    Destroy(sGroup);
                }
                Destroy(iceBlockInstance);
            }
        }
        isBusy = false;
    }
Example #29
0
    public override void Start()
    {
        base.Start();
        group = GetComponent <SortingGroup>();

        renderer = this.gameObject.GetComponentInChildren <SpriteRenderer>();

        aiAgent.canMove = false;
        QueueSpawn();
    }
 // Start is called before the first frame update
 void Start()
 {
     sortingGroup = GetComponent <SortingGroup>();
     sortingGroup.sortingLayerID = SortingLayer.NameToID("Entities");
     if (groundContact == null)
     {
         groundContact = transform;
     }
     sortingGroup.sortingOrder = -(int)(groundContact.position.y * 100.0f);
 }