/*[SerializeField] private PlayerView _patrolView; * public AIConfig aIConfig; * private SimplePatrolAIModel simplePatrolAIModel; * private EnemiesConfigurators enemiesConfigurator; * private SimplePatrolAI simplePatrolAI;*/ private void Awake() { levelCompleteManager = new LevelCompleteManager(_playerView, _loose, _wins, _text); playerConfig = Resources.Load <SpriteAnimatorConfig>("AnimPlayerCfg"); _playerAnimatorController = new SpriteAnimatorController(playerConfig); _playerAnimatorController.StartAnimation(_playerView._spriteRenderer, AnimState.Run, true, _animationSpeed); mainHeroPhysicsWalker = new MainHeroPhysicsWalker(_playerView, _playerAnimatorController); pinkyConfig = Resources.Load <SpriteAnimatorConfig>("AnimPinkyCfg"); _pinkyAnimatorController = new SpriteAnimatorController(pinkyConfig); _pinkyAnimatorController.StartAnimation(_pinkyView._spriteRenderer, AnimState.Idle, true, _animationSpeed); pinkyWalker = new PinkyWalker(_pinkyView, _pinkyAnimatorController); waterConfig = Resources.Load <SpriteAnimatorConfig>("AnimWaterCfg"); _waterAnimatorController = new SpriteAnimatorController(waterConfig); _waterAnimatorController.StartAnimation(_waterView._spriteRenderer, AnimState.Run, true, _animationSpeed); waterAnimation = new WaterAnimation(_waterView, _waterAnimatorController); aimingMuzzle = new AimingMuzzle(cannonView._muzzleTransform, cannonView._aimTransform); bulletsEmitter = new BulletsEmitter(cannonView._bullets, bulletsEmitterTransform); /*simplePatrolAIModel = new SimplePatrolAIModel(aIConfig); * simplePatrolAI = new SimplePatrolAI(_patrolView, simplePatrolAIModel);*/ }
public void Update() { _doJump = Input.GetAxis("Vertical") > 0; _xAxisInput = Input.GetAxis("Horizontal"); var goSideWay = Mathf.Abs(_xAxisInput) > _movingThresh; if (IsGrounded()) { _freeze = false; if (goSideWay) { GoSideWay(); } _spriteAnimator.StartAnimation(_view._spriteRenderer, goSideWay ? AnimState.Run : AnimState.Idle, true, _animationsSpeed); if (_doJump && _yVelocity == 0) { _yVelocity = _jumpStartSpeed; } else if (_yVelocity < 0) { _yVelocity = 0; } } else { if (goSideWay) { GoSideWay(); } if (Mathf.Abs(_yVelocity) > _flyThresh && Mathf.Abs(_yVelocity) < _flyFreezePoint || _freeze) { _freeze = true; _spriteAnimator.StartAnimation(_view._spriteRenderer, AnimState.Fly, true, _animationsJumpSpeed); } else if (Mathf.Abs(_yVelocity) > _flyFreezePoint && !_freeze) { _freeze = false; _spriteAnimator.StartAnimation(_view._spriteRenderer, AnimState.Jump, true, _animationsSpeed); } _yVelocity += _g * Time.deltaTime; _view._transform.position += Vector3.up * (Time.deltaTime * _yVelocity); //_view._rigidbody2D.AddForce(Vector3.up * _jumpForce); } }
public void FixedUpdate() { _doJump = Input.GetAxis(_verticalAxisName) > 0; _goSideWay = Input.GetAxis(_horizontalAxisName); _contactsPoller.Update(); var walks = Mathf.Abs(_goSideWay) > _movingThresh; if (walks) { _view._spriteRenderer.flipX = _goSideWay < 0; } var newVelocity = 0f; if (walks && (_goSideWay > 0 || !_contactsPoller.HasLeftContacts) && (_goSideWay < 0 || !_contactsPoller.HasRightContacts)) { newVelocity = Time.fixedDeltaTime * _walkSpeed * (_goSideWay < 0 ? -1 : 1); } _view._rigidbody2D.velocity = _view._rigidbody2D.velocity.Change( x: newVelocity); if (_contactsPoller.IsGrounded && _doJump && Mathf.Abs(_view._rigidbody2D.velocity.y) <= _jumpThresh) { _view._rigidbody2D.AddForce(Vector3.up * _jumpForse); } //animations if (_contactsPoller.IsGrounded) { var track = walks ? AnimState.Run : AnimState.Idle; _spriteAnimator.StartAnimation(_view._spriteRenderer, track, true, _animationsSpeed); } else if (Mathf.Abs(_view._rigidbody2D.velocity.y) > _flyThresh) { var track = AnimState.Jump; _spriteAnimator.StartAnimation(_view._spriteRenderer, track, true, _animationsSpeed); } }
public CoinsManager(PlayerView characterView, List <PlayerView> coinViews, SpriteAnimatorController spriteAnimator) { _characterView = characterView; _spriteAnimator = spriteAnimator; _coinViews = coinViews; _characterView.OnLevelObjectContact += OnLevelObjectContact; foreach (var coinView in coinViews) { _spriteAnimator.StartAnimation(coinView._spriteRenderer, AnimState.Run, true, _animationsSpeed); } }
private void Awake() { _cam = Camera.main; _prlxCtrl1 = new ParalaxController(_paralaxView1, 0.3f, ref _cam); _prlxCtrl2 = new ParalaxController(_paralaxView2, 0.18f, ref _cam); _playerConfig = Resources.Load <SpriteAnimatorConfig>("PlayerAnimCfg"); _playerAnimator = new SpriteAnimatorController(_playerConfig); _playerAnimator.StartAnimation(_playerView._spriteRenderer, "Player", AnimState.Run, true, _animationSpeed); _enemyConfig = Resources.Load <SpriteAnimatorConfig>("EnemyAnimCfg"); _enemyAnimator = new SpriteAnimatorController(_enemyConfig); _enemyAnimator.StartAnimation(_enemyView._spriteRenderer, "Enemy1", AnimState.Forward, true, _animationSpeed); }
public void Update() { _spriteAnimator.StartAnimation(_view._spriteRenderer, AnimState.Run, true, _animationsSpeed); }