Пример #1
0
    public void InitGame()
    {
        soundsController.PlaySound(SoundsController.Type.Click);

        initUI.SetActive(false);
        musicController.StartGame();

        lifeTime   = 0;
        starsCount = 0;
        timer.SetActive(true);

        Destroy(starsParent.gameObject);

        starsParent        = (new GameObject("StarsParent")).transform;
        starsParent.parent = this.transform;

        stars.Clear();

        player = Instantiate(playerPrefab, starsParent) as CharacterStarController;
        player.Init(Vector3.zero, startMass);
        player.onDead += PlayerDead;
        player.onEat  += () =>
        {
            soundsController.PlaySound(SoundsController.Type.Eat);
            starsCount++;
        };

        cameraFollower.Init(player);
    }
Пример #2
0
        private void InitPlayer()
        {
            var playerRecord = ScriptableUtils.GetCurrentPlayerRecord();
            var commonRecord = ScriptableUtils.GetCommonElements();

            _view = Object.Instantiate(playerRecord.PlayerPrefab);
            _view.ModelUpdate(_model);
            var rigidbody = _view.GetComponent <Rigidbody>();

            InitMoveComponent(rigidbody);

            _cameraFollower = Object.Instantiate(commonRecord.Camera);
            _cameraFollower.Init(_view.transform);

            EventHolder <GameEventType> .Dispatcher.Broadcast(GameEventType.WeaponSwap, _model.CurrentWeapon());
        }