public AMovieClip GetCurrentState()
        {
            if (m_states.ContainsKey(m_currentStateID))
            {
                return(m_states[m_currentStateID]);
            }

            AFDebug.LogError("O ID: " + m_currentStateID + " Nao foi encontrado");
            return(m_states[m_defaultStateID]);
        }
Exemple #2
0
//     public void OnLoginHandler(Sfs2X.Core.BaseEvent ev)
//     {
//         //PlayerPrefs.SetInt(PlayerInfo.PLAYERPREFS_IS_PLAYER_SUBSCRIBER, 1);
//         //PlayerInfo.IsSubscriber = true;
//     }
//
//     public void OnLoginErrorHandler(Sfs2X.Core.BaseEvent ev)
//     {
//        // PlayerPrefs.SetInt(PlayerInfo.PLAYERPREFS_IS_PLAYER_SUBSCRIBER, 0);
//        // PlayerInfo.IsSubscriber = false;
//     }

    public void SetButtonView(Image image, string path)
    {
        AFDebug.Log(AFAssetManager.GetPathTargetPlatformWithResolution() + path);

        Sprite sp = AFAssetManager.Instance.Load <Sprite>(AFAssetManager.GetPathTargetPlatformWithResolution() + path);

        if (sp != null)
        {
            image.sprite = sp;
        }
        else
        {
            AFDebug.LogError("Problem to load asset");
        }
    }
Exemple #3
0
        public T Instantiate <T>(string nameOrPath) where T : UnityEngine.Object
        {
            T L_object = Load <T>(nameOrPath);

            if (AFObject.IsNull(L_object))
            {
                AFDebug.LogError("Was not Possible to load or instantiate follow gameObject: " + name);
            }
            else
            {
                T L_objectInstantiated = Instantiate(L_object) as T;

                if (AFObject.IsNull(L_object))
                {
                    AFDebug.LogError("Was not Possible to load or instantiate follow gameObject: " + name);
                }

                return(L_objectInstantiated);
            }

            return(null);
        }
Exemple #4
0
        public override void BuildState()
        {
#if UNITY_EDITOR
            AFAssetManager.SimulatedDPI     = AFAssetManager.DPI_IPHONE_4_5;
            AFAssetManager.SimulatePlatform = AFAssetManager.EPlataform.IOS;
#endif
            _cameraGameObject      = new GameObject();
            _cameraGameObject.name = "StateCam";
            m_camera = _cameraGameObject.AddComponent <MyCamera>().GetCamera();

            string path = AFAssetManager.GetPathTargetPlatform() + "Prefabs/StartSceneCanvas";

            AFDebug.Log(AFAssetManager.GetPathTargetPlatform() + "Prefabs/StartScene");

            GameObject startSceneToIntantiate = AFAssetManager.Instance.Load <GameObject>(path);

            if (!AFObject.IsNull(startSceneToIntantiate))
            {
                m_interface = AFAssetManager.Instance.Instantiate <GameObject>(path);

                if (!AFObject.IsNull(m_interface))
                {
                    Canvas L_canvas = m_interface.GetComponent <Canvas>();

                    if (!AFObject.IsNull(L_canvas))
                    {
                        L_canvas.renderMode  = RenderMode.ScreenSpaceCamera;
                        L_canvas.worldCamera = m_camera;
                    }
                    else
                    {
                        AFDebug.LogError("Canvas not found!");
                    }

                    _background  = GameObject.Find("Background");
                    _startButton = GameObject.Find("StartButton");

                    path = AFAssetManager.GetPathTargetPlatformWithResolution("Scenes/StartScene/Background");
                    AFDebug.Log(path);
                    Sprite L_sprite = AFAssetManager.Instance.Load <Sprite>(path);
                    _background.GetComponent <Image>().sprite = L_sprite;


                    path     = AFAssetManager.GetPathTargetPlatformWithResolution("Scenes/StartScene/StartButton");
                    L_sprite = AFAssetManager.Instance.Load <Sprite>(path);
                    AFDebug.Log(path);
                    _startButton.GetComponent <Image>().sprite = L_sprite;

                    _startButton.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(() => { OnClick(); });
                }
                else
                {
                    AFDebug.LogError("Nao foi possivel encontrar a interface do login");
                }
            }
            else
            {
                AFDebug.LogError("Nao foi possivel encontrar a interface do login para clonar");
            }


            Add(m_interface);

            base.BuildState();
        }
Exemple #5
0
        public T Load <T>(string name, string path) where T : UnityEngine.Object
        {
            T res = null;

            try
            {
                res = GetAsset <T>(name);

                if (AFObject.IsNull(res))
                {
                    if (typeof(T) == typeof(AFTextureAtlas))
                    {
                        res = Add(name, new AFTextureAtlas(name, path, AFTextureAtlas.EFileType.kTextTypes_Csv)) as T;
                    }
                    else
                    {
                        res = Resources.Load <T>(path);

                        if (!AFObject.IsNull(res))
                        {
                            if (typeof(T) == typeof(Texture))
                            {
                                Add(name, res as Texture);
                            }
                            else if (typeof(T) == typeof(GameObject))
                            {
                                Add(name, res as GameObject);
                            }
                            else if (typeof(T) == typeof(Texture))
                            {
                                Add(name, res as Texture);
                            }
                            else if (typeof(T) == typeof(AudioClip))
                            {
                                Add(name, res as AudioClip);
                            }
                            else
                            {
                                Add(name, res);
                            }

                            Resources.UnloadUnusedAssets();
                        }
                        else
                        {
                            AFDebug.LogError("Asset not found: " + name);
                        }
                    }

                    AFDebug.Log("I'll store an object of: " + typeof(T).ToString());
                }
            }
            catch (NullReferenceException nullEx)
            {
                AFDebug.LogError("The asset was not found: " + nullEx.Message);
            }
            catch (Exception ex)
            {
                //TODO: Discover what happens when unity throw this error
                AFDebug.LogError("The asset was not found: " + ex.Message);
            }

            return(res);
        }