Cute_demon_attacks/meng_yao/Assets/communal/mount.cs

292 lines
8.0 KiB
C#
Raw Normal View History

2024-11-02 11:19:48 +08:00
using System;
2024-10-29 16:00:02 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
2024-10-30 18:45:08 +08:00
using Unity.VisualScripting;
2024-10-29 16:00:02 +08:00
using UnityEngine;
2024-11-01 05:26:28 +08:00
using UnityEngine.U2D;
using UnityEngine.UI;
2024-10-30 19:42:59 +08:00
using static UnityEditor.PlayerSettings;
2024-10-30 01:06:46 +08:00
[System.Serializable]
public struct Register
{
public string Phone;
}
2024-10-30 19:42:59 +08:00
public struct AddGold
{
public int Gold;
}
2024-10-30 22:03:04 +08:00
public struct Login
{
public string Phone;
}
2024-10-31 16:50:35 +08:00
public struct GetListByPhone
{
public string Phone;
}
2024-11-02 11:19:48 +08:00
[Serializable]
public class Item//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>item
{
public int Id;
public int Num;
public int Type;
public string Name;
public float ActivateValue;
public float StoreValue;
public float Yield;
public int Limit;
public int EndureTime;
public int RemainEndureTime;
public List<float> ReferrerBouns;
public string CreateDateTime;
}
public class VoucherItem//<2F><><EFBFBD>صĴ<D8B5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
public string Id;
public int Num;
public int Type;
public string OwnerId;
public float ActivateValue;
public float GenerateValue;
public float AlreadyGenerateValue;
public float RemainEndureTime;
public float EndureTime;
public string CreateDateTime;
}
[Serializable]
public class Response : Res//<2F>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
public Item[] List;
}
[Serializable]
public class ResponseVoucher : Res//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
public VoucherItem[] List;
}
[Serializable]
2024-11-02 23:00:54 +08:00
public class GenerateForFisherElf //Ա<><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-02 11:19:48 +08:00
{
public int Num;
public int Count;
}
[Serializable]
public class Use //ʹ<>õ<EFBFBD><C3B5><EFBFBD>
{
public string Id;
}
[Serializable]
public class ids:Res
{
public List<string> Ids;
}
public class Res//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
public int ErrorCode;
public string ErrorMessage;
}
2024-10-31 01:28:14 +08:00
2024-11-01 05:26:28 +08:00
[System.Serializable]
public class ItemData//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>еĵ<D0B5><C4B5>߶<EFBFBD><DFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9>
{
public int Num;
public string Name;
public int Hp;
public float HpUpMul;
public int Attack;
public float AttackUpMul;
public int Defense;
public float DefenseUpMul;
public int AttackSpeed;
public float AttackSpeedUpMul;
public int Move;
public float MoveUpMul;
public int[] Skill;
public int Attribute;
public string LevelUpNeedThingsJson;
public string Expand;
public int Type;
public int Rarity;
public string WeaponBulletEffectPath;
public string WeaponBulletHitEffectPath;
public int UltimateSkill;
public int Access;
public int[] SellDate;
public int Cash;
public float CashDiscount;
public int Gold;
public float GoldDiscount;
public int Gem;
public float GemDiscount;
public int IsSell;
public string IconPath;
public int IconAtlasLocation;
}
2024-10-31 01:28:14 +08:00
2024-11-02 11:19:48 +08:00
2024-10-29 16:00:02 +08:00
public class mount : MonoBehaviour
{
2024-11-01 05:26:28 +08:00
//ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public static Dictionary<string, Sprite> SpriteDic = new Dictionary<string, Sprite>();
public static Dictionary<string, Sprite[]> SpriteSheetDic = new Dictionary<string, Sprite[]>();
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD>߼<EFBFBD><DFBC>ػ<EFBFBD><D8BB><EFBFBD>
public Dictionary<int,ItemData> itemDataList = new Dictionary<int, ItemData>();
// <20><><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC>ͼ<EFBFBD><CDBC><EFBFBD>е<EFBFBD>ij<EFBFBD><C4B3>Sprite<74>ľ<EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
public static Sprite LoadSprite(string path, int index = -1)
{
if (index == -1)
{
// <20><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڸ<EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (SpriteDic.ContainsKey(path))
{
return SpriteDic[path];
}
// <20><>ָ<EFBFBD><D6B8>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Sprite texture = Resources.Load<Sprite>(path);
if (texture != null)
{
// <20><><EFBFBD>سɹ<D8B3><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>
SpriteDic[path] = texture;
return texture;
}
else
{
Debug.LogError("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>" + path);
return null;
}
}
else
{
// <20><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڸ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӵӻ<D3B4><D3BB><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD>
if (SpriteSheetDic.ContainsKey(path))
{
Sprite[] sprites = SpriteSheetDic[path];
if (index >= 0 && index < sprites.Length)
{
return sprites[index];
}
else
{
Debug.LogError("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7>·<EFBFBD><C2B7><EFBFBD><EFBFBD>" + path);
return null;
}
}
2024-11-01 02:27:50 +08:00
2024-11-01 05:26:28 +08:00
// <20><>ָ<EFBFBD><D6B8>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
Sprite[] spriteSheet = Resources.LoadAll<Sprite>(path);
if (spriteSheet != null && spriteSheet.Length > 0)
{
// <20><><EFBFBD>سɹ<D8B3><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>
SpriteSheetDic[path] = spriteSheet;
if (index >= 0 && index < spriteSheet.Length)
{
return spriteSheet[index];
}
else
{
Debug.LogError("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7>·<EFBFBD><C2B7><EFBFBD><EFBFBD>" + path);
return null;
}
}
else
{
Debug.LogError("<22><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ʧ<EFBFBD>ܣ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>" + path);
return null;
}
}
}
void LoadAllJsonFiles()
{
// <20><><EFBFBD><EFBFBD> Resources/json <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD> JSON <20>ļ<EFBFBD>
TextAsset[] jsonFiles = Resources.LoadAll<TextAsset>("json");
foreach (TextAsset jsonFile in jsonFiles)
{
// ʹ<><CAB9> JsonUtility <20><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF> JSON <20>ļ<EFBFBD>
ItemData itemData = JsonUtility.FromJson<ItemData>(jsonFile.text);
itemDataList.Add(itemData.Num, itemData);
}
Debug.Log("<22><>Ʒjson<6F><6E><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
2024-11-01 02:27:50 +08:00
2024-10-30 04:21:58 +08:00
public static mount mountitem;
2024-10-29 16:00:02 +08:00
// Start is called before the first frame update
2024-10-31 13:27:31 +08:00
public virtual void Awake()
2024-10-29 16:00:02 +08:00
{
2024-11-01 05:26:28 +08:00
2024-10-29 16:00:02 +08:00
DontDestroyOnLoad(this);
2024-11-01 05:26:28 +08:00
2024-10-29 20:47:58 +08:00
2024-10-30 04:21:58 +08:00
//mountitem.login_screen();
2024-10-29 20:47:58 +08:00
}
2024-10-31 20:40:09 +08:00
private void Start()
{
2024-11-01 05:26:28 +08:00
mountitem = this;
LoadAllJsonFiles();
//game.GetComponent<Image>().sprite = LoadSprite("animation/miner_new/miner_stand_6",11);
2024-10-31 20:40:09 +08:00
//give_firend();
}
2024-10-30 04:21:58 +08:00
public GameObject add_pop_up(bool is_force = false)//<2F><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>
2024-10-29 20:47:58 +08:00
{
GameObject prefab = Resources.Load<GameObject>("preform/gui/pop_up_ui");
GameObject ranking_list_item = Instantiate(prefab, this.transform);
2024-10-30 04:21:58 +08:00
ranking_list_item.GetComponent<input_box_pop_up_window>().is_force = is_force;
2024-10-29 20:47:58 +08:00
return ranking_list_item;
}
//0 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
//2 ȡ<><C8A1><EFBFBD><EFBFBD>ť ȷ<><C8B7><EFBFBD><EFBFBD>ť
2024-10-30 04:21:58 +08:00
//3 <20><><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>item
//4 <20><><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
2024-10-29 20:47:58 +08:00
public void login_screen()//ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
2024-10-30 03:42:06 +08:00
List<BoxType> boxTypes = new List<BoxType>();
boxTypes.Add(new BoxType { Name = "account_number", textName = " <20>ֻ<EFBFBD><D6BB><EFBFBD>", prompt= "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>", Type = 1, is_required = true });
boxTypes.Add(new BoxType { Name = "verification_code", textName = " <20><>֤<EFBFBD><D6A4> ", prompt = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>", Type = 0, is_required = true });
2024-10-31 20:40:09 +08:00
2024-10-30 03:42:06 +08:00
boxTypes.Add(new BoxType { Name = "submit", textName = " ȡ<><C8A1>ȷ<EFBFBD><C8B7> ",Type = 2});
2024-10-30 04:21:58 +08:00
GameObject gameObject = add_pop_up(true);//<2F><><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>ĸ<EFBFBD><C4B8>
2024-10-30 01:06:46 +08:00
List<GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, <><D7A2>");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
2024-10-29 20:47:58 +08:00
gameObjects[0].GetComponent<input_box_pop_up_window_item>().register_click((BoxType boxType,int type) =>//<2F>ֻ<EFBFBD><D6BB>Ż<EFBFBD>ȡ<EFBFBD><C8A1>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
2024-10-30 01:06:46 +08:00
if (boxType.is_required && string.IsNullOrWhiteSpace(boxType.content)) {
2024-10-29 20:47:58 +08:00
Promptmgr.Instance.PromptBubble("<22>벻Ҫ" + boxType.textName + <><CEAA>");
return; }
Debug.Log("<22><>ȡ<EFBFBD><C8A1>֤<EFBFBD><D6A4>");
});
gameObjects[2].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//<2F><>¼ȷ<C2BC><C8B7><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
{
if (type == 0){
2024-10-30 18:45:08 +08:00
gameObject.GetComponent<input_box_pop_up_window>().destroy();
2024-10-29 20:47:58 +08:00
}
else if (type == 1){
2024-10-30 01:06:46 +08:00
Register register = new Register();
register.Phone = boxTypes[0].content;
//register.Code = boxTypes[0].content;
2024-10-30 01:06:46 +08:00
string jsonString = JsonUtility.ToJson(register);
2024-10-30 03:42:06 +08:00
string response = await web.SendRequest("http://47.109.133.52/Player/Register", "POST", jsonString);
2024-10-29 20:47:58 +08:00
Debug.Log(response);
}
});
2024-10-30 03:42:06 +08:00
}
2024-10-30 19:42:59 +08:00
2024-10-30 04:46:20 +08:00
2024-10-29 16:00:02 +08:00
}