Пример #1
0
    // 攻击
    public bool Attack(Unit target)
    {
        if (!CanAttack(target))
        {
            return(false);
        }

        didAttack = true;
        Vector3 direction = target.transform.position - transform.position; direction.y = 0f;

        transform.rotation = Quaternion.LookRotation(direction);

        weapon.Play(target);
        int del = Random.Range(30, 40);

        target.UnderAttack(del);
        return(true);
    }
Пример #2
0
    /// <summary>Makes an attack on the target. Unit event callback will be passed an eventCode of 2</summary>
    public bool Attack(Unit target)
    {
        if (!CanAttack(target))
        {
            return(false);
        }

        didAttack = true;

        // turn to face target
        Vector3 direction = target.transform.position - transform.position; direction.y = 0f;

        transform.rotation = Quaternion.LookRotation(direction);

        weapon.Play(target);

        return(true);
    }