bool FadeToggle() { if (ActiveHandler == null) { return(false); } _logger.Log("Toggling fade"); ActiveHandler.FromBlack(); return(true); }
void OnTriggerEnter2D(Collider2D col) { PlayerController playerController = col.gameObject.GetComponent <PlayerController>(); if (playerController != null) { playerController.gameObject.SetActive(false); _messenger.Publish(new DeathMessage(this, playerController.playerNumber)); _logger.Log(playerController.gameObject.name + " dies!"); } }
private static void Main() { Debug.Log("Startup"); Debug.Log("Starting bootstrap"); Bootstrap(); _logger = Container.Resolve <ILoggerFactory>().Create(null); _logger.Log("Done bootstrap"); }
private static void Main() { Debug.Log("Startup"); Debug.Log("Starting bootstrap"); Bootstrap(); UnityEngine.Random.InitState(Convert.ToInt32(DateTime.Now.Ticks % int.MaxValue)); _logger = Container.Resolve <ILoggerFactory>().Create(null); _logger.Log("Done bootstrap"); }
// Start is called before the first frame update void Start() { _animator = _playerSkin.GetComponent <Animator>(); _playerController = this.GetComponent <PlayerController>(); _rigidbody = this.GetComponent <Rigidbody2D>(); _messenger = Game.Container.Resolve <IMessenger>(); _logger = Game.Container.Resolve <ILoggerFactory>().Create(this); _changeDirectionToken = _messenger.Subscribe <ChangeDirectionMessage>((message) => { if (message.PlayerNumber == _playerController.playerNumber) { _logger.Log($"Player {message.PlayerNumber} changed direction."); _playerSkin.transform.localScale = new Vector3(_playerSkin.transform.localScale.x * -1f, _playerSkin.transform.localScale.z, _playerSkin.transform.localScale.z); } }); _dashAnimationToken = _messenger.Subscribe <DashAnimationMessage>((message) => { if (message.PlayerNumber == _playerController.playerNumber && _dashParticlePrefab != null) { if (_playerSkin != null) { var particles = GameObject.Instantiate(_dashParticlePrefab); particles.transform.SetParent(_playerSkin.transform); particles.transform.localScale = Vector3.one; particles.transform.localPosition = Vector3.zero; } } }); _slappedAnimationToken = _messenger.Subscribe <WasSlappedMessage>((message) => { if (message.PlayerNumber == _playerController.playerNumber && _slapParticlePrefab != null) { if (_playerSkin != null) { var particles = GameObject.Instantiate(_slapParticlePrefab); particles.transform.SetParent(_playerSkin.transform); particles.transform.localScale = Vector3.one; particles.transform.localPosition = Vector3.zero; } } }); }
void FixedUpdate() { Vector2 down = -Vector2.up; bool didHit = false; for (float f = -0.5f * groundRayAngle; f <= 0.5f * groundRayAngle; f += groundRayAngle / groundRayNumber) { var direction = Quaternion.Euler(0, 0, f) * down; RaycastHit2D hit = Physics2D.Raycast(transform.position + rayCenterOffset, direction, groundRayDistance, groundLayers); didHit = didHit || (hit.collider != null); } isGrounded = didHit; if (!canMakeActions) { return; } float moveHorizontal = Input.GetAxis($"Player{playerNumber}Horizontal"); float moveVertical = Input.GetAxis($"Player{playerNumber}Vertical"); bool isJumping = Input.GetAxis($"Player{playerNumber}Jump") > 0; bool isSlapping = Input.GetAxis($"Player{playerNumber}Fire1") > 0; bool isSprinting = Input.GetAxis($"Player{playerNumber}Fire2") > 0; if (debugEnabled) { if (moveHorizontal > 0) { _logger.Log("Right"); } if (moveHorizontal < 0) { _logger.Log("Left"); } if (moveVertical > 0) { _logger.Log("Up"); } if (moveVertical < 0) { _logger.Log("Down"); } if (isJumping) { _logger.Log("Jump"); } if (isSlapping) { _logger.Log("Slap!"); } if (isSprinting) { _logger.Log("Sprint!"); } } Vector2 newVelocity = _body.velocity; newVelocity = Move(moveHorizontal, moveVertical); // Slap if (isSlapping) { Slap(); } // Sprint / Slap if (_slapped) { savedVelocity = new Vector2(1, 0); _slapped = false; } newVelocity.x = HandleDash(newVelocity.x, isSprinting); _body.velocity = newVelocity; // Jump (only if grounded) if (isJumping && isGrounded) { Jump(); } }