46 changed files with 565 additions and 1309 deletions
@ -0,0 +1,137 @@ |
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 8 |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_Name: PlayerStepMark |
|||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} |
|||
m_Parent: {fileID: 0} |
|||
m_ModifiedSerializedProperties: 0 |
|||
m_ValidKeywords: |
|||
- _ALPHAPREMULTIPLY_ON |
|||
- _SURFACE_TYPE_TRANSPARENT |
|||
m_InvalidKeywords: [] |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: 3001 |
|||
stringTagMap: |
|||
RenderType: Transparent |
|||
disabledShaderPasses: |
|||
- DepthOnly |
|||
- SHADOWCASTER |
|||
m_LockedProperties: |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BaseMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _SpecGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- unity_Lightmaps: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- unity_LightmapsInd: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- unity_ShadowMasks: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Ints: [] |
|||
m_Floats: |
|||
- _AlphaClip: 0 |
|||
- _AlphaToMask: 0 |
|||
- _Blend: 0 |
|||
- _BlendModePreserveSpecular: 1 |
|||
- _BumpScale: 1 |
|||
- _ClearCoatMask: 0 |
|||
- _ClearCoatSmoothness: 0 |
|||
- _Cull: 2 |
|||
- _Cutoff: 0.5 |
|||
- _DetailAlbedoMapScale: 1 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 10 |
|||
- _DstBlendAlpha: 10 |
|||
- _EnvironmentReflections: 1 |
|||
- _GlossMapScale: 0 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.005 |
|||
- _QueueOffset: 1 |
|||
- _ReceiveShadows: 1 |
|||
- _Smoothness: 0 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 1 |
|||
- _SrcBlend: 1 |
|||
- _SrcBlendAlpha: 1 |
|||
- _Surface: 1 |
|||
- _WorkflowMode: 1 |
|||
- _ZWrite: 0 |
|||
m_Colors: |
|||
- _BaseColor: {r: 0.08627453, g: 0.77254903, b: 0.70487916, a: 0.7490196} |
|||
- _Color: {r: 0.0862745, g: 0.77254903, b: 0.70487916, a: 0.7490196} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} |
|||
m_BuildTextureStacks: [] |
|||
--- !u!114 &5999080594394386120 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 11 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
version: 7 |
|||
@ -1,8 +1,8 @@ |
|||
fileFormatVersion: 2 |
|||
guid: c3f33c18d92e4c142aa468b5e2448cf6 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
guid: 2ec9a21f0a6530249b852e4deea04d31 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 2100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
|
Before Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 1.1 MiB |
@ -1,8 +0,0 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 1fa9b405ca4e84b468cfd0902f79c50c |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -1,8 +0,0 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 6a532d13c0722bc4591a8e2bff02a70a |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -1,194 +0,0 @@ |
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Data; |
|||
using System.IO; |
|||
using UnityEngine; |
|||
using UnityEngine.InputSystem; |
|||
|
|||
public class ServantBottleCat : Servant |
|||
{ |
|||
[Header ("技能资源")] |
|||
public GameObject bulletPrefab; |
|||
|
|||
public override void SkillePreviewSelector(int index) |
|||
{ |
|||
switch (index) |
|||
{ |
|||
case 0: |
|||
PreEffect_0(); |
|||
break; |
|||
case 1: |
|||
PreEffect_1(); |
|||
break; |
|||
case 2: |
|||
PreEffect_2(); |
|||
break; |
|||
} |
|||
} |
|||
public override void SkillePreviewEffectSelector(int index, MapUnity currentMapUnity) |
|||
{ |
|||
switch (index) |
|||
{ |
|||
case 0: |
|||
PreEffectRange_0(currentMapUnity); |
|||
break; |
|||
case 1: |
|||
PreEffectRange_1(currentMapUnity); |
|||
break; |
|||
case 2: |
|||
PreEffectRange_2(currentMapUnity); |
|||
break; |
|||
} |
|||
} |
|||
public override void SkilleEffectSelector(int index) |
|||
{ |
|||
switch (index) |
|||
{ |
|||
case 0: |
|||
Effect_0(); |
|||
break; |
|||
case 1: |
|||
Effect_1(); |
|||
break; |
|||
case 2: |
|||
Effect_2(); |
|||
break; |
|||
} |
|||
} |
|||
//预览范围
|
|||
public void PreEffect_0() |
|||
{ |
|||
arrowInMap.gameObject.SetActive(true );//打开箭头
|
|||
MovePreView(); |
|||
} |
|||
public void PreEffect_1() |
|||
{ |
|||
arrowInMap.gameObject.SetActive(true);//打开箭头
|
|||
influencePreviewPool.UnionWith(MapUnityManager.Instance.findReachableTiles(GameManager.Instance.servantOn,skillList [currentSkillInex].throwRange )); |
|||
//遍历影响池变色
|
|||
foreach (MapUnity mapUnity in influencePreviewPool) |
|||
{ |
|||
mapUnity.PlayerInfluenced(influencePreviewPool); |
|||
mapUnity.playerMark.material = mapUnity.red; |
|||
} |
|||
TurnMaster.Instance.servantAction = TurnMaster.ServantAction.useSkill; |
|||
} |
|||
public void PreEffect_2() |
|||
{ |
|||
arrowInMap.gameObject.SetActive(true);//打开箭头
|
|||
influencePreviewPool.UnionWith(MapUnityManager.Instance.findReachableTiles(GameManager.Instance.servantOn, skillList[currentSkillInex].throwRange)); |
|||
//遍历影响池变色
|
|||
foreach (MapUnity mapUnity in influencePreviewPool) |
|||
{ |
|||
mapUnity.PlayerInfluenced(influencePreviewPool); |
|||
mapUnity.playerMark.material = mapUnity.red; |
|||
} |
|||
TurnMaster.Instance.servantAction = TurnMaster.ServantAction.useSkill; |
|||
} |
|||
//预览效果范围
|
|||
public void PreEffectRange_0(MapUnity currentMapUnity ) |
|||
{ |
|||
effectRangePreviewPool.Add(currentMapUnity); |
|||
HighLightEffectRange(); |
|||
} |
|||
public void PreEffectRange_1(MapUnity currentMapUnity) |
|||
{ |
|||
effectRangePreviewPool.Add(currentMapUnity); |
|||
HighLightEffectRange(); |
|||
} |
|||
public void PreEffectRange_2(MapUnity currentMapUnity) |
|||
{ |
|||
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|||
if (Physics.Raycast(ray, out RaycastHit raycastHit, 500, chooseNodeLayerMask.value)) |
|||
{ |
|||
Vector3 direction = raycastHit.transform.position - transform.position; |
|||
|
|||
float angle1 = Vector3.SignedAngle(transform.forward, direction, transform.up); |
|||
|
|||
if (angle1 < 0) |
|||
{ |
|||
angle1 += 360f; |
|||
} |
|||
Debug.Log(angle1+"前"); |
|||
|
|||
if (angle1 >= 300f) |
|||
{ |
|||
angle1 = 330f; |
|||
} |
|||
else if (angle1 >= 240f) |
|||
{ |
|||
angle1 = 270f; |
|||
} |
|||
else if (angle1 >= 180f) |
|||
{ |
|||
angle1 = 210f; |
|||
} |
|||
else if (angle1 >= 120f) |
|||
{ |
|||
angle1 = 150f; |
|||
} |
|||
else if (angle1 >= 60f) |
|||
{ |
|||
angle1 = 90f; |
|||
} |
|||
else if (angle1 >= 0f) |
|||
{ |
|||
angle1 = 30f; |
|||
} |
|||
Debug.Log(angle1 + "后"); |
|||
effectRangePreviewPool = getNodeTools.setEffectRangePreviewNoCard("3_1", angle1, currentMapUnity); |
|||
HighLightEffectRange(); |
|||
|
|||
} |
|||
|
|||
} |
|||
public void Effect_0() |
|||
{ |
|||
StartCoroutine(MoveToChooseNode()); |
|||
} |
|||
public void Effect_1() |
|||
{ |
|||
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|||
if (Physics.Raycast(ray, out RaycastHit raycastHit, 500,chooseNodeLayerMask.value)) |
|||
{ |
|||
Debug.Log(raycastHit.collider.name); |
|||
MapUnity currentNode = raycastHit.transform.GetComponent<MapUnity>(); |
|||
if (currentNode.enemyNode != null ) |
|||
{ |
|||
var bullet = Instantiate(bulletPrefab, this.transform.position, bulletPrefab.transform.rotation); |
|||
BulletMove bulletMove = bullet.GetComponent<BulletMove>(); |
|||
bulletMove.destination = raycastHit.transform.position; |
|||
bulletMove.destination.y = 0.4f; |
|||
currentNode.enemyNode.EnemyState.currentHP -= skillList[currentSkillInex].value; |
|||
|
|||
anim.SetTrigger("shoot"); |
|||
|
|||
SettleSkillCoolDown(skillList[currentSkillInex], skillNodeList[currentSkillInex]); |
|||
} |
|||
|
|||
} |
|||
|
|||
ResetPreView(); |
|||
} |
|||
public void Effect_2() |
|||
{ |
|||
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|||
if (Physics.Raycast(ray, out RaycastHit raycastHit, 500, chooseNodeLayerMask.value)) |
|||
{ |
|||
Debug.Log(raycastHit.collider.name); |
|||
MapUnity currentNode = raycastHit.transform.GetComponent<MapUnity>(); |
|||
if(currentNode .influenced ==true ) |
|||
{ |
|||
foreach (var node in effectRangePreviewPool) |
|||
{ |
|||
//node.whoColour = MapUnity.WhoColour.playerColour;
|
|||
} |
|||
anim.SetTrigger("shoot"); |
|||
SettleSkillCoolDown(skillList[currentSkillInex], skillNodeList[currentSkillInex]); |
|||
} |
|||
|
|||
} |
|||
ResetPreView(); |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 1a6bd56e8e7c0b34ab0b3bf7baa437ae |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -1,440 +0,0 @@ |
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using Unity.VisualScripting; |
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
using UnityEngine.InputSystem; |
|||
|
|||
|
|||
public class Servant : MonoBehaviour |
|||
{ |
|||
public int startPositionX, startPositionY; |
|||
public HashSet<MapUnity> influencePreviewPool = new HashSet<MapUnity>();//记录预览影响的对象池
|
|||
public HashSet<MapUnity> effectRangePreviewPool = new HashSet<MapUnity>();//效果作用范围
|
|||
|
|||
[Header("层级检测")] |
|||
public LayerMask chooseNodeLayerMask;//移动射线选择的层级
|
|||
public LayerMask playerLayerMask;//角色层级
|
|||
[Header("路径")] |
|||
public List<MapUnity> movePath = new List<MapUnity>(); |
|||
|
|||
[Header("动画器")] |
|||
public Animator anim; |
|||
[Header("跑步速度")] |
|||
public float speed = 2; |
|||
[Header("瞄准箭头")] |
|||
public ArrowInMap arrowInMap; |
|||
[Header("技能瞄准上一帧瞄准格子")] |
|||
public MapUnity latestMapUnity;//与当前帧不一致刷新范围
|
|||
private bool isRefresh; |
|||
[Header("步数标识个数集(UI)")] |
|||
public int stepIconCount; |
|||
public Transform StepIconFather; |
|||
public GameObject stepIconPrefab; |
|||
|
|||
[Header("技能UI列表(UI)")] |
|||
public GameObject SkillUI; |
|||
public List<ServantSkill> skillList = new List<ServantSkill>(); |
|||
public List<ServantSkillNode> skillNodeList = new List<ServantSkillNode>(); |
|||
public List<Vector3> skillUIPos = new List<Vector3>(); |
|||
|
|||
[Header("技能UI生成资源")] |
|||
public GameObject SkillUIPrefab; |
|||
[Header("技能UI生成参数")] |
|||
public float radius; |
|||
public float angle; |
|||
public float startAngle; |
|||
public int pathNodeNum; |
|||
|
|||
[Header("当前处于哪个技能的范围预览")] |
|||
public int currentSkillInex; |
|||
|
|||
private void Start() |
|||
{ |
|||
GameManager.Instance.servant = this; |
|||
Invoke("StartSevent", 10f); |
|||
|
|||
InstantiateSkillUI(); |
|||
} |
|||
public void StartSevent() |
|||
{ |
|||
MapUnity currentNode = GameManager.Instance.X[startPositionX].Y[startPositionY]; |
|||
currentNode.playerOn = true; |
|||
GameManager.Instance.servantOn = currentNode; |
|||
this.gameObject.transform.position = new Vector3(currentNode.transform.position.x, 0.5f, currentNode.transform.position.z); |
|||
this.gameObject.transform.SetParent(currentNode.CylinderFloor.transform); |
|||
} |
|||
public virtual void Update() |
|||
{ |
|||
if (Mouse.current.leftButton.wasReleasedThisFrame && TurnMaster.Instance.playerAction != TurnMaster.PlayerAction.useCard && TurnMaster.Instance.servantAction != TurnMaster.ServantAction.banAction) |
|||
{ |
|||
//if (GameManager.Instance.servantState.currentStepRange > 0 && !Usermanager.playerAbnormalCondition.ContainsKey(AbnormalCondition.banStep))
|
|||
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|||
if (Physics.Raycast(ray, out RaycastHit raycastHit, 500, playerLayerMask.value)) |
|||
{ |
|||
if (raycastHit.collider.gameObject.tag == "Servant") |
|||
{ |
|||
GameManager.Instance.character = GameManager.SelectedCharacter.servant; |
|||
//Debug.Log(raycastHit.collider.gameObject.name);
|
|||
//展开技能表
|
|||
ShowSkillUI(); |
|||
} |
|||
else if (raycastHit.collider.gameObject.tag == "ServantSkillUI")//检测到是技能
|
|||
{ |
|||
GameManager.Instance.character = GameManager.SelectedCharacter.servant; |
|||
//技能范围预览(button触发添加技能序号)
|
|||
//MovePreView();
|
|||
if (skillList[currentSkillInex].currentStorageTimes > 0) |
|||
{ |
|||
TurnMaster.Instance.servantAction = TurnMaster.ServantAction.useSkill; |
|||
isRefresh = true; |
|||
SkillePreviewSelector(currentSkillInex); |
|||
ColorInUseSkillUI(); |
|||
} |
|||
} |
|||
else if (Physics.Raycast(ray, out RaycastHit raycastHitMap, 500, chooseNodeLayerMask.value)) |
|||
{ |
|||
isRefresh = false; |
|||
//检测到地面,释放技能实际效果
|
|||
if (GameManager.Instance.character == GameManager.SelectedCharacter.servant && TurnMaster.Instance.servantAction == TurnMaster.ServantAction.useSkill) |
|||
{ |
|||
SkilleEffectSelector(currentSkillInex); |
|||
ColorResrtUseSkillUI(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
else |
|||
{ |
|||
ResetPreView(); |
|||
} |
|||
|
|||
} |
|||
|
|||
if (Mouse.current.rightButton.wasPressedThisFrame) |
|||
{ |
|||
ResetPreView(); |
|||
} |
|||
|
|||
//鼠标移动就刷新范围预览
|
|||
if (isRefresh ==true) |
|||
{ |
|||
Ray rayMap = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|||
if (Physics.Raycast(rayMap, out RaycastHit raycastHitRefresh, 500, chooseNodeLayerMask.value)) |
|||
{ |
|||
MapUnity currentMapUnity = raycastHitRefresh.transform.GetComponent<MapUnity>(); |
|||
if (currentMapUnity != latestMapUnity) |
|||
{ |
|||
CleanEffectRange(); |
|||
SkillePreviewEffectSelector(currentSkillInex,currentMapUnity); |
|||
latestMapUnity = currentMapUnity; |
|||
} |
|||
|
|||
} |
|||
} |
|||
//同步步数UI标识
|
|||
if (GameManager.Instance.servantState.currentStepRange != stepIconCount) |
|||
{ |
|||
for (int i = StepIconFather.childCount - 1; i >= 0; i--) |
|||
{ |
|||
Destroy(StepIconFather.GetChild(i).gameObject); |
|||
} |
|||
stepIconCount = GameManager.Instance.servantState.currentStepRange; |
|||
|
|||
for (int i = 0; i <stepIconCount; i++) |
|||
{ |
|||
Instantiate(stepIconPrefab, StepIconFather); |
|||
} |
|||
|
|||
} |
|||
} |
|||
//技能范围预览
|
|||
public virtual void SkillePreviewSelector(int index) |
|||
{ |
|||
|
|||
} |
|||
//技能效果范围预览
|
|||
public virtual void SkillePreviewEffectSelector(int index,MapUnity currentMapUnity ) |
|||
{ |
|||
|
|||
} |
|||
//技能效果释放
|
|||
public virtual void SkilleEffectSelector(int index) |
|||
{ |
|||
|
|||
} |
|||
//高亮效果作用范围
|
|||
public void HighLightEffectRange() |
|||
{ |
|||
foreach (MapUnity mapUnity in effectRangePreviewPool ) |
|||
{ |
|||
mapUnity.infHighLight = true; |
|||
} |
|||
|
|||
} |
|||
//消除效果作用范围
|
|||
public void CleanEffectRange() |
|||
{ |
|||
foreach (MapUnity mapUnity in effectRangePreviewPool) |
|||
{ |
|||
mapUnity.infHighLight = false; |
|||
} |
|||
effectRangePreviewPool.Clear(); |
|||
} |
|||
|
|||
//展开技能表
|
|||
public void ShowSkillUI() |
|||
{ |
|||
if (SkillUI.activeInHierarchy == false) |
|||
{ |
|||
SkillUI.SetActive(true); |
|||
foreach (var skill in skillNodeList) |
|||
{ |
|||
skill.StopAllCoroutines(); |
|||
skill.transform.localPosition = new Vector3(0, 1, 0); |
|||
skill.StartCoroutine(skill.GoDistination()); |
|||
} |
|||
|
|||
} |
|||
else |
|||
{ |
|||
SkillUI.SetActive(false); |
|||
} |
|||
|
|||
} |
|||
//半透明技能UI
|
|||
public void ColorInUseSkillUI() |
|||
{ |
|||
foreach (var skillNode in skillNodeList ) |
|||
{ |
|||
skillNode.UIInUseSkill(); |
|||
} |
|||
} |
|||
//恢复半透明技能UI
|
|||
public void ColorResrtUseSkillUI() |
|||
{ |
|||
foreach (var skillNode in skillNodeList) |
|||
{ |
|||
skillNode.UIResetUseSkill(); |
|||
} |
|||
} |
|||
//生成技能UI
|
|||
public void InstantiateSkillUI() |
|||
{ |
|||
|
|||
for(int i=0;i<skillList .Count;i++) |
|||
{ |
|||
var currentUI = Instantiate(SkillUIPrefab, SkillUI.transform); |
|||
ServantSkillNode servantSkillNode = currentUI.GetComponent<ServantSkillNode>(); |
|||
servantSkillNode.servantSkill = skillList[i]; |
|||
servantSkillNode.servant = this; |
|||
skillNodeList.Add(servantSkillNode); |
|||
|
|||
//每个角度分五个节点
|
|||
for(int a=1;a<=pathNodeNum ;a ++) |
|||
{ |
|||
float currentAngle = startAngle + angle * (i - 1) + a * angle / (float)pathNodeNum; |
|||
// currentUI.transform.localPosition = new Vector3(radius * Mathf.Sin(currentAngle * Mathf.Deg2Rad), radius * (1 - Mathf.Cos(currentAngle * Mathf.Deg2Rad)), 0);
|
|||
//currentUI.transform.localEulerAngles -= SkillUI.transform.localEulerAngles;//矫正角度
|
|||
skillUIPos.Add(new Vector3(radius * Mathf.Sin(currentAngle * Mathf.Deg2Rad), radius * (1 + Mathf.Cos(currentAngle * Mathf.Deg2Rad)), 0)); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
//取消释放技能重置状态
|
|||
public void ResetPreView() |
|||
{ |
|||
// StepPreviewInfluencedNode(step);
|
|||
CloseStepPreviewInfluencedNode();//取消格子预览
|
|||
CleanEffectRange();//取消范围预览
|
|||
|
|||
ColorResrtUseSkillUI();//恢复技能UI
|
|||
arrowInMap.gameObject.SetActive(false);//关闭箭头
|
|||
isRefresh = false; |
|||
if (TurnMaster.Instance.servantAction != TurnMaster.ServantAction.banAction) |
|||
TurnMaster.Instance.servantAction = TurnMaster.ServantAction.none; |
|||
} |
|||
//点击移动技能预览移动范围
|
|||
public void MovePreView() |
|||
{ |
|||
influencePreviewPool.UnionWith(MapUnityManager.Instance.findReachableTiles(GameManager.Instance.servantOn, GameManager.Instance.servantState.currentStepRange)); |
|||
//遍历影响池变色
|
|||
foreach (MapUnity mapUnity in influencePreviewPool) |
|||
{ |
|||
mapUnity.PlayerInfluenced(influencePreviewPool); |
|||
mapUnity.playerMark.material = mapUnity.red; |
|||
} |
|||
//StepPreviewInfluencedNode(GameManager.Instance.playerState.currentStepRange);
|
|||
//TurnMaster.Instance.servantAction = TurnMaster.ServantAction.move;
|
|||
TurnMaster.Instance.servantAction = TurnMaster.ServantAction.useSkill; |
|||
} |
|||
public IEnumerator MoveToChooseNode()//射线检测选择一个mapNode
|
|||
{ |
|||
//关闭箭头
|
|||
arrowInMap.gameObject.SetActive(false); |
|||
//关闭高亮预览
|
|||
CleanEffectRange(); |
|||
|
|||
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|||
if (Physics.Raycast(ray, out RaycastHit raycastHit, 500, chooseNodeLayerMask.value)) |
|||
{ |
|||
// Debug.Log(raycastHit.collider.gameObject.name);
|
|||
MapUnity mapNode = raycastHit.collider.transform.GetComponent<MapUnity>(); |
|||
|
|||
//改变缩放翻转
|
|||
FlipLocalScale(raycastHit.point); |
|||
|
|||
//角色移动
|
|||
if (mapNode.influenced && mapNode.blocked == false && mapNode.enemyNode == null&&mapNode .playerOn ==false ) |
|||
{ |
|||
//获得路径
|
|||
movePath = AStarManager.Instance.FindPathWithEndNode(GameManager.Instance.servantOn, mapNode); |
|||
//判断能否到达
|
|||
if (movePath.Count - 1 > GameManager.Instance.servantState.currentStepRange) |
|||
{ |
|||
Debug.Log("不能移动到该位置"); |
|||
yield break; |
|||
} |
|||
|
|||
//改变动画
|
|||
anim.SetBool("move", true); |
|||
|
|||
if (GameManager.Instance.servantOn != null) |
|||
{ |
|||
GameManager.Instance.servantOn.playerOn = false; |
|||
GameManager.Instance.servantOn.influenced = false; |
|||
} |
|||
//遍历影响池变色
|
|||
CloseStepPreviewInfluencedNode(); |
|||
|
|||
//标记终点
|
|||
mapNode.infHighLight = true; |
|||
|
|||
for (int i = 1; i < movePath.Count; i++) |
|||
{ |
|||
bool move = true; |
|||
float time = 0; |
|||
Vector3 startPos = transform.position; |
|||
Vector3 endpos = new Vector3(movePath[i].transform.position.x, transform.position.y, movePath[i].transform.position.z); |
|||
while (move) |
|||
{ |
|||
transform.position = Vector3.Lerp(startPos, endpos, time += Time.deltaTime * speed); |
|||
if (Vector3.Distance(transform.position, endpos) < 0.1f) |
|||
{ |
|||
move = false; |
|||
} |
|||
|
|||
yield return 0; |
|||
} |
|||
//判断寄生,流血是否生效
|
|||
//Usermanager.Instance.ParasitismnRealize(movePath[i]);//传入当前node
|
|||
// Usermanager.Instance.bleedRealize();
|
|||
//减体力
|
|||
GameManager.Instance.servantState.currentStepRange -= 1; |
|||
//同步技能UI
|
|||
if (GameManager.Instance.servantState.currentStepRange <= 0) |
|||
{ |
|||
skillList[0].currentStorageTimes = 0; |
|||
skillNodeList[0].image.sprite = skillList[0].coolDownIcon; |
|||
} |
|||
} |
|||
|
|||
this.gameObject.transform.position = new Vector3(mapNode.transform.position.x, 0.5f, mapNode.transform.position.z); |
|||
mapNode.playerOn = true; |
|||
GameManager.Instance.servantOn = mapNode; |
|||
this.gameObject.transform.SetParent(mapNode.CylinderFloor.transform); |
|||
|
|||
//改变动画
|
|||
anim.SetBool("move", false); |
|||
|
|||
//取消标记终点
|
|||
mapNode.infHighLight = false; |
|||
TurnMaster.Instance.servantAction = TurnMaster.ServantAction.none; |
|||
|
|||
|
|||
} |
|||
else |
|||
{ |
|||
Debug.Log("不能移动到该位置"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public void CloseStepPreviewInfluencedNode() |
|||
{ |
|||
//遍历影响池变色
|
|||
foreach (MapUnity mapUnity in influencePreviewPool) |
|||
{ |
|||
mapUnity.influenced = false; |
|||
} |
|||
influencePreviewPool.Clear(); |
|||
|
|||
} |
|||
//改变缩放翻转
|
|||
public void FlipLocalScale(Vector3 point) |
|||
{ |
|||
if (point.x < transform.position.x) |
|||
{ |
|||
anim.transform.localScale = new Vector3(-0.06f, 0.06f, 0.06f); |
|||
} |
|||
else |
|||
{ |
|||
anim.transform.localScale = new Vector3(0.06f, 0.06f, 0.06f); |
|||
} |
|||
} |
|||
//技能冷却结算
|
|||
public void SettleSkillCoolDown(ServantSkill skill ,ServantSkillNode skillNode) |
|||
{ |
|||
if(skill .currentStorageTimes >0) |
|||
{ |
|||
skill.currentUseTimes--; |
|||
if(skill .currentUseTimes <=0) |
|||
{ |
|||
skill.currentStorageTimes--; |
|||
skill.currentUseTimes = skill.useTimes; |
|||
} |
|||
} |
|||
if (skill.currentStorageTimes <= 0) |
|||
{ |
|||
skillNode.image .sprite = skill.coolDownIcon; |
|||
} |
|||
if (skill.currentStorageTimes < skill.storageTimes) |
|||
{ |
|||
skillNode.coolDownText.gameObject.SetActive(true); |
|||
skillNode.coolDownText.text = skill.currentCoolDown .ToString (); |
|||
} |
|||
} |
|||
|
|||
|
|||
[System .Serializable ] |
|||
public class ServantSkill |
|||
{ |
|||
public string name; |
|||
public string disdescription; |
|||
public int effectIndex; |
|||
public int value; |
|||
public int throwRange; |
|||
public int effectRange; |
|||
public int coolDown;//冷却时间
|
|||
public int useTimes;//一回合能用几次
|
|||
public int storageTimes;//最高存几次使用
|
|||
public int currentCoolDown; |
|||
public int currentUseTimes; |
|||
public int currentStorageTimes; |
|||
|
|||
public SkillType skillType; |
|||
public enum SkillType |
|||
{ |
|||
bullet, |
|||
melee, |
|||
magic, |
|||
aoe, |
|||
move, |
|||
noneRange |
|||
} |
|||
public Sprite Icon; |
|||
public Sprite coolDownIcon; |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 0e88f38f638f532498966deadd648cd0 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -1,41 +0,0 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.InputSystem; |
|||
|
|||
public class ArrowInMap : MonoBehaviour |
|||
{ |
|||
public LineRenderer lineRenderer; |
|||
public float density = 2f; //ÃܶÈ
|
|||
public float speed;//ËÙ¶È
|
|||
public Vector3 destination;//Ä¿µÄµØ
|
|||
public LayerMask aimLayerMask; |
|||
private int id = Shader.PropertyToID("_MainTex"); |
|||
private Material material; |
|||
private Vector2 offset = new Vector2(0, 0); |
|||
|
|||
|
|||
private void OnEnable() |
|||
{ |
|||
material = lineRenderer.material; |
|||
|
|||
} |
|||
void Update() |
|||
{ |
|||
Ray ray = Camera.main.ScreenPointToRay(Mouse.current.position.value); |
|||
if (Physics.Raycast(ray, out RaycastHit raycastHit, 500, aimLayerMask.value)) |
|||
{ |
|||
destination = raycastHit.point; |
|||
lineRenderer.SetPosition(0,this.transform.position); |
|||
lineRenderer.SetPosition(1,destination); |
|||
|
|||
float lineLength = (lineRenderer.GetPosition(1) - lineRenderer.GetPosition(0)).magnitude; |
|||
material.SetTextureScale(id, new Vector2(lineLength * density, 0)); |
|||
|
|||
offset -= new Vector2(speed, 0); |
|||
material.SetTextureOffset(id, offset); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
fileFormatVersion: 2 |
|||
guid: d7f89d6a95cea3849b3ea899f72d31c1 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -1,80 +0,0 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.EventSystems; |
|||
using UnityEngine.UI; |
|||
|
|||
public class ServantSkillNode : MonoBehaviour |
|||
{ |
|||
public Servant servant; |
|||
public Servant.ServantSkill servantSkill; |
|||
|
|||
public Collider col; |
|||
public Image image; |
|||
public Button button; |
|||
public Text coolDownText; |
|||
public float speed; |
|||
|
|||
public string atlasPath; |
|||
private void Start() |
|||
{ |
|||
button = GetComponent<Button>(); |
|||
button.onClick.AddListener(PreEffect); |
|||
|
|||
col = GetComponent<BoxCollider>(); |
|||
image = GetComponent<Image>(); |
|||
image.sprite = servantSkill .Icon ; |
|||
} |
|||
|
|||
public void PreEffect() |
|||
{ |
|||
servant.currentSkillInex = servantSkill.effectIndex; |
|||
// servant.SkillePreviewSelector(servantSkill.effectIndex);
|
|||
} |
|||
|
|||
public void UIInUseSkill() |
|||
{ |
|||
col.enabled = false; |
|||
button.enabled = false; |
|||
if(servant .currentSkillInex != servantSkill .effectIndex ) |
|||
{ |
|||
image.color = new Color(128f, 128f, 128f, 0.5f); |
|||
} |
|||
else |
|||
{ |
|||
image.color = new Color(225f, 225f, 225f, 1f); |
|||
} |
|||
} |
|||
public void UIResetUseSkill() |
|||
{ |
|||
col.enabled = true; |
|||
button.enabled = true; |
|||
image.color = new Color(225f, 225f, 225f, 1f); |
|||
//±éÀúÓ°Ïì³Ø±äÉ«
|
|||
servant. CloseStepPreviewInfluencedNode(); |
|||
} |
|||
|
|||
public IEnumerator GoDistination() |
|||
{ |
|||
//int startIndex = servantSkill.effectIndex * servant.pathNodeNum;
|
|||
transform.localPosition = servant.skillUIPos[servant.pathNodeNum-1]; |
|||
for (int i= servant.pathNodeNum; i<(servantSkill.effectIndex+1) * servant.pathNodeNum ; i++) |
|||
{ |
|||
Vector3 startPos = transform.localPosition; |
|||
float time = 0; |
|||
bool go = true; |
|||
while (go) |
|||
{ |
|||
transform.localPosition = Vector3.Lerp(startPos, servant.skillUIPos[i], time += Time.deltaTime * speed); |
|||
|
|||
if (Vector3.Distance(transform.localPosition, servant.skillUIPos[i]) <= 0.01f) |
|||
{ |
|||
transform.localPosition = servant.skillUIPos[i]; |
|||
go = false; |
|||
} |
|||
yield return null; |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
fileFormatVersion: 2 |
|||
guid: dcce6360d5c9e3447b2423e902e0c254 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -1,25 +0,0 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Playables; |
|||
using UnityEngine.UI; |
|||
|
|||
public class ServantUIBar : MonoBehaviour |
|||
{ |
|||
public Image HPBar; |
|||
public Text textCurrentHPdValue; |
|||
public Text textMaxHPValue; |
|||
// public Text stepText;
|
|||
public Text textShieldValue; |
|||
|
|||
private void Update() |
|||
{ |
|||
textCurrentHPdValue.text = GameManager.Instance.servantState.currentHP.ToString(); |
|||
textMaxHPValue.text = GameManager.Instance.servantState.maxHP.ToString(); |
|||
HPBar.fillAmount = GameManager.Instance.servantState.currentHP / GameManager.Instance.servantState.maxHP; |
|||
//stepText.text = GameManager.Instance.playerState.currentStepRange.ToString();
|
|||
textShieldValue.text = GameManager.Instance.servantState.currentShieldValue.ToString(); |
|||
|
|||
|
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
fileFormatVersion: 2 |
|||
guid: dd6e273739b0d53489110c9304a93b01 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -1,18 +0,0 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
public class ServentStateManager : Singleton<ServentStateManager> |
|||
{ |
|||
[Header("使魔数据")] |
|||
//使魔数据
|
|||
public ServantState_SO servantState; |
|||
|
|||
private void Start() |
|||
{ |
|||
|
|||
DontDestroyOnLoad(this.gameObject); |
|||
|
|||
|
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 86c2fab3deda01e4fb16a6d8fbcda640 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
Loading…
Reference in new issue