Exemplo n.º 1
0
        /// <summary>
        /// Open the market, setup all the return buttons to return to the main screen and enable the main screen
        /// </summary>
        public void OpenMarket()
        {
            CachedGameObject.SetActive(true);
            SetupReturnButtons();

            PutScreenInFocus(screens.MainScreen);
        }
Exemplo n.º 2
0
        public void Initialize(
            Vector2d position = default(Vector2d),
            Vector2d rotation = default(Vector2d))
        {
            IsActive     = true;
            CheckCasting = true;


            CachedGameObject.SetActive(true);
            if (Body.IsNotNull())
            {
                Body.Initialize(position.ToVector3d(), rotation);
            }

            if (Influencer.IsNotNull())
            {
                Influencer.Initialize();
            }



            abilityManager.Initialize();
            if (Animator.IsNotNull())
            {
                Animator.Initialize();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Starts the video
 /// </summary>
 public virtual void StartVideo(TEvent @event)
 {
     RenderTexture.SetActive(true);
     CachedGameObject.SetActive(true);
     playingVideo = true;
     VideoPlayer.Play();
 }
Exemplo n.º 4
0
 public virtual void SetActive(bool active)
 {
     if (CachedGameObject.activeSelf != active)
     {
         CachedGameObject.SetActive(active);
     }
 }
Exemplo n.º 5
0
    private T AddComponentBasedOnPlatform <T> () where T : MonoBehaviour
    {
        System.Type _basicType    = typeof(T);
        string      _baseTypeName = _basicType.ToString();

        // Check if we have free version specific class
        string _platformSpecificTypeName = null;

#if UNITY_EDITOR
        _platformSpecificTypeName = _baseTypeName + "Editor";
#elif UNITY_IOS
        _platformSpecificTypeName = _baseTypeName + "IOS";
#elif UNITY_ANDROID
        _platformSpecificTypeName = _baseTypeName + "Android";
#endif

        if (!string.IsNullOrEmpty(_platformSpecificTypeName))
        {
#if !NETFX_CORE
            System.Type _platformSpecificClassType = _basicType.Assembly.GetType(_platformSpecificTypeName, false);
#else
            System.Type _platformSpecificClassType = _basicType;
#endif

            return(CachedGameObject.AddComponent(_platformSpecificClassType) as T);
        }

        return(CachedGameObject.AddComponent <T>());
    }
Exemplo n.º 6
0
        private void Start()
        {
            CancellationToken token = CachedGameObject.GetCancellationTokenOnDestroy();

            InvokeFixedUpdateEvents().AttachExternalCancellation(token);
            InvokeMainUpdateEvents().AttachExternalCancellation(token);
        }
Exemplo n.º 7
0
 private void DisableContinueButton()
 {
     if (!UserSettings.SettingsExist)
     {
         CachedGameObject.SetActive(false);
     }
 }
Exemplo n.º 8
0
        protected override void OnInit(UIForm uiform, object userData)
        {
            base.OnInit(uiform, userData);
            m_CachedCanvas                 = CachedGameObject.GetOrAddComponent <Canvas>();
            m_CachedCanvas.worldCamera     = GameEntry.UI.UICamera; //设置UI相机
            m_CachedCanvas.overrideSorting = true;
            OriginalDepth = m_CachedCanvas.sortingOrder;            //初始深度

            m_CanvasGroup = CachedGameObject.GetOrAddComponent <CanvasGroup>();

            RectTransform rectTrans = CachedTransform as RectTransform;

            rectTrans.anchorMin        = Vector2.zero;
            rectTrans.anchorMax        = Vector2.one;
            rectTrans.anchoredPosition = Vector2.zero;
            rectTrans.sizeDelta        = Vector2.zero;

            CachedGameObject.GetOrAddComponent <GraphicRaycaster>();

            //设置所有字体
            Text[] texts = GetComponentsInChildren <Text>(true);
            for (int i = 0; i < texts.Length; i++)
            {
                texts[i].font = s_MainFont;
                if (!string.IsNullOrEmpty(texts[i].text))
                {
                    texts[i].text = GameEntry.Localization.GetString(texts[i].text);
                }
            }
        }
    public override void HandleHide(bool instant)
    {
        if (instant)
        {
            CachedGameObject.SetActive(false);
            animationTracker.SampleAnimation(anim_Hide, 1f);

            HideComplete(anim_Hide);
        }
        else
        {
            float time = 1f - GetShowAmount();

            if (!shareAnimationTimes)
            {
                time = 0f;
            }

            if (time == 1f)
            {
                HideComplete(anim_Hide);
            }
            else
            {
                animationTracker.PlayAnimation(anim_Hide);
                animationTracker.SetAnimationTime(anim_Hide, time);
            }
        }
    }
    public override void HandleShow(bool instant)
    {
        if (instant)
        {
            animationTracker.SampleAnimation(anim_Show, 1f);

            CachedGameObject.SetActive(true);

            ShowComplete(anim_Show);
        }
        else
        {
            float time = GetShowAmount();

            if (!shareAnimationTimes)
            {
                time = 0f;
            }

            if (time == 1f)
            {
                ShowComplete(anim_Show);
            }
            else
            {
                CachedGameObject.SetActive(true);

                animationTracker.PlayAnimation(anim_Show);

                animationTracker.SetAnimationTime(anim_Show, time);
            }
        }
    }
Exemplo n.º 11
0
        public virtual void Show(object args)
        {
            CachedGameObject.SetActive(true);
            isActivated = true;

            this._args = args;
        }
Exemplo n.º 12
0
        public virtual void Initialize(
            Vector2d position = default(Vector2d),
            Vector2d rotation = default(Vector2d))
        {
            IsActive     = true;
            CheckCasting = true;

            // put game object under it's agent commander
            CachedGameObject.transform.parent = this.Controller.Commander.GetComponentInChildren <RTSAgents>().transform;

            CachedGameObject.SetActive(true);
            if (Body.IsNotNull())
            {
                Body.Initialize(position.ToVector3d(), rotation);
            }

            if (Influencer.IsNotNull())
            {
                Influencer.Initialize();
            }

            abilityManager.Initialize();
            if (Animator.IsNotNull())
            {
                Animator.Initialize();
            }
        }
Exemplo n.º 13
0
        public void Initialize(
            Vector2d position = default(Vector2d),
            Vector2d rotation = default(Vector2d))
        {
            IsActive     = true;
            CheckCasting = true;


            CachedGameObject.SetActiveIfNot(true);
            if (Body.IsNotNull())
            {
                Body.Initialize(new Vector2dHeight(position), rotation);
            }

            if (Triggers.IsNotNull())
            {
                foreach (LSTrigger trigger in Triggers)
                {
                    trigger.Initialize();
                }
            }

            if (Influencer.IsNotNull())
            {
                Influencer.Initialize();
            }



            abilityManager.Initialize();
            if (Animator.IsNotNull())
            {
                Animator.Initialize();
            }
        }
Exemplo n.º 14
0
 public Rigidbody2D ForceGetRigidbody2D()
 {
     if (CachedRigidbody2D == null)
     {
         _cachedRigidbody2D = CachedGameObject.AddComponent <Rigidbody2D>();
     }
     return(_cachedRigidbody2D);
 }
Exemplo n.º 15
0
 public Rigidbody ForceGetRigidbody()
 {
     if (CachedRigidbody == null)
     {
         _cachedRigidbody = CachedGameObject.AddComponent <Rigidbody>();
     }
     return(_cachedRigidbody);
 }
Exemplo n.º 16
0
 /*
  *  Function: Activates this gameobject. It is mandatory to have this method for pooling porpouses
  *  Parameters: isFirstTime is true when the object is preloaded in the pool
  *  Return: None
  */
 public override void OnSpawn(bool isFirstTime)
 {
     if (mustShowDebugInfo)
     {
         Debug.Log("OnObjectPooledAudioObject at First Time[" + isFirstTime + "]");
     }
     CachedGameObject.SetActive(true);
 }
Exemplo n.º 17
0
 private void Pool()
 {
     AgentController.CacheAgent(this);
     if (CachedGameObject != null)
     {
         CachedGameObject.SetActive(false);
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Call this when all parameters are supplied as desired.
 /// </summary>
 public void Initialize()
 {
     CachedGameObject.SetActive(true);
     StartCoroutine(LifeTimer());
     if (OnInitialize.IsNotNull())
     {
         OnInitialize();
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// Called when this effect is deactivated.
 /// </summary>
 public void Deactivate()
 {
     CachedTransform.SetParent(null);
     CachedGameObject.SetActive(false);
     if (OnDeactivate.IsNotNull())
     {
         OnDeactivate();
     }
 }
Exemplo n.º 20
0
        public void Hide()
        {
            CachedGameObject.SetActive(false);
            AppFacade.Instance.GetManager <UIMgr>(ManagerName.UI).SetPanelDepth(this, false);

            this.OnPlayCloseUIAudio();

            OnHide();
        }
Exemplo n.º 21
0
        public void Initialize(
            AgentController controller,
            ushort localID,
            ushort globalID,
            Vector2d position = default(Vector2d),
            Vector2d rotation = default(Vector2d))
        {
            LocalID    = localID;
            GlobalID   = globalID;
            Controller = controller;

            IsActive     = true;
            CheckCasting = true;
            Selectable   = true;


            CachedGameObject.SetActiveIfNot(true);
            if (Body.IsNotNull())
            {
                Body.Initialize(new Vector2dHeight(position), rotation);
            }

            if (Triggers.IsNotNull())
            {
                foreach (LSTrigger trigger in Triggers)
                {
                    trigger.Initialize();
                }
            }

            if (Influencer.IsNotNull())
            {
                Influencer.Initialize();
            }

            if (Animator.IsNotNull())
            {
                Animator.Initialize();
            }

            abilityManager.Initialize();
            if (StatsBarer != null)
            {
                StatsBarer.Initialize();
            }
            if (Ringer.IsNotNull())
            {
                Ringer.Initialize();
                IsSelected    = false;
                IsHighlighted = false;
            }
            if (onInitialized != null)
            {
                onInitialized(this);
            }
        }
Exemplo n.º 22
0
    /*
     *  Function: DeActivates this gameobject and cleans its clip reference. It is mandatory to have this method for pooling porpouses
     *  Parameters: None
     *  Return: None
     */
    public override void OnDespawn()
    {
        if (mustShowDebugInfo)
        {
            Debug.Log("OnDespawnObjectPooledAudioObject");
        }

        audioObjReference.currentClip.clip = null;
        CachedGameObject.SetActive(false);
    }
Exemplo n.º 23
0
        void ResetToInitialState()
        {
            CachedGameObject.SetActive(initialState.Active);
            enabled = initialState.Enabled;

            for (int i = 0; i < initialState.ComponentStates.Length; i++)
            {
                componentBehaviours[i].enabled = initialState.ComponentStates[i];
            }
        }
Exemplo n.º 24
0
    void CreateGround()
    {
        float x = 0f;

        groundCollider = CachedGameObject.AddComponent <BoxCollider2D> ();

        topCollider = tup.gameObject.AddComponent <BoxCollider2D> ();

        leftCollider  = tleft.gameObject.AddComponent <BoxCollider2D> ();
        rightCollider = tright.gameObject.AddComponent <BoxCollider2D> ();

        Vector2 size   = new Vector2(worldWidth, 5f);
        Vector2 offset = new Vector2(0f, -(worldHeight * 0.5f + 2.5f));

        groundCollider.offset = offset;
        groundCollider.size   = size;

        offset = new Vector2(0f, (2.5f));

        topCollider.offset = offset;
        topCollider.size   = size;

        size   = new Vector2(5f, worldHeight);
        offset = new Vector2(-(2.5f), 0f);

        leftCollider.offset = offset;
        leftCollider.size   = size;

        size   = new Vector2(5f, worldHeight);
        offset = new Vector2((2.5f), 0f);

        rightCollider.offset = offset;
        rightCollider.size   = size;

        while (x <= worldWidth)
        {
            TrashGround ground = GetNewGround();

            //ground.CachedTransform.parent = CachedTransform;

            float x_pos = GetXPositionFor(ground, x);

            x = GetNextXPositionFor(ground, x_pos);

            x_pos += tleft.position.x;

            float y = tdown.position.y - ground.GetHeight() * 0.5f;

            Vector2 pos = new Vector2(x_pos, y);

            ground.CachedTransform.position = pos;

            cache_Ground_Size = ground.GetHeight() * 0.99f;
        }
    }
    protected void HideComplete(string anim)
    {
        if (_onHideCompleted != null)
        {
            _onHideCompleted();
        }

        CachedGameObject.SetActive(false);

        OnHideComplete();
    }
Exemplo n.º 26
0
    void LayoutHidden()
    {
        if (_layoutHidden != null)
        {
            _layoutHidden();
        }

        _layoutHidden = null;

        CachedGameObject.SetActive(false);
    }
Exemplo n.º 27
0
        void Cache()
        {
            if (CachedGameObject == null)
            {
                CachedGameObject = this.gameObject;
            }
            if (CachedTransform == null)
            {
                CachedTransform = this.transform;
            }
            if (CachedRectTransform == null)
            {
                CachedRectTransform = CachedGameObject.GetComponent <RectTransform>();
            }

            if (canvas == null)
            {
                canvas = GetComponent <Canvas>();
            }
            if (uiCamera == null)
            {
                uiCamera = FindInChild <Camera>(CachedTransform, "UICamera");
            }
            if (sceneRoot == null)
            {
                sceneRoot = FindInChild <RectTransform>(CachedTransform, "SceneRoot");
            }
            if (windowRoot == null)
            {
                windowRoot = FindInChild <RectTransform>(CachedTransform, "WindowRoot");
            }
            if (popupRoot == null)
            {
                popupRoot = FindInChild <RectTransform>(CachedTransform, "PopupRoot");
            }
            if (otherRoot == null)
            {
                otherRoot = FindInChild <RectTransform>(CachedTransform, "OtherRoot");
            }
            if (maskRoot == null)
            {
                maskRoot = FindInChild <RectTransform>(CachedTransform, "MaskRoot");
            }

            if (fullScreenMask == null)
            {
                fullScreenMask = FindInChild <Image>(CachedTransform, "mask");
            }

            fullScreenMask.gameObject.GetComponent <Button>().onClick.AddListener(OnClickMask);

            // find EventSystem
        }
Exemplo n.º 28
0
        void InitializeHierarchyIfNeeded()
        {
            if (children != null)
            {
                return;
            }

            parent = CachedGameObject.GetComponentInParent <EntityBehaviour>(true);
            var childList = new List <EntityBehaviour>();

            PopulateChildren(CachedTransform, childList);
            children = childList.ToArray();
        }
Exemplo n.º 29
0
 /// <summary>
 /// Called when this effect is deactivated. Perform resets here.
 /// </summary>
 internal void Deactivate()
 {
     if (CachedShuriken != null)
     {
         CachedShuriken.Stop();
     }
     CachedTransform.SetParent(null);
     CachedGameObject.SetActive(false);
     if (OnDeactivate.IsNotNull())
     {
         OnDeactivate();
     }
 }
Exemplo n.º 30
0
    /// <summary>
    /// Init the screen and calls the specified screenChangeCallback.
    /// </summary>
    /// <param name="screenChangeCallback">Screen change callback.</param>
    public void Init(UIScreenController.ScreenChangedEventHandler screenChangeCallback)
    {
        if (Application.isPlaying)
        {
            if (mustShowDebugInfo)
            {
                Debug.Log("Init UIScreenManager[" + CachedGameObject.name + "] with Id[" + uniqueScreenId + "]");
            }

            if (mustSurviveSceneChange && !_alreadyMarkedAsPerpetual)
            {
                UnityEngine.GameObject.DontDestroyOnLoad(CachedGameObject);
                _alreadyMarkedAsPerpetual = true;
            }

            //look for ui screen component
            if (_currentUIScreen == null)
            {
                _currentUIScreen = GetComponent <UIScreen>();
            }
            if (_camera == null)
            {
                _camera = GetComponent <Camera>();
            }

            UpdateCameraDepth(screenCameraDepth);
            if (_currentUIScreen == null)
            {
                if (mustShowDebugInfo)
                {
                    Debug.LogWarning("UIManager[" + CachedGameObject.name + "] could not found UIScreen component, it will not work properly");
                }
                if (mustActiveRecursively)
                {
                    CachedGameObject.ForceActivateRecursively(true);
                }
            }
            else
            {
                if (mustActiveRecursively)
                {
                    CachedGameObject.ForceActivateRecursively(true);
                }
                _currentUIScreen.Activate(screenChangeCallback);
            }
        }
        else
        {
            CachedGameObject.ForceActivateRecursively(true);
        }
    }