コード例 #1
0
    private void Start()
    {
        m_playerHealth = GameConfiguration.Instance.Player.GetComponent <HealthBehaviour>();

        m_playerHealth.OnHitTaken        += PlayerDamaged;
        m_levelOrchestrator.OnBossAppear += ShowBossUI;
    }
コード例 #2
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            TagBehaviour tagBehaviour = other.GetComponent <TagBehaviour>();

            if (tagBehaviour == null)
            {
                return;
            }

            // Destroy when impacting solid objects
            if (tagBehaviour.HasTag("Solid"))
            {
                Sparks();
                Destroy(gameObject);
            }

            // Damage target
            if (tagBehaviour.HasTag(TargetTag))
            {
                HealthBehaviour healthBehaviour = other.GetComponent <HealthBehaviour>();
                if (healthBehaviour != null)
                {
                    healthBehaviour.Value -= Damage;
                    Destroy(gameObject);
                }
            }
        }
コード例 #3
0
ファイル: BowGuyBehaviour.cs プロジェクト: joelnl/GameJam
 private void Start()
 {
     _notice   = GetComponent <NoticeBehaviour>();
     _bow      = GetComponentInChildren <BowBehaviour>();
     _playerHp = GameObject.FindGameObjectWithTag("Player").GetComponent <HealthBehaviour>();
     _nav      = GetComponent <NavMeshAgent>();
 }
コード例 #4
0
    public void MyUpdate()
    {
        Move();
        if (target == null)
        {
            return;
        }

        //get the distance between the chaser and the target
        float distance = Vector2.Distance(transform.position, target.position);

        //so long as the chaser is farther away than the minimum distance, move towards it at rate speed.
        if (distance < MINDIST)
        {
            HealthBehaviour health = target.GetComponent(typeof(HealthBehaviour)) as HealthBehaviour;
            DamageBehaviour damage = gameObject.GetComponent(typeof(DamageBehaviour)) as DamageBehaviour;
            if (health != null && damage != null)
            {
                if (!health.IsImmune)
                {
                    target.GetComponent <AudioSource>().Play();
                }
                health.ApplyDamage(damage.DamageAmount);
            }
        }

        if (target.position.x > transform.position.x && xMoveDirection < 0 ||
            target.position.x < transform.position.x && xMoveDirection > 0)
        {
            xMoveDirection *= -1;
        }
    }
        private void Awake()
        {
            _playerHealthBehaviour = GameObject.Find("Player").GetComponent <HealthBehaviour>();
            _roomTraversedEventId  = EventManager.Register <RoomTraversedEventArgs>(OnRoomTraversedEvent);

            Description = string.Format(Description, IncreaseValue);
        }
コード例 #6
0
 private void OnDieHandler()
 {
     UserInfo.KillEnemy();
     MeshRenderer.material.color = DieColor;
     AttackBehaviour.Untarget();
     Target = null;
 }
コード例 #7
0
    public void Awake()
    {
        _moveBehaviour   = GetComponent <MoveBehaviour>();
        _healthBehaviour = GetComponent <HealthBehaviour>();

        _startPos = transform.position;
    }
コード例 #8
0
 private void SetHealthUI(HealthBehaviour healthBehaviour)
 {
     if (healthBehaviour.Equals(characterHealth))
     {
         SetHealthUI();
     }
 }
コード例 #9
0
ファイル: PlayerDeathHandler.cs プロジェクト: joelnl/GameJam
 private void Start()
 {
     _hp = GetComponent <HealthBehaviour>();
     Debug.Log("<color=green>FIXING TIME SCALE</color>");
     Time.fixedDeltaTime = startingFixedDeltaTime;
     Time.timeScale      = startingTimeScale;
 }
コード例 #10
0
        public override void Start()
        {
            base.Start();

            Description      = string.Format(Description, IncreaseValue);
            _healthBehaviour = GameObject.Find("Player").GetComponent <HealthBehaviour>();
        }
コード例 #11
0
 private void Start()
 {
     _targetHealthBehaviour   = Target.GetComponent <HealthBehaviour>();
     _healthChangedEventId    = EventManager.Register <HealthChangedEventArgs>(OnHealthChanged);
     _healthMaxChangedEventId = EventManager.Register <HealthMaxChangedEventArgs>(OnHealthMaxChanged);
     UpdateCells();
 }
コード例 #12
0
    protected virtual void CheckAttackCollisions()
    {
        float   direction    = m_characterController.FacingDirection == EDirection.LEFT ? -1f : 1f;
        Vector2 attackOrigin = new Vector2(transform.position.x + (direction * (m_sr.size.x / 2f)),
                                           transform.position.y + m_sr.size.y / 2f);

        Vector2 boxOrigin = new Vector2(attackOrigin.x + (direction * (m_attackX / 2f)), attackOrigin.y);

        Collider2D[] collisions = Physics2D.OverlapBoxAll(boxOrigin, new Vector2(m_attackX, m_attackY), 0f, LayerMask.GetMask("HitBox"));

        Debug.Log("CheckAttackCollisions : " + collisions.Length);

        for (int i = 0; i < collisions.Length; i++)
        {
            Debug.Log("CheckAttackCollisions : " + TargetTag);
            Debug.Log("CheckAttackCollisions : " + collisions[i].tag);

            if (collisions[i].CompareTag(TargetTag))
            {
                HealthBehaviour hittable = collisions[i].GetComponentInParent <HealthBehaviour>();
                if (hittable != null && hittable.gameObject != gameObject)
                {
                    hittable.Hit(gameObject, m_damage);
                }
            }
        }
        Debug.Log("CheckAttackCollisions : END");
    }
コード例 #13
0
 private void DecreaseHealth(HealthBehaviour hb)
 {
     if (hb.Health > 0)
     {
         hb.CharacterTakeDamage(_attackDamage);
         hb.ChangeHealth(hb.Health);
     }
 }
コード例 #14
0
    public void Start()
    {
        playerStats = GetComponentInParent <PlayerGameplayValues>();

        controllerBehaviour = transform.parent.GetComponent <ControllerBehaviour>();
        healthBehaviour     = transform.parent.GetComponent <HealthBehaviour>();
        bowController       = transform.parent.GetComponent <BowController>();
    }
コード例 #15
0
 // Start is called before the first frame update
 void Start()
 {
     mobileHealth = transform.GetComponentInParent <HealthBehaviour>();
     mobileHealth.OnDamageTakenEvent += new HealthBehaviour.OnDamageTakenEventHandler(OnDamageTakenEvent);
     slider = transform.Find("Slider").GetComponent <Slider>();
     fill   = slider.transform.Find("Fill").GetComponent <Image>();
     Init();
 }
コード例 #16
0
    void Start()
    {
        m_rb2d         = GetComponent <Rigidbody2D>();
        m_healthSystem = GetComponent <HealthBehaviour>();

        m_healthSystem.OnDeath += Death;
        m_healthSystem.OnHit   += Attack;
    }
コード例 #17
0
ファイル: UnitData.cs プロジェクト: bad-bots/towar-defense
 void Start()
 {
     currentHealth               = type.maxHealth;
     m_Animator                  = gameObject.GetComponent <Animator>();
     m_healthBehaviour           = GetComponent <HealthBehaviour>();
     m_healthBehaviour.maxHealth = type.maxHealth;
     m_healthBehaviour.health    = type.maxHealth;
 }
コード例 #18
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         HealthBehaviour playerHealthScript = collision.gameObject.GetComponent <HealthBehaviour>();
         playerHealthScript.TakeDamage(damageAmount);
     }
 }
コード例 #19
0
    private void Awake()
    {
        m_healthBehaviour = GetComponentInParent <HealthBehaviour>();
        UpdateLife();

        m_healthBehaviour.OnHit  += (GameObject p_attacker, int p_amount) => { UpdateLife(); };
        m_healthBehaviour.OnHeal += (int p_amount) => { UpdateLife(); };
    }
コード例 #20
0
        public ArticleConfigDetail(ConfigCode _code, ConfigName _name, ConfigGang _gang,
                                   ConfigType _type, ConfigBind _bind,
                                   TaxingBehaviour _taxing, HealthBehaviour _health, SocialBehaviour _social, params ConfigCode[] _path)
            : base(_code, _gang, _type, _bind, _taxing, _health, _social)
        {
            InternalName = _name;

            InternalPath = _path.ToList();
        }
コード例 #21
0
 private void Awake()
 {
     _playerScript            = GetComponent <Player>();
     _playerRigidbody         = _playerScript.GetComponent <Rigidbody>();
     _playerShootingBehaviour = _playerScript.GetComponent <ShootingBehaviour>();
     _playerStealthBehaviour  = _playerScript.GetComponent <StealthBehaviour>();
     _playerCollider          = _playerScript.GetComponent <Collider>();
     _healthBehaviour         = _playerScript.GetComponent <HealthBehaviour>();
 }
コード例 #22
0
        private void Start()
        {
            GameObject playerObject = GameObject.Find("Player");

            _playerMovementBehaviour = playerObject.GetComponent <PlayerMovementBehaviour>();
            _healthBehaviour         = playerObject.GetComponent <HealthBehaviour>();

            _damageRateInverse = 1.0f / DamageRate;
        }
コード例 #23
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.name == "Player")
     {
         HealthBehaviour healthBehaviour = other.GetComponent <HealthBehaviour>();
         healthBehaviour.Value -= Damage;
         _boxCollider2D.enabled = false;
     }
 }
コード例 #24
0
    private void Awake()
    {
        RandomizeRooms();
        DeckShuffler.Shuffle(enemyDeck.Cards);
        enemyDeck.ResetIndex();

        player       = GameObject.FindGameObjectWithTag("Player").GetComponent <Combatant>();
        playerHealth = player.GetComponent <HealthBehaviour>();
    }
コード例 #25
0
    private void OnCollisionEnter(Collision collision)
    {
        HealthBehaviour health = collision.gameObject.GetComponent <HealthBehaviour>();

        if (health != null && health.name == _target.name)
        {
            health.TakeDamage(_damage);
        }
    }
コード例 #26
0
    private void OnDisable()
    {
        HealthBehaviour healthBehaviour = GetComponent <HealthBehaviour>();

        if (healthBehaviour != null)
        {
            healthBehaviour.OnDeath -= HandleOnDeath;
        }
    }
コード例 #27
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         if (HealthBehaviour.IsLife)
         {
             Target = other.GetComponent <HealthBehaviour>();
         }
     }
 }
コード例 #28
0
ファイル: Bullet.cs プロジェクト: erdem325/TanksWarGame
    private void OnCollisionEnter(Collision collision)
    {
        HealthBehaviour health = collision.gameObject.GetComponent <HealthBehaviour>();

        if (health != null)
        {
            health.TakeDamage(20);
        }
        Destroy(gameObject, 1f);
    }
コード例 #29
0
    private void OnTriggerEnter(Collider other)
    {
        HealthBehaviour health = other.GetComponent <HealthBehaviour>();

        if (health != null && other.name != owner)
        {
            health.TakeDamage(_damage);
            Destroy(gameObject);
        }
    }
コード例 #30
0
        public ConfigStub CloneMasterStub(ConfigCode _code, ConfigRole _role, ConfigGang _gang,
                                          ConfigType _type, ConfigBind _bind,
                                          TaxingBehaviour _taxing, HealthBehaviour _health, SocialBehaviour _social)
        {
            ConfigStub returnStub = CloneUtils <ConfigStub> .CloneOrNull(InternalStub);

            returnStub.SetSourceConfig(_code, _role, _gang, _type, _bind, _taxing, _health, _social);

            return(returnStub);
        }