Exemplo n.º 1
0
    //move to next target
    void UpdateMovingToNextPatrolPoint()
    {
        destinationDistance = Vector3.Distance(destinationPosition, this.transform.position); //Check Distance Spawnpoint to Enemy

        if (destinationDistance < 1f)
        {
            timeToWaitBeforeNextMove = Random.Range(delayNextTargetMin, delayNextTargetMax);
            moveBehavior             = MoveAroundBehavior.Waiting;
            ctrlAnimState            = ControlAnimationState.Idle;
            moveSpeed = 0;
        }

        // Move to destination
        if (ctrlAnimState == ControlAnimationState.Move)
        {
            this.transform.rotation = Quaternion.Lerp(this.transform.rotation, targetRotation, Time.deltaTime * 25);

            if (controller.isGrounded)
            {
                movedir = Vector3.zero;
                movedir = transform.TransformDirection(Vector3.forward * moveSpeed);
            }
        }
        else
        {
            movedir = Vector3.Lerp(movedir, Vector3.zero, Time.deltaTime * 10);
        }
        movedir.y -= 20 * Time.deltaTime;
        controller.Move(movedir * Time.deltaTime);
    }
 void OnControllerColliderHit(ControllerColliderHit hit)
 {
     if (hit.gameObject.tag == "Collider" && behavior == EnemyBehavior.MoveAround && !chaseTarget && !target)
     {
         ctrlAnimState = ControlAnimationState.Idle;
         moveBehavior  = MoveAroundBehavior.Waiting;
     }
 }
Exemplo n.º 3
0
 //wait for next move
 void UpdateWaitingForNextMove()
 {
     timeToWaitBeforeNextMove -= Time.deltaTime;
     if (timeToWaitBeforeNextMove < 0.0f)
     {
         RandomPostion();
         moveBehavior  = MoveAroundBehavior.MoveToNext;
         ctrlAnimState = ControlAnimationState.Move;
         moveSpeed     = enemyStatus.status.movespd;
     }
 }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        //set spawn point
        destinationPosition = this.transform.position;

        //get anathor component
        animationManager = this.GetComponent <AnimationManagerEnemy>();
        enemyStatus      = this.GetComponent <EnemyStatus>();
        controller       = this.GetComponent <CharacterController>();
        questData        = GameObject.Find("QuestData").GetComponent <Quest_Data>();

        delayAttack = 100;     //Declare delay 100 sec
        flinchValue = 100;     //Declare flinch value (if zero it will flinch)
        fadeValue   = 1;       //Set fade value

        //Set first spawn point
        spawnPoint = transform.position;

        //set default value
        defaultReturnPhase = returnPhase;
        defaultHP          = enemyStatus.status.hp;
        defaultMP          = enemyStatus.status.mp;

        defaultColor = new Color[modelMesh.Count];
        SetDefualtColor();

        if (behavior == EnemyBehavior.MoveAround)
        {
            moveBehavior = MoveAroundBehavior.Waiting;
        }

        //warning when enemy isn't detect area
        if (nature == EnemyNature.Wild)
        {
            detectArea = GameObject.Find("DetectArea");

            if (detectArea == null)
            {
                Debug.LogWarning("Don't found DetectArea in Enemy -" + enemyStatus.name);
            }
        }
    }