Exemple #1
0
    public override void Initialize()
    {
        base.Initialize();

#if UNITY_EDITOR
        AFAssetManager.SimulatedDPI     = AFAssetManager.DPI_IPAD_3;
        AFAssetManager.SimulatePlatform = AFAssetManager.EPlataform.IOS;
#endif

        m_interface    = GameObject.Find("ButtonsCanvas");
        m_btBateRebate = GameObject.Find("BateRebateButton");
        m_btCataBalao  = GameObject.Find("CataBalaoButton");
        m_btQuebraCuca = GameObject.Find("QuebraCucaButton");
        m_background   = GameObject.Find("Background");

        m_bateRebateButton = m_btBateRebate.GetComponent <Button>();
        m_quebraCucaButton = m_btQuebraCuca.GetComponent <Button>();
        m_cataBalaoButton  = m_btCataBalao.GetComponent <Button>();

        SetButtonView(m_btBateRebate.GetComponent <Image>(), "Scenes/StartScene/BateRebate");
        SetButtonView(m_btCataBalao.GetComponent <Image>(), "Scenes/StartScene/Button_CataBalao");
        SetButtonView(m_btQuebraCuca.GetComponent <Image>(), "Scenes/StartScene/QuebraCuca");
        SetButtonView(m_background.GetComponent <Image>(), "Scenes/StartScene/Background");

        m_bateRebateButton.onClick.AddListener(() => { OnBaterebateButtonCLickHandler(); });
        m_quebraCucaButton.onClick.AddListener(() => { OnQuebraCucaButtonCLickHandler(); });
        m_cataBalaoButton.onClick.AddListener(() => { OnCataBalaoButtonCLickHandler(); });

        AFDebug.Log(AFAssetManager.GetDirectoryOwner("Sound/sfxWrongHit"));
        AFSoundManager.Instance.Add(AFAssetManager.GetDirectoryOwner("Sounds/sfxWrongHit"), null, 1.0f, 1.0f, false, false);
    }
Exemple #2
0
        public AFSound Add(string name, string path, Transform emitter = null, float volume = 1.0f, float pitch = 1.0f, bool loop = false, bool playOncePertime = true)
        {
            if (Exists(name))
            {
                AFDebug.LogWarning("Audio already registered: " + name);
                return(m_audios[name]);
            }

            return(Put(AFSound.Create(path, name, emitter, volume, pitch, loop, playOncePertime)));
        }
        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 #4
0
        public AFSound Add(AFSound sound)
        {
            if (Exists(sound.GetName()))
            {
                AFDebug.LogWarning("Audio already registered: " + name);
                return(m_audios[sound.GetName()]);
            }

            return(Put(sound));
        }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
#if UNITY_EDITOR
        AFAssetManager.SimulatedDPI     = AFAssetManager.DPI_IPAD_3;
        AFAssetManager.SimulatePlatform = AFAssetManager.EPlataform.IOS;
        AFDebug.Log(AFAssetManager.GetPathTargetPlatformWithResolution());
#endif //UNITY_EDITOR

        Sprite sp    = AFAssetManager.Instance.Load <Sprite>(AFAssetManager.GetPathTargetPlatformWithResolution() + "/" + "Scenes/Login/Background");
        Image  L_img = gameObject.GetComponent <Image>();
        L_img.sprite = sp;
    }
Exemple #6
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 #7
0
        internal AFSound Put(AFSound sound)
        {
            if (Exists(sound.GetName()))
            {
                AFDebug.LogWarning("Audio already registered: " + sound.GetName());
                return(m_audios[sound.GetName()]);
            }

            m_audios[sound.GetName()] = sound;
            OnAudioAdd.Dispatch(sound);
            audiosInList++;

            sound.gameObject.transform.SetParent(this.gameObject.transform);

            return(sound);
        }
Exemple #8
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);
        }
        public void Add(int name, AMovieClip state, bool defaultState = false)
        {
            if (m_states.ContainsKey(name))
            {
                AFDebug.LogWarning("The State " + name + " already was created");

                return;
            }

            if (!defaultState)
            {
                state.Stop();
            }
            else
            {
                if (m_defaultStateID != 0)
                {
                    UnityEngine.Debug.LogWarning("The default state was changed to <" + name + ">");
                }

                m_defaultStateID = name;
                m_lastStateID    = name;
                state.Play();
            }


            state.gameObject.SetActive(defaultState);
            m_currentState   = state;
            m_currentStateID = name;
            m_states.Add(name, state);

#if UNITY_EDITOR
            SetNameOfCurrentState();
#endif //UNITY_EDITOR

            //Setting StatesController to owner this object
            state.gameObject.transform.parent = this.gameObject.transform;
        }
Exemple #10
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 #11
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);
        }