Пример #1
0
    private void Update()
    {
        CheckInput();

        playerRay = cam.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));

        if (currentWeapon != null && currentWeapon.gameObject.activeSelf == false)
        {
            currentWeapon = null;
        }

        if (currentWeapon == null && hand.childCount > 0)
        {
            currentWeapon = hand.GetComponentInChildren <WeaponBase>();
            if (currentWeapon != null)
            {
                currentWeapon.CallStart();
            }
        }

        if (currentExplosive == null && hand.childCount > 0)
        {
            currentExplosive = hand.GetComponentInChildren <ExplosiveBase>();
            if (currentExplosive != null)
            {
                currentExplosive.CallStart();
            }
        }

        if (currentWeapon != null && currentWeapon.gameObject.activeSelf && !PlayerController.instance.toggleEscMenu)
        {
            currentWeapon.CallUpdate();
        }

        if (currentExplosive != null && currentExplosive.gameObject.activeSelf && !PlayerController.instance.toggleEscMenu)
        {
            currentExplosive.CallUpdate();
        }

        if (Input.GetButton("Fire2"))
        {
            animator.SetBool("AimHandgun", true);
        }
        else
        {
            animator.SetBool("AimHandgun", false);
        }
    }
Пример #2
0
    private void Start()
    {
        localStats = GetComponent <Stats>();
        animator   = GetComponent <SyncAnimator>();

        instance = this;
        if (hand.childCount > 0)
        {
            currentWeapon = hand.GetComponentInChildren <WeaponBase>();
            if (currentWeapon != null)
            {
                currentWeapon.CallStart();
            }
            currentExplosive = hand.GetComponentInChildren <ExplosiveBase>();
            if (currentExplosive != null)
            {
                currentExplosive.CallStart();
            }
        }

        Console.Toggle();
    }
Пример #3
0
    protected void Toss()
    {
        bool primaryPressed;

        primaryPressed = Input.GetButtonDown(useButton);
        RaycastHit hit;
        Quaternion fireRotation = Quaternion.LookRotation(transform.forward);

        if (primaryPressed)
        {
            if (Physics.Raycast(ViewController.playerRay, out hit, tossDistance))
            {
                Transform t = Instantiate(explosivePrefab).transform;
                t.rotation = Quaternion.LookRotation(hit.normal);
                t.position = hit.point;
                t.SetParent(hit.transform);
                explosive = t.GetComponent <ExplosiveBase>();
                explosive.CallStart();
                explosive.isExploding = true;
                explosive.transform.SetParent(null);
                explosive.Invoke("Explode", explosionDelay);
            }
        }
    }