Exemple #1
0
    virtual public void StartNewAction()
    {
        float shouldMoveConfidence   = 0;
        float shouldAttackConfidence = 0;

        if (movementBehaviour)
        {
            shouldMoveConfidence = movementBehaviour.ShouldMove();
        }
        if (attackBehaviour)
        {
            shouldAttackConfidence = attackBehaviour.ShouldAttack();
        }

        if (shouldMoveConfidence == 0 && shouldAttackConfidence == 0)
        {
            return;
        }

        float totalConfidence = shouldMoveConfidence + shouldAttackConfidence;
        float random          = UnityEngine.Random.Range(0, totalConfidence);

        if (random < shouldMoveConfidence)
        {
            movementBehaviour.Move();
        }
        else
        {
            attackBehaviour.Attack();
        }
    }
Exemple #2
0
 public void TurnOn()
 {
     _movingBehaviour = GetComponent <MovementBehaviour>();
     if (_movingBehaviour != null)
     {
         _movingBehaviour.Move();
     }
     StartCoroutine(SawAnimation());
 }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        // Rotate
        movement.Rotate();

        // Move
        movement.Move();

        // Shoot
        attack.Shoot();

        // Reload
        attack.ReloadInit();

        shootCooldown -= Time.deltaTime;
    }
Exemple #4
0
    private void Aggro()
    {
        if (Target != null)
        {
            movement.Move(Target);

            if (!aggro.TargetStillInRange(Target))
            {
                EnemyState = EntityState.Idle;
                return;
            }

            if (attack.AllowedToAttack())
            {
                EnemyState = EntityState.Attack;
                return;
            }
        }
        else
        {
            EnemyState = EntityState.Idle;
        }
    }
Exemple #5
0
 public void Move(float direction)
 {
     body = movement.Move(body, bodyTransform, direction);
 }
Exemple #6
0
 private void Update()
 {
     Movement.Move(MovementAction.action.ReadValue <Vector2>());
     Turret.RotateByMousePosition(TurretRotationAction.action.ReadValue <Vector2>());
 }
 private void FixedUpdate()
 {
     movementBehaviour.Move(transform.up * -1);
 }
Exemple #8
0
 private void FixedUpdate()
 {
     // Already handles a null velocity.
     movementBehaviour.Move(transform.right * horizontalMovement);
 }
Exemple #9
0
 public void Move(float direction)
 {
     parentBody = movement.Move(parentBody, parentTransform, direction);
 }