示例#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);
 }