Пример #1
0
    // Update is called once per frame
    private void Update()
    {
        currPos = transform.position;
        if (timer <= 0)
        {
            if (!isMoving)
            {
                getTarget();
                isMoving = true;
                bulletspawner.Shoot(isShooting = false);
                Move(targetPosition, movementSpeed);
            }
            else if (currPos != lastPos)
            {
                Move(targetPosition, movementSpeed);
            }
            else
            {
                timer    = moveTimer;
                isMoving = false;
            }
        }
        else
        {
            bulletspawner.Shoot(isShooting = true);
            timer -= Time.deltaTime;
        }

        lastPos = currPos;
    }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Fire1"))
     {
         bulletSpawner.Shoot();
     }
 }
Пример #3
0
    private void Update()
    {
        // Walking GameMode
        if (GameController.singleton.GetGameMode() == GameController.GameMode.walking)
        {
            // Find the point where to go
            if (Input.GetMouseButton(0))
            {
                if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out hit))
                {
                    agent.SetDestination(hit.point);
                }
                targetPosition = hit.point;
            }

            // Animation controlling in Walking GameMode
            if (agent.velocity == Vector3.zero)
            {
                animator.SetBool("Walk", false);
            }
            else
            {
                animator.SetBool("Walk", true);
            }

            // Switching GameMode if the player is on Tower and he can aim enemy
            if (isOnTower && !animator.GetBool("Walk") && CheckToSwitchGameMode())
            {
                GameController.singleton.SetGameModeMethod(GameController.GameMode.shooting);
            }
        }
        // Shooting GameMode
        else if (GameController.singleton.GetGameMode() == GameController.GameMode.shooting)
        {
            if (Input.GetMouseButton(0))
            {
                // Find shoot point
                if (Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition), out hit))
                {
                    headTransform.LookAt(hit.point);
                    armTransform.LookAt(hit.point);
                    armTransform.rotation = armTransform.rotation * Quaternion.Euler(offset);
                    gunTransform.LookAt(hit.point);
                }

                // counting shooting Delay
                curTimeout += Time.deltaTime;
                if (curTimeout > timeOut)
                {
                    curTimeout = 0;
                    bulletSpawner.Shoot();
                }
            }
            else
            {
                curTimeout += Time.deltaTime; // counting shooting Delay
            }
        }
    }
Пример #4
0
 private void WeaponFireChecks()
 {
     if (Input.GetButtonDown("Fire1"))
     {
         if (UpperBodyMode == UpperBodyModes.Melee && !ub_animator.GetBool("ActionInProgress"))
         {
             ub_animator.SetTrigger("melee_attack");
         }
         else if (UpperBodyMode == UpperBodyModes.Rifle)
         {
             bulletSpawner.StartRepeatingFire();
         }
         else
         {
             bulletSpawner.Shoot(UpperBodyMode);
         }
     }
     if (Input.GetButtonUp("Fire1"))
     {
         bulletSpawner.EndRepeatingFire();
     }
 }