Beispiel #1
0
 public void CheakTrigger(bool RainOn)
 {
     objects = Physics2D.OverlapCircleAll(transform.position, radius, 1 << LayerMask.NameToLayer("Player"));
     if (gameController.CurrentRound != Start_round)
     {
         ThunderVoice.Play();
         ThunderAnimation.SetBool("ThunderDetermine", true);
         ThunderWarning.Play("Warning");
         foreach (var obj in objects)
         {
             PlayerUnit u = obj.gameObject.GetComponent <PlayerUnit>();
             if (u != null)
             {
                 if (!RainOn)
                 {
                     u.Damage(0.4f * u.MaxHealth);
                 }
                 else
                 {
                     u.Damage(u.MaxHealth);
                 }
                 u.controlled = true;
                 u.SetControl(1);
             }
         }
         Destroy(gameObject, 1.2f);
     }
 }
Beispiel #2
0
    /**************** Simple FSM ****************/

    private void Attack(GameObject target)
    {
        PlayerUnit u = target.GetComponent <PlayerUnit>();

        if (u != null)
        {
            u.Damage(AttackValue);
        }
        target.GetComponent <Rigidbody2D>().AddForce((target.transform.position - transform.position) * PushForce, ForceMode2D.Impulse);
    }
    public override void Act()
    {
        PlayerUnit temp = target;

        target = null;
        if (currentMove.type == MoveType.DAMAGE)
        {
            temp.Damage(currentMove.damage);
        }
    }
Beispiel #4
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         PlayerUnit u = other.GetComponent <PlayerUnit>();
         if (u != null)
         {
             u.Damage(Damage + DamagePara * u.MaxHealth);
         }
     }
 }
Beispiel #5
0
 private void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.tag == "HeartPart")
     {
         Collider2D[] cols = Physics2D.OverlapBoxAll((Vector2)transform.position + new Vector2(0, -h), new Vector2(a, b), 0, 1 << LayerMask.NameToLayer("Player"));
         if (cols.Length != 0)
         {
             foreach (var col in cols)
             {
                 PlayerUnit u = col.GetComponent <PlayerUnit>();
                 u.Damage(1);
             }
         }
         Destroy(other.gameObject);
         Destroy(gameObject);
         Debug.Log("get");
     }
 }
Beispiel #6
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.tag == "Map")
        {
            // destroy
            Destroy(gameObject);
        }
        if (other.gameObject.tag == "Player")
        {
            PlayerUnit u = other.gameObject.GetComponent <PlayerUnit>();
            if (u != null)
            {
                u.Damage(Damage);
                Destroy(gameObject);
            }
        }

        Destroy(gameObject, 2f);
    }
Beispiel #7
0
    public override void ImpulseInteraction(GameObject other)
    {
        PlayerUnit other_unit = other.GetComponent <PlayerUnit>();
        PlayerUnit self_unit  = gameObject.GetComponent <PlayerUnit>();

        if (other_unit == null)
        {
            Debug.Log("PlayerUnit is NULL");
            return;
        }
        // float weight = gameObject.GetComponent<PlayerUnit>().Weight;
        // other.gameObject.GetComponent<Rigidbody2D>().velocity = Dir.normalized * velocity * weight / other_unit.Weight;
        // this.gameObject.GetComponent<Rigidbody2D>().drag = 30;
        if (self_unit.SelfTeam != other_unit.SelfTeam)
        {
            other_unit.Damage(self_unit.DamageValue + 0.25f * other_unit.MaxHealth);
        }
        else
        {
            return;
        }
    }
Beispiel #8
0
 public void CheakTrigger()
 {
     objects = Physics2D.OverlapCircleAll(transform.position, radius, 1 << LayerMask.NameToLayer("Player"));
     if (gameController.CurrentRound != Start_round)
     {
         // MeteoriteVoice.Play();
         MeteoriteWarning.Play("MeteoriteWarningEnd");
         MeteoriteAnimation.SetBool("MeteoriteDetermine", true);
         StartCoroutine(WarningFade());
         foreach (var obj in objects)
         {
             PlayerUnit u = obj.gameObject.GetComponent <PlayerUnit>();
             if (u != null)
             {
                 u.Damage(0.3f * u.MaxHealth);
             }
         }
         GameObject Magma = Instantiate(MagmaPrefab, gameObject.transform.position, Quaternion.identity);
         Magma.GetComponent <MeteoriteMagma>().StartRound = gameController.CurrentRound;
         Destroy(gameObject, 3);
     }
 }