Esempio n. 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();
        }
    }
Esempio n. 2
0
 public void TurnOn()
 {
     _movingBehaviour = GetComponent <MovementBehaviour>();
     if (_movingBehaviour != null)
     {
         _movingBehaviour.Move();
     }
     StartCoroutine(SawAnimation());
 }
Esempio n. 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;
    }
Esempio n. 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;
        }
    }
Esempio n. 5
0
 public void Move(float direction)
 {
     body = movement.Move(body, bodyTransform, direction);
 }
Esempio n. 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);
 }
Esempio n. 8
0
 private void FixedUpdate()
 {
     // Already handles a null velocity.
     movementBehaviour.Move(transform.right * horizontalMovement);
 }
Esempio n. 9
0
 public void Move(float direction)
 {
     parentBody = movement.Move(parentBody, parentTransform, direction);
 }