提交 fd320181 编写于 作者: 秃头给你一拳's avatar 秃头给你一拳

Beta

上级 572b6915
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FootStepTrigger : MonoBehaviour
{
//成员_触发器
protected Collider _trigger;
public Collider Trigger
{
get
{
if (_trigger == null) _trigger = GetComponent<Collider>();
return _trigger;
}
}
//成员_音源
protected AudioSource _audioSource;
public AudioSource AudioSource
{
get
{
if (_audioSource == null) _audioSource = GetComponent<AudioSource>();
return _audioSource;
}
}
//冷却时间
protected float coolTime=.45f;
protected bool canUse = true;
//debug绘制
void OnDrawGizmos()
{
if (!Trigger) return;
Color color = Color.green;
color.a = 0.5f;
Gizmos.color = color;
if (Trigger is SphereCollider)
{
Gizmos.DrawSphere((Trigger.bounds.center), (Trigger as SphereCollider).radius);
}
}
private void OnTriggerEnter(Collider other)
{
if (other.GetComponent<InteractableObj>()) return;
if (!canUse) return;
var stepAudioList = AudioManager.GetInstance().FootStepAudios;
AudioClip audioTemp = stepAudioList[Random.Range(0, stepAudioList.Length)];
AudioSource.PlayOneShot(audioTemp);
canUse = false;
StartCoroutine(SetCanUse());
}
IEnumerator SetCanUse()
{
yield return new WaitForSeconds(coolTime);
canUse = true;
}
}
fileFormatVersion: 2
guid: 14342d96177d6de46b0bca90c7823d0d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -79,19 +79,19 @@ namespace FunTools ...@@ -79,19 +79,19 @@ namespace FunTools
Vector3 GetInputTranslationDirection() Vector3 GetInputTranslationDirection()
{ {
Vector3 direction = new Vector3(); Vector3 direction = new Vector3();
if (Input.GetKey(KeyCode.W)) if (Input.GetKey(KeyCode.UpArrow))
{ {
direction += Vector3.forward; direction += Vector3.forward;
} }
if (Input.GetKey(KeyCode.S)) if (Input.GetKey(KeyCode.DownArrow))
{ {
direction += Vector3.back; direction += Vector3.back;
} }
if (Input.GetKey(KeyCode.A)) if (Input.GetKey(KeyCode.LeftArrow))
{ {
direction += Vector3.left; direction += Vector3.left;
} }
if (Input.GetKey(KeyCode.D)) if (Input.GetKey(KeyCode.RightArrow))
{ {
direction += Vector3.right; direction += Vector3.right;
} }
...@@ -108,14 +108,15 @@ namespace FunTools ...@@ -108,14 +108,15 @@ namespace FunTools
void Update() void Update()
{ {
// Exit Sample // Exit Sample 傻逼,这边之前是直接退出游戏,复用别人代码之前还是得看看
if (Input.GetKey(KeyCode.Escape)) // 相机还是直接通过PlayerManager关闭吧,这边关闭逻辑有点混乱,输入都在PlayerInput当中处理
/*if (Input.GetKey(KeyCode.Escape))
{ {
Application.Quit(); Application.Quit();
#if UNITY_EDITOR #if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false; UnityEditor.EditorApplication.isPlaying = false;
#endif #endif
} }*/
// Hide and lock cursor when right mouse button pressed // Hide and lock cursor when right mouse button pressed
if (Input.GetMouseButtonDown(1)) if (Input.GetMouseButtonDown(1))
......
...@@ -52,9 +52,10 @@ public class PlayerManager : MonoBehaviour ...@@ -52,9 +52,10 @@ public class PlayerManager : MonoBehaviour
cameraSjw.SetActive(egleFlag); //将摄像机的状态设为启用或者不启用 cameraSjw.SetActive(egleFlag); //将摄像机的状态设为启用或者不启用
} }
// 如果开启鹰眼的话,就不处理玩家的其他输入,, 加一个如何开启了事件面板就不处理玩家输入 // 如果开启鹰眼的话,就不处理玩家的其他输入,, 加一个如果开启了事件面板就不处理玩家输入
if (!egleFlag) //暂时注释掉了,可以同时操控相机和玩家
{ //if (!egleFlag)
//{
playerInput.HandleInput(); playerInput.HandleInput();
if (cameraHandler != null) if (cameraHandler != null)
...@@ -62,7 +63,7 @@ public class PlayerManager : MonoBehaviour ...@@ -62,7 +63,7 @@ public class PlayerManager : MonoBehaviour
cameraHandler.FollowTarget(delta); cameraHandler.FollowTarget(delta);
cameraHandler.HandleCameraRotation(delta, playerInput.mouseX, playerInput.mouseY); cameraHandler.HandleCameraRotation(delta, playerInput.mouseX, playerInput.mouseY);
} }
} //}
} }
private void FixedUpdate() private void FixedUpdate()
...@@ -71,8 +72,8 @@ public class PlayerManager : MonoBehaviour ...@@ -71,8 +72,8 @@ public class PlayerManager : MonoBehaviour
// 如果开启鹰眼的话,就不处理玩家的其他输入,, 加一个如何开启了事件面板就不处理玩家输入 && !UIManager.GetInstance().accidentPanel.isActiveAndEnabled // 如果开启鹰眼的话,就不处理玩家的其他输入,, 加一个如何开启了事件面板就不处理玩家输入 && !UIManager.GetInstance().accidentPanel.isActiveAndEnabled
if (!egleFlag) //if (!egleFlag)
{ //{
//操作刚体 //操作刚体
playerMove.UpdateMoveDirection(Camera.main.transform); playerMove.UpdateMoveDirection(Camera.main.transform);
playerMove.HandleMovement(); playerMove.HandleMovement();
...@@ -81,6 +82,6 @@ public class PlayerManager : MonoBehaviour ...@@ -81,6 +82,6 @@ public class PlayerManager : MonoBehaviour
playerMove.ControlJumpBehaviour(); playerMove.ControlJumpBehaviour();
playerMove.AirControl(); playerMove.AirControl();
playerMove.UpdateAnimatorParameters(); playerMove.UpdateAnimatorParameters();
} //}
} }
} }
...@@ -86,6 +86,8 @@ public class PlayerMove : MonoBehaviour ...@@ -86,6 +86,8 @@ public class PlayerMove : MonoBehaviour
if (!isGround) return; if (!isGround) return;
//处于特殊动画时,不让动(交由动画控制) //处于特殊动画时,不让动(交由动画控制)
if (playerAnimation.GetBoolParameter("isInteracting")) return; if (playerAnimation.GetBoolParameter("isInteracting")) return;
//不让动时,不让动(废话)(对话时不让动)(临时屎代码)
if (!CanControlMove()) return;
//设置人物的速度(实际),动画混合数的速度(动画) //设置人物的速度(实际),动画混合数的速度(动画)
SetControllerMoveSpeed(); SetControllerMoveSpeed();
...@@ -99,11 +101,12 @@ public class PlayerMove : MonoBehaviour ...@@ -99,11 +101,12 @@ public class PlayerMove : MonoBehaviour
//设置预定的控制器速度(moveSpeed) //设置预定的控制器速度(moveSpeed)
protected virtual void SetControllerMoveSpeed() protected virtual void SetControllerMoveSpeed()
{ {
var targetSpringSpeed = GameDataManager.GetInstance().saveData.isFastRun ? sprintSpeed * 10 : sprintSpeed;
if (GetMoveAmout() == 0) //TODO:无法顺滑停止。以后再说 if (GetMoveAmout() == 0) //TODO:无法顺滑停止。以后再说
{ {
moveSpeed = Mathf.Lerp(moveSpeed, 0, 6 * Time.deltaTime);//6是平滑过渡值 moveSpeed = Mathf.Lerp(moveSpeed, 0, 6 * Time.deltaTime);//6是平滑过渡值
} }
else moveSpeed = Mathf.Lerp(moveSpeed, isSprinting ? sprintSpeed : normalSpeed, 6 * Time.deltaTime);//6是平滑过渡值 else moveSpeed = Mathf.Lerp(moveSpeed, isSprinting ? targetSpringSpeed : normalSpeed, 6 * Time.deltaTime);//6是平滑过渡值
} }
...@@ -188,7 +191,6 @@ public class PlayerMove : MonoBehaviour ...@@ -188,7 +191,6 @@ public class PlayerMove : MonoBehaviour
#endregion #endregion
#region 处理旋转 #region 处理旋转
public void HandleRotation() public void HandleRotation()
{ {
...@@ -215,9 +217,15 @@ public class PlayerMove : MonoBehaviour ...@@ -215,9 +217,15 @@ public class PlayerMove : MonoBehaviour
/// </summary> /// </summary>
public void TryDoJump() public void TryDoJump()
{ {
//TODO:感觉这里和处理移动那里挺像的。但又不像。 //不在地上时,检查无限跳
if (!isGround) Debug.Log("可以禁止无限跳,但没必要"); if (!isGround)
{
if (!GameDataManager.GetInstance().saveData.isUnlimitJump) return;
}
if (playerAnimation.GetBoolParameter("isInteracting")) return; if (playerAnimation.GetBoolParameter("isInteracting")) return;
//不让动时,不让动(废话)(对话时不让动)(临时屎代码)
if (!CanControlMove()) return;
//跳! //跳!
jumpCounter = jumpTimer; jumpCounter = jumpTimer;
...@@ -256,15 +264,18 @@ public class PlayerMove : MonoBehaviour ...@@ -256,15 +264,18 @@ public class PlayerMove : MonoBehaviour
/// </summary> /// </summary>
public virtual void AirControl() public virtual void AirControl()
{ {
//Debug.Log(isGround);
//目前属实没啥内容很单薄。单薄到想移到别的地方去。不过还是先放着吧 //目前属实没啥内容很单薄。单薄到想移到别的地方去。不过还是先放着吧
if (isGround) return; if (isGround) return;
//TODO:重要bug,有时候不知道为啥检测的isground是错的,来不及了不管了,直接暴力if
//猜测是地面检测的射线还是什么东西检测到了紧贴的非地面的其他物体上导致误判,来不及了不管了
if (!CanControlMove()) return;
MoveUnit(moveDirection, true); MoveUnit(moveDirection, true);
} }
#endregion #endregion
#region 地面检测 #region 地面检测
public virtual void CheckGround() public virtual void CheckGround()
...@@ -341,6 +352,15 @@ public class PlayerMove : MonoBehaviour ...@@ -341,6 +352,15 @@ public class PlayerMove : MonoBehaviour
#endregion #endregion
//对话时,不让移动和跳跃,目前写的比较粗暴
public bool CanControlMove()
{
if (UIManager.GetInstance().dialogPanel.gameObject.activeInHierarchy)
{
StopCharacterWithLerp();
return false;
}
return true;
}
} }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Day_Follows_Night : MonoBehaviour
{
public Material[] mats;
private int index = 0;
// Start is called before the first frame update
void Start()
{
//判断是否是夜晚,是则进行切换 默认加载白天
if((int)GameDataManager.GetInstance().saveData.dayTimeEnum == 2)
{
Debug.Log(GameDataManager.GetInstance().saveData.dayTimeEnum);
ChangeBox();
Change_Light();
}
}
/// <summary>
/// 改变天空盒
/// </summary>
private void ChangeBox()
{
RenderSettings.skybox = mats[index];
index++;
index %= mats.Length;
}
/// <summary>
/// 根据场景的不同对灯光进行不同的处理
/// </summary>
private void Change_Light()
{
if (LoadManager.LoadSceneName == null) return;
if (LoadManager.LoadSceneName.Equals("05_PlayGroundScene"))
{
GameObject sun = GameObject.Find("Directional Light B");
if (sun!=null)
sun.SetActive(false);
}
}
}
fileFormatVersion: 2
guid: e6a564421404bf346a75a69b9e82623a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -60,7 +60,6 @@ public class IImpactEffect : MonoBehaviour ...@@ -60,7 +60,6 @@ public class IImpactEffect : MonoBehaviour
case ImpactType.降低体力://暂定:以后是否新写一个消耗类或条件类。加上前置判断。 case ImpactType.降低体力://暂定:以后是否新写一个消耗类或条件类。加上前置判断。
GameDataManager.GetInstance().saveData.currentAP -= impact.value; GameDataManager.GetInstance().saveData.currentAP -= impact.value;
UIManager.GetInstance().tipsInfoPanel.AddTipsInfo("你的体力消耗了" + impact.value + "点");
break; break;
...@@ -88,7 +87,7 @@ public class IImpactEffect : MonoBehaviour ...@@ -88,7 +87,7 @@ public class IImpactEffect : MonoBehaviour
break; break;
case ImpactType.完成任务: case ImpactType.完成任务:
EventManager.GetInstance().EventTrigger(impact.quest_SO.questNeed.NeedToString()); EventManager.GetInstance().EventTrigger(impact.quest_SO.NeedToString());
break; break;
case ImpactType.场景跳转到: case ImpactType.场景跳转到:
...@@ -100,6 +99,7 @@ public class IImpactEffect : MonoBehaviour ...@@ -100,6 +99,7 @@ public class IImpactEffect : MonoBehaviour
UIManager.GetInstance().accidentPanel.SetAccident_SO(); UIManager.GetInstance().accidentPanel.SetAccident_SO();
break; break;
default: default:
Debug.Log(impact.value); Debug.Log(impact.value);
break; break;
......
...@@ -16,6 +16,9 @@ public class InteractableObj : MonoBehaviour , IInteraction ...@@ -16,6 +16,9 @@ public class InteractableObj : MonoBehaviour , IInteraction
protected void OnTriggerEnter(Collider other) protected void OnTriggerEnter(Collider other)
{ {
//给屎山加点料
if (other.GetComponent<FootStepTrigger>()) return;
//PlayerManager player=other.GetComponent<PlayerManager>(); //PlayerManager player=other.GetComponent<PlayerManager>();
PlayerManager player = other.GetComponentInParent<PlayerManager>();//现在是检测UnitBlockerCollider了 PlayerManager player = other.GetComponentInParent<PlayerManager>();//现在是检测UnitBlockerCollider了
if (player != null)//检测到玩家进入交互范围 if (player != null)//检测到玩家进入交互范围
...@@ -26,6 +29,9 @@ public class InteractableObj : MonoBehaviour , IInteraction ...@@ -26,6 +29,9 @@ public class InteractableObj : MonoBehaviour , IInteraction
protected void OnTriggerExit(Collider other) protected void OnTriggerExit(Collider other)
{ {
//给屎山加点料
if (other.GetComponent<FootStepTrigger>()) return;
PlayerManager player = other.GetComponentInParent<PlayerManager>(); PlayerManager player = other.GetComponentInParent<PlayerManager>();
if (player != null)//检测到玩家离开交互范围 if (player != null)//检测到玩家离开交互范围
{ {
......
...@@ -24,22 +24,31 @@ public class NpcInteract : InteractableObj ...@@ -24,22 +24,31 @@ public class NpcInteract : InteractableObj
public void Awake() public void Awake()
{ {
if (npc_SO == null)
{
Destroy(gameObject);
return;
}
//读取SO。设置Npc实体的各项属性 //读取SO。设置Npc实体的各项属性
dialog_SO = npc_SO.dialog_SO; dialog_SO = npc_SO.dialog_SO;
//播放指定动画 //播放指定动画
anim = GetComponentInChildren<Animator>(); anim = GetComponentInChildren<Animator>();
if (anim)
anim.CrossFade(npc_SO.PlayAnimName, .2f); anim.CrossFade(npc_SO.PlayAnimName, .2f);
if (pivotTrans!=null) if (pivotTrans!=null)
{ {
Text textUI = GetComponentInChildren<Text>(); Text textUI = GetComponentInChildren<Text>();
if (textUI!=null)
textUI.text = npc_SO.NpcName; textUI.text = npc_SO.NpcName;
} }
} }
private void OnEnable() private void OnEnable()
{ {
if (anim)
anim.CrossFade(npc_SO.PlayAnimName,.2f); anim.CrossFade(npc_SO.PlayAnimName,.2f);
} }
...@@ -58,10 +67,9 @@ public class NpcInteract : InteractableObj ...@@ -58,10 +67,9 @@ public class NpcInteract : InteractableObj
UIManager.GetInstance().dialogPanel.StartADialog(dialog_SO, 0); UIManager.GetInstance().dialogPanel.StartADialog(dialog_SO, 0);
//事件中心:交互NPC //事件中心:交互NPC
var need = new QuestNeed(); //TODO: 比较临时工的行为
need.questNeedType = QuestNeedType.交互; EventManager.GetInstance().EventTrigger("交互_"+npc_SO.NpcName);
need.stringValue = npc_SO.NpcName;
EventManager.GetInstance().EventTrigger(need.NeedToString());
} }
else else
{ {
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioManager : MonoSingleTon<AudioManager>
{
public AudioClip[] FootStepAudios;
public AudioClip bgm;
protected AudioSource bgmAudioSource;
private void Awake()
{
bgmAudioSource = GetComponent<AudioSource>();
bgmAudioSource.clip = bgm;
bgmAudioSource.Play();
}
}
fileFormatVersion: 2
guid: c13b7e6532a778f42b90fde655fc109e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -6,9 +6,27 @@ public class GameDataManager : MonoSingleTon<GameDataManager> ...@@ -6,9 +6,27 @@ public class GameDataManager : MonoSingleTon<GameDataManager>
{ {
//玩家存档数据。一般是开始游戏后会读取或新建一个默认的。手动拖拽赋值只用于测试。 //玩家存档数据。一般是开始游戏后会读取或新建一个默认的。手动拖拽赋值只用于测试。
public PlayerSaveData_SO saveData; public PlayerSaveData_SO saveData;
//新存档。开始游戏时用,不过实际上应该时可以选皮肤改名字选初始职业(卷王 土豪 一无所有者)
public PlayerSaveData_SO newSaveData;
public void Awake() public void Awake()
{ {
QuestManager.GetInstance().Init(); QuestManager.GetInstance().Init();
} }
public void TempSetSaveDataToNew()
{
saveData.Strength = newSaveData.Strength;
saveData.Intelligence = newSaveData.Intelligence;
saveData.Communication = newSaveData.Communication;
saveData.money = newSaveData.money;
saveData.mood = newSaveData.mood;
saveData.GradeNum = 1;
saveData.dayTimeEnum = 0;
saveData.currentQuest.Clear();
saveData.finishedQuest.Clear();
}
} }
...@@ -5,7 +5,7 @@ using UnityEngine.SceneManagement; ...@@ -5,7 +5,7 @@ using UnityEngine.SceneManagement;
public class LoadManager : MonoSingleTon<LoadManager> public class LoadManager : MonoSingleTon<LoadManager>
{ {
public string LoadSceneName; public static string LoadSceneName;
protected AsyncOperation operation; protected AsyncOperation operation;
...@@ -20,12 +20,11 @@ public class LoadManager : MonoSingleTon<LoadManager> ...@@ -20,12 +20,11 @@ public class LoadManager : MonoSingleTon<LoadManager>
LoadSceneName = sceneName; LoadSceneName = sceneName;
UIManager.GetInstance().tryCloseCurrentUIObj(); UIManager.GetInstance().tryCloseCurrentUIObj();
StartCoroutine(LoadLevel()); StartCoroutine(LoadLevel());
} }
IEnumerator LoadLevel() IEnumerator LoadLevel()
{ {
UIManager.GetInstance().loadPanel.gameObject.SetActive(true); UIManager.GetInstance().loadPanel.RunEnable();
yield return new WaitForSeconds(1); yield return new WaitForSeconds(1);
...@@ -34,7 +33,7 @@ public class LoadManager : MonoSingleTon<LoadManager> ...@@ -34,7 +33,7 @@ public class LoadManager : MonoSingleTon<LoadManager>
while (!operation.isDone) while (!operation.isDone)
{ {
UIManager.GetInstance().loadPanel.loadProgressText.text = operation.progress.ToString(); UIManager.GetInstance().loadPanel.loadProgressText.text = operation.progress.ToString();
UIManager.GetInstance().loadPanel.slider.value = operation.progress;
if (operation.progress >= 0.9f) if (operation.progress >= 0.9f)
{ {
...@@ -50,4 +49,5 @@ public class LoadManager : MonoSingleTon<LoadManager> ...@@ -50,4 +49,5 @@ public class LoadManager : MonoSingleTon<LoadManager>
} }
#endregion #endregion
} }
...@@ -5,7 +5,7 @@ using UnityEngine; ...@@ -5,7 +5,7 @@ using UnityEngine;
//不用放进场景 //不用放进场景
public class NpcGenerateManager : MonoSingleTon<NpcGenerateManager> public class NpcGenerateManager : MonoSingleTon<NpcGenerateManager>
{ {
private float generateRate = 0.4f;//每个npc随机生成的概率(也可以理解为可随机npc池子里,最终会刷出的npc的占比) private float generateRate = 0.6f;//每个npc随机生成的概率(也可以理解为可随机npc池子里,最终会刷出的npc的占比)
//包含场景内所有Npc //包含场景内所有Npc
[SerializeField]private List<NpcInteract> npcList = new List<NpcInteract>(); [SerializeField]private List<NpcInteract> npcList = new List<NpcInteract>();
...@@ -50,12 +50,13 @@ public class NpcGenerateManager : MonoSingleTon<NpcGenerateManager> ...@@ -50,12 +50,13 @@ public class NpcGenerateManager : MonoSingleTon<NpcGenerateManager>
//筛选出满足条件的Npc //筛选出满足条件的Npc
foreach (var item in npcList) foreach (var item in npcList)
{ {
if (item.Npc_SO == null) continue;
item.gameObject.SetActive(false); item.gameObject.SetActive(false);
if (item.Npc_SO.requirement.getRequireBool()) if (item.Npc_SO.requirement==null
{ || item.Npc_SO.requirement.getRequireBool())
npcCanGenList.Add(item); npcCanGenList.Add(item);
} }
}
//选取出将要生成的Npc //选取出将要生成的Npc
bool tempB = true; bool tempB = true;
......
...@@ -11,6 +11,7 @@ public class QuestManager : MonoSingleTon<QuestManager> ...@@ -11,6 +11,7 @@ public class QuestManager : MonoSingleTon<QuestManager>
//初始化进行中任务的监听 //初始化进行中任务的监听
foreach (var item in GameDataManager.GetInstance().saveData.currentQuest) foreach (var item in GameDataManager.GetInstance().saveData.currentQuest)
{ {
QuestRemoveListener(item);
QuestAddListener(item); QuestAddListener(item);
} }
} }
...@@ -37,15 +38,15 @@ public class QuestManager : MonoSingleTon<QuestManager> ...@@ -37,15 +38,15 @@ public class QuestManager : MonoSingleTon<QuestManager>
protected void QuestAddListener(Quest_SO quest_SO) protected void QuestAddListener(Quest_SO quest_SO)
{ {
//增加监听。当听到达成某条件时,将对应任务"完成"。 //增加监听。当听到达成某条件时,将对应任务"完成"。
EventManager.GetInstance().AddEventListener(quest_SO.questNeed.NeedToString(), quest_SO.QuestFinish); EventManager.GetInstance().AddEventListener(quest_SO.NeedToString(), quest_SO.QuestFinish);
Debug.Log("添加事件监听:" + quest_SO.questNeed.NeedToString()); Debug.Log("添加事件监听:" + quest_SO.NeedToString());
} }
//为某任务移除监听 //为某任务移除监听
public void QuestRemoveListener(Quest_SO quest_SO) public void QuestRemoveListener(Quest_SO quest_SO)
{ {
EventManager.GetInstance().RemoveEventListener(quest_SO.questNeed.NeedToString(), quest_SO.QuestFinish); EventManager.GetInstance().RemoveEventListener(quest_SO.NeedToString(), quest_SO.QuestFinish);
Debug.Log("移除事件监听:" + quest_SO.questNeed.NeedToString()); Debug.Log("移除事件监听:" + quest_SO.NeedToString());
} }
/// <summary> /// <summary>
......
...@@ -47,6 +47,8 @@ public class SingleDialogSelection : IInteraction ...@@ -47,6 +47,8 @@ public class SingleDialogSelection : IInteraction
//重要! //重要!
public void DoInteract(PlayerManager playerManager) public void DoInteract(PlayerManager playerManager)
{ {
//交给那边的方法去判断处理
UIManager.GetInstance().dialogPanel.HandleNextDialog(nextDialogIndexes);
//实现效果 //实现效果
foreach (var item in impacts) foreach (var item in impacts)
{ {
...@@ -61,8 +63,7 @@ public class SingleDialogSelection : IInteraction ...@@ -61,8 +63,7 @@ public class SingleDialogSelection : IInteraction
{ {
UIManager.GetInstance().dialogPanel.EndDialog(); UIManager.GetInstance().dialogPanel.EndDialog();
}*/ }*/
//交给那边的方法去判断处理
UIManager.GetInstance().dialogPanel.HandleNextDialog(nextDialogIndexes);
} }
......
...@@ -31,6 +31,9 @@ public class PlayerSaveData_SO : ScriptableObject ...@@ -31,6 +31,9 @@ public class PlayerSaveData_SO : ScriptableObject
public List<Quest_SO> currentQuest;//进行中任务 public List<Quest_SO> currentQuest;//进行中任务
public List<Quest_SO> finishedQuest;//已完成任务 public List<Quest_SO> finishedQuest;//已完成任务
[Header("修改器设置")]
public bool isUnlimitJump = true;//是否能无限跳
public bool isFastRun = false;//是否超级速度
} }
public enum DayTimeEnum { 早晨,中午,晚上}; public enum DayTimeEnum { 早晨,中午,晚上};
...@@ -13,7 +13,7 @@ public enum QuestFinishType { ...@@ -13,7 +13,7 @@ public enum QuestFinishType {
public enum QuestNeedType public enum QuestNeedType
{ {
交互 交互,只能ImpactEffect
} }
[System.Serializable] [System.Serializable]
...@@ -28,10 +28,19 @@ public class QuestNeed ...@@ -28,10 +28,19 @@ public class QuestNeed
[Tooltip("对应的int值(没有就不填)")] [Tooltip("对应的int值(没有就不填)")]
public int intValue = 1; public int intValue = 1;
public string NeedToString() //public string NeedToString()
{ //{
return questNeedType + "_" + stringValue; // switch (questNeedType)
} // {
// case QuestNeedType.交互:
// return questNeedType + "_" + stringValue;
// case QuestNeedType.只能ImpactEffect:
// return questNeedType + "_" + ;
// break;
// default:
// break;
// }
//}
} }
#endregion #endregion
...@@ -50,6 +59,8 @@ public class Quest_SO : ScriptableObject ...@@ -50,6 +59,8 @@ public class Quest_SO : ScriptableObject
[TextArea] public string QuestNeedDescription;//任务达成条件描述(偏正式) [TextArea] public string QuestNeedDescription;//任务达成条件描述(偏正式)
[Tooltip("是否只能领取一次")] [Tooltip("是否只能领取一次")]
public bool onlyOnce = false; public bool onlyOnce = false;
[Tooltip("完成后直接移除")]
public bool deleteFinish = false;
[Tooltip("达成条件")] [Tooltip("达成条件")]
public QuestNeed questNeed; public QuestNeed questNeed;
...@@ -58,6 +69,18 @@ public class Quest_SO : ScriptableObject ...@@ -58,6 +69,18 @@ public class Quest_SO : ScriptableObject
public ImpactValue[] QuestReward;//任务报酬 public ImpactValue[] QuestReward;//任务报酬
public string NeedToString()
{
switch (questNeed.questNeedType)
{
case QuestNeedType.交互:
return questNeed.questNeedType + "_" + questNeed.stringValue;
}
return questNeed + "_" + QuestName + "_" + name ;
}
//任务完成时的效果 //任务完成时的效果
public void QuestFinish() public void QuestFinish()
{ {
...@@ -66,7 +89,7 @@ public class Quest_SO : ScriptableObject ...@@ -66,7 +89,7 @@ public class Quest_SO : ScriptableObject
QuestManager.GetInstance().QuestRemoveListener(this); QuestManager.GetInstance().QuestRemoveListener(this);
//列表添加删除 //列表添加删除
GameDataManager.GetInstance().saveData.currentQuest.Remove(this); GameDataManager.GetInstance().saveData.currentQuest.Remove(this);
GameDataManager.GetInstance().saveData.finishedQuest.Add(this); if (!deleteFinish) GameDataManager.GetInstance().saveData.finishedQuest.Add(this);
//提示 //提示
UIManager.GetInstance().tipsInfoPanel.AddTipsInfo("【"+QuestName+"】已完成!"); UIManager.GetInstance().tipsInfoPanel.AddTipsInfo("【"+QuestName+"】已完成!");
//实现效果 //实现效果
...@@ -76,6 +99,7 @@ public class Quest_SO : ScriptableObject ...@@ -76,6 +99,7 @@ public class Quest_SO : ScriptableObject
} }
} }
//任务给予者 //任务给予者
//完成条件 //完成条件
} }
......
...@@ -7,6 +7,7 @@ public class DialogPanel : MonoBehaviour ...@@ -7,6 +7,7 @@ public class DialogPanel : MonoBehaviour
{ {
protected Text dialogTextUI; protected Text dialogTextUI;
protected Dialog_SO currentDialogSO; protected Dialog_SO currentDialogSO;
string allText;// 给屎山代码加点料,因为需要鼠标点击的时候全部输出需要的变量
private void Awake() private void Awake()
{ {
...@@ -68,6 +69,28 @@ public class DialogPanel : MonoBehaviour ...@@ -68,6 +69,28 @@ public class DialogPanel : MonoBehaviour
protected void SetDialogText(string text) protected void SetDialogText(string text)
{ {
dialogTextUI.text = text; allText = text;
StopAllCoroutines();
StartCoroutine(TypeText(text, 0.05f));
}
// 协程逐字打印文本的效果,用协程产生延时的效果
IEnumerator TypeText(string str,float interval)
{
int i = 0;
while (i <= str.Length)
{
dialogTextUI.text = str.Substring(0, i++);
yield return new WaitForSeconds(interval);
}
}
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
StopAllCoroutines();
dialogTextUI.text = allText;
}
} }
} }
...@@ -9,7 +9,10 @@ using UnityEngine.UI; ...@@ -9,7 +9,10 @@ using UnityEngine.UI;
public class LoadPanel : MonoBehaviour public class LoadPanel : MonoBehaviour
{ {
//加载文字。目前对这玩意儿的改动都暂时在GameDataManager里。 //加载文字。目前对这玩意儿的改动都暂时在GameDataManager里。
[HideInInspector] public Text loadProgressText; public Text loadProgressText;
public Slider slider;//加载的进度条
public Image sliderImage;// 进度条上的图片,为了实现进度条的滚动
[Tooltip("显示的百分比")]public Text text;//显示的百分比
protected Image backGroundImg; protected Image backGroundImg;
public Sprite[] imgArrays; public Sprite[] imgArrays;
...@@ -21,38 +24,92 @@ public class LoadPanel : MonoBehaviour ...@@ -21,38 +24,92 @@ public class LoadPanel : MonoBehaviour
backGroundImg = GetComponentInChildren<Image>(); backGroundImg = GetComponentInChildren<Image>();
} }
private void OnEnable() //临时用,不管了
public void RunEnable()
{ {
StartCoroutine(ChangeBackgroundImg());//持续切换背景图片 gameObject.SetActive(true);
//StartCoroutine(ChangeBackgroundImg());//持续切换背景图片
ChangeBackgroundImg();
StartCoroutine(RunSlider());
} }
private void OnEnable()
IEnumerator ChangeBackgroundImg()
{
while(gameObject.activeInHierarchy)
{ {
SetBackgroundImg(); //全放到上面的RunEnable里了
yield return new WaitForSeconds(4);
}
} }
protected void SetBackgroundImg() private void OnDisable()
{ {
Sprite nextImg = null; StopAllCoroutines();
if (backGroundImg == null) return; }
if (imgArrays.Length == 1)
// 两个update都试了一下,滚动的校徽看起来都挺卡的,聊胜于无吧
/*private void FixedUpdate()
{ {
nextImg = imgArrays[0]; sliderImage.transform.localEulerAngles = new Vector3(0, 0, sliderImage.transform.rotation.z + 100f);
} }
else
private void Update()
{ {
while (nextImg != backGroundImg.sprite) sliderImage.transform.localEulerAngles = new Vector3(0, 0, sliderImage.transform.rotation.z + 100f);
}*/
/// <summary>
/// 协程实现进度条上的图片的滚动
/// </summary>
IEnumerator RunSlider()
{
int i = 0;
while(i < 250)
{ {
nextImg = imgArrays[Random.Range(0, imgArrays.Length)]; sliderImage.transform.localEulerAngles = new Vector3(0, 0, sliderImage.transform.rotation.z + 100f);
yield return new WaitForSeconds(0.04f);
} }
StopAllCoroutines();
} }
backGroundImg.sprite = nextImg;
/// <summary>
/// 实现随机选择一张图片进行加载
/// </summary>
private void ChangeBackgroundImg()
{
backGroundImg.sprite = imgArrays[Random.Range(0,imgArrays.Length)];
}
//IEnumerator ChangeBackgroundImg()
//{
// while(gameObject.activeInHierarchy)
// {
// SetBackgroundImg();
// yield return new WaitForSeconds(4);
// }
//}
protected void SetBackgroundImg()
{
//Sprite nextImg = null;
//if (backGroundImg == null) return;
//if (imgArrays.Length == 1)
//{
// nextImg = imgArrays[0];
//}
//else
//{
// //TODO:沈建伟来写一下开始时随机选一张图
//这边while代码最好不要了,会有死循环
// //while (nextImg != backGroundImg.sprite)
// //{
// // //
// // //nextImg = imgArrays[Random.Range(0, imgArrays.Length)];
// //}
//}
//backGroundImg.sprite = nextImg;
} }
} }
...@@ -47,9 +47,10 @@ public class MainMenu : MonoBehaviour ...@@ -47,9 +47,10 @@ public class MainMenu : MonoBehaviour
/// <param name="obj"></param> /// <param name="obj"></param>
void NewGame(PlayableDirector obj) void NewGame(PlayableDirector obj)
{ {
//设置SO
GameDataManager.GetInstance().TempSetSaveDataToNew();
// 转换场景 // 转换场景
LoadManager.GetInstance().LoadSceneByName("03_dormitory02"); LoadManager.GetInstance().LoadSceneByName("03_dormitory02");
//LoadManager.GetInstance().LoadSceneByName("03_dormitory02");
Debug.Log("开始新游戏"); Debug.Log("开始新游戏");
...@@ -57,8 +58,9 @@ public class MainMenu : MonoBehaviour ...@@ -57,8 +58,9 @@ public class MainMenu : MonoBehaviour
void ContinueGame() void ContinueGame()
{ {
Debug.Log("读取存档");
//转换场景,读取进度 //转换场景,读取进度
LoadManager.GetInstance().LoadSceneByName("03_dormitory02");
Debug.Log("读取存档");
} }
void SettingsGame() void SettingsGame()
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Panel : MonoBehaviour
{
public Image panelImage;
public AnimationCurve showCurve;
public AnimationCurve hideCurve;
public float animationSpeed = 2;
public float transparency = 0.5f;
// 使用协程来进行面板的渐入渐出效果
IEnumerator ShowPanel()
{
float timer = 0;
while (panelImage.color.a < 1)
{
panelImage.color = new Vector4(1, 1, 1, showCurve.Evaluate(timer));
timer += Time.deltaTime * animationSpeed;
yield return null;
}
}
IEnumerator HidePanel()
{
float timer = 0;
while (panelImage.color.a > 0)
{
panelImage.color = new Vector4(1, 1, 1, hideCurve.Evaluate(timer));
timer += Time.deltaTime * animationSpeed;
yield return null;
}
}
// 打开面板,渐入效果
public void OpenPanel()
{
StopAllCoroutines();
StartCoroutine(ShowPanel());
}
// 关闭面板,渐出效果
public void ClosePanel()
{
StopAllCoroutines();
StartCoroutine(HidePanel());
}
// 这是测试,要删掉,左键打开,右键关闭
public void Update()
{
if (Input.GetMouseButtonDown(0))
{
StopAllCoroutines();
StartCoroutine(ShowPanel());
}
if (Input.GetMouseButtonDown(1))
{
StopAllCoroutines();
StartCoroutine(HidePanel());
}
}
}
fileFormatVersion: 2
guid: f28d31d667701cd4ba784ce6cf9a312a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class App_Modifier : MonoBehaviour
{
public Text playerInfoText;//目前暂时使用手动拖拽赋值
//激活时自动调用
private void OnEnable()
{
SetInfoText();
}
public void SwitchUnlimitJump()
{
var saveData = GameDataManager.GetInstance().saveData;
saveData.isUnlimitJump = !saveData.isUnlimitJump;
SetInfoText();
}
public void SwitchFastRun()
{
var saveData = GameDataManager.GetInstance().saveData;
saveData.isFastRun = !saveData.isFastRun;
SetInfoText();
}
protected void SetInfoText()
{
//读取目前玩家游戏数据
var saveData = GameDataManager.GetInstance().saveData;
string s = "";
//设置字符串
s += "无限跳:" + BoolToRichText(saveData.isUnlimitJump) + "\n";
s += "兔符咒:" + BoolToRichText(saveData.isFastRun) + "\n";
playerInfoText.text = s;
}
protected string BoolToRichText(bool value)
{
return value ? "<color=yellow> 启用 </color>" : "<color=red> 关闭 </color>";
}
}
fileFormatVersion: 2
guid: 84ffaa8a55751fc41bcf13e08c439c03
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -24,6 +24,11 @@ public class App_PlayerInfo : MonoBehaviour ...@@ -24,6 +24,11 @@ public class App_PlayerInfo : MonoBehaviour
s += "气力:" + saveData.Strength + "\n"; s += "气力:" + saveData.Strength + "\n";
s += "学识:" + saveData.Intelligence + "\n"; s += "学识:" + saveData.Intelligence + "\n";
s += "社交:" + saveData.Communication + "\n"; s += "社交:" + saveData.Communication + "\n";
s += "\n";
s += "金钱: " + saveData.money + "\n";
s += "心情: " + saveData.money + "\n";
s += "年级: " + saveData.GradeNum + "\n";
s += "时间段: " + saveData.dayTimeEnum.ToString() + "\n";
playerInfoText.text = s; playerInfoText.text = s;
} }
......
...@@ -37,6 +37,8 @@ public class PhonePanel : MonoBehaviour ...@@ -37,6 +37,8 @@ public class PhonePanel : MonoBehaviour
/// <param name="add"></param> /// <param name="add"></param>
public void PointApp(int add) public void PointApp(int add)
{ {
if (gameObject.activeSelf == false) return;
currentAppIndex += add; currentAppIndex += add;
currentAppIndex = (currentAppIndex + appList.Count) % appList.Count;//循环 currentAppIndex = (currentAppIndex + appList.Count) % appList.Count;//循环
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册