Ejemplo n.º 1
0
        public void Initialize()
        {
            _characterAnimations = AFObject.Create <AFStatesController>();

            string     path      = PathConstants.GetGameScenePath() + "cucaSprites";
            AMovieClip animation = AnimationFactory.Instance.BuildAnimation(path, STATE_HITED);

            _characterAnimations.Add(STATE_HITED, animation, false);

            animation = AnimationFactory.Instance.BuildAnimation(path, STATE_ANGRY);
            _characterAnimations.Add(STATE_ANGRY, animation, false);

            animation = AnimationFactory.Instance.BuildAnimation(path, STATE_IDLE);
            _characterAnimations.Add(STATE_IDLE, animation, true);


            _characterAnimations.gameObject.transform.parent = this.gameObject.transform;
            _sprite = _characterAnimations.GetCurrentState().GetSprite();
            this.gameObject.AddComponent <BoxColliderResizer>().Initialize();

            if (this.gameObject.GetComponent <AnimationController>())
            {
                this.gameObject.GetComponent <AnimationController>().Initialize();
            }
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        //create the mesh + renderers + filters
        createMesh();

        //Issue an OnPathUpdated event
        List <Vector3> pathPoints = PathConstants.GetPathPoints();

        OnPathUpdated(pathPoints);
    }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        dummyParent = new GameObject("Debug Points");
        dummyParent.transform.parent = this.transform.parent;
        List <Vector3> pts = PathConstants.GetPathPoints();

        for (int p_idx = 0; p_idx < pts.Count; p_idx++)
        {
            generatePathPoint(pts[p_idx], p_idx);
        }
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes the paths.
        /// </summary>
        private void InitializePaths()
        {
            // Clear
            constantsListView.Items.Clear();

            // Get all path constants
            PathConstant[] pathConstants = PathConstants.GetAllPathConstants();
            foreach (PathConstant pathConstant in pathConstants)
            {
                // Create listview item
                ListViewItem listViewItem = new ListViewItem(pathConstant.Constant);
                listViewItem.SubItems.Add(pathConstant.Description);

                // Add listview item
                constantsListView.Items.Add(listViewItem);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Load All Settings from file
        /// </summary>
        /// <returns>return settings</returns>
        /// <exception cref="ArgumentNullException">throw null exception if data not found</exception>
        public static GameSettings LoadSettings()
        {
            string file = PathConstants.GetPath(PathConstants.DATA_PATH + PathConstants.SETTING_FILE);

            if (FileHelper <GameSettings> .FileExist(file))
            {
                string       json         = File.ReadAllText(file);
                GameSettings gameSettings = FileHelper <GameSettings> .JsonStringParserToObject(json, new GameSettings());

                return(gameSettings);
            }

            GameSettings gameSetting = LoadDefaultGameSettings();

            File.WriteAllText(@"" + PathConstants.DATA_PATH + PathConstants.SETTING_FILE,
                              FileHelper <GameSettings> .ObjectParserToJsonString(gameSetting));

            return(gameSetting);
        }
Ejemplo n.º 7
0
        void Update()
        {
            _points = PointsController.GetPoints();
            if (_pointsObj != null)
            {
                _pointsObj.GetComponent <Text>().text = _points.ToString();
            }

            _lifes = LifesController.GetLifes();

            /*if (_lifesObj != null)
             * {
             *  _lifesObj.GetComponent<UILabel>().text = _lifes.ToString();
             * }*/

            for (int i = 0; i < _listOfLifes.Count(); i++)
            {
                //_listOfLifes[i].transform.localPosition = new Vector3(Screen.width * 2 - (_listOfLifes[i].GetComponent<UI2DSprite>().width * i) - _offSetX * i, (Screen.height * 2 - _listOfLifes[i].GetComponent<UI2DSprite>().height / 2f));
                if (LifesController.GetLifes() > 0)
                {
                    for (int k = LifesController.GetLifes(); k < LifesController.GetInitialLifes(); k++)
                    {
                        _listOfLifes[k].GetComponent <Image>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "lifeIcon_empty");
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public void CreateLifeHud()
        {
            _listOfLifes = new List <GameObject>();

            /*_lifeHUD = new GameObject();
             * _lifeHUD.name = "lifeHud";
             * _lifeHUD.transform.parent = this.gameObject.transform;*/

            for (int i = 0; i < LifesController.GetInitialLifes(); i++)
            {
                GameObject _life = new GameObject();
                _life.transform.parent = _canvas.transform;
                _life.name             = "life" + i;
                _life.AddComponent <CanvasRenderer>();
                _life.AddComponent <Image>().sprite         = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "lifeIcon_full");
                _life.GetComponent <Image>().preserveAspect = true;
                _listOfLifes.Add(_life);

                float lifeWidth = _life.GetComponent <Image>().sprite.bounds.size.x * 100f;

                Debug.Log("lifeWidth: " + lifeWidth);

                _life.GetComponent <RectTransform>().anchorMin        = _anchorMin;
                _life.GetComponent <RectTransform>().anchorMax        = _anchorMax;
                _life.GetComponent <RectTransform>().anchoredPosition = new Vector2(_lifeHUD.GetComponent <RectTransform>().anchoredPosition.x + _lifeHUD.GetComponent <Text>().preferredWidth + lifeWidth * i + (_offSetX * i), _lifeHUD.GetComponent <RectTransform>().anchoredPosition.y);

                /*_life.GetComponent<UI2DSprite>().SetAnchor(this.gameObject);
                 * _life.GetComponent<UI2DSprite>().topAnchor.absolute = 817;
                 * _life.GetComponent<UI2DSprite>().bottomAnchor.absolute = 528;
                 * _life.GetComponent<UI2DSprite>().leftAnchor.absolute = 622 - lifeWidth * i - (_offSetX * i);
                 * _life.GetComponent<UI2DSprite>().rightAnchor.absolute = 1320 - lifeWidth * i - (_offSetX * i);
                 * _life.GetComponent<UI2DSprite>().UpdateAnchors();
                 * _life.GetComponent<UI2DSprite>().MakePixelPerfect();
                 * FindObjectOfType<IndexController>().AddObjectToLIstByIndex(_life, 4);*/
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Search If Checkpoint Exist;
        /// </summary>
        /// <returns>return true if CheckPoint Exist, return false
        /// if CheckPoint not Exist</returns>
        public static bool CheckPointExist()
        {
            string file = PathConstants.GetPath(CHECKPOINT_FILES);

            return(FileHelper <CheckPoint> .FileExist(file));
        }
Ejemplo n.º 10
0
        private void CreateBackground()
        {
            _background      = new GameObject();
            _background.name = "background";
            _background.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "background");
            _background.transform.localPosition           = new Vector3(0, 0, 1);
            _background.AddComponent <BoxCollider>().size = new Vector3(_background.GetComponent <SpriteRenderer>().sprite.bounds.size.x,
                                                                        _background.GetComponent <SpriteRenderer>().sprite.bounds.size.y);

            float _backgroundWidth  = _background.GetComponent <SpriteRenderer>().bounds.size.x;
            float _backgroundHeight = _background.GetComponent <SpriteRenderer>().bounds.size.y;

            Resolution res = Screen.currentResolution;

            //UIEventListener.Get(_background).onClick += OnClickBG;

            _leftWall3      = new GameObject();
            _leftWall3.name = "_leftWall3";
            _leftWall3.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "leftWall3");
            _leftWall3.transform.localPosition = new Vector3((_backgroundWidth / -2f) + _leftWall3.GetComponent <SpriteRenderer>().bounds.size.x / 2f, (_backgroundHeight / 2f) - _leftWall3.GetComponent <SpriteRenderer>().bounds.size.y / 2f, 0);
            FindObjectOfType <IndexController>().AddObjectToLIstByIndex(_leftWall3, 2);

            _rightWall3      = new GameObject();
            _rightWall3.name = "_rightWall3";
            _rightWall3.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "rightWall3");
            _rightWall3.transform.localPosition = new Vector3((_backgroundWidth / 2f) - _rightWall3.GetComponent <SpriteRenderer>().bounds.size.x / 2f, (_backgroundHeight / 2f) - _rightWall3.GetComponent <SpriteRenderer>().bounds.size.y / 2f, 0);
            FindObjectOfType <IndexController>().AddObjectToLIstByIndex(_rightWall3, 2);

            _floor3      = new GameObject();
            _floor3.name = "_floor3";
            _floor3.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "floor3");
            _floor3.transform.localPosition = new Vector3(0, (_backgroundHeight / -2f) + _floor3.GetComponent <SpriteRenderer>().bounds.size.y / 2f, 0);
            FindObjectOfType <IndexController>().AddObjectToLIstByIndex(_floor3, 2);

            _leftWall2      = new GameObject();
            _leftWall2.name = "_leftWall2";
            _leftWall2.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "leftWall2");
            _leftWall2.transform.localPosition = new Vector3((_backgroundWidth / -2f) + _leftWall2.GetComponent <SpriteRenderer>().bounds.size.x / 2f, (_backgroundHeight / 2f) - _leftWall2.GetComponent <SpriteRenderer>().bounds.size.y / 2f, 0);
            FindObjectOfType <IndexController>().AddObjectToLIstByIndex(_leftWall2, 4);

            _rightWall2      = new GameObject();
            _rightWall2.name = "_rightWall2";
            _rightWall2.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "rightWall2");
            _rightWall2.transform.localPosition = new Vector3((_backgroundWidth / 2f) - _rightWall2.GetComponent <SpriteRenderer>().bounds.size.x / 2f, (_backgroundHeight / 2f) - _rightWall2.GetComponent <SpriteRenderer>().bounds.size.y / 2f, 0);
            FindObjectOfType <IndexController>().AddObjectToLIstByIndex(_rightWall2, 4);

            _floor2      = new GameObject();
            _floor2.name = "_floor2";
            _floor2.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "floor2");
            _floor2.transform.localPosition = new Vector3(0, (_backgroundHeight / -2f) + _floor2.GetComponent <SpriteRenderer>().bounds.size.y / 2f, 0);
            FindObjectOfType <IndexController>().AddObjectToLIstByIndex(_floor2, 4);

            _leftWall1      = new GameObject();
            _leftWall1.name = "_leftWall1";
            _leftWall1.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "leftWall1");
            _leftWall1.transform.localPosition = new Vector3((_backgroundWidth / -2f) + _leftWall1.GetComponent <SpriteRenderer>().bounds.size.x / 2f, (_backgroundHeight / 2f) - _leftWall1.GetComponent <SpriteRenderer>().bounds.size.y / 2f, 0);
            FindObjectOfType <IndexController>().AddObjectToLIstByIndex(_leftWall1, 6);

            _rightWall1      = new GameObject();
            _rightWall1.name = "_rightWall1";
            _rightWall1.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "rightWall1");
            _rightWall1.transform.localPosition = new Vector3((_backgroundWidth / 2f) - _rightWall1.GetComponent <SpriteRenderer>().bounds.size.x / 2f, (_backgroundHeight / 2f) - _rightWall1.GetComponent <SpriteRenderer>().bounds.size.y / 2f, 0);
            FindObjectOfType <IndexController>().AddObjectToLIstByIndex(_rightWall1, 6);

            _floor1      = new GameObject();
            _floor1.name = "_floor1";
            _floor1.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "floor1");
            _floor1.transform.localPosition = new Vector3(0, (_backgroundHeight / -2f) + _floor1.GetComponent <SpriteRenderer>().bounds.size.y / 2f, 0);
            FindObjectOfType <IndexController>().AddObjectToLIstByIndex(_floor1, 6);

            _roof      = new GameObject();
            _roof.name = "_roof";
            _roof.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(PathConstants.GetGameScenePath() + "roof1");
            _roof.transform.localPosition = new Vector3(0, (_backgroundHeight / 2f) - _roof.GetComponent <SpriteRenderer>().bounds.size.y / 2f, 0);
            FindObjectOfType <IndexController>().AddObjectToLIstByIndex(_roof, 6);

            Resources.UnloadUnusedAssets();

            /*_pointsBg = new GameObject();
             * _pointsBg.name = "_pointsBg";
             * _pointsBg.AddComponent<UI2DSprite>().sprite2D = Resources.Load<Sprite>(PathConstants.GetGameScenePath() + "pointsBg");
             * _pointsBg.GetComponent<UI2DSprite>().MakePixelPerfect();
             * _pointsBg.GetComponent<UI2DSprite>().SetAnchor(_camera);
             * _pointsBg.GetComponent<UI2DSprite>().leftAnchor.absolute = 4096;
             * _pointsBg.GetComponent<UI2DSprite>().rightAnchor.absolute = -4102;
             * _pointsBg.GetComponent<UI2DSprite>().bottomAnchor.absolute = 4327;
             * _pointsBg.GetComponent<UI2DSprite>().topAnchor.absolute = -3063;
             * _pointsBg.GetComponent<UI2DSprite>().UpdateAnchors();
             * _pointsBg.GetComponent<UI2DSprite>().MakePixelPerfect();
             * FindObjectOfType<IndexController>().AddObjectToLIstByIndex(_pointsBg, 3);*/
        }