Example #1
0
        public static void CreateExpansionLayoutScreen()
        {
            GameObject            gameObject    = new GameObject("LayoutElementScreen");
            RectTransform         rectTransform = CreateRectTransform(gameObject, Selection.activeTransform);
            UiLayoutElementScreen element       = gameObject.AddComponent <UiLayoutElementScreen>();

            UiAnimationClip animationShow = new UiAnimationClip
            {
                Name = "Screen Show Animation",
                PlayOnLayoutElementShow = true
            };

            UiAnimationClip animationHide = new UiAnimationClip
            {
                Name = "Screen Hide Animation",
                PlayOnLayoutElementHide = true
            };

            UiAnimation animation = gameObject.AddComponent <UiAnimation>();

            animation.AnimationClips = new System.Collections.Generic.List <UiAnimationClip>
            {
                animationShow,
                animationHide
            };

            element.AnimationShow = animationShow.Name;
            element.AnimationHide = animationHide.Name;

            Selection.activeObject = gameObject;
        }
Example #2
0
        /// <summary>
        /// MonoBehavior Awake handler.
        /// In inherited classes always use base.Awake() when overriding this method.
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            _animation = GetComponent <UiAnimation>();

            if (_animation != null)
            {
                _animation.OnComplete += OnAnimationCompleted;

                _animationShow = _animation.GetAnimationClipByName(AnimationShow);
                _animationHide = _animation.GetAnimationClipByName(AnimationHide);

                if (_animationShow != null)
                {
                    _animationShow.PlayOnAwake             = false;
                    _animationShow.PlayOnLayoutElementShow = false;
                    _animationShow.PlayOnLayoutElementHide = false;
                    _animationShow.Loop = false;
                }

                if (_animationHide != null)
                {
                    _animationHide.PlayOnAwake             = false;
                    _animationHide.PlayOnLayoutElementShow = false;
                    _animationHide.PlayOnLayoutElementHide = false;
                    _animationHide.Loop = false;
                }
            }
        }
Example #3
0
        protected void Update(UiContext context, Vector2 myPos)
        {
            aspectRatio = context.ViewportWidth / context.ViewportHeight;
            TimeSpan delta;

            if (lastTime == TimeSpan.FromSeconds(0))
            {
                delta = TimeSpan.FromSeconds(0);
            }
            else
            {
                delta = context.GlobalTime - lastTime;
            }
            lastTime = context.GlobalTime;
            if (CurrentAnimation != null)
            {
                CurrentAnimation.SetWidgetPosition(myPos);
                CurrentAnimation.Update(delta.TotalSeconds, aspectRatio);
                if (!CurrentAnimation.Running)
                {
                    if (CurrentAnimation.FinalPositionSet.HasValue)
                    {
                        animSetPos = CurrentAnimation.FinalPositionSet.Value;
                    }
                    CurrentAnimation = null;
                }
            }
        }
Example #4
0
 private void HandleCollectTroopResult(SHIPMENT_RESULT result, ulong shipmentDBID)
 {
     if (result == SHIPMENT_RESULT.SUCCESS && shipmentDBID == this.m_shipmentDBID)
     {
         if (this.m_glowLoopHandle != null)
         {
             UiAnimation anim = this.m_glowLoopHandle.GetAnim();
             if (anim != null)
             {
                 anim.Stop(0.5f);
             }
         }
         UiAnimMgr.instance.PlayAnim("GreenCheck", this.m_greenCheckEffectRoot, Vector3.get_zero(), 1.8f, 0f);
         Main.instance.m_UISound.Play_GreenCheck();
         this.m_training = false;
         this.m_troopBuildProgressRing.get_gameObject().SetActive(false);
         this.m_troopBuildProgressFill.get_gameObject().SetActive(false);
         this.m_troopOwnedCheckmark.get_gameObject().SetActive(true);
         this.m_troopPortraitImage.get_gameObject().SetActive(true);
         this.m_timeRemainingText.get_gameObject().SetActive(false);
         this.m_troopPortraitImage.set_material(null);
         PersistentShipmentData.shipmentDictionary.Remove(shipmentDBID);
         MobilePlayerGarrisonDataRequest mobilePlayerGarrisonDataRequest = new MobilePlayerGarrisonDataRequest();
         mobilePlayerGarrisonDataRequest.GarrTypeID = 3;
         Login.instance.SendToMobileServer(mobilePlayerGarrisonDataRequest);
     }
 }
 private void ClearEffects()
 {
     iTween.StopByName(this.m_theActualButton, "RecruitWobble");
     iTween.StopByName(this.m_theActualButton, "RecruitWobbleL");
     iTween.StopByName(this.m_theActualButton, "RecruitButtonSwing");
     this.m_theActualButton.get_transform().set_localScale(Vector3.get_one());
     this.m_theActualButton.get_transform().set_localRotation(Quaternion.get_identity());
     iTween.StopByName(this.m_numReadyTroopsTextBG, "RecruitNumSwing");
     this.m_numReadyTroopsTextBG.get_transform().set_localRotation(Quaternion.get_identity());
     if (this.m_glowHandle != null)
     {
         UiAnimation anim = this.m_glowHandle.GetAnim();
         if (anim != null)
         {
             anim.Stop(0.5f);
         }
     }
     if (this.m_glowLoopHandle != null)
     {
         UiAnimation anim2 = this.m_glowLoopHandle.GetAnim();
         if (anim2 != null)
         {
             anim2.Stop(0.5f);
         }
     }
 }
Example #6
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUILayout.Space(5);

            UiLayoutElement layoutElement = target as UiLayoutElement;
            UiAnimation     animation     = layoutElement.GetComponent <UiAnimation>();

            if (animation != null)
            {
                int indexShow = 0;
                int indexHide = 0;

                string[] animations = new string[animation.AnimationClips.Count + 1];

                animations[0] = "None";

                for (int i = 0; i < animation.AnimationClips.Count; i++)
                {
                    animations[i + 1] = animation.AnimationClips[i].Name;
                }

                for (int i = 0; i < animations.Length; i++)
                {
                    if (layoutElement.AnimationShow != null && layoutElement.AnimationShow == animations[i])
                    {
                        indexShow = i;
                    }

                    if (layoutElement.AnimationHide != null && layoutElement.AnimationHide == animations[i])
                    {
                        indexHide = i;
                    }
                }

                EditorGUI.BeginChangeCheck();
                indexShow = EditorGUILayout.Popup("Animation Show", indexShow, animations);
                if (EditorGUI.EndChangeCheck())
                {
                    layoutElement.AnimationShow = indexShow > 0 ? animations[indexShow] : null;
                }

                EditorGUI.BeginChangeCheck();
                indexHide = EditorGUILayout.Popup("Animation Hide", indexHide, animations);
                if (EditorGUI.EndChangeCheck())
                {
                    layoutElement.AnimationHide = indexHide > 0 ? animations[indexHide] : null;
                }
            }
            else
            {
                layoutElement.AnimationShow = null;
                layoutElement.AnimationHide = null;
                EditorGUILayout.HelpBox("\nAdd UiTweener component to create Show and Hide animations.\n", MessageType.Info);
            }
        }
Example #7
0
 private void UpdateAnimation(string name, ref UiAnimation backingField, UiAnimation newValue)
 {
     if (backingField == newValue)
     {
         return;
     }
     _animator.RemoveAnimation(name);
     backingField = newValue;
     AddAnimation(name, backingField);
 }
 public void StopAKReadyToUseAnim()
 {
     if (this.m_akReadyToConsumeEffectHandle != null)
     {
         UiAnimation anim = this.m_akReadyToConsumeEffectHandle.GetAnim();
         if (anim != null)
         {
             anim.Stop(0f);
         }
         this.m_akReadyToConsumeEffectHandle = null;
     }
 }
Example #9
0
    public UiAnimMgr.UiAnimHandle PlayAnim(string animName, Transform parent, Vector3 localPos, float localScale, float fadeTime = 0f)
    {
        GameObject gameObject = this.CreateAnimObj(animName, false);

        if (gameObject == null)
        {
            return(null);
        }
        gameObject.get_transform().SetParent(parent, false);
        gameObject.get_transform().set_localPosition(localPos);
        gameObject.get_transform().set_localScale(new Vector3(localScale, localScale, localScale));
        UiAnimation component = gameObject.GetComponent <UiAnimation>();

        component.Play(fadeTime);
        return(new UiAnimMgr.UiAnimHandle(component));
    }
Example #10
0
        public void Animate(string name, float offsetTime, float duration)
        {
            switch (name.ToLowerInvariant())
            {
            case "flyinleft":
                var left = new FlyInLeft(Vector2.Zero, offsetTime, duration);
                left.From        = -GetDimensions().X - 10;
                CurrentAnimation = left;
                CurrentAnimation.Begin();
                break;

            case "flyoutleft":
                var outleft = new FlyOutLeft(Vector2.Zero, offsetTime, duration);
                outleft.To       = -GetDimensions().X - 10;
                CurrentAnimation = outleft;
                CurrentAnimation.Begin();
                break;
            }
        }
Example #11
0
        public void Animate(string name, float offsetTime, float duration)
        {
            switch (name.ToLowerInvariant())
            {
            case "flyinleft":
                var left = new FlyInLeft(Vector2.Zero, offsetTime, duration);
                left.From        = -GetDimensions().X - 10;
                CurrentAnimation = left;
                CurrentAnimation.Begin(aspectRatio);
                break;

            case "flyinright":
                var right = new FlyInRight(Vector2.Zero, offsetTime, duration);
                CurrentAnimation = right;
                CurrentAnimation.Begin(aspectRatio);
                break;

            case "flyoutleft":
                var outleft = new FlyOutLeft(Vector2.Zero, offsetTime, duration);
                outleft.To       = -GetDimensions().X - 10;
                CurrentAnimation = outleft;
                CurrentAnimation.Begin(aspectRatio);
                break;

            case "flyoutright":
                var outright = new FlyOutRight(Vector2.Zero, aspectRatio, Width, offsetTime, duration);
                CurrentAnimation = outright;
                CurrentAnimation.Begin(aspectRatio);
                break;

            case "flyinbottom":
                var inbottom = new FlyInBottom(Vector2.Zero, offsetTime, duration);
                CurrentAnimation = inbottom;
                CurrentAnimation.Begin(aspectRatio);
                break;

            case "flyoutbottom":
                var outbottom = new FlyOutBottom(Vector2.Zero, offsetTime, duration);
                CurrentAnimation = outbottom;
                CurrentAnimation.Begin(aspectRatio);
                break;
            }
        }
Example #12
0
        protected void Update(UiContext context, Vector2 myPos)
        {
            aspectRatio = context.ViewportWidth / context.ViewportHeight;
            double delta = context.DeltaTime;

            callback?.Invoke(delta);
            if (CurrentAnimation != null)
            {
                CurrentAnimation.SetWidgetPosition(myPos);
                CurrentAnimation.Update(delta, aspectRatio);
                if (!CurrentAnimation.Running)
                {
                    if (CurrentAnimation.FinalPositionSet.HasValue)
                    {
                        animSetPos = CurrentAnimation.FinalPositionSet.Value;
                    }
                    CurrentAnimation = null;
                }
            }
        }
Example #13
0
 private void StopGlowEffect()
 {
     if (this.m_glowSpinHandle != null)
     {
         UiAnimation anim = this.m_glowSpinHandle.GetAnim();
         if (anim != null)
         {
             anim.Stop(0.5f);
         }
         this.m_glowSpinHandle = null;
     }
     if (this.m_glowPulseHandle != null)
     {
         UiAnimation anim2 = this.m_glowPulseHandle.GetAnim();
         if (anim2 != null)
         {
             anim2.Stop(0.5f);
         }
         this.m_glowPulseHandle = null;
     }
 }
Example #14
0
 public void ClearResults()
 {
     this.m_enableLootEffect_success = false;
     this.m_enableLootEffect_fail    = false;
     if (this.m_greenCheck != null)
     {
         this.m_greenCheck.get_gameObject().SetActive(false);
     }
     if (this.m_redX != null)
     {
         this.m_redX.get_gameObject().SetActive(false);
     }
     if (this.m_effectHandle != null)
     {
         UiAnimation anim = this.m_effectHandle.GetAnim();
         if (anim != null)
         {
             anim.Stop(0f);
         }
     }
 }
 private void StopGlowEffect()
 {
     if (this.m_glowSpinHandle != null)
     {
         UiAnimation anim = this.m_glowSpinHandle.GetAnim();
         if (anim != null)
         {
             anim.Stop(0.5f);
         }
         this.m_glowSpinHandle = null;
     }
     if (this.m_glowPulseHandle != null)
     {
         UiAnimation anim2 = this.m_glowPulseHandle.GetAnim();
         if (anim2 != null)
         {
             anim2.Stop(0.5f);
         }
         this.m_glowPulseHandle = null;
     }
     this.m_greenSelectionGlow.get_gameObject().SetActive(false);
 }
Example #16
0
    public void AnimComplete(UiAnimation script)
    {
        GameObject gameObject = script.get_gameObject();

        UiAnimMgr.AnimData animData;
        this.m_animData.TryGetValue(gameObject.get_name(), ref animData);
        if (animData == null)
        {
            Debug.Log("Error! UiAnimMgr could not find completed anim " + gameObject.get_name());
            return;
        }
        if (!animData.m_activeObjects.Remove(gameObject))
        {
            Debug.Log("Error! anim obj " + gameObject.get_name() + "not in UiAnimMgr active list");
        }
        animData.m_availableObjects.Push(gameObject);
        gameObject.SetActive(false);
        gameObject.get_transform().SetParent(this.m_parentObj.get_transform());
        UiAnimation component = gameObject.GetComponent <UiAnimation>();

        component.m_ID = 0;
    }
Example #17
0
 public void HandleMissionChanged(int newMissionID)
 {
     if (this.m_isStackablePreview || this.m_garrMissionID == 0)
     {
         return;
     }
     if (this.m_selectedEffectAnimHandle != null)
     {
         UiAnimation anim = this.m_selectedEffectAnimHandle.GetAnim();
         if (anim != null)
         {
             anim.Stop(0.5f);
         }
     }
     if (newMissionID == this.m_garrMissionID)
     {
         this.m_selectedEffectAnimHandle = UiAnimMgr.instance.PlayAnim("MinimapLoopPulseAnim", this.m_selectedEffectRoot, Vector3.get_zero(), 2.5f, 0f);
     }
     if (this.m_selectionRing != null)
     {
         this.m_selectionRing.get_gameObject().SetActive(newMissionID == this.m_garrMissionID);
     }
 }
 public void ClearResults()
 {
     this.m_enableLootEffect_success = false;
     this.m_enableLootEffect_fail    = false;
     if (this.m_greenCheck != null)
     {
         this.m_greenCheck.gameObject.SetActive(false);
     }
     if (this.m_redX != null)
     {
         this.m_redX.gameObject.SetActive(false);
     }
     if (this.m_effectHandle != null)
     {
         UiAnimation anim = this.m_effectHandle.GetAnim();
         if (anim != null)
         {
             anim.Stop(0f);
         }
     }
     if (this.m_glowEffectHandle != null)
     {
         UiAnimation anim2 = this.m_glowEffectHandle.GetAnim();
         if (anim2 != null)
         {
             anim2.Stop(0f);
         }
     }
     if (this.m_akReadyToConsumeEffectHandle != null)
     {
         UiAnimation anim3 = this.m_akReadyToConsumeEffectHandle.GetAnim();
         if (anim3 != null)
         {
             anim3.Stop(0f);
         }
     }
 }
Example #19
0
 public void AddCustomAnimation(string name, UiAnimation animation, bool isLoop = false)
 {
     animation.Owner  = this;
     animation.IsLoop = isLoop;
     _animator.AddAnimation(name, animation);
 }
Example #20
0
    private GameObject CreateAnimObj(string animName, bool createForInit = false)
    {
        UiAnimMgr.AnimData animData;
        this.m_animData.TryGetValue(animName, ref animData);
        if (animData == null)
        {
            return(null);
        }
        GameObject gameObject = null;

        if (!createForInit && animData.m_availableObjects.get_Count() > 0)
        {
            gameObject = animData.m_availableObjects.Pop();
        }
        if (gameObject != null)
        {
            if (animData.m_activeObjects.Contains(gameObject))
            {
                Debug.Log("Error! new anim object already in active object list.");
            }
            else
            {
                animData.m_activeObjects.Add(gameObject);
            }
            gameObject.SetActive(true);
            UiAnimation component = gameObject.GetComponent <UiAnimation>();
            component.Reset();
            component.m_ID = this.GetNextID();
            return(gameObject);
        }
        gameObject = new GameObject();
        if (createForInit)
        {
            animData.m_availableObjects.Push(gameObject);
        }
        else if (animData.m_activeObjects.Contains(gameObject))
        {
            Debug.Log("Error! new anim object already in active object list.");
        }
        else
        {
            animData.m_activeObjects.Add(gameObject);
        }
        CanvasGroup canvasGroup = gameObject.AddComponent <CanvasGroup>();

        canvasGroup.set_blocksRaycasts(false);
        canvasGroup.set_interactable(false);
        gameObject.set_name(animName);
        UiAnimation uiAnimation = gameObject.AddComponent <UiAnimation>();

        uiAnimation.m_ID = this.GetNextID();
        uiAnimation.Deserialize(animName);
        RectTransform rectTransform = gameObject.AddComponent <RectTransform>();

        rectTransform.SetSizeWithCurrentAnchors(0, uiAnimation.GetFrameWidth());
        rectTransform.SetSizeWithCurrentAnchors(1, uiAnimation.GetFrameHeight());
        using (Dictionary <string, UiAnimation.UiTexture> .ValueCollection.Enumerator enumerator = uiAnimation.m_textures.get_Values().GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                UiAnimation.UiTexture current     = enumerator.get_Current();
                GameObject            gameObject2 = new GameObject();
                gameObject2.set_name(current.m_parentKey + "_Texture");
                gameObject2.get_transform().SetParent(gameObject.get_transform(), false);
                current.m_image = gameObject2.AddComponent <Image>();
                current.m_image.set_sprite(current.m_sprite);
                current.m_image.get_canvasRenderer().SetAlpha(current.m_alpha);
                if (current.m_alphaMode == "ADD")
                {
                    current.m_image.set_material(new Material(UiAnimMgr.instance.m_additiveMaterial));
                }
                else
                {
                    current.m_image.set_material(new Material(UiAnimMgr.instance.m_blendMaterial));
                }
                current.m_image.get_material().set_mainTexture(current.m_sprite.get_texture());
                RectTransform component2 = gameObject2.GetComponent <RectTransform>();
                int           num;
                if (current.m_anchor != null && current.m_anchor.relativePoint != null)
                {
                    string text = current.m_anchor.relativePoint;
                    if (text != null)
                    {
                        if (UiAnimMgr.< > f__switch$map9 == null)
                        {
                            Dictionary <string, int> dictionary = new Dictionary <string, int>(9);
                            dictionary.Add("TOP", 0);
                            dictionary.Add("BOTTOM", 1);
                            dictionary.Add("LEFT", 2);
                            dictionary.Add("RIGHT", 3);
                            dictionary.Add("CENTER", 4);
                            dictionary.Add("TOPLEFT", 5);
                            dictionary.Add("TOPRIGHT", 6);
                            dictionary.Add("BOTTOMLEFT", 7);
                            dictionary.Add("BOTTOMRIGHT", 8);
                            UiAnimMgr.< > f__switch$map9 = dictionary;
                        }
                        if (UiAnimMgr.< > f__switch$map9.TryGetValue(text, ref num))
                        {
                            switch (num)
                            {
                            case 0:
                                component2.set_anchorMin(new Vector2(0.5f, 1f));
                                component2.set_anchorMax(component2.get_anchorMin());
                                break;

                            case 1:
                                component2.set_anchorMin(new Vector2(0.5f, 0f));
                                component2.set_anchorMax(component2.get_anchorMin());
                                break;

                            case 2:
                                component2.set_anchorMin(new Vector2(0f, 0.5f));
                                component2.set_anchorMax(component2.get_anchorMin());
                                break;

                            case 3:
                                component2.set_anchorMin(new Vector2(1f, 0.5f));
                                component2.set_anchorMax(component2.get_anchorMin());
                                break;

                            case 4:
                                component2.set_anchorMin(new Vector2(0.5f, 0.5f));
                                component2.set_anchorMax(component2.get_anchorMin());
                                break;

                            case 5:
                                component2.set_anchorMin(new Vector2(0f, 1f));
                                component2.set_anchorMax(component2.get_anchorMin());
                                break;

                            case 6:
                                component2.set_anchorMin(new Vector2(1f, 1f));
                                component2.set_anchorMax(component2.get_anchorMin());
                                break;

                            case 7:
                                component2.set_anchorMin(new Vector2(0f, 0f));
                                component2.set_anchorMax(component2.get_anchorMin());
                                break;

                            case 8:
                                component2.set_anchorMin(new Vector2(1f, 0f));
                                component2.set_anchorMax(component2.get_anchorMin());
                                break;
                            }
                        }
                    }
                }
                Vector2 anchoredPosition = default(Vector2);
                if (current.m_anchor != null && current.m_anchor.point != null)
                {
                    string text = current.m_anchor.point;
                    if (text != null)
                    {
                        if (UiAnimMgr.< > f__switch$mapA == null)
                        {
                            Dictionary <string, int> dictionary = new Dictionary <string, int>(9);
                            dictionary.Add("TOP", 0);
                            dictionary.Add("BOTTOM", 1);
                            dictionary.Add("LEFT", 2);
                            dictionary.Add("RIGHT", 3);
                            dictionary.Add("CENTER", 4);
                            dictionary.Add("TOPLEFT", 5);
                            dictionary.Add("TOPRIGHT", 6);
                            dictionary.Add("BOTTOMLEFT", 7);
                            dictionary.Add("BOTTOMRIGHT", 8);
                            UiAnimMgr.< > f__switch$mapA = dictionary;
                        }
                        if (UiAnimMgr.< > f__switch$mapA.TryGetValue(text, ref num))
                        {
                            switch (num)
                            {
                            case 0:
                                anchoredPosition.Set(0f, -0.5f * current.m_image.get_sprite().get_rect().get_height());
                                break;

                            case 1:
                                anchoredPosition.Set(0f, 0.5f * current.m_image.get_sprite().get_rect().get_height());
                                break;

                            case 2:
                                anchoredPosition.Set(0.5f * current.m_image.get_sprite().get_rect().get_width(), 0f);
                                break;

                            case 3:
                                anchoredPosition.Set(-0.5f * current.m_image.get_sprite().get_rect().get_width(), 0f);
                                break;

                            case 5:
                                anchoredPosition.Set(0.5f * current.m_image.get_sprite().get_rect().get_width(), -0.5f * current.m_image.get_sprite().get_rect().get_height());
                                break;

                            case 6:
                                anchoredPosition.Set(-0.5f * current.m_image.get_sprite().get_rect().get_width(), -0.5f * current.m_image.get_sprite().get_rect().get_height());
                                break;

                            case 7:
                                anchoredPosition.Set(0.5f * current.m_image.get_sprite().get_rect().get_width(), 0.5f * current.m_image.get_sprite().get_rect().get_height());
                                break;

                            case 8:
                                anchoredPosition.Set(-0.5f * current.m_image.get_sprite().get_rect().get_width(), 0.5f * current.m_image.get_sprite().get_rect().get_height());
                                break;
                            }
                        }
                    }
                }
                component2.set_anchoredPosition(anchoredPosition);
                component2.SetSizeWithCurrentAnchors(0, current.m_image.get_sprite().get_rect().get_width());
                component2.SetSizeWithCurrentAnchors(1, current.m_image.get_sprite().get_rect().get_height());
            }
        }
        using (Dictionary <string, UiAnimation.UiTexture> .ValueCollection.Enumerator enumerator2 = uiAnimation.m_textures.get_Values().GetEnumerator())
        {
            while (enumerator2.MoveNext())
            {
                UiAnimation.UiTexture current2       = enumerator2.get_Current();
                RectTransform         rectTransform2 = current2.m_image.get_rectTransform();
                current2.m_localPosition = rectTransform2.get_localPosition();
            }
        }
        return(gameObject);
    }
    public void SetCharShipment(int charShipmentID, ulong shipmentDBID, int ownedGarrFollowerID, bool training, int iconFileDataID = 0)
    {
        CharShipmentRec record = StaticDB.charShipmentDB.GetRecord(charShipmentID);

        if (record == null)
        {
            Debug.LogError("Invalid Shipment ID: " + charShipmentID);
            return;
        }
        if (this.m_glowLoopHandle != null)
        {
            UiAnimation anim = this.m_glowLoopHandle.GetAnim();
            if (anim != null)
            {
                anim.Stop(0.5f);
            }
            this.m_glowLoopHandle = null;
        }
        this.m_collected = false;
        this.m_collectingSpinner.SetActive(false);
        this.m_ownedGarrFollowerID = ownedGarrFollowerID;
        this.m_training            = training;
        this.m_shipmentDBID        = shipmentDBID;
        if (training)
        {
            if (!PersistentShipmentData.shipmentDictionary.ContainsKey(shipmentDBID))
            {
                training = false;
                Debug.LogWarning("Shipment not found in Persistent: " + charShipmentID);
            }
            else
            {
                JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)PersistentShipmentData.shipmentDictionary.get_Item(shipmentDBID);
                this.m_shipmentCreationTime = jamCharacterShipment.CreationTime;
                this.m_shipmentDuration     = jamCharacterShipment.ShipmentDuration;
            }
        }
        if (record.GarrFollowerID > 0u)
        {
            this.SetCharShipmentTroop(record, iconFileDataID);
        }
        else if (record.DummyItemID > 0)
        {
            this.SetCharShipmentItem(record);
        }
        if (ownedGarrFollowerID != 0)
        {
            this.m_troopBuildProgressRing.get_gameObject().SetActive(false);
            this.m_troopBuildEmptyRing.get_gameObject().SetActive(false);
            this.m_troopBuildProgressFill.get_gameObject().SetActive(false);
            this.m_troopOwnedCheckmark.get_gameObject().SetActive(true);
            this.m_troopPortraitImage.get_gameObject().SetActive(true);
            this.m_timeRemainingText.get_gameObject().SetActive(false);
            return;
        }
        if (training)
        {
            this.m_troopBuildEmptyRing.get_gameObject().SetActive(true);
            this.m_troopBuildProgressRing.get_gameObject().SetActive(true);
            this.m_troopBuildProgressRing.set_fillAmount(0f);
            this.m_troopBuildProgressFill.get_gameObject().SetActive(true);
            this.m_troopBuildProgressFill.set_fillAmount(0f);
            this.m_troopOwnedCheckmark.get_gameObject().SetActive(false);
            this.m_troopPortraitImage.get_gameObject().SetActive(true);
            this.m_timeRemainingText.get_gameObject().SetActive(true);
            this.m_timeRemainingText.set_text(string.Empty);
            if (this.m_grayscaleShader != null)
            {
                Material material = new Material(this.m_grayscaleShader);
                this.m_troopPortraitImage.set_material(material);
            }
        }
        else
        {
            this.m_troopBuildEmptyRing.get_gameObject().SetActive(false);
            this.m_troopBuildProgressRing.get_gameObject().SetActive(false);
            this.m_troopBuildProgressFill.get_gameObject().SetActive(false);
            this.m_troopOwnedCheckmark.get_gameObject().SetActive(false);
            this.m_troopPortraitImage.get_gameObject().SetActive(false);
            this.m_timeRemainingText.get_gameObject().SetActive(false);
        }
    }
Example #22
0
    private GameObject CreateAnimObj(string animName, bool createForInit = false)
    {
        UiAnimMgr.AnimData animData;
        this.m_animData.TryGetValue(animName, out animData);
        if (animData == null)
        {
            return(null);
        }
        GameObject gameObject = null;

        if (!createForInit && animData.m_availableObjects.Count > 0)
        {
            gameObject = animData.m_availableObjects.Pop();
        }
        if (gameObject != null)
        {
            if (animData.m_activeObjects.Contains(gameObject))
            {
                Debug.Log("Error! new anim object already in active object list.");
            }
            else
            {
                animData.m_activeObjects.Add(gameObject);
            }
            gameObject.SetActive(true);
            UiAnimation component = gameObject.GetComponent <UiAnimation>();
            component.Reset();
            component.m_ID = this.GetNextID();
            return(gameObject);
        }
        gameObject = new GameObject();
        if (createForInit)
        {
            animData.m_availableObjects.Push(gameObject);
        }
        else if (animData.m_activeObjects.Contains(gameObject))
        {
            Debug.Log("Error! new anim object already in active object list.");
        }
        else
        {
            animData.m_activeObjects.Add(gameObject);
        }
        CanvasGroup canvasGroup = gameObject.AddComponent <CanvasGroup>();

        canvasGroup.blocksRaycasts = false;
        canvasGroup.interactable   = false;
        gameObject.name            = animName;
        UiAnimation uiAnimation = gameObject.AddComponent <UiAnimation>();

        uiAnimation.m_ID = this.GetNextID();
        uiAnimation.Deserialize(animName);
        RectTransform rectTransform = gameObject.AddComponent <RectTransform>();

        rectTransform.SetSizeWithCurrentAnchors(0, uiAnimation.GetFrameWidth());
        rectTransform.SetSizeWithCurrentAnchors(1, uiAnimation.GetFrameHeight());
        foreach (UiAnimation.UiTexture uiTexture in uiAnimation.m_textures.Values)
        {
            GameObject gameObject2 = new GameObject();
            gameObject2.name = uiTexture.m_parentKey + "_Texture";
            gameObject2.transform.SetParent(gameObject.transform, false);
            uiTexture.m_image        = gameObject2.AddComponent <Image>();
            uiTexture.m_image.sprite = uiTexture.m_sprite;
            uiTexture.m_image.canvasRenderer.SetAlpha(uiTexture.m_alpha);
            if (uiTexture.m_alphaMode == "ADD")
            {
                uiTexture.m_image.material = new Material(UiAnimMgr.instance.m_additiveMaterial);
            }
            else
            {
                uiTexture.m_image.material = new Material(UiAnimMgr.instance.m_blendMaterial);
            }
            uiTexture.m_image.material.mainTexture = uiTexture.m_sprite.texture;
            RectTransform component2 = gameObject2.GetComponent <RectTransform>();
            if (uiTexture.m_anchor != null && uiTexture.m_anchor.relativePoint != null)
            {
                string relativePoint = uiTexture.m_anchor.relativePoint;
                switch (relativePoint)
                {
                case "TOP":
                    component2.anchorMin = new Vector2(0.5f, 1f);
                    component2.anchorMax = component2.anchorMin;
                    break;

                case "BOTTOM":
                    component2.anchorMin = new Vector2(0.5f, 0f);
                    component2.anchorMax = component2.anchorMin;
                    break;

                case "LEFT":
                    component2.anchorMin = new Vector2(0f, 0.5f);
                    component2.anchorMax = component2.anchorMin;
                    break;

                case "RIGHT":
                    component2.anchorMin = new Vector2(1f, 0.5f);
                    component2.anchorMax = component2.anchorMin;
                    break;

                case "CENTER":
                    component2.anchorMin = new Vector2(0.5f, 0.5f);
                    component2.anchorMax = component2.anchorMin;
                    break;

                case "TOPLEFT":
                    component2.anchorMin = new Vector2(0f, 1f);
                    component2.anchorMax = component2.anchorMin;
                    break;

                case "TOPRIGHT":
                    component2.anchorMin = new Vector2(1f, 1f);
                    component2.anchorMax = component2.anchorMin;
                    break;

                case "BOTTOMLEFT":
                    component2.anchorMin = new Vector2(0f, 0f);
                    component2.anchorMax = component2.anchorMin;
                    break;

                case "BOTTOMRIGHT":
                    component2.anchorMin = new Vector2(1f, 0f);
                    component2.anchorMax = component2.anchorMin;
                    break;
                }
            }
            Vector2 vector = default(Vector2);
            if (uiTexture.m_anchor != null && uiTexture.m_anchor.point != null)
            {
                string point = uiTexture.m_anchor.point;
                switch (point)
                {
                case "TOP":
                    vector.Set(0f, -0.5f * uiTexture.m_image.sprite.rect.height);
                    break;

                case "BOTTOM":
                    vector.Set(0f, 0.5f * uiTexture.m_image.sprite.rect.height);
                    break;

                case "LEFT":
                    vector.Set(0.5f * uiTexture.m_image.sprite.rect.width, 0f);
                    break;

                case "RIGHT":
                    vector.Set(-0.5f * uiTexture.m_image.sprite.rect.width, 0f);
                    break;

                case "TOPLEFT":
                    vector.Set(0.5f * uiTexture.m_image.sprite.rect.width, -0.5f * uiTexture.m_image.sprite.rect.height);
                    break;

                case "TOPRIGHT":
                    vector.Set(-0.5f * uiTexture.m_image.sprite.rect.width, -0.5f * uiTexture.m_image.sprite.rect.height);
                    break;

                case "BOTTOMLEFT":
                    vector.Set(0.5f * uiTexture.m_image.sprite.rect.width, 0.5f * uiTexture.m_image.sprite.rect.height);
                    break;

                case "BOTTOMRIGHT":
                    vector.Set(-0.5f * uiTexture.m_image.sprite.rect.width, 0.5f * uiTexture.m_image.sprite.rect.height);
                    break;
                }
            }
            component2.anchoredPosition = new Vector2(vector.x + uiTexture.m_anchor.x, vector.y + uiTexture.m_anchor.y);
            int num2 = 0;
            int num3 = 0;
            int.TryParse(uiTexture.m_width, out num2);
            int.TryParse(uiTexture.m_height, out num3);
            component2.SetSizeWithCurrentAnchors(0, (num2 <= 0) ? uiTexture.m_image.sprite.rect.width : ((float)num2));
            component2.SetSizeWithCurrentAnchors(1, (num3 <= 0) ? uiTexture.m_image.sprite.rect.height : ((float)num3));
        }
        foreach (UiAnimation.UiTexture uiTexture2 in uiAnimation.m_textures.Values)
        {
            RectTransform rectTransform2 = uiTexture2.m_image.rectTransform;
            uiTexture2.m_localPosition = rectTransform2.localPosition;
        }
        return(gameObject);
    }
Example #23
0
 public UiAnimHandle(UiAnimation anim)
 {
     this.m_anim = anim;
     this.m_ID   = anim.m_ID;
 }