Exemplo n.º 1
0
 private void Update()
 {
     //사용가능한 디바이스가 없으면 다시 호출
     //예를 들어 사용도중 배터리가 방전시
     if (!currentUsingDevice.isValid)
     {
         TryInitialize();
         CheckHandOrController();
         SetControllerPosition();
         return;
     }
     if (!renderController)
     {
         UpdateHandAnimation();
     }
     if (currentUsingDevice.TryGetFeatureValue(CommonUsages.triggerButton, out menuButtonValue) && menuButtonValue && currentWeapon != null)
     {
         if (currentWeapon.GetType() == typeof(DoubleGun))
         {
             currentWeapon.Attack();
         }
         else if (oneClicktriggerButtonCheck && currentWeapon.GetType() == typeof(Gun))
         {
             currentWeapon.Attack();
             oneClicktriggerButtonCheck = false;
         }
     }
     else
     {
         oneClicktriggerButtonCheck = true;
     }
 }
Exemplo n.º 2
0
 private void FireStartingGun(Gun currentGun, bool overrideCoolDown = false)
 {
     currentGun.Attack();
     if (overrideCoolDown)
     {
         currentGun.ClearCooldowns();
     }
     currentGun.ClearReloadData();
     return;
 }
Exemplo n.º 3
0
 public override Vector2 GetMoveDir()
 {
     if (target != null)
     {
         Vector2 deltaPos = new Vector2(target.transform.position.x - transformer.GetPos().x,
                                        target.transform.position.z - transformer.GetPos().z);
         if (deltaPos.sqrMagnitude >= sqrAttackRange)
         {
             return(deltaPos.normalized);
         }
         else
         {
             this.target = target.transform;
             weapon.Attack('b');
             return(Vector2.zero);
         }
     }
     return(Vector2.zero);
 }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        // print("Enemy2 distance: " + Vector3.Distance(this.transform.position, player.transform.position));

        if ((Vector3.Distance(this.transform.position, player.transform.position) < followRadius) && (Vector3.Distance(this.transform.position, player.transform.position) > agent.stoppingDistance - bufferFromPlayer) && isFollowing)
        {
            if (!death)
            {
                agent.SetDestination(player.transform.position);
                gun.Attack();
            }
        }

        if ((Vector3.Distance(this.transform.position, player.transform.position) < agent.stoppingDistance - bufferFromPlayer) && isFollowing)
        {
            if (!death)
            {
                agent.SetDestination(RandomNavmeshLocation(runawayPointDistance));
            }
            isFollowing = false;
        }

        if (agent.remainingDistance > agent.stoppingDistance)
        {
            character.Move(agent.desiredVelocity, false, true);
        }
        else
        {
            character.Move(Vector3.zero, false, true);
            Vector3 rel = (player.transform.position - transform.position).normalized;
            rel.y = 0;
            Quaternion desiredRotation = Quaternion.LookRotation(rel, Vector3.up);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, desiredRotation, angularSpeed * Time.deltaTime);
            isFollowing        = true;
        }
    }
Exemplo n.º 5
0
 public void Attack()
 {
     _gun.Attack();
 }