Merge branch 'main' of http://shu.sheziwanglo.cn:3000/shurongsen/Cute_demon_attacks
This commit is contained in:
commit
b0a0f2425f
File diff suppressed because it is too large
Load Diff
@ -28,8 +28,8 @@ RectTransform:
|
||||
m_GameObject: {fileID: 5560367099341029388}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_LocalScale: {x: 1.5, y: 1.5, z: 1.5}
|
||||
m_ConstrainProportionsScale: 1
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
@ -150,4 +150,4 @@ MonoBehaviour:
|
||||
- {fileID: 1223695407, guid: 8e4ba394e8569844caaefbadd38d117e, type: 3}
|
||||
image: {fileID: 5560367099341029391}
|
||||
Aintime: 40
|
||||
myspritesIndex: 2
|
||||
myspritesIndex: 0
|
||||
|
@ -150,4 +150,4 @@ MonoBehaviour:
|
||||
- {fileID: 2757781, guid: e50b6368d200c5449965f9f59f7c89e9, type: 3}
|
||||
image: {fileID: 5560367099341029391}
|
||||
Aintime: 40
|
||||
myspritesIndex: 2
|
||||
myspritesIndex: 0
|
||||
|
@ -150,4 +150,4 @@ MonoBehaviour:
|
||||
- {fileID: -781113928, guid: 0ade53ff0d572bc4b8185c042acd7d7f, type: 3}
|
||||
image: {fileID: 5560367099341029391}
|
||||
Aintime: 40
|
||||
myspritesIndex: 2
|
||||
myspritesIndex: 0
|
||||
|
@ -24,8 +24,13 @@ public class SpriteAniationpro : MonoBehaviour
|
||||
|
||||
|
||||
private int index=0;
|
||||
private Mysprites mysprites;
|
||||
private Mysprites myspritesAni;
|
||||
// Start is called before the first frame update
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
SetAni(myspritesIndex);
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
if (image==null)
|
||||
@ -35,25 +40,24 @@ public class SpriteAniationpro : MonoBehaviour
|
||||
if (sprites.Count==0)
|
||||
{
|
||||
Debug.LogError("sprites is not");
|
||||
}
|
||||
|
||||
SetAni(myspritesIndex);
|
||||
}
|
||||
|
||||
InvokeRepeating("ainstart", 0f,(Aintime / 1000));
|
||||
}
|
||||
|
||||
|
||||
public void SetAni(int Index)
|
||||
{
|
||||
mysprites = sprites[Index];
|
||||
{
|
||||
Debug.Log("SetAni"+ Index);
|
||||
myspritesAni = sprites[Index];
|
||||
index = 0;
|
||||
}
|
||||
|
||||
void ainstart()
|
||||
{
|
||||
image.overrideSprite = mysprites.mysprites[index];
|
||||
{
|
||||
image.overrideSprite = myspritesAni.mysprites[index];
|
||||
index++;
|
||||
if (index > mysprites.mysprites.Count - 1)
|
||||
if (index > myspritesAni.mysprites.Count - 1)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
@ -62,6 +66,6 @@ public class SpriteAniationpro : MonoBehaviour
|
||||
private void OnDestroy()
|
||||
{
|
||||
sprites = null;
|
||||
mysprites = null;
|
||||
myspritesAni = null;
|
||||
}
|
||||
}
|
||||
|
121
meng_yao/Assets/script/scene_jinshakuang/jskPanel.cs
Normal file
121
meng_yao/Assets/script/scene_jinshakuang/jskPanel.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class jskPanel : mount
|
||||
{
|
||||
|
||||
public static jskPanel instance;
|
||||
public delegate void OnClikeWT(int type, int num);
|
||||
public event OnClikeWT OnType;//点击事件
|
||||
|
||||
public List<Sprite> iconS;
|
||||
|
||||
public List<GameObject> lands = new List<GameObject>();
|
||||
|
||||
public bool Generate1 = false;
|
||||
public bool Generate2 = false;
|
||||
public bool Generate3 = false;
|
||||
public override void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public async void buy_ship()
|
||||
{
|
||||
// Cinemachine_2dCon.SetCameraContorl(false);
|
||||
//Debug.LogError("禁用生成船只逻辑");
|
||||
jishadao_contorl.canClick = false;
|
||||
List<BoxType> boxTypes = new List<BoxType>();
|
||||
int index = 1;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
boxTypes.Add(new BoxType { Name = index.ToString() + "文本", prompt = "第" + ArabicToChineseNumberConverter.ConvertToChineseNumbers(index.ToString()) + "层", Type = 4, is_required = true });
|
||||
boxTypes.Add(new BoxType { Name = "捕鱼" + index.ToString(), prompt = "捕鱼" + 1, Type = 3, goldNumerobj = (200 * index).ToString(), icon = iconS[index - 1] });
|
||||
index++;
|
||||
}
|
||||
|
||||
GameObject gameObject = add_pop_up();
|
||||
gameObject.GetComponent<input_box_pop_up_window>().minHeight = 800;//设置最低高度
|
||||
gameObject.GetComponent<input_box_pop_up_window>().setScrollMode(1);//设置滚动模式为滚动
|
||||
//gameObject.GetComponent<input_box_pop_up_window>().setScrollMode(0);//设置滚动模式为自动填充
|
||||
List<GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, "购买人才");//测试输入框回调处理
|
||||
|
||||
gameObject.GetComponent<input_box_pop_up_window>().OnEnd += () =>
|
||||
{
|
||||
//关闭摄像头逻辑
|
||||
// Cinemachine_2dCon.SetCameraContorl(true);
|
||||
jishadao_contorl.canClick = true;
|
||||
};
|
||||
|
||||
gameObjects[1].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
|
||||
{
|
||||
if (type == 1)
|
||||
{
|
||||
if (!Generate1 && (PlayerManager.Instance.Coins - 200) > 0)
|
||||
{
|
||||
|
||||
lands[0].GetComponent<roomcontroller>().add_fish();
|
||||
PlayerManager.Instance.SetMoney(MoneyType.Coins, -200);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
gameObjects[3].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
|
||||
{
|
||||
if (type == 1)
|
||||
{
|
||||
if (!Generate1 && (PlayerManager.Instance.Coins - 400) > 0)
|
||||
{
|
||||
|
||||
lands[1].GetComponent<roomcontroller>().add_fish();
|
||||
PlayerManager.Instance.SetMoney(MoneyType.Coins, -400);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
gameObjects[5].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
|
||||
{
|
||||
if (type == 1)
|
||||
{
|
||||
if (!Generate1 && (PlayerManager.Instance.Coins - 600) > 0)
|
||||
{
|
||||
lands[2].GetComponent<roomcontroller>().add_fish();
|
||||
PlayerManager.Instance.SetMoney(MoneyType.Coins, -600);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
gameObjects[7].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
|
||||
{
|
||||
if (type == 1)
|
||||
{
|
||||
if (!Generate1 && (PlayerManager.Instance.Coins - 600) > 0)
|
||||
{
|
||||
lands[2].GetComponent<roomcontroller>().add_fish();
|
||||
PlayerManager.Instance.SetMoney(MoneyType.Coins, -600);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
gameObjects[9].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
|
||||
{
|
||||
if (type == 1)
|
||||
{
|
||||
if (!Generate1 && (PlayerManager.Instance.Coins - 600) > 0)
|
||||
{
|
||||
lands[2].GetComponent<roomcontroller>().add_fish();
|
||||
PlayerManager.Instance.SetMoney(MoneyType.Coins, -600);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
11
meng_yao/Assets/script/scene_jinshakuang/jskPanel.cs.meta
Normal file
11
meng_yao/Assets/script/scene_jinshakuang/jskPanel.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11af77df5ea7ca34e920cb4eb096ff39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
323
meng_yao/Assets/script/scene_jinshakuang/roomcontroller.cs
Normal file
323
meng_yao/Assets/script/scene_jinshakuang/roomcontroller.cs
Normal file
@ -0,0 +1,323 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class roomcontroller : MonoBehaviour
|
||||
{
|
||||
[Range(0f, 1f)]
|
||||
public float probabilityOfStand = 0.2f;//站立状态
|
||||
[Header("精灵走路的概率")]
|
||||
[Range(0f, 1f)]
|
||||
public float probabilityOfWalk = 0.3f;//走路状态
|
||||
[Header("精灵挖矿的概率")]
|
||||
[Range(0f, 1f)]
|
||||
public float probabilityOfDig = 0.5f;//挖矿状态
|
||||
[Header("精灵的预制体")]
|
||||
public GameObject fishManPrefab;
|
||||
[Header("购买的精灵数据")]
|
||||
public List<VoucherItem> listItem = new List<VoucherItem>();
|
||||
private GameObject fishMan;//生成的渔船
|
||||
private SpriteAniationpro fishManShipContorl;//渔船的控制器
|
||||
|
||||
[Header("精灵生成点")]
|
||||
public Transform startPos;
|
||||
[Header("精灵终点")]
|
||||
public Transform endPos;
|
||||
|
||||
[Header("房间类型编号")]
|
||||
public int type;
|
||||
|
||||
public float ActivateValue = 0;
|
||||
public int Num = 0;
|
||||
public int Type = 0;
|
||||
|
||||
[Header("精灵路径点集合")]
|
||||
public List<Path> paths;
|
||||
//航行时间
|
||||
[Header("走路时间")]
|
||||
public float pathsNeedTimer = 30f;
|
||||
//捕鱼时间
|
||||
[Header("挖矿时间")]
|
||||
public float fishingNeedTimer = 30f;
|
||||
//休息时间
|
||||
[Header("休息时间")]
|
||||
public float restTimer = 5f;
|
||||
|
||||
|
||||
|
||||
[Header("显示精灵数量")]
|
||||
public Text shipNumberTextPro;
|
||||
|
||||
|
||||
[Header("点击的特效")]
|
||||
public GameObject effectPrefab;//特效
|
||||
|
||||
[Header("点击按钮出现的动画")]
|
||||
public Transform OnBtnAni;
|
||||
|
||||
public float FishPrice;
|
||||
|
||||
public GameObject map;
|
||||
|
||||
|
||||
public static bool canClick = true;
|
||||
|
||||
public List<string> ids = new List<string>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Awake()
|
||||
{
|
||||
listItem = new List<VoucherItem>();
|
||||
UpdateShipNumberTextPro(listItem.Count.ToString());
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
FishPrice = 10;
|
||||
}
|
||||
|
||||
|
||||
async void addman(int type, int number)
|
||||
{
|
||||
if (type == this.type)
|
||||
{
|
||||
GenerateForFisherElf generateForFisherElf = new GenerateForFisherElf(); // 购买渔夫
|
||||
generateForFisherElf.Num = Num;
|
||||
generateForFisherElf.Count = 1;
|
||||
string userponse = await web.SendRequest(web.URL + "/Voucher/GenerateForFisherElf", "POST", JsonUtility.ToJson(generateForFisherElf));
|
||||
ids itemList = JsonUtility.FromJson<ids>(userponse);
|
||||
Debug.Log(itemList.Ids[0]);
|
||||
if (itemList.ErrorCode == 0) // 如果购买成功
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble("购买成功", Color.black, Color.blue);
|
||||
|
||||
/* foreach (string item in itemList.Ids)
|
||||
{
|
||||
Use use = new Use(); // 使用渔夫
|
||||
use.Id = item;
|
||||
string rect = await web.SendRequest(web.URL + "/Voucher/Use", "POST", JsonUtility.ToJson(use));
|
||||
Res res = JsonUtility.FromJson<ids>(userponse);
|
||||
if (res.ErrorCode == 0)
|
||||
{
|
||||
|
||||
Promptmgr.Instance.PromptBubble("购买成功", Color.black, Color.blue);
|
||||
//增加船只数量
|
||||
//ChangeShipNumber(1);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble(res.ErrorMessage, Color.black, Color.red);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
else// 如果购买失败
|
||||
{
|
||||
Res res = JsonUtility.FromJson<ids>(userponse);
|
||||
Promptmgr.Instance.PromptBubble(res.ErrorMessage, Color.black, Color.red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClick()
|
||||
{
|
||||
|
||||
if (!canClick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (fishMan == null)
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble("还没有买精灵!", Color.black, Color.red);
|
||||
return;
|
||||
}
|
||||
|
||||
add_fish();
|
||||
|
||||
}
|
||||
public void add_fish(string timerStr = null)//生成船只
|
||||
{
|
||||
|
||||
if (timerStr != null)
|
||||
{
|
||||
fishMan = GameObject.Instantiate(fishManPrefab, this.transform);
|
||||
fishMan.transform.position = endPos.position;
|
||||
fishManShipContorl = fishMan.GetComponent<SpriteAniationpro>();
|
||||
|
||||
Debug.Log("更新船时间");
|
||||
|
||||
//dig();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
fishMan = GameObject.Instantiate(fishManPrefab, this.transform);
|
||||
fishMan.transform.position = startPos.position;
|
||||
fishManShipContorl = fishMan.GetComponent<SpriteAniationpro>();
|
||||
|
||||
MoveToFishingPos();
|
||||
}
|
||||
void MoveToFishingPos()
|
||||
{
|
||||
|
||||
// 随机选择一条路径
|
||||
Path selectedPath = paths[Random.Range(0, paths.Count)];
|
||||
|
||||
|
||||
// 移动到挖矿点
|
||||
StartCoroutine(MoveToFishingPoint(selectedPath.pathPoints));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
IEnumerator MoveToFishingPoint(List<Transform> path)
|
||||
{
|
||||
// 将路径点转换为 Vector3 数组
|
||||
Vector3[] pathPoints = new Vector3[path.Count];
|
||||
for (int i = 0; i < path.Count; i++)
|
||||
{
|
||||
pathPoints[i] = path[i].position;
|
||||
}
|
||||
|
||||
//改变朝向
|
||||
ChangeShipLook(pathPoints[0], pathPoints[path.Count - 1]);
|
||||
|
||||
|
||||
|
||||
//动作变化,移动
|
||||
fishManShipContorl.SetAni(1);
|
||||
|
||||
// 使用 DOPath 沿着路径移动到捕鱼点,并禁用旋转变化
|
||||
yield return fishMan.transform.DOPath(pathPoints, pathsNeedTimer, PathType.CatmullRom)
|
||||
.SetOptions(false) // 禁用旋转
|
||||
.SetEase(Ease.InOutSine)
|
||||
.WaitForCompletion();
|
||||
//挖矿
|
||||
dig();
|
||||
}
|
||||
|
||||
async void dig()
|
||||
{
|
||||
//动作变化,捕鱼
|
||||
fishManShipContorl.SetAni(2);
|
||||
|
||||
RangNumber();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//根据前后位置改变朝向
|
||||
void ChangeShipLook(Vector3 _startpos, Vector3 _endpos)
|
||||
{
|
||||
if (_startpos.x > _endpos.x)
|
||||
{
|
||||
Debug.Log("朝向左边");
|
||||
fishMan.transform.rotation = Quaternion.Euler(0,180,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("朝向右边");
|
||||
fishMan.transform.rotation = Quaternion.Euler(0, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 随机生成状态
|
||||
void RangNumber()
|
||||
{
|
||||
|
||||
// 计算概率总和并进行归一化
|
||||
float totalProbability = probabilityOfStand + probabilityOfWalk + probabilityOfDig;
|
||||
if (totalProbability != 1f)
|
||||
{
|
||||
probabilityOfStand /= totalProbability;
|
||||
probabilityOfWalk /= totalProbability;
|
||||
probabilityOfDig /= totalProbability;
|
||||
}
|
||||
|
||||
// 根据概率范围随机生成状态
|
||||
float randomValue = Random.value;
|
||||
if (randomValue < probabilityOfStand)
|
||||
{
|
||||
fishManShipContorl.SetAni(0);
|
||||
RangNumber();
|
||||
}
|
||||
else if (randomValue < probabilityOfStand + probabilityOfWalk)
|
||||
{
|
||||
fishManShipContorl.SetAni(1);
|
||||
StartCoroutine(movego());
|
||||
RangNumber();
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(workgo());
|
||||
RangNumber();
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator movego()
|
||||
{
|
||||
float x = Random.Range(startPos.position.x,endPos.position.x);
|
||||
Vector3 newV = new Vector3(x,fishMan.transform.position.y, fishMan.transform.position.z);
|
||||
ChangeShipLook(fishMan.transform.position, newV);
|
||||
fishMan.transform.DOMove(newV,3f);
|
||||
yield return new WaitForSeconds(3f);
|
||||
}
|
||||
|
||||
IEnumerator workgo()
|
||||
{
|
||||
if ((fishMan.transform.position.x - endPos.position.x) < 0.01f)
|
||||
{
|
||||
fishManShipContorl.SetAni(2);
|
||||
yield return new WaitForSeconds(3f);
|
||||
}
|
||||
else
|
||||
{
|
||||
fishMan.transform.DOMove(endPos.position, 3f);
|
||||
yield return new WaitForSeconds(3f);
|
||||
fishManShipContorl.SetAni(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//更新精灵数量显示
|
||||
public void UpdateShipNumberTextPro(string str)
|
||||
{
|
||||
if (shipNumberTextPro.text == str)
|
||||
{
|
||||
return;
|
||||
}
|
||||
shipNumberTextPro.text = str;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//使用代金卷
|
||||
async void UseShip()
|
||||
{
|
||||
Use use = new Use(); // 使用渔夫
|
||||
use.Id = listItem[0].Id;
|
||||
string rect = await web.SendRequest(web.URL + "/Voucher/Use", "POST", JsonUtility.ToJson(use));
|
||||
Res res = JsonUtility.FromJson<ids>(rect);
|
||||
if (res.ErrorCode == 0)
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble("使用成功", Color.black, Color.blue);
|
||||
}
|
||||
else
|
||||
{
|
||||
Promptmgr.Instance.PromptBubble(res.ErrorMessage, Color.black, Color.red);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc4ace221bc630d49ad2cfc1a43e80f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user