コード例 #1
0
ファイル: AttackComponent.cs プロジェクト: navezof/Disarmed
    /**
     * Main function of this class
     *
     */
    public void Attack(APawn newTarget)
    {
        // The target should be passed to the function, but if the target is null, the closest one to the player is requested from the Swarmcontroller
        if (newTarget == null)
        {
            target = SwarmController.GetSwarmController().GetClosestEnemy(pawn);
        }
        else
        {
            target = newTarget;
        }

        // Setting the status of the pawn
        pawn.SetStatus(APawn.EStatus.ATTACKING);
        // If the pawn is an AI, the threat level of this AI is incrased
        if (pawn is PawnAI)
        {
            PawnAI ai = pawn as PawnAI;
            ai.AddThreat(1);
        }

        transform.LookAt(target.transform);

        // Animator values are set
        pawn.GetAnimator().SetInteger("cAttackIndex", currentAttackIndex);
        pawn.GetAnimator().SetInteger("cRange", GetRange());
        pawn.GetAnimator().SetTrigger("Attack");

        // In order to launch different animation, the animation index is modified here. If it exceed the max number of attack it goes back to zero
        currentAttackIndex++;
        if (currentAttackIndex > maxAttackIndex)
        {
            currentAttackIndex = 0;
        }
    }
コード例 #2
0
ファイル: AttackComponent.cs プロジェクト: navezof/Disarmed
 // Called at the end of an animation
 void EndAttack()
 {
     if (pawn.controller.nextInput == PlayerController.EInput.NONE)
     {
         currentAttackIndex = 0;
     }
     pawn.SetStatus(APawn.EStatus.IDLE);
     if (pawn.controller is AIController)
     {
         PawnAI ai = pawn as PawnAI;
         ai.AddThreat(-1);
         SwarmController.GetSwarmController().TakeToken();
     }
 }