示例#1
0
    public void DestroyLine(GameObject line, HealthPoints playerHealth)
    {
        if (onDead)
        {
            return;
        }

        if (gameObject.tag == "bossEnemy")
        {
            boss = GameObject.FindObjectOfType <HA_Movement>().gameObject;
            boss.GetComponent <EnemyHealth>().CommonDamage(GameObject.FindObjectOfType <HealthPoints>());
        }

        healthLine--;
        //SoundMng.instance.PlaySound(lineDestructionSound);
        Destroy(line);

        if (healthLine <= 0)
        {
            gameObject.layer = 12;
            healthLine       = 0;
            playerHealth.RestoreHealth(deathRestore);
            SoundMng.instance.PlaySound(enemyDeathSound);
            onDead = true;
        }
    }
示例#2
0
    void Update()
    {
        var zone = GetComponent <CapsuleCollider>();

        if (moving_time >= time_to_next_zone && zone_number != 3)
        {
            t += Time.deltaTime;
            {
                if (transform.parent.localScale.x != minimum)
                {
                    transform.parent.localScale = new Vector3(Mathf.Lerp(maximum, minimum, t / 20), Mathf.Lerp(maximum, minimum, t / 20), 100);
                }
                else
                {
                    t       = 0;
                    maximum = minimum;
                    zone_number++;
                    moving_time = 0;
                    minimum     = maximum - 1300;;
                }
            }
        }
        else
        {
            moving_time += Time.deltaTime;
        }
        if (!in_zone)
        {
            player_stats          = player.GetComponent <HealthPoints>();
            player_stats.healthp -= 0.001f * zone_number;
        }
    }
示例#3
0
    void Update()
    {
        GameObject player = enemy.min_dist;

        if (player == null)
        {
            return;
        }
        player_stats = player.GetComponent <HealthPoints>();
        if (Vector3.Distance(transform.position, player.transform.position) <= bot_atack_range)
        {
            bot_cast_time_left -= Time.deltaTime;
            CastAnim(bot_cast_time_left);
            if (bot_cast_time_left <= 0)
            {
                player_stats.TakeDamage();

                bot_cast_time_left = bot_cast_time;
            }
        }
        else if (Vector3.Distance(transform.position, player.transform.position) > bot_atack_range)
        {
            bot_cast_time_left = bot_cast_time;
        }
    }
示例#4
0
    void Update()
    {
        Collider2D[] results = new Collider2D[18];


        int nCollisions = Physics2D.OverlapCollider(damageZone, contactFilter, results);

        if (nCollisions > 0)
        {
            for (int i = 0; i < nCollisions; i++)
            {
                Collider2D otherCollider = results[i];
                Collider2D collider      = Physics2D.OverlapBox(otherCollider.bounds.center, otherCollider.bounds.size, 0, enemyMask);
                Vector2    direction;

                HealthPoints playerHp = otherCollider.GetComponent <HealthPoints>();

                if ((playerHp != null) && (gameObject.layer != 12))
                {
                    direction = otherCollider.bounds.center - collider.bounds.center;
                    direction.Normalize();
                    direction.y = 1f;

                    playerHp.DealDamage(20, direction);
                }
            }
        }
    }
示例#5
0
文件: Player.cs 项目: Edoxil/Infinity
 private void Die(HealthPoints healthPoints)
 {
     if (healthPoints == _stats.currentHP)
     {
         Destroy(gameObject);
     }
 }
示例#6
0
    // public RuntimeAnimatorController tempAnimator;

    private void Awake()
    {
        if (photonView.IsMine)
        {
            localPlayer = this;
        }
        // we flag as don't destroy on load so that instance survives level synchronization, thus giving a seamless experience when levels load.
        DontDestroyOnLoad(this.gameObject);

        HealthPoints          = GetComponent <HealthPoints>();
        HealthPoints.OnDeath += CheckForGameOver;

        animator = GetComponent <Animator>();

        wallet = new Wallet();

        if (photonView.IsMine)
        {
            InitAtributes();
        }
        SetPlayerClassAndVisual();

        //set name ui
        var hpBar = GetComponentInChildren <FloatingHPBarUI>();

        hpBar.chracterName = photonView.Owner.NickName;
    }
示例#7
0
 void Start()
 {
     anim  = GetComponentInChildren <Animation>();
     enemy = gameObject.GetComponent <AI_agr>();
     bot_cast_time_left = bot_cast_time;
     bot = gameObject.GetComponent <HealthPoints>();
 }
示例#8
0
    IEnumerator SetUp()
    {
        yield return(new WaitUntil(() => PlayerManager.localPlayer));

        healthPoints = PlayerManager.localPlayer.GetComponent <HealthPoints>();

        healthPoints.OnHPChange += ChangeValue;
    }
示例#9
0
 public Unit(int id, UnitStatsConfig stats)
 {
     InstanceId    = id;
     HealthPoints  = new HealthPoints(stats.HealthPoints);
     MovementRange = stats.MovementRange;
     AttackRange   = stats.AttackRange;
     AttackPoints  = stats.AttackPoints;
 }
示例#10
0
 private void OnDied(HealthPoints healthPoints)
 {
     if(healthPoints==_stats.currentHP)
     {
         Close();
         _stats = null;
     }
 }
示例#11
0
    public void SetStartInfo()
    {
        HealthPoints = 100;
        Score        = 0;

        txtHealth.text = HealthPoints.ToString();
        txtScore.text  = Score.ToString();
    }
示例#12
0
        // For cloning.
        public object Clone()
        {
            // We don't clone Cell to avoid recursion.
            BasicUnit unit = new BasicUnit(null, Facing, Class.Tag);

            unit.HealthPoints = (Parameter <int>)HealthPoints.Clone();
            unit.ActionPoints = (Parameter <int>)ActionPoints.Clone();
            return(unit);
        }
示例#13
0
    public void ChangeTarget(Transform destination)
    {
        var hp = destination.GetComponent <HealthPoints>();

        if (hp != null)
        {
            target = hp;
        }
    }
示例#14
0
 protected override void Awake()
 {
     base.Awake();
     moveRange   = new Stat(4);
     attackRange = new Stat(1);
     attack      = new Stat(20);
     defence     = new Stat(1);
     hp          = new HealthPoints(100);
 }
示例#15
0
 protected override void Awake()
 {
     base.Awake();
     moveRange   = new Stat(3);
     attackRange = new Stat(2);
     attack      = new Stat(35);
     defence     = new Stat(0);
     hp          = new HealthPoints(150, 5);
 }
示例#16
0
 public Hero(int instanceId, HeroStatsConfig stats)
 {
     InstanceId       = instanceId;
     Team             = stats.Team;
     HealthPoints     = new HealthPoints(stats.HealthPoints);
     MaxMovementForce = stats.MaxMovementForce;
     Attack           = AttackFactory.GetAttack(stats.AttackConfig);
     Ability          = AbilityFactory.GetAbility(stats.AbilityConfig);
 }
 void Start()
 {
     enemy = gameObject.GetComponent <Ubica_agr>();
     bot_cast_time_left = bot_cast_time;
     bot         = gameObject.GetComponent <HealthPoints>();
     player      = enemy.min_dist;
     playerstats = player.GetComponent <PlayerStats>();
     speed       = playerstats.playerspeed;
 }
示例#18
0
 protected override void Awake()
 {
     base.Awake();
     moveRange   = new Stat(6);
     attackRange = new Stat(5);
     attack      = new Stat(25);
     defence     = new Stat(0);
     hp          = new HealthPoints(100);
     mp          = new ManaPoints(100);
 }
示例#19
0
 protected virtual bool AddToCurrentHealth(HealthPoints health)
 {
     if (HealthContainer.CurrentHealth != HealthContainer.MaxHealth)
     {
         HealthContainer.CurrentHealth =
             HealthPoints.Min(HealthContainer.CurrentHealth + health, HealthContainer.MaxHealth);
         return(true);
     }
     return(false);
 }
示例#20
0
 protected virtual bool SubtractFromCurrentHealth(HealthPoints health, HitType hitType)
 {
     if (HealthContainer.CurrentHealth == HealthPoints.Zero)
     {
         return(false);
     }
     HealthContainer.CurrentHealth =
         HealthPoints.Max(HealthContainer.CurrentHealth - health, HealthPoints.Zero);
     return(true);
 }
示例#21
0
 protected virtual void Awake()
 {
     moveRange   = new Stat(3);
     attackRange = new Stat(1);
     attack      = new Stat(10);
     defence     = new Stat(0);
     leech       = new Stat(0);
     hp          = new HealthPoints(100);
     mp          = new ManaPoints(0);
 }
示例#22
0
    public override bool Heal(HealthPoints value)
    {
        if (AddToCurrentHealth(value))
        {
            AfterHeal.SafeInvoke();
            return(true);
        }

        return(false);
    }
示例#23
0
    private void PlayOnDeathVFX(HealthPoints hp, Projectile projectile)
    {
        GameObject onHit = Instantiate(
            hp.getOnDeathVFX(),
            projectile.gameObject.transform.position,
            projectile.gameObject.transform.rotation
            );

        Destroy(onHit, .5f);
    }
示例#24
0
 protected override bool SubtractFromCurrentHealth(HealthPoints health, HitType hitType)
 {
     if (HealthContainer.CurrentHealth == HealthPoints.Zero || hitType != HitType.Explosion)
     {
         return(false);
     }
     HealthContainer.CurrentHealth =
         HealthPoints.Max(HealthContainer.CurrentHealth - health, HealthPoints.Zero);
     return(true);
 }
示例#25
0
    private void PlayOnHitVFX(HealthPoints hp)
    {
        GameObject onHit = Instantiate(
            hp.getOnHitVFX(),
            gameObject.transform.position,
            gameObject.transform.rotation
            );

        Destroy(onHit, .5f);
    }
示例#26
0
 private void HideIfActive(HealthPoints healthPoints)
 {
     if (!isActiveAndEnabled)
     {
         return;
     }
     if (_stats.currentHP == healthPoints)
     {
         Unselect();
     }
 }
示例#27
0
    public int HealthToRegen = 3;               // How many hp bonus will regen


    public override void PickUpMe(GameObject byObject)
    {
        HealthPoints OtherHP = byObject.GetComponent <HealthPoints>();

        if (OtherHP != null)
        {
            GameManager.Instance.IncreaseGamePoints(PointsOnTake);
            OtherHP.RegenHP(HealthToRegen);
            Destroy(gameObject);
        }
    }
示例#28
0
    // Start is called before the first frame update
    void Start()
    {
        Life   = this.GetComponent <HealthPoints>();
        Attack = this.GetComponent <AttackPoints>();

        // Se eu tirar isso vai dar merda?
        isBossNode = false;

        setInitialState();
        DisplayInHUD();
    }
示例#29
0
    private void OnTriggerEnter2D(Collider2D otherObject)
    {
        HealthPoints healthDecrease = otherObject.GetComponent <HealthPoints>();
        Enemy        enemy          = otherObject.GetComponent <Enemy>();

        // If projectile collides with enemy then deal damage
        if (enemy && healthDecrease)
        {
            healthDecrease.DealDamage(damageAmount);
            // Destroy projectile if collided with enemy
            Destroy(gameObject);
        }
    }
示例#30
0
文件: Enemy.cs 项目: snaami/AHLike
 public void SetStatsFromInfo(EnemyInfo info)
 {
     _name                = info.Name;
     _attackRate          = info.AttackRate;
     _damage              = info.Damage;
     _attackLogic         = info.AttackLogic;
     _moveLogic           = info.MoveLogic;
     _moveLogic.Transform = transform;
     _moveLogic.Speed     = info.MoveSpeed;
     _moveLogic.SetLayer();
     _moveLogic.SetTransform(transform);
     _hp = new HealthPoints(info.MaxHP);
 }