备份CatanBuilding瘦身独立工程
This commit is contained in:
10
Assets/Scripts/SandDig/GameScript/BroadItem.cs
Normal file
10
Assets/Scripts/SandDig/GameScript/BroadItem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class BroadItem : MonoBehaviour
|
||||
{
|
||||
public BroadData Data { get; set; }
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/BroadItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/BroadItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d566f746e59488297aa129450b536f0
|
||||
timeCreated: 1723866882
|
||||
8
Assets/Scripts/SandDig/GameScript/DgSandBg.cs
Normal file
8
Assets/Scripts/SandDig/GameScript/DgSandBg.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DgSandBg : MonoBehaviour
|
||||
{
|
||||
public GameObject DgSand_bgend;
|
||||
}
|
||||
11
Assets/Scripts/SandDig/GameScript/DgSandBg.cs.meta
Normal file
11
Assets/Scripts/SandDig/GameScript/DgSandBg.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e4560b2d8650954bac0c77068c3538d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
304
Assets/Scripts/SandDig/GameScript/GridItem.cs
Normal file
304
Assets/Scripts/SandDig/GameScript/GridItem.cs
Normal file
@@ -0,0 +1,304 @@
|
||||
using System.Collections;
|
||||
using System.Threading.Tasks;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class GridItem : MonoBehaviour
|
||||
{
|
||||
|
||||
public GridData Data { get; set; }
|
||||
public GridEffectType GridEffectType { get; set; }
|
||||
GridEffectType Passive;
|
||||
private LayerMask _clickableLayer;
|
||||
|
||||
private GameObject _baseObj;
|
||||
private Animation _baseAni;
|
||||
|
||||
Transform fx_root;
|
||||
|
||||
/// <summary>
|
||||
/// 两个mesh 用来处理 点击两次的情况
|
||||
/// </summary>
|
||||
private GameObject _mesh1;
|
||||
private GameObject _mesh2;
|
||||
|
||||
private string[] _moveEffectNames = new string[] { "gridshake1", "gridshake2", "gridshake3" };
|
||||
private string _moveEffctName = string.Empty;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_clickableLayer = LayerMask.GetMask("Default");
|
||||
|
||||
_baseObj = transform.Find("AnimationRoot")?.gameObject;
|
||||
|
||||
if (_baseObj)
|
||||
{
|
||||
_mesh1 = _baseObj.FindChildGameObject("Mesh1");
|
||||
_mesh2 = _baseObj.FindChildGameObject("Mesh2");
|
||||
}
|
||||
|
||||
_baseAni = this.GetComponent<Animation>();
|
||||
|
||||
fx_root = transform.Find("fx_root");
|
||||
if (fx_root != null)
|
||||
{
|
||||
fx_root.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
SetMash(GridMeshType.Mesh1);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Data != null && Data.IsOpen == false && Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, Mathf.Infinity, _clickableLayer))
|
||||
{
|
||||
if (hit.collider.gameObject == gameObject)
|
||||
{
|
||||
OnClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 这个方法会被 overlay 相机影响
|
||||
// private void OnMouseDown()
|
||||
// {
|
||||
// DiggingGameManager.LogError("x::" + Data.Row + " y::" + Data.Col + " Data.IsBorder::" + Data.IsBorder);
|
||||
// OnClick();
|
||||
// }
|
||||
|
||||
public async void OnClick()
|
||||
{
|
||||
DiggingGameManager diggingGameManager = GContext.container.Resolve<DiggingGameManager>();
|
||||
if (diggingGameManager.GameState != SandDigGameState.Going)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!diggingGameManager.IsCanClick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int digCount = diggingGameManager.DataModel.GetDigCount();
|
||||
|
||||
if (digCount <= 0)
|
||||
{
|
||||
int propId = diggingGameManager.GetActivityPropId();
|
||||
if (propId > 0)
|
||||
{
|
||||
cfg.Item item = GContext.container.Resolve<Tables>().GetItemData(propId);
|
||||
string itemName = LocalizationMgr.GetText(item.Name_l10n_key);
|
||||
ToastPanel.Show(LocalizationMgr.GetFormatTextValue("UI_ToastPanel_75", itemName));
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
diggingGameManager.DataModel.UseDig();
|
||||
}
|
||||
if (!Data.IsBorder)
|
||||
{
|
||||
diggingGameManager.IsCanClick = false;
|
||||
if (Data.DoubleClick && Data.hasClickCount < 1)
|
||||
{
|
||||
int level = diggingGameManager.GetCurLevel();
|
||||
int clickCount = diggingGameManager.DataModel.GetClickCount();
|
||||
diggingGameManager.SandDigPoint(GridType.None, level, clickCount);
|
||||
Data.IsOpen = false;
|
||||
Data.hasClickCount++;
|
||||
Passive = GridEffectType.DoubleClick;
|
||||
|
||||
GridEffectType = GridEffectType.DoubleClick;
|
||||
|
||||
diggingGameManager.DataModel.SaveAll();
|
||||
|
||||
diggingGameManager.ShowDigEffect(ClickDigType.Smail, Data.LocalPos);
|
||||
|
||||
PlayEffect();
|
||||
await Task.Delay(SandDigEventConst.ShovelAnimTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.IsOpen = true;
|
||||
EventGridClick eventGridClick = new EventGridClick(Data, false);
|
||||
GContext.Publish(eventGridClick);
|
||||
bool isBig = eventGridClick.IsBigDig;
|
||||
//DiggingGameManager.LogError("大挖不:::" + isBig);
|
||||
GridEffectType = isBig ? GridEffectType.ClickBigDig : GridEffectType.ClickDig;
|
||||
PlayEffect();
|
||||
if (isBig)
|
||||
await Task.Delay(SandDigEventConst.BigShovelAnimTime);
|
||||
else
|
||||
await Task.Delay(SandDigEventConst.ShovelAnimTime);
|
||||
if (isBig)
|
||||
{
|
||||
await Task.Delay(2000);
|
||||
}
|
||||
}
|
||||
diggingGameManager.IsCanClick = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 被动爆炸 触发点击
|
||||
/// </summary>
|
||||
public void PassiveClick()
|
||||
{
|
||||
if (gameObject.activeSelf && !Data.IsBorder)
|
||||
{
|
||||
if (Data.DoubleClick && Data.hasClickCount < 1)
|
||||
{
|
||||
Data.IsOpen = false;
|
||||
Data.hasClickCount++;
|
||||
Passive = GridEffectType;
|
||||
GridEffectType = GridEffectType.DoubleClick;
|
||||
PlayEffect();
|
||||
GContext.container.Resolve<DiggingGameManager>().DataModel.SaveAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.IsOpen = true;
|
||||
PlayEffect();
|
||||
GContext.Publish(new EventGridClick(Data, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayPassClampEffect()
|
||||
{
|
||||
GridEffectType = GridEffectType.PassClamp;
|
||||
PlayEffect();
|
||||
}
|
||||
|
||||
private void PlayEffect()
|
||||
{
|
||||
StartCoroutine(IEPlayEffect());
|
||||
}
|
||||
// public const int BigShovelEffectTime = 833;//特效出现延迟
|
||||
//public const int BigShovelBlockAnimTime = 866;//块消失动画播放时间
|
||||
//public const int BigShovelBlockDisappearTime = 1133;//块消失时间
|
||||
IEnumerator PlayBigEffect(int EffectTime)
|
||||
{
|
||||
yield return new WaitForSeconds(EffectTime * 0.001f);
|
||||
fx_root.gameObject.SetActive(true);
|
||||
}
|
||||
IEnumerator PlayBigAni(int BigShovelBlockAnimTime)
|
||||
{
|
||||
yield return new WaitForSeconds(BigShovelBlockAnimTime * 0.001f);
|
||||
_baseAni?.Play("griddisappear");
|
||||
}
|
||||
IEnumerator IEPlayEffect()
|
||||
{
|
||||
DiggingGameManager diggingGameManager = GContext.container.Resolve<DiggingGameManager>();
|
||||
var configInit = diggingGameManager.DataModel.digActivityConfig;
|
||||
if (GridEffectType == GridEffectType.ClickDig)
|
||||
{
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
//普通挖掘效果
|
||||
StartCoroutine(PlayBigEffect(SandDigEventConst.ShovelEffectTime));
|
||||
StartCoroutine(PlayBigAni(SandDigEventConst.ShovelBlockAnimTime));
|
||||
|
||||
//_digEffect.SetActive(true);
|
||||
//SetMash(GridMeshType.None);
|
||||
yield return new WaitForSeconds(SandDigEventConst.ShovelBlockDisappearTime * 0.001f);
|
||||
//_digEffect.SetActive(false);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
else if (GridEffectType == GridEffectType.ClickBigDig)
|
||||
{
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
//挖到了道具的特殊特效
|
||||
StartCoroutine(PlayBigEffect(SandDigEventConst.BigShovelEffectTime));
|
||||
StartCoroutine(PlayBigAni(SandDigEventConst.BigShovelBlockAnimTime));
|
||||
yield return new WaitForSeconds(SandDigEventConst.BigShovelBlockDisappearTime * 0.001f);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
else if (GridEffectType == GridEffectType.DoubleClick)
|
||||
{
|
||||
//挖两次才能打开的格子特效
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
float time = SandDigEventConst.ShovelEffectTime * 0.001f;
|
||||
if (Passive == GridEffectType.PassiveBomb)
|
||||
{
|
||||
time = configInit.BombBlockAniTime;
|
||||
}
|
||||
else if (Passive == GridEffectType.PassiveClear)
|
||||
{
|
||||
time = configInit.BombBlockAniTime;
|
||||
}
|
||||
yield return new WaitForSeconds(time);
|
||||
fx_root.gameObject.SetActive(true);
|
||||
SetMash(GridMeshType.Mesh2);
|
||||
yield return new WaitForSeconds(1);
|
||||
fx_root.gameObject.SetActive(false);
|
||||
}
|
||||
else if (GridEffectType == GridEffectType.PassiveBomb)
|
||||
{
|
||||
yield return new WaitForSeconds(configInit.BombBlockAniTime);
|
||||
//随机晃动
|
||||
System.Random random = new System.Random();
|
||||
int randomNumber = random.Next(0, _moveEffectNames.Length);
|
||||
_moveEffctName = _moveEffectNames[randomNumber];
|
||||
_baseAni?.Play(_moveEffctName);
|
||||
//yield return new WaitForSeconds(1);
|
||||
//特效触发
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
fx_root.gameObject.SetActive(true);
|
||||
//SetMash(GridMeshType.None);
|
||||
yield return new WaitForSeconds(SandDigEventConst.BombBlockDisappearTime * 0.001f);
|
||||
_baseAni.Stop();
|
||||
fx_root.gameObject.SetActive(false);
|
||||
gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
else if (GridEffectType == GridEffectType.PassiveClear)
|
||||
{
|
||||
yield return new WaitForSeconds(configInit.ClearBlockAniTime);
|
||||
//随机晃动
|
||||
System.Random random = new System.Random();
|
||||
int randomNumber = random.Next(0, _moveEffectNames.Length);
|
||||
_moveEffctName = _moveEffectNames[randomNumber];
|
||||
_baseAni?.Play(_moveEffctName);
|
||||
//特效触发
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
fx_root.gameObject.SetActive(true);
|
||||
//SetMash(GridMeshType.None);
|
||||
yield return new WaitForSeconds(SandDigEventConst.ClearBlockDisappearTime * 0.001f);
|
||||
_baseAni.Stop();
|
||||
fx_root.gameObject.SetActive(false);
|
||||
gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
else if (GridEffectType == GridEffectType.PassClamp)
|
||||
{
|
||||
//挖通关了 ,清屏
|
||||
diggingGameManager.ShowFX(GridEffectType, fx_root);
|
||||
fx_root.gameObject.SetActive(true);
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMash(GridMeshType type)
|
||||
{
|
||||
_mesh1?.SetActive(false);
|
||||
_mesh2?.SetActive(false);
|
||||
if (type == GridMeshType.Mesh1)
|
||||
{
|
||||
_mesh1?.SetActive(true);
|
||||
}
|
||||
else if (type == GridMeshType.Mesh2)
|
||||
{
|
||||
_mesh2?.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/GridItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/GridItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 405c66376b2f4e8a9fbc9fc8e7bef9c6
|
||||
timeCreated: 1723805058
|
||||
175
Assets/Scripts/SandDig/GameScript/GridPropItem.cs
Normal file
175
Assets/Scripts/SandDig/GameScript/GridPropItem.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using Script.RuntimeScript.Interface;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class GridPropItem : MonoBehaviour, BroadEffectInterface
|
||||
{
|
||||
public int PlayEffectPriority { set; get; } = 1;
|
||||
/// <summary>
|
||||
/// 飞行动画
|
||||
/// </summary>
|
||||
private MoveWithCurve _effectScript;
|
||||
/// <summary>
|
||||
/// 展示动画
|
||||
/// </summary>
|
||||
private Animation _showEffect;
|
||||
GameObject DgSand;
|
||||
GameObject DgSandShadow;
|
||||
Transform fx_diggingitem_drop;
|
||||
public DiggingItemProp EffectType { get; set; }
|
||||
private GridPropData _data;
|
||||
Vector3 PositionRootLocalPos;
|
||||
public GridPropData Data
|
||||
{
|
||||
get { return _data; }
|
||||
set
|
||||
{
|
||||
_data = value;
|
||||
EffectType = _data.Config.DiggingType;
|
||||
}
|
||||
}
|
||||
bool isNormal = true;
|
||||
public async void Init(GridPropData data, float time)
|
||||
{
|
||||
Data = data;
|
||||
isNormal = EffectType is Normal;
|
||||
_effectScript = this.gameObject.GetComponent<MoveWithCurve>();
|
||||
PositionRootLocalPos = transform.Find("PositionRoot").localPosition;
|
||||
Transform animationRoot = transform.Find("PositionRoot/AnimationRoot");
|
||||
_showEffect = animationRoot.GetComponent<Animation>();
|
||||
if (isNormal)
|
||||
{
|
||||
DgSand = animationRoot.GetChild(0).gameObject;
|
||||
DgSandShadow = animationRoot.GetChild(1).gameObject;
|
||||
|
||||
fx_diggingitem_drop = animationRoot.Find("fx_diggingitem_drop");
|
||||
if (fx_diggingitem_drop != null)
|
||||
{
|
||||
fx_diggingitem_drop.localScale = Vector3.one * Data.Config.ItemFxScale;
|
||||
}
|
||||
SetShowShadow(true);
|
||||
if (_showEffect != null)
|
||||
{
|
||||
_showEffect.transform.localScale = Vector3.zero;
|
||||
await Awaiters.Seconds(time);
|
||||
_showEffect?.Play("propshow");
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetShowShadow(bool value)
|
||||
{
|
||||
if (isNormal)
|
||||
{
|
||||
DgSand.SetActive(!value);
|
||||
DgSandShadow.SetActive(value);
|
||||
}
|
||||
}
|
||||
public async void PlayEffect(bool overCheck)
|
||||
{
|
||||
int upDelay = SandDigEventConst.UpDelay;
|
||||
if (overCheck)
|
||||
{
|
||||
upDelay = SandDigEventConst.InUpDelay;
|
||||
}
|
||||
await System.Threading.Tasks.Task.Delay(upDelay);
|
||||
if (EffectType is Normal)
|
||||
{
|
||||
SetShowShadow(false);
|
||||
PlayNormalEffect(PlayNormalPropFly);
|
||||
}
|
||||
else if (EffectType is Resource)
|
||||
{
|
||||
PlayResourceEffect(PlayResourcePropFly);
|
||||
}
|
||||
}
|
||||
|
||||
private async void PlayNormalPropFly()
|
||||
{
|
||||
_showEffect?.Play("propshake");
|
||||
DiggingGameManager diggingGameManager = GContext.container.Resolve<DiggingGameManager>();
|
||||
diggingGameManager.ShowFX(Data.Config.Fx, false);
|
||||
diggingGameManager.ShowFX(Data.Config.Fx, true);
|
||||
await System.Threading.Tasks.Task.Delay(SandDigEventConst.UpWaitTime + SandDigEventConst.ShovelEffectTime);
|
||||
|
||||
if (Data.TargetPropItem == null)
|
||||
{
|
||||
DiggingGameManager.LogWarning("没找到目标 ,原地消失");
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
_effectScript.SetStartPosition(_effectScript.transform.position);
|
||||
_effectScript.EndPoint = Data.TargetPropItem.transform.position;
|
||||
//_effectScript.EndPoint.z += SandDigEventConst.TargetPropOffsetZ;
|
||||
_effectScript.Begin(() =>
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_itemdrop"));
|
||||
//隐藏目标道具
|
||||
Data.TargetPropItem.gameObject.SetActive(false);
|
||||
if (fx_diggingitem_drop != null)
|
||||
{
|
||||
fx_diggingitem_drop.gameObject.SetActive(true);
|
||||
}
|
||||
PropSparkItem propSparkItem = gameObject.AddComponent<PropSparkItem>();
|
||||
propSparkItem.Init(Data.Config.ItemFxScale);
|
||||
GContext.Publish(new GridPropEffectOver(Data.PropId, true));
|
||||
});
|
||||
this.transform.DOScale(SandDigEventConst.GetScale, 0.5f);
|
||||
}
|
||||
|
||||
private async void PlayResourcePropFly()
|
||||
{
|
||||
_showEffect?.Play("scale");
|
||||
await System.Threading.Tasks.Task.Delay(SandDigEventConst.ResourceEffectTime + SandDigEventConst.ShovelEffectTime);
|
||||
|
||||
this.gameObject.SetActive(false);
|
||||
GContext.Publish(new GridPropEffectOver(Data.PropId, true));
|
||||
|
||||
Vector3 worldPosition = this.transform.position;
|
||||
Vector3 screenPosition = ConvertTools.WorldToScreenPoint(worldPosition);
|
||||
screenPosition.z = 0;
|
||||
|
||||
Resource res = (EffectType as Resource);
|
||||
DiggingGameManager.LogError("添加道具:" + res.ItemID + " count:" + res.Param + " pos::" + screenPosition.ToString());
|
||||
GContext.Publish(new EventSandDigAddItem(res.ItemID, res.Param, screenPosition));
|
||||
}
|
||||
|
||||
|
||||
private void PlayNormalEffect(Action effectOver)
|
||||
{
|
||||
this.transform.DORotate(new Vector3(0, 0, 0), SandDigEventConst.UpTime)
|
||||
.SetLoops(-1, LoopType.Incremental)
|
||||
.SetEase(Ease.Linear);
|
||||
|
||||
Vector3 targetPositon = GContext.container.Resolve<DiggingGameManager>().ShowPropPositon.transform.position;
|
||||
Vector3 toPostion = new Vector3(targetPositon.x, targetPositon.y, SandDigEventConst.UpValue);
|
||||
Vector3 offstPosition = PositionRootLocalPos;
|
||||
offstPosition.x *= SandDigEventConst.UpScale;
|
||||
offstPosition.y *= SandDigEventConst.UpScale;
|
||||
offstPosition.z = 0;
|
||||
toPostion -= offstPosition;
|
||||
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_itemfly"));
|
||||
|
||||
this.transform.DOMove(toPostion, SandDigEventConst.UpTime).OnComplete(() =>
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_itemshake"));
|
||||
this.transform.DOKill(); // 停止旋转动画
|
||||
this.transform.rotation = Quaternion.identity; // 角度变为0
|
||||
effectOver.Invoke();
|
||||
}).SetId(this);
|
||||
this.transform.DOScale(new Vector3(SandDigEventConst.UpScale, SandDigEventConst.UpScale, SandDigEventConst.UpScale), SandDigEventConst.UpTime);
|
||||
}
|
||||
|
||||
private void PlayResourceEffect(Action effectOver)
|
||||
{
|
||||
effectOver.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/GridPropItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/GridPropItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ae4a1cbefb74d4c82d94e70d85d5f5e
|
||||
timeCreated: 1723895712
|
||||
78
Assets/Scripts/SandDig/GameScript/MoveWithCurve.cs
Normal file
78
Assets/Scripts/SandDig/GameScript/MoveWithCurve.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveWithCurve : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public Vector3 EndPoint = new Vector3();
|
||||
[Tooltip("x轴路线形状 起始和结尾 点值必须为0")]
|
||||
public AnimationCurve CurveX;
|
||||
[Tooltip("y轴路线形状 起始和结尾 点值必须为0")]
|
||||
public AnimationCurve CurveY;
|
||||
[Tooltip("z轴路线形状 起始和结尾 点值必须为0")]
|
||||
public AnimationCurve CurveZ;
|
||||
[Tooltip("y轴运动速度 结尾点值必须为1")]
|
||||
public AnimationCurve CurveSpeedY;
|
||||
[Tooltip("z轴运动速度 结尾点值必须为1")]
|
||||
public AnimationCurve CurveSpeedZ;
|
||||
[Tooltip("弧度缩放系数")]
|
||||
public float RadianScale = 1f;
|
||||
|
||||
private float _duration = 0.5f;
|
||||
private float _elapsedTime = 0f;
|
||||
private Vector3 _startPoint = Vector3.zero;
|
||||
|
||||
private bool _begin = false;
|
||||
private Action _effectOver;
|
||||
|
||||
public void Begin(Action callBack)
|
||||
{
|
||||
_begin = true;
|
||||
_elapsedTime = 0;
|
||||
_effectOver = callBack;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
if (CurveX.length > 0)
|
||||
{
|
||||
float startTime = CurveX.keys[0].time;
|
||||
float endTime = CurveX.keys[CurveX.length - 1].time;
|
||||
_duration = endTime - startTime;
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
public void SetStartPosition(Vector3 value)
|
||||
{
|
||||
_startPoint = value;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!_begin) return;
|
||||
_elapsedTime += Time.deltaTime;
|
||||
if (_elapsedTime > _duration)
|
||||
{
|
||||
_elapsedTime = _duration;
|
||||
_begin = false;
|
||||
_effectOver?.Invoke();
|
||||
}
|
||||
|
||||
Vector3 l = Vector3.Lerp(_startPoint, EndPoint, _elapsedTime/_duration);
|
||||
float speedY = CurveSpeedY != null?CurveSpeedY.Evaluate(_elapsedTime):1;
|
||||
float speedZ = CurveSpeedZ != null?CurveSpeedZ.Evaluate(_elapsedTime):1;
|
||||
// 使用曲线计算位置
|
||||
|
||||
float newX = CurveX.Evaluate(_elapsedTime) * RadianScale + l.x;
|
||||
float newY = CurveY.Evaluate(_elapsedTime) * RadianScale * speedY + l.y;
|
||||
float newZ = CurveZ.Evaluate(_elapsedTime) * RadianScale * speedZ + l.z;
|
||||
transform.position = new Vector3(newX, newY, newZ);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
Assets/Scripts/SandDig/GameScript/MoveWithCurve.cs.meta
Normal file
11
Assets/Scripts/SandDig/GameScript/MoveWithCurve.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0eee85decfac6d54ab44d0b613ce8308
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Scripts/SandDig/GameScript/PropBoxItem.cs
Normal file
33
Assets/Scripts/SandDig/GameScript/PropBoxItem.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using asap.core;
|
||||
using Game;
|
||||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class PropBoxItem : MonoBehaviour
|
||||
{
|
||||
public GameObject fx_diggingbox_finish;
|
||||
IDisposable disposable;
|
||||
private void OnEnable()
|
||||
{
|
||||
disposable = GContext.OnEvent<EventSandDigNewClamp>().Subscribe(OnPassClamp);
|
||||
}
|
||||
private void OnPassClamp(EventSandDigNewClamp obj)
|
||||
{
|
||||
//if (transform.childCount > 0)
|
||||
//{
|
||||
// fx_diggingbox_finish = transform.GetChild(0).gameObject;
|
||||
fx_diggingbox_finish?.SetActive(false);
|
||||
fx_diggingbox_finish?.SetActive(true);
|
||||
//}
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_itemfinish"));
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/PropBoxItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/PropBoxItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df38683d1998f6d4988725f7723d5b04
|
||||
timeCreated: 1723805031
|
||||
10
Assets/Scripts/SandDig/GameScript/PropItem.cs
Normal file
10
Assets/Scripts/SandDig/GameScript/PropItem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class PropItem : MonoBehaviour
|
||||
{
|
||||
public PropData Data { get; set; }
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/PropItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/PropItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dfab24de1004add865226887084c530
|
||||
timeCreated: 1723805031
|
||||
39
Assets/Scripts/SandDig/GameScript/PropSparkItem.cs
Normal file
39
Assets/Scripts/SandDig/GameScript/PropSparkItem.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class PropSparkItem : MonoBehaviour
|
||||
{
|
||||
Transform fx_diggingitem_spark;
|
||||
private void Awake()
|
||||
{
|
||||
fx_diggingitem_spark = transform.Find("PositionRoot/AnimationRoot/fx_diggingitem_spark");
|
||||
}
|
||||
|
||||
public void Init(float ItemFxScale)
|
||||
{
|
||||
if (fx_diggingitem_spark)
|
||||
{
|
||||
fx_diggingitem_spark.localScale = Vector3.one * ItemFxScale;
|
||||
StartCoroutine(PlaySpark());
|
||||
}
|
||||
}
|
||||
IEnumerator PlaySpark()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
int seconds = Random.Range(2, 4);
|
||||
yield return new WaitForSeconds(seconds);
|
||||
fx_diggingitem_spark.gameObject.SetActive(true);
|
||||
seconds = Random.Range(2, 4);
|
||||
yield return new WaitForSeconds(seconds);
|
||||
fx_diggingitem_spark.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/GameScript/PropSparkItem.cs.meta
Normal file
3
Assets/Scripts/SandDig/GameScript/PropSparkItem.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 949a91166c4618d46803fd57e45eb0f7
|
||||
timeCreated: 1723805031
|
||||
81
Assets/Scripts/SandDig/GameScript/SpecialEventItem.cs
Normal file
81
Assets/Scripts/SandDig/GameScript/SpecialEventItem.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using Game;
|
||||
using Script.RuntimeScript.Interface;
|
||||
using Script.RuntimeScript.model.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.GameLogic
|
||||
{
|
||||
public class SpecialEventItem : MonoBehaviour, BroadEffectInterface
|
||||
{
|
||||
public int PlayEffectPriority { set; get; } = 0;
|
||||
public GridPropData Data { get; set; }
|
||||
|
||||
private Animation _ani;
|
||||
GameObject animationRoot;
|
||||
GameObject dgSand_sandpit;
|
||||
private void Awake()
|
||||
{
|
||||
animationRoot = this.transform.Find("AnimationRoot").gameObject;
|
||||
dgSand_sandpit = this.transform.Find("SandpitRoot").gameObject;
|
||||
}
|
||||
public void Start()
|
||||
{
|
||||
dgSand_sandpit.SetActive(false);
|
||||
animationRoot.SetActive(false);
|
||||
this.gameObject.SetActive(true);
|
||||
}
|
||||
public void ShowSandpit()
|
||||
{
|
||||
dgSand_sandpit.SetActive(true);
|
||||
}
|
||||
public async void PlayEffect(bool overCheck)
|
||||
{
|
||||
int upDelay = SandDigEventConst.BigShovelAnimTime;
|
||||
if (overCheck)
|
||||
{
|
||||
upDelay = SandDigEventConst.InUpDelay;
|
||||
}
|
||||
await System.Threading.Tasks.Task.Delay(upDelay);
|
||||
animationRoot.SetActive(true);
|
||||
if (_ani == null)
|
||||
{
|
||||
_ani = animationRoot.GetComponent<Animation>();
|
||||
}
|
||||
string effectName = string.Empty;
|
||||
DiggingGameManager diggingGameManager = GContext.container.Resolve<DiggingGameManager>();
|
||||
var configInit = diggingGameManager.DataModel.digActivityConfig;
|
||||
float time = configInit.SpecRowColAniTime;
|
||||
if (Data.Config.DiggingType is BombClear)
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_starfish"));
|
||||
effectName = (Data.Config.DiggingType as BombClear).AppearAnim;
|
||||
//time = SandDigEventConst.BombAnimTime;
|
||||
time = configInit.SpecBombAniTime;
|
||||
}
|
||||
else if (Data.Config.DiggingType is ColumnClear)
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_crab"));
|
||||
effectName = (Data.Config.DiggingType as ColumnClear).AppearAnim;
|
||||
}
|
||||
else if (Data.Config.DiggingType is RowClear)
|
||||
{
|
||||
GContext.Publish(new EventUISound("audio_ui_sanddig_crab"));
|
||||
effectName = (Data.Config.DiggingType as RowClear).AppearAnim;
|
||||
}
|
||||
else
|
||||
{
|
||||
DiggingGameManager.LogWarning("特殊事件没有配置动画,请检查!");
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
GContext.Publish(new ExplosionClick(this));
|
||||
if (!string.IsNullOrEmpty(effectName))
|
||||
{
|
||||
_ani.Play(effectName);
|
||||
await Awaiters.Seconds(time);
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd301704dc534d62ba8eb9d1df7834a4
|
||||
timeCreated: 1723805107
|
||||
Reference in New Issue
Block a user