コード例 #1
0
    //public void AttackPlayer()
    //{
    //    attackRay.origin = transform.position;
    //    attackRay.direction = transform.forward;

    //    if (Physics.Raycast(attackRay, out attackHit))
    //    {
    //        if (player.health.CurValue > 0)
    //        {
    //            player.TakeDamage(attackDamage, attackHit.point);
    //        }
    //    }
    //    attackTimer = 0;
    //}

    public void AttackTurret()
    {
        attackRay.origin    = transform.position;
        attackRay.direction = transform.forward;

        if (Physics.Raycast(attackRay, out attackHit))
        {
            if (turret.health.CurValue > 0)
            {
                turret.TakeDamage(attackDamage, attackHit.point);
            }
        }
        attackTimer = 0;
    }
コード例 #2
0
    //public void GetTargets()
    //{
    //    if (dayRef.GetMeridiem() == DayNightCycle.Meridiem.PM)
    //        if (dayRef.GetHour() == 8)
    //            targetManager.GetTargets();
    //    else
    //        return;
    //}

    public void Attack()
    {
        attackRay.origin    = transform.position;
        attackRay.direction = transform.forward;

        if (targetsInRange[2] == true && health.CurValue > 0)
        {
            if (Physics.Raycast(attackRay, out attackHit))
            {
                attackTimer += Time.deltaTime;

                if (attackTimer >= attackSpeed)
                {
                    if (turret.health.CurValue > 0)
                    {
                        turret.TakeDamage(attackDamage, attackHit.point);
                    }
                    attackTimer = 0;
                }
            }
        }
    }
コード例 #3
0
    public void Attack()
    {
        attackRay.origin    = transform.position - new Vector3(0f, 0.5f, 0f);
        attackRay.direction = transform.forward;

        if (targetsInRange[0] == true && health.CurValue > 0)
        {
            if (Physics.Raycast(attackRay, out attackHit))
            {
                attackTimer += Time.deltaTime;

                if (attackTimer >= attackSpeed)
                {
                    if (player.health.CurValue > 0)
                    {
                        player.TakeDamage(attackDamage, attackHit.point);
                    }
                    attackTimer = 0;
                }
            }
        }

        if (targetsInRange[1] == true && health.CurValue > 0)
        {
            if (Physics.Raycast(attackRay, out attackHit))
            {
                attackTimer += Time.deltaTime;

                if (attackTimer >= attackSpeed)
                {
                    if (fire.health.CurValue > 0)
                    {
                        fire.TakeDamage(attackDamage, attackHit.point);
                    }
                    attackTimer = 0;
                }
            }
        }

        if (targetsInRange[2] == true && health.CurValue > 0)
        {
            if (Physics.Raycast(attackRay, out attackHit))
            {
                BaseTurret turretHealth = attackHit.collider.GetComponent <BaseTurret>();
                attackTimer += Time.deltaTime;

                if (attackTimer >= attackSpeed)
                {
                    if (turretHealth.health.CurValue > 0)
                    {
                        turretHealth.TakeDamage(attackDamage, attackHit.point);
                    }
                    attackTimer = 0;
                }
            }
        }

        if (targetsInRange[3] == true && health.CurValue > 0)
        {
            if (Physics.Raycast(attackRay, out attackHit))
            {
                Durability wallHealth = attackHit.collider.GetComponent <Durability>();
                attackTimer += Time.deltaTime;

                if (attackTimer >= attackSpeed)
                {
                    if (wallHealth != null)
                    {
                        wallHealth.TakeDamage(attackDamage, attackHit.point);
                    }
                    attackTimer = 0;
                }
            }
        }
    }