示例#1
0
    protected override float StartAttack()
    {
        // If making a counter attack, make the enemy tremble a bit before attacking
        if (ragingCount > ragingThreshold)
        {
            TDS_EnemyAttack _attack = GetAttack();
            if (_attack == null)
            {
                return(0);
            }

            IsAttacking = true;
            _attack.ConsecutiveUses++;
            attacks.ToList().Where(a => a != _attack).ToList().ForEach(a => a.ConsecutiveUses = 0);

            if (resetRagingThreshold != null)
            {
                StopCoroutine(resetRagingThreshold);
            }
            trembleAnimation = StartCoroutine(TrembleAnimation(_attack));

            return(_attack.Cooldown);
        }
        return(base.StartAttack());
    }
示例#2
0
 /// <summary>
 /// Get the casted attack and check if it can be casted, if so, cast it
 /// Else compute path until reaching a attacking position
 /// </summary>
 public override void TakeDecision()
 {
     if (!PhotonNetwork.isMasterClient)
     {
         return;
     }
     if (!castedAttack)
     {
         castedAttack = GetAttack();
     }
     base.TakeDecision();
 }
示例#3
0
    protected IEnumerator TrembleAnimation(TDS_EnemyAttack _attack)
    {
        transform.position = new Vector3(transform.position.x - .05f, transform.position.y, transform.position.z);
        yield return(new WaitForSeconds(.03f));

        for (int _i = 0; _i < 5; _i++)
        {
            transform.position = new Vector3(transform.position.x + .1f, transform.position.y, transform.position.z);
            yield return(new WaitForSeconds(.03f));

            transform.position = new Vector3(transform.position.x - .1f, transform.position.y, transform.position.z);
            yield return(new WaitForSeconds(.03f));
        }

        transform.position = new Vector3(transform.position.x + .05f, transform.position.y, transform.position.z);

        SetAnimationState(_attack.AnimationID);
    }
示例#4
0
    // Implement this method to draw Handles
    protected virtual void OnSceneGUI()
    {
        if (Selection.activeGameObject == null)
        {
            return;
        }
        Vector3 _pos = Selection.activeGameObject.transform.position;

        if (attacks == null)
        {
            return;
        }
        if (attacks.arraySize == 0)
        {
            return;
        }
        for (int i = 0; i < attacks.arraySize; i++)
        {
            TDS_EnemyAttack _attack = (serializedObject.targetObject as TDS_Enemy).Attacks[i];
            if (_attack == null)
            {
                continue;
            }
            switch (_attack.AnimationID)
            {
            case 6:
                Handles.color = Color.red;
                break;

            case 7:
                Handles.color = Color.green;
                break;

            case 8:
                Handles.color = Color.blue;
                break;

            case 9:
                Handles.color = Color.magenta;
                break;

            default:
                Handles.color = Color.white;
                break;
            }
            Handles.DrawWireDisc(_pos, Vector3.up, _attack.MaxRange);
            Handles.DrawWireDisc(_pos, Vector3.up, _attack.MinRange);
            Handles.Label(_pos + new Vector3(_attack.MaxRange, 0), _attack.AttackName);
        }

        Handles.color = Color.cyan;
        if (canThrow.boolValue)
        {
            Handles.DrawWireDisc((serializedObject.targetObject as TDS_Enemy).transform.position, Vector3.up, throwRange.floatValue);
            Handles.Label(_pos + new Vector3(throwRange.floatValue, 0), "Throw Range");
        }

        Handles.color = Color.yellow;

        if (Application.isPlaying)
        {
            Handles.color = Color.grey;
            _pos          = (serializedObject.targetObject as TDS_Enemy).PlayerTarget ? (serializedObject.targetObject as TDS_Enemy).PlayerTarget.transform.position : Vector3.zero;
            Handles.DrawWireDisc(_pos, Vector3.up, wanderingRangeMin.floatValue);
            Handles.DrawWireDisc(_pos, Vector3.up, wanderingRangeMax.floatValue);
        }
    }
示例#5
0
 private void OnAttackTypeSelected(TDS_EnemyAttack _attack)
 {
     Debug.Log(_attack.GetType().ToString());
 }
示例#6
0
    /// <summary>
    /// Cast an the casted Attack
    /// Stop the agent movements
    /// Set its orientation
    /// Start the attack and wait until its end, then wait for the cooldown of the attack
    /// Set the casted as null then set its state to search
    /// </summary>
    /// <returns></returns>
    public override IEnumerator CastAttack()
    {
        yield return(base.CastAttack());

        castedAttack = null;
    }