Пример #1
0
    public void InitPool()
    {
        //设置实例
        if (poolInstance == null)
        {
            poolInstance = this;
        }
        else
        {
            Destroy(this);
        }
        //  DontDestroyOnLoad(this);
        //设置载体
        if (poolParent == null)
        {
            Debug.Log("需要设置poolParent");
            return;
        }

        //初始化数据
        poolAmount  = 5;
        objectIndex = 0;
        lockPool    = false;


        objects = new List <GameObject>();
        for (int i = 0; i < poolAmount; i++)
        {
            objects.Add(Instantiate(objectPrefabs[Random.Range(0, objectPrefabs.Length - 1)], poolParent.transform));
            objects[i].SetActive(false);
        }
    }
Пример #2
0
 public GameMiningController(GameMiningView view, MiningSceneViewDescription miningViewDescription, GameManager gameManager)
 {
     _view                         = view;
     _gameManager                  = gameManager;
     _ballPool                     = new BallPool(64, view.Ball);
     _gamePoleController           = new GamePoleController(_view.HintAnimation, _view.GamePoleView, _ballPool, _view.BallSpritesViewDescription, miningViewDescription, _view);
     _gamePoleController.GameOver += GameOver;
     _view.EndGame.onClick.AddListener(OnEndGame);
 }
Пример #3
0
 public void Init(BallPool ballPool, PlayerShip ship, EnemyController enemyController)
 {
     this.ballPool        = ballPool;
     this.ship            = ship;
     this.enemyController = enemyController;
     gameController       = GameController.Instance;
     gameController.OnGameStateChanged += RefreshUi;
     RefreshUi();
 }
Пример #4
0
    void Awake()
    {
        Singleton = this;

        for (int i = 0; i < this.transform.childCount; i++)
        {
            this.transform.GetChild(i).gameObject.SetActive(false);
            _ballPoolList.Add(this.transform.GetChild(i).gameObject);
        }
    }
Пример #5
0
 public GenerateBalls(BallPoint sizePole, MiningSceneViewDescription miningViewDescription, BallPool ballPool)
 {
     _sizeGamePole          = sizePole;
     _typeBallResource      = miningViewDescription.TypeBallResource;
     _countColor            = miningViewDescription.Balls.Count;
     _percentageResources   = miningViewDescription.PercentageResources;
     _resources             = new ResourcesCount(miningViewDescription.TypeResources, miningViewDescription.CountResource);
     _miningViewDescription = miningViewDescription;
     _ballPool = ballPool;
 }
Пример #6
0
 private void Awake()
 {
     InitSingleton();
     gameState = GameState.Menu;
     uiManager = GetComponent <UIManager>();
     pool      = GetComponent <BallPool>();
     timer     = GetComponent <GameTimer>();
     timer.Init(uiManager, TimeUp);
     MusicPlayer.SetFilterActive(true);
 }
Пример #7
0
    private void PushBall()
    {
        Ball ball = BallPool.Get();

        ball.transform.SetParent(transform);
        ball.transform.localRotation = Quaternion.Euler(0, 0, angle);
        ball.transform.localScale    = Vector3.one;
        ball.SetActive(true);
        ball.transform.localPosition = Vector2.zero;
        ball.Rigid.AddForce(-ball.transform.right * BallSpeed, ForceMode2D.Impulse);
    }
Пример #8
0
        public GamePoleController(HintView hintView, GamePoleView gamePole, BallPool ballPool, BallSpritesViewDescription spritesViewDescription, MiningSceneViewDescription miningViewDescription, MonoBehaviour monoBehaviour)
        {
            _balls = new BallController[gamePole.CountHorCell, gamePole.CountVertCell];
            var checkBall                  = new CheckBall(new BallPoint(gamePole.CountHorCell, gamePole.CountVertCell));
            var movedController            = new MovedController(_balls, gamePole, checkBall);
            var destroyControler           = new DestroyControllerBall(_balls, movedController, ballPool);
            var checkChangedBallController = new CheckChangedBallController(_balls, checkBall);
            var fallBallContorller         = new FallControllerBall(_balls, movedController);
            var generateBalls              = new GenerateBalls(new BallPoint(gamePole.CountHorCell, gamePole.CountVertCell), miningViewDescription, ballPool);
            var newGenerateController      = new NewGenerateController(generateBalls, gamePole, _balls, spritesViewDescription, movedController);
            var hintController             = new HintControler(hintView, checkChangedBallController, monoBehaviour);

            _gamePoleStateControler           = new GamePoleStateControler(destroyControler, fallBallContorller, movedController, newGenerateController, checkChangedBallController, _balls, hintController);
            _gamePoleStateControler.GameOver += CallGameOver;

            gamePole.Activate();
            _gamePoleStateControler.StartGame();
        }
Пример #9
0
    public Ball CreateActiveBall()
    {
        Ball ball = BallPool.GetObject().OnInit(FuncManager.RandomBallType());

        return(ball);
    }
Пример #10
0
 private void Start()
 {
     ballPool = BallPool.poolInstance;
     setScore.SendMessage("Reset");
 }
Пример #11
0
 private void Start()
 {
     ballPool  = GetComponentInChildren <BallPool>();
     ballCount = 0;
 }
Пример #12
0
 public void Restart()
 {
     BallPool.Reset();
     SceneManager.LoadScene(0);
 }
Пример #13
0
 public DestroyControllerBall(BallController[,] ballPole, MovedController movedController, BallPool ballPool)
 {
     _ballPole        = ballPole;
     _movedController = movedController;
     _ballPool        = ballPool;
 }