public void onBulletHitsPlayer(PlayerHitbox ph, BulletBehaviour bb) { if (onBulletHitsPlayerEvent != null) { onBulletHitsPlayerEvent(ph, bb); } }
protected virtual void onHitPlayer(PlayerHitbox ph, BulletBehaviour bb) { if (bb.Equals(this)) { this.playerEffect(ph); } }
public static void Main(string[] args) { Console.WriteLine("Starting game..."); Player player = new Player(); PlayerController playerController = new PlayerController(player); PlayerHitbox hitbox = new PlayerHitbox(player); InventoryController inventoryController = new InventoryController(player); inventoryController.Inventory.AddItem(new Stone()); inventoryController.Inventory.AddItem(new StaminaPotion()); inventoryController.Draw(); player.Draw(); inventoryController.Update(); player.Draw(); playerController.Update(); player.Draw(); inventoryController.Draw(); Stone randomStone = new Stone(); player.PickupItem(randomStone); inventoryController.Draw(); hitbox.OnTriggerEnter(new Stone()); inventoryController.SelectItem(2); player.Draw(); }
private void OnTriggerEnter2D(Collider2D other) { PlayerHitbox playerHitbox = other.GetComponent <PlayerHitbox>(); if (playerHitbox != null) { AudioSource.PlayClipAtPoint(ExplosionSfx, transform.position, GameManager.Instance.Volume); Instantiate(ExplosionPrefab, transform.position, Quaternion.identity); Destroy(gameObject); return; } PlayerHurtbox playerHurtbox = other.GetComponent <PlayerHurtbox>(); if (playerHurtbox != null) { playerHurtbox.TakeDamage(); } if (other.gameObject.layer == LayerMask.NameToLayer("Ground")) { AudioSource.PlayClipAtPoint(SplashSfx, transform.position, GameManager.Instance.Volume); _rigidbody.velocity = Vector2.zero; _rigidbody.gravityScale = 0.0f; _collider.enabled = false; _animator.SetTrigger(SplashAnimaton); } }
//[HideInInspector] public InputPlayer inputs; //[HideInInspector] public InputAction.CallbackContext ctx; void Awake() { _movementComponent = GetComponent <MovementComponent>(); _dodgeComponent = GetComponent <DodgeComponent>(); _lockOnComponent = GetComponent <PlayerLockOnScript>(); _powerComponent = GetComponent <PlayerPowerHandler>(); _hitboxComponent = GetComponentInChildren <PlayerHitbox>(); //_hitboxComponent.gameObject.SetActive(false); //_modelController = GetComponentInChildren<ModelMovement>(); //_respawnComponent = GetComponent<PlayerRespawn>(); _playerAttributes = GetComponent <PlayerAttributes>(); _modelController = GetComponentInChildren <ModelController>(); _stateMachine = GetComponent <PlayerStateMachine>(); InitializeStateMachine(); _rb = GetComponent <Rigidbody>(); _Camera = Camera.main.transform; _playerCamera = _Camera.GetComponentInParent <PlayerCamera>(); }
private void OnTriggerEnter2D(Collider2D other) { PlayerHurtbox playerHurtbox = other.GetComponent <PlayerHurtbox>(); if (playerHurtbox != null) { playerHurtbox.TakeDamage(); Destroy(gameObject); return; } PlayerHitbox playerHitbox = other.GetComponent <PlayerHitbox>(); if (playerHitbox != null && !_canHurtOwner) { _canHurtOwner = true; _rigidbody2D.velocity = new Vector2(_originalDirection * XSpeedReflect * -1, YSpeedReflect); AudioSource.PlayClipAtPoint(ChingSfx, transform.position, GameManager.Instance.Volume); return; } if (_canHurtOwner) { EnemyHurtbox enemyHurtbox = other.GetComponent <EnemyHurtbox>(); if (enemyHurtbox != null && enemyHurtbox == _owner) { enemyHurtbox.TakeDamage(1f); Destroy(gameObject); return; } } if (other.gameObject.layer == LayerMask.NameToLayer("Ground")) { AudioSource.PlayClipAtPoint(ChingSfx, transform.position, GameManager.Instance.Volume); Destroy(gameObject); } }
protected virtual void playerEffect(PlayerHitbox ph) { }
private void Start() { playerHitbox = hitbox.GetComponent <PlayerHitbox>(); }