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