Exemplo n.º 1
0
        private void UpdateActions(float deltatime)
        {
            if (currentAction != null)
            {
                switch (currentAction.finish)
                {
                case NpcActorActionFinish.OnEnemyKilled:
                    if (enemyTarget != null)
                    {
                        if (enemyTarget.isDead)
                        {
                            FinishCurrentAction();
                        }
                    }
                    break;

                case NpcActorActionFinish.OnEnemyOutOfSight:
                    if (enemyTarget == null)
                    {
                        FinishCurrentAction();
                    }
                    break;

                case NpcActorActionFinish.OnReachWalkTargetPosition:
                    if (position.Equals(currentAction.walkPosition))     // create = operator and Vector3.Distance-method
                    {
                        FinishCurrentAction();
                    }
                    break;

                case NpcActorActionFinish.OnEndTimer:
                    if (currentActionExecutionTime >= currentAction.actionExecutionTime)
                    {
                        FinishCurrentAction();
                    }
                    else
                    {
                        currentActionExecutionTime += deltatime;
                    }
                    break;
                }

                switch (currentAction.actionType)
                {
                case NpcActorActionType.AttackLiveActor:
                    AttackLiveActor(currentAction.attackTargetActor);
                    break;

                case NpcActorActionType.GotoPosition:
                    GotoPosition(currentAction.walkPosition);
                    break;

                case NpcActorActionType.PerformAnimation:
                    specialAnimation = currentAction.performedAnimation;
                    break;
                }
            }
        }
Exemplo n.º 2
0
 public NpcActorAction(NpcActorActionType actiontype, NpcActorActionFinish finish = NpcActorActionFinish.OnEndTimer, LiveActor attacktargetactor = null, Vector3 walkposition = default(Vector3), NpcActorActionTypeAnimation performedanimation = NpcActorActionTypeAnimation.Idle, float actionexecutiontime = 0, bool isloop = false)
 {
     actionType               = actiontype;
     this.finish              = finish;
     attackTargetActor        = attacktargetactor;
     walkPosition             = walkposition;
     performedAnimation       = performedanimation;
     this.actionExecutionTime = actionexecutiontime;
     isLoop = isloop;
 }
Exemplo n.º 3
0
        private void FinishCurrentAction()
        {
            switch (currentAction.actionType)
            {
            case NpcActorActionType.AttackLiveActor:
                enemyTarget = null;
                break;

            case NpcActorActionType.GotoPosition:
                // If walkTarget = new Vector3(0, 0, 0) the npc will run to this position
                break;

            case NpcActorActionType.PerformAnimation:
                specialAnimation = NpcActorActionTypeAnimation.Idle;
                break;
            }

            currentActionExecutionTime = 0;
            if (!currentAction.isLoop)
            {
                SelectNextAction();
            }
        }
Exemplo n.º 4
0
 private void PerformAnimation(NpcActorActionTypeAnimation animation)
 {
     QueueAction(new NpcActorAction(NpcActorActionType.PerformAnimation, performedanimation: animation));
 }