Esempio n. 1
0
    public void OnTriggerEnter2D(Collider2D _col)
    {
        if (_col.gameObject == owner.gameObject)
        {
            return;
        }

        if (_col.gameObject.layer != LayerMask.NameToLayer("Doll"))
        {
            return;
        }

        CharacterDoll tar = _col.gameObject.GetComponent <CharacterDoll>();

        if (tar.faction.isPlayer == owner.faction.isPlayer)
        {
            return;
        }

        float damage = owner.chaInfo.attackPower * 0.75f;

        if (state > 0)
        {
            damage = owner.chaInfo.attackPower * 2f;
        }
        else
        {
            tar.moveLock += 1;
        }
        tar.TakeDamage((int)damage);

        tar.rb.velocity = Vector2.zero;
        End();
    }
Esempio n. 2
0
    public void OnTriggerEnter2D(Collider2D _col)
    {
        if (state != 0)
        {
            return;
        }

        if (_col.gameObject == owner.gameObject)
        {
            return;
        }

        if (_col.gameObject.layer != LayerMask.NameToLayer("Doll"))
        {
            return;
        }

        CharacterDoll tar = _col.gameObject.GetComponent <CharacterDoll>();

        if (tar.faction.isPlayer == owner.faction.isPlayer)
        {
            return;
        }

        shadow.transform.position = owner.transform.position;
        slash.transform.position  = tar.transform.position;
        shadow.gameObject.SetActive(true);
        slash.gameObject.SetActive(true);
        slash.Play("Slash");
        ++state;
        timer = 0f;

        float damage = owner.chaInfo.attackPower * 2f;

        tar.TakeDamage((int)damage);

        float   rad = tar.col.radius + owner.col.radius + 0.1f;
        Vector3 pos = tar.transform.position + (tar.transform.up * -rad);

        owner.transform.position = pos;
        owner.rb.velocity        = Vector2.zero;
        owner.transform.rotation = GameManager.CalculateLookRotation(owner, tar);

        SoundManager.Instance.PlayFX(fx);
    }
Esempio n. 3
0
    public void OnCollisionEnter2D(Collision2D col)
    {
        GameManager g = GameManager.Instance;

        Vector3 posStart = this.transform.position;
        Vector3 n        = rb.velocity.normalized;
        Vector3 posEnd   = posStart + n;

        this.transform.rotation = Quaternion.Euler(0, 0, -Mathf.Atan2(posEnd.x - posStart.x, posEnd.y - posStart.y) * Mathf.Rad2Deg);

        if (col.gameObject.layer == LayerMask.NameToLayer("Doll") &&
            g.attacker == this)
        {
            CharacterDoll hit = col.gameObject.GetComponent <CharacterDoll>();
            if (hit.faction.isPlayer != this.faction.isPlayer)
            {
                if (hit.defMode)
                {
                    col.rigidbody.velocity = Vector2.zero;
                }
                else
                {
                    col.rigidbody.velocity = CalculateVelocity(this, hit);
                }
                hit.receivedDamage = hit.TakeDamage(this);
                g.victim           = hit;
                g.attacker         = null;
            }
        }
        else if (col.gameObject.layer == LayerMask.NameToLayer("Wall") && receivedDamage > 0)
        {
            int wallDmg = (int)(receivedDamage * 0.2f);
            if (wallDmg < 1)
            {
                wallDmg = 1;
            }
            TakeDamage(wallDmg);
            receivedDamage = 0;
        }
    }