Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        //初始化视线
        Ray tar = new Ray(transform.position + shootRectify, transform.forward);

        if (Physics.Raycast(tar, out sightHit))
        {
            lookAtPoint = sightHit.point;
        }

        //初始化动作
        switch (weaponController.category)
        {
        case WeaponCategory.Handgun:
            humanController.ToHandgun(weapon);
            break;

        case WeaponCategory.Heavy:
            humanController.ToHeavy(weapon);
            break;

        case WeaponCategory.Infantry:
            humanController.ToInfantry(weapon);
            break;

        case WeaponCategory.Knife:
            humanController.ToKnife(weapon);
            break;
        }

        SetPatrol();
    }
Exemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        knife            = Instantiate(knifePrefab, new Vector3(0f, 0f, 0f), Quaternion.identity);
        weaponNow        = knife;
        weaponController = weaponNow.GetComponent <WeaponController>();
        playerController.ToKnife(knife);

        /*初始化准星目标点,设置视线 */
        // Ray ray = Camera.main.ScreenPointToRay(new Vector3(Camera.main.pixelWidth / 2, Camera.main.pixelHeight / 2, 0f));
        // if(Physics.Raycast(ray, out hit))
        // {
        //     sightTargetPoint = hit.point;
        // }
        sightTargetPoint = transform.forward * 5;
        playerController.SetSightGetter(this);  //视线设置以便于人物面向准星的位置

        /*设置血量、子弹等 */
        MaxHealth = playerController.MaxHealth;
        health    = MaxHealth;
        healthTransform.localScale = new Vector3(1f, 1f, 1f);
        SetBulletUI();
        SetWeaponInfoUI();
    }