private void CreateUI() { pauseScene = AFAssetManager.Instance.Instantiate <GameObject>(AFAssetManager.GetDirectoryOwner(pauseScenePreFabUrl)); pauseScene.name = "pauseTela"; pauseScene.AddComponent <BatePauseState>().StartScene(this); pauseScene.SetActive(false); Add(pauseScene); scoreLeftOver = GameObject.Find("scoreLeftOver"); scoreRightOver = GameObject.Find("scoreRightOver"); Font typographyofcoop = Resources.Load <Font>(AFAssetManager.GetDirectoryOwner("Fonts/TypographyofCoop-Black")); scoreLeftOver.GetComponent <Text>().font = typographyofcoop; scoreLeftOver.GetComponent <Text>().fontSize = 230; scoreLeftOver.GetComponent <Text>().supportRichText = true; scoreRightOver.GetComponent <Text>().font = typographyofcoop; scoreRightOver.GetComponent <Text>().fontSize = 230; scoreRightOver.GetComponent <Text>().supportRichText = true; pauseBtn = GameObject.Find("pausebtn"); pauseBtn.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(pauseBtnAssetUrl); pauseBtn.GetComponent <Image>().preserveAspect = true; pauseBtn.GetComponent <Button>().onClick.AddListener(OnClickPause); }
public override void Initialize() { AFAssetManager.SetDirectoryOwner("QuebraCuca"); m_stateManager = AFObject.Create <AFStateManager>(); m_stateManager.Initialize(new GameStateFactory()); _resolutionController = ResolutionController.Instance(); _paths = PathConstants.Instance(); _sounds = SoundConstants.Instance(); GameObject _soundManager = new GameObject(); _soundManager.name = "SoundManager"; _soundManager.AddComponent <SoundManager>().Init(); //SoundManager.PlaySoundByName(SoundConstants.BG_SOUND); AFSingleTransition tras = AFObject.Create <AFSingleTransition>(); SpriteRenderer sr = tras.gameObject.AddComponent <SpriteRenderer>(); sr.transform.position = new Vector3(0, 0, 6); sr.sprite = AFAssetManager.Instance.CreateSpriteFromTexture("Common/High/loadingscreen"); sr.transform.localScale = new Vector3(1, 1, 1); m_stateManager.AddTransition(tras); m_stateManager.GotoState(AState.EGameState.MENU); base.Initialize(); }
virtual public void Initialize() { if (m_hasEvents) { OnStart.Dispatch(); } if (!m_initialized) { m_engine = AFEngine.Instance; m_stateManger = AFEngine.Instance.GetStateManger(); m_soundManager = AFSoundManager.Instance; m_assetManager = AFAssetManager.Instance; m_input = AFInput.Instance; m_objects = new List <AFObject>(); m_gameObjects = new List <GameObject>(); if (m_hasEvents) { OnInitialized.Dispatch(); } BuildState(); m_initialized = true; } else { Resume(); } }
virtual public void Destroy() { if (m_destroyable) { m_stateManger = null; m_soundManager = null; m_input = null; m_engine = null; m_assetManager = null; for (int i = 0; i < m_objects.Count; ++i) { Destroy(m_objects[i].gameObject); } m_objects.Clear(); m_objects = null; } else { Debug.LogWarning("State could not be destroyed, set the destroyable value to true for complete the action"); } if (m_hasEvents) { OnDestroy.Dispatch(); } }
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); }
public override void BuildState() { main = BateController.Instance; m_selectionScene = AFAssetManager.Instance.Instantiate <GameObject>(AFAssetManager.GetDirectoryOwner("preFabs/PreFabSelectionScene")); background = GameObject.Find("BG"); bgAssetUrl = main.AddPlatformAndQualityToUrl(bgAssetUrl); background.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(bgAssetUrl); background.GetComponent <Image>().preserveAspect = true; btP1 = GameObject.Find("onePBtn"); p1AssetUrl = main.AddPlatformAndQualityToUrl(p1AssetUrl); btP1.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(p1AssetUrl); btP1.GetComponent <Button>().onClick.AddListener(OnClickP1); btP1.GetComponent <Image>().preserveAspect = true; btP2 = GameObject.Find("twoPBtn"); p2AssetUrl = main.AddPlatformAndQualityToUrl(p2AssetUrl); btP2.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(p2AssetUrl); btP2.GetComponent <Button>().onClick.AddListener(OnClickP2); btP2.GetComponent <Image>().preserveAspect = true; Add(m_selectionScene); base.BuildState(); }
public string AddPlatformAndQualityToUrl(string url, string platform = "IOS", string quality = "High") { char delim = '/'; //url = platform + delim + quality + delim + url; return(AFAssetManager.GetPathTargetPlatformWithResolution(url)); }
public AFStatesController buildHeroAnimation() { AFStatesController m_heroStates; UnityEngine.Debug.Log(AFAssetManager.GetPathTargetPlatformWithResolution() + "/" + "hero_sprites"); AFTextureAtlas heroAtlas = AFAssetManager.Instance.Load <AFTextureAtlas>(AFAssetManager.GetPathTargetPlatformWithResolution() + "/" + "hero_sprites"); m_heroStates = AFObject.Create <AFStatesController>("Hero Controller"); AFMovieClip animation = AFObject.Create <AFMovieClip>("small_walk"); animation.Init(heroAtlas.GetSprites("small_walk")); animation.gameObject.AddComponent <BoxCollider2D>(); m_heroStates.Add("small_walk", animation, false); animation = AFObject.Create <AFMovieClip>("small_stop"); animation.Init(heroAtlas.GetSprites("small_stop")); animation.gameObject.AddComponent <BoxCollider2D>(); m_heroStates.Add("small_stop", animation, true); m_heroStates.gameObject.AddComponent <Rigidbody2D>(); m_heroStates.transform.localScale = new UnityEngine.Vector3(3, 3, 3); return(m_heroStates); }
void Start() { Sprite sp = AFAssetManager.Instance.Load <Sprite>(AFAssetManager.GetPathTargetPlatformWithResolution() + "/" + path); Image L_img = gameObject.GetComponent <Image>(); if (L_img != null) { L_img.sprite = sp; } }
// 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; }
private void CreateParticles() { string path = AFAssetManager.GetPathTargetPlatformWithResolution("CFXM_GroundHit"); m_particleEmiter = Resources.Load <GameObject>(path); path = AFAssetManager.GetPathTargetPlatformWithResolution("CFXM3_Flying_EmberCFXM_Hit_B"); GameObject goEmiter = Instantiate(Resources.Load <GameObject>(path)) as GameObject; goEmiter.transform.position = new Vector3(0, 1.8f, 0); goEmiter.GetComponent <ParticleSystem>().renderer.sortingLayerName = "Foreground"; goEmiter.GetComponent <ParticleSystem>().renderer.sortingOrder = 999; }
// 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"); } }
public override void BuildState() { main = BateController.Instance; main.IsPaused = false; main.IsSounding = true; main.PlayerNumber = 1; bgAssetUrl = main.AddPlatformAndQualityToUrl(bgAssetUrl); titleAssetUrl = main.AddPlatformAndQualityToUrl(titleAssetUrl); btJogarAssetUrl = main.AddPlatformAndQualityToUrl(btJogarAssetUrl); btVoltarAssetUrl = main.AddPlatformAndQualityToUrl(btVoltarAssetUrl); m_menuScene = AFAssetManager.Instance.Instantiate <GameObject>(AFAssetManager.GetDirectoryOwner("preFabs/PreFabMenuScene")); background = GameObject.Find("menuBg"); backgroundTitle = GameObject.Find("menuTitle"); btJogar = GameObject.Find("menuBtJogar"); btVoltar = GameObject.Find("menuBtVoltar"); background.transform.localScale = Vector3.one; backgroundTitle.transform.localScale = Vector3.one; btJogar.transform.localScale = Vector3.one; btVoltar.transform.localScale = Vector3.one; background.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(bgAssetUrl); background.GetComponent <Image>().preserveAspect = true; backgroundTitle.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(titleAssetUrl); backgroundTitle.GetComponent <Image>().preserveAspect = true; btJogar.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(btJogarAssetUrl); btJogar.GetComponent <Image>().preserveAspect = true; btVoltar.GetComponent <Image>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(btVoltarAssetUrl); btVoltar.GetComponent <Image>().preserveAspect = true; btJogar.GetComponent <Button>().onClick.AddListener(OnBtJogarClick); btVoltar.GetComponent <Button>().onClick.AddListener(OnBtVoltarClick); Add(m_menuScene); AddSounds(); base.BuildState(); }
override public void AFDestroy() { m_stateManger = null; m_soundManager = null; m_assetManager = null; m_input = null; m_engine = null; for (int i = 0; i < m_objects.Count; ++i) { m_objects[i].AFDestroy(); } for (int i = 0; i < m_gameObjects.Count; ++i) { if (AFObject.IsNull(m_gameObjects[i])) { Destroy(m_gameObjects[i]); } } m_objects.Clear(); m_objects = null; OnStart.RemoveAll(); OnStart = null; OnDestroy.RemoveAll(); OnDestroy = null; OnInitialized.RemoveAll(); OnInitialized = null; OnPause.RemoveAll(); OnPause = null; OnObjectAdded.RemoveAll(); OnObjectAdded = null; OnObjectRemoved.RemoveAll(); OnObjectRemoved = null; base.AFDestroy(); }
public override void Initialize() { //AFDebug.SetConfigs( AFDebugSettings.OUTPUT_SCREEN | AFDebugSettings.OUTPUT_UNITY ); AFAssetManager.SetDirectoryOwner(""); m_stateManager = AFObject.Create <AFStateManager>(); m_stateManager.Initialize(new StartStateFactory()); m_stateManager.GotoState(AState.EGameState.MENU); base.Initialize(); AFSingleTransition tras = AFObject.Create <AFSingleTransition>(); SpriteRenderer sr = tras.gameObject.AddComponent <SpriteRenderer>(); sr.sprite = AFAssetManager.Instance.CreateSpriteFromTexture("Common/High/loadingscreen"); sr.transform.localScale = new Vector3(1, 1, 1); m_stateManager.AddTransition(tras); }
public override void BuildState() { main = BateController.Instance; gameScene = AFAssetManager.Instance.Instantiate <GameObject>(AFAssetManager.GetDirectoryOwner("preFabs/PreFabGameScene")); playerNumber = main.PlayerNumber; VerifyScreenRes(); CreateBackGround(); CreateWalls(); CreateUI(); CreateBall(); CreatePaddles(); CreateTouches(); touchLeft.GetComponent <PaddleBehaviour>().AwakenPaddle(); touchRight.GetComponent <PaddleBehaviour>().AwakenPaddle(); ball.GetComponent <BallBehaviour>().AwakeBall(); Add(gameScene); base.BuildState(); }
public override void Initialize() { AFAssetManager.SetDirectoryOwner("BateRebate"); AFAssetManager.SimulatedDPI = AFAssetManager.DPI_IPAD_RETINA; AFAssetManager.SimulatePlatform = AFAssetManager.EPlataform.IOS; m_stateManager = AFObject.Create <AFStateManager>(); m_stateManager.Initialize(new BateStateFactory()); //AFSingleTransition tras = AFObject.Create<AFSingleTransition>(); //SpriteRenderer sr = tras.gameObject.AddComponent<SpriteRenderer>(); //sr.sprite = AFAssetManager.Instance.CreateSpriteFromTexture("Common/High/loadingscreen"); //sr.transform.localScale = new Vector3(1, 1, 1); //m_stateManager.AddTransition(tras); //m_stateManager.GotoState(AState.EGameState.MENU); BateRebateMain.Instance.GetStateManger().GotoState(AState.EGameState.MENU); //BateRebateMain.Instance.GetStateManger().GotoState(AState.EGameState.SELECTION); //BateRebateMain.Instance.GetStateManger().GotoState(AState.EGameState.GAME); base.Initialize(); }
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(); }
private void OnBaterebateButtonCLickHandler() { AFSoundManager.Instance.Play(AFAssetManager.GetDirectoryOwner("Sounds/sfxWrongHit")); //m_bateRebateButton.onClick.RemoveAllListeners(); //Application.LoadLevel(GAME_BATE_RETATE); }
private void CreateBall() { ball = new GameObject(); ball.name = "ball"; ball.AddComponent <SpriteRenderer>().sprite = AFAssetManager.Instance.Instantiate <Sprite>(ballAsset); ball.AddComponent <CircleCollider2D>(); ball.AddComponent <Rigidbody2D>().mass = 0.00001f; ball.GetComponent <Rigidbody2D>().gravityScale = 0f; ball.collider2D.sharedMaterial = AFAssetManager.Instance.Instantiate <PhysicsMaterial2D>(AFAssetManager.GetDirectoryOwner("Materials/ballMaterial")); ball.transform.position = new Vector3(GetPos().x, GetPos().y, 0); ball.AddComponent <BallBehaviour>(); ball.GetComponent <BallBehaviour>().scoreLeftOver = scoreLeftOver; ball.GetComponent <BallBehaviour>().scoreRightOver = scoreRightOver; Add(ball); }