Sniper scope added

This commit is contained in:
=
2021-09-17 06:04:39 +05:30
parent 13ffe9b18b
commit 6316312962
304 changed files with 316761 additions and 295868 deletions

View File

@@ -25,7 +25,7 @@ public class NetworkStatsMenu : MonoBehaviour
}
if(leaderboardOpacity < 0.1f){leaderboardOpacity=0;}
leaderboard.alpha = leaderboardOpacity;
depthOfField.focusDistance.value = (1-leaderboardOpacity) * defaultDof;
// depthOfField.focusDistance.value = (1-leaderboardOpacity) * defaultDof;
}

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HQFPSWeapons;
public class scopeBehaviour : MonoBehaviour
{
public Player player;
public CanvasGroup scopeCanvas;
public weaponAttachmentsMgr attachmentsMgr;
void Start()
{
player.Aim.AddStartListener(OnAimStart);
player.Aim.AddStopListener(OnAimStop);
}
void Update() {
scopeCanvas.alpha = attachmentsMgr.aimed;
}
void OnAimStart(){
attachmentsMgr.focus(true);
}
void OnAimStop(){
attachmentsMgr.focus(false);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 856c25fd0b3d74c08915584c47a1ceb2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HQFPSWeapons;
using UnityEngine.Rendering.PostProcessing;
public class weaponAttachmentsMgr : MonoBehaviour
{
public Player player;
[SerializeField]
public AttachmentConfig[] attachmentConfigs;
public PostProcessVolume pp;
DepthOfField depthOfField;
bool aimValue;
[Range(0.00f,1.00f)]
public float aimed;
void Start()
{
player.EquippedItem.AddChangeListener((SaveableItem item) => { changeAttachments((item == null) ? "" : item.Name); });
pp.profile.TryGetSettings(out depthOfField);
}
// Update is called once per frame
void Update()
{
if(aimValue && aimed < 1){
aimed+=0.05f;depthOfField.focusDistance.value = 0.1f + (0.1f * (1-aimed));
}else if(!aimValue && aimed > 0){
aimed-=0.05f;depthOfField.focusDistance.value =0.1f + (0.1f * (1-aimed));
}
}
void changeAttachments(string item){
StartCoroutine(waitAndChangeAttachments(item));
}
IEnumerator waitAndChangeAttachments(string item){
yield return new WaitForSeconds(0.6f);
foreach(AttachmentConfig config in attachmentConfigs){
bool isSelected = config.weaponName == item;
foreach(GameObject attachment in config.attachments){
attachment.SetActive(isSelected);
}
}
}
public void focus(bool value){
aimValue = value;
}
// IEnumerator _focus(bool value){
// aimed = (value) ? 0: 1;
// if(value){
// while(aimed < 1){
// aimed +=0.1f;
// yield return new WaitForEndOfFrame();
// }
// }else{
// while(aimed > 0){
// aimed -=0.1f;
// depthOfField.focusDistance.value = 1-aimed;
// yield return new WaitForEndOfFrame();
// }
// }
// }
}
[Serializable]
public class AttachmentConfig{
public string weaponName;
public List<GameObject> attachments;
public AttachmentConfig(string _weaponName){
weaponName = _weaponName;
attachments = new List<GameObject>();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a62dd0a72c9b1125dbfc5cfd5e0a21dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: