
1.编写留言系统 (1.当玩家无Catch的时候,记录长按Y的时间,若时间大于两秒,呼唤UI,触发相应事件 *.编写撰写留言板逻辑 (*.清空操作地图 (1.呼出留言板UI (2.当按下确认键,确认建立一个本地留言板,并初始化该本地留言板,恢复操作地图 (3.将留言板数据传向云端 *.编写留言板逻辑 (1.内含BoardInfo内的信息 (2.继承于可交互物体 (3.当交互,呼出留言板UI,显示内容、UID等信息 (4.当按下返回键,关闭UI *.编写拉取留言板系统 (1.加在开幕演出中,开幕时呼叫sql上的脚本,拉取若干条留言板 (2.在场景内创建留言板,并初始化信息 *.替换和实装美术素材,增加部分动画 1.增加村内上树动画 2.更新村场景,使得玩家可以走到村下 3.制作以撒闪电攻击动画 4.制作以撒冲撞攻击动画 5.制作以撒雕像碎裂动画 6.贴上对话框 7.制作以撒闪电攻击动画 8.制作村民和贵族的待机角色 9.制作特洛伊木马死亡动画 10.制作特洛伊木马的喷射动画 *优化和修复 1.修复佛教前置关掉怪陷阱有时不会触发的问题 2.重做渲染层,避免出现覆盖问题 3.修复玩家会卡在村里桥上的问题 4.解决了屎山代码的warming问题 5.删除了子弹时间,效果太差 建议: 1.给击中添加一些效果,目前还是打击感太弱 2.目前木马死后,灰尘不会消失 *.至此,留言系统全部完成 下班
131 lines
4.3 KiB
C#
131 lines
4.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
using Sirenix.OdinInspector;
|
|
|
|
/// <summary>
|
|
/// 以撒鬼魂类,控制以撒攻击时出现的鬼魂
|
|
/// </summary>
|
|
public class YiSaGoust : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 冲撞将消耗的时间
|
|
/// </summary>
|
|
[Header("冲撞将消耗的时间")]
|
|
public float rushTime;
|
|
private YiSa owner;
|
|
/// <summary>
|
|
/// 落雷的游戏物体
|
|
/// </summary>
|
|
[Header("落雷的游戏物体")][HideInInspector]
|
|
public GameObject lightning;
|
|
|
|
[Header("粒子材质")]
|
|
#pragma warning disable 0108
|
|
public ParticleSystem particleSystem;
|
|
private CapsuleCollider2D capsuleCollider2D;
|
|
public Animator animator;
|
|
void Start(){
|
|
Init();
|
|
}
|
|
private void Init(){
|
|
//找到必要的组件和物体
|
|
animator = GetComponent<Animator>();
|
|
owner = FindObjectOfType<YiSa>();
|
|
capsuleCollider2D = GetComponent<CapsuleCollider2D>();
|
|
//如果落雷没有落雷组件,则添加一个
|
|
lightning = GameObject.Find("落雷").transform.GetChild(0).gameObject;
|
|
if(!lightning.TryGetComponent<Lightning>(out Lightning t))
|
|
lightning.AddComponent<Lightning>();
|
|
}
|
|
public void RushATK(Vector2 rushDir){
|
|
//创建并执行一段冲锋的动画
|
|
capsuleCollider2D.enabled = true;
|
|
Tweener tweener = transform.DOMove(
|
|
transform.position + (Vector3)rushDir * 2,
|
|
rushTime
|
|
);
|
|
tweener.SetEase(Ease.InElastic);
|
|
//结束后,鬼魂逐渐消隐
|
|
TweenCallback action = () => {
|
|
capsuleCollider2D.enabled = false;
|
|
GetComponent<SpriteRenderer>().DOFade(0,1);
|
|
StartCoroutine(SetParticleColor(particleSystem, 0, 1f));
|
|
//消隐结束后删除自己
|
|
Invoke("DestroySelf",1.1f);
|
|
//宣告攻击结束
|
|
owner.ATKEnd();
|
|
};
|
|
tweener.OnStepComplete(action);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 闪电攻击的时候触发
|
|
/// </summary>
|
|
public void LightningATK(){
|
|
//激活落雷
|
|
lightning.SetActive(true);
|
|
//将落雷的X位置改变到鬼魂的X
|
|
lightning.transform.position = new Vector3(
|
|
transform.position.x,
|
|
lightning.transform.position.y,
|
|
lightning.transform.position.z
|
|
);
|
|
//极短的时间后关闭落雷
|
|
Invoke("TurnOffLightning",0.2f);
|
|
//宣告攻击结束
|
|
owner.ATKEnd();
|
|
//淡出鬼魂
|
|
StartCoroutine(SetParticleColor(particleSystem, 0, 1f));
|
|
GetComponent<SpriteRenderer>().DOFade(0,1).OnStepComplete(()=>{
|
|
|
|
//淡出结束后,删除游戏物体
|
|
Destroy(gameObject);
|
|
});
|
|
}
|
|
|
|
private void TurnOffLightning(){lightning.SetActive(false);}
|
|
private void DestroySelf(){Destroy(gameObject);}
|
|
|
|
void OnTriggerEnter2D(Collider2D other)
|
|
{
|
|
//如果创到玩家
|
|
if(other.gameObject.TryGetComponent<MyPlayer>(out MyPlayer player)){
|
|
//告诉玩家,你被攻击了
|
|
player.OnBeHit(owner.ATK,
|
|
((transform.position.x -
|
|
player.transform.position.x)
|
|
> 0) ? 1 : -1);//通过自身位置和玩家位置的比较来返回玩家本次的受击方向
|
|
}
|
|
}
|
|
|
|
private class Lightning : MonoBehaviour
|
|
{
|
|
void OnTriggerStay2D(Collider2D other){
|
|
//如果创到玩家
|
|
if(other.gameObject.TryGetComponent<MyPlayer>(out MyPlayer player)){
|
|
//告诉玩家,你被攻击了
|
|
player.OnBeHit(FindObjectOfType<YiSa>().ATK,
|
|
((transform.position.x -
|
|
player.transform.position.x)
|
|
> 0) ? 1 : -1);//通过自身位置和玩家位置的比较来返回玩家本次的受击方向
|
|
}
|
|
}
|
|
}
|
|
|
|
//修改粒子,使粒子淡出
|
|
private IEnumerator SetParticleColor(ParticleSystem particleSystem,float endValue,float speed)
|
|
{
|
|
#pragma warning disable 0618
|
|
Color color = particleSystem.startColor;
|
|
while (particleSystem.startColor.a>0)
|
|
{
|
|
yield return new WaitForSeconds(speed/255);
|
|
color.a -= 1;
|
|
particleSystem.startColor = color;
|
|
}
|
|
|
|
}
|
|
}
|