Compare commits
No commits in common. "master" and "v0.1.0_android" have entirely different histories.
master
...
v0.1.0_and
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c41a7273e266a0468c52d3a52652dbd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,195 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BFEditor.Build
|
||||
{
|
||||
public class CompareAssetBundleWindow : EditorWindow
|
||||
{
|
||||
private string newestABPath = "";
|
||||
private string lastABPath = "";
|
||||
public bool IsAndroid = true;
|
||||
private List<string> ABList = new List<string>();
|
||||
Vector2 resultScrollPos;
|
||||
public CompareAssetBundleWindow()
|
||||
{
|
||||
titleContent = new GUIContent("AssetBundle对比");
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
GetNewestABPath();
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUILayout.Space(18);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("当前版本AB路径");
|
||||
GUILayout.TextField(newestABPath, GUILayout.Width(600));
|
||||
if (GUILayout.Button("选择", GUILayout.Width(80)))
|
||||
{
|
||||
string openPath = EditorUtility.OpenFolderPanel("select ab path", newestABPath, "");
|
||||
if (openPath.CompareTo("") != 0){
|
||||
newestABPath = openPath;
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(10);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("上个版本AB路径");
|
||||
GUILayout.TextField(lastABPath, GUILayout.Width(600));
|
||||
if (GUILayout.Button("选择", GUILayout.Width(80)))
|
||||
{
|
||||
string openPath = EditorUtility.OpenFolderPanel("select ab path", lastABPath, "");
|
||||
if (openPath.CompareTo("") != 0){
|
||||
lastABPath = openPath;
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(10);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(150);
|
||||
if (GUILayout.Button("对比", GUILayout.Width(200), GUILayout.Height(40)))
|
||||
{
|
||||
CheckMD5AndAssetHash();
|
||||
}
|
||||
|
||||
GUILayout.Space(100);
|
||||
if (GUILayout.Button("使用上个版本的AB修复", GUILayout.Width(200), GUILayout.Height(40)))
|
||||
{
|
||||
UseLastABFix();
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(30);
|
||||
|
||||
DrawResult();
|
||||
}
|
||||
|
||||
private void DrawResult()
|
||||
{
|
||||
resultScrollPos = GUILayout.BeginScrollView(resultScrollPos, GUILayout.Width(800), GUILayout.Height(620));
|
||||
for (int i = ABList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var path = ABList[i];
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(20);
|
||||
EditorGUILayout.TextField(path);
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
private void CheckMD5AndAssetHash()
|
||||
{
|
||||
if (string.IsNullOrEmpty(newestABPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(lastABPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
ABList.Clear();
|
||||
var manifestPath = System.IO.Path.Combine(newestABPath, "asset_bundle_manifest.ab");
|
||||
var manifestAB = AssetBundle.LoadFromFile(manifestPath);
|
||||
var Manifest = manifestAB.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
|
||||
manifestAB.Unload(false);
|
||||
|
||||
var lastManifestPath = System.IO.Path.Combine(lastABPath, "asset_bundle_manifest.ab");
|
||||
var lastManifestAB = AssetBundle.LoadFromFile(lastManifestPath);
|
||||
var lastManifest = lastManifestAB.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
|
||||
lastManifestAB.Unload(false);
|
||||
|
||||
var allAB = Manifest.GetAllAssetBundles();
|
||||
foreach(var path in allAB)
|
||||
{
|
||||
if (path.Contains("ab_config.bytes") || path.Contains("asset_bundle_manifest.ab"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var fullPathA = Path.Combine(newestABPath, path);
|
||||
var fullPathB = Path.Combine(lastABPath, path);
|
||||
if (File.Exists(fullPathB) && BF.GameLaunchUtils.GetFileMD5(fullPathA).CompareTo(BF.GameLaunchUtils.GetFileMD5(fullPathB)) != 0)
|
||||
{
|
||||
if (Manifest.GetAssetBundleHash(path) == lastManifest.GetAssetBundleHash(path))
|
||||
{
|
||||
// md5 不一致但是AssetHash一致的情况
|
||||
ABList.Add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UseLastABFix()
|
||||
{
|
||||
if (string.IsNullOrEmpty(newestABPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(lastABPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ABList.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach(var path in ABList)
|
||||
{
|
||||
var fullPathA = Path.Combine(newestABPath, path);
|
||||
var fullPathB = Path.Combine(lastABPath, path);
|
||||
File.Copy(fullPathB, fullPathA, true);
|
||||
}
|
||||
var version = newestABPath.Substring(newestABPath.Replace("\\", "/").LastIndexOf("/") + 1);
|
||||
AssetBundleUtils.RegenerateABConfigMd5(newestABPath, version);
|
||||
|
||||
ABList.Clear();
|
||||
}
|
||||
|
||||
public static void ShowWindow()
|
||||
{
|
||||
var window = GetWindow<CompareAssetBundleWindow>();
|
||||
window.Show();
|
||||
}
|
||||
|
||||
private void GetNewestABPath()
|
||||
{
|
||||
var bundleCachePath = IsAndroid ? Application.dataPath + "/../HistoryAssetBundles" : Application.dataPath + "/../HistoryAssetBundles/IOS";
|
||||
var dirInfo = new DirectoryInfo(bundleCachePath);
|
||||
var dirs = dirInfo.GetDirectories();
|
||||
if (dirs.Length == 0)
|
||||
{
|
||||
newestABPath = "";
|
||||
lastABPath = "";
|
||||
}
|
||||
if (dirs.Length == 1)
|
||||
{
|
||||
newestABPath = dirs[0].FullName;
|
||||
lastABPath = "";
|
||||
}
|
||||
var hightestIndex = 0;
|
||||
var secondIndex = 0;
|
||||
for (var i = 1; i < dirs.Length; i++)
|
||||
{
|
||||
if (dirs[i].FullName.CompareTo(dirs[hightestIndex].FullName) > 0)
|
||||
{
|
||||
secondIndex = hightestIndex;
|
||||
hightestIndex = i;
|
||||
}
|
||||
}
|
||||
newestABPath = dirs[hightestIndex].FullName;
|
||||
if (hightestIndex > 0)
|
||||
{
|
||||
lastABPath = dirs[secondIndex].FullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea05efeb3467b0947b735c8fe281cb8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -34,12 +34,12 @@ namespace BFEditor.Build
|
||||
|
||||
public bool IsGPChannel()
|
||||
{
|
||||
return bundleName == "com.combo.heroes.puzzle.rpg";
|
||||
return bundleName == "com.knight.connect.rpg";
|
||||
}
|
||||
|
||||
public bool IsGPOfficial()
|
||||
{
|
||||
return bundleName == "com.combo.heroes.puzzle.rpg";
|
||||
return bundleName == "com.knight.connect.rpg";
|
||||
}
|
||||
|
||||
// dev包使用mono编译,不会导出as工程
|
||||
|
||||
@ -192,34 +192,10 @@ namespace BFEditor.Build
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("打包工具/AssetBundles/对比上一个版本AB Android", priority = 207)]
|
||||
static void CompareLastVersionABAndroid()
|
||||
{
|
||||
var window = (CompareAssetBundleWindow)EditorWindow.GetWindowWithRect(typeof(CompareAssetBundleWindow),
|
||||
new Rect(Screen.width / 2, Screen.height / 2, 800, 800), true);
|
||||
window.IsAndroid = true;
|
||||
window.Show();
|
||||
}
|
||||
|
||||
[MenuItem("打包工具/AssetBundles/对比上一个版本AB IOS", priority = 208)]
|
||||
static void CompareLastVersionABIOS()
|
||||
{
|
||||
var window = (CompareAssetBundleWindow)EditorWindow.GetWindowWithRect(typeof(CompareAssetBundleWindow),
|
||||
new Rect(Screen.width / 2, Screen.height / 2, 800, 800), true);
|
||||
window.IsAndroid = false;
|
||||
window.Show();
|
||||
}
|
||||
|
||||
[MenuItem("打包工具/打包窗口", priority = 301)]
|
||||
static void ShowBuildWindow()
|
||||
{
|
||||
BuildProjectWindow.ShowWindow();
|
||||
}
|
||||
|
||||
[MenuItem("打包工具/Android转换为AAB工程", priority = 401)]
|
||||
static void ConvertAndroidStudioToAAB()
|
||||
{
|
||||
BuildAndroidUtils.ConvertToAAB();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,12 +13,10 @@ namespace BFEditor.Build
|
||||
|
||||
public class BuildProjectWindow : EditorWindow
|
||||
{
|
||||
private static int versionCode = 18;
|
||||
private static string versionName = "1.6.5";
|
||||
BFPlatformOptions platform = BFPlatformOptions.AndroidDev;
|
||||
const string ANDROID_DEV_PACKAGE_NAME = "com.juzu.b6.dev.android";
|
||||
const string ANDROID_RELEASE_PACKAGE_NAME = "com.juzu.b6.release.android";
|
||||
const string ANDROID_GP_PACKAGE_NAME = "com.combo.heroes.puzzle.rpg";
|
||||
const string ANDROID_GP_PACKAGE_NAME = "com.knight.connect.rpg";
|
||||
const string IOS_PACKAGE_NAME = "com.juzu.b6.dev.ios";
|
||||
|
||||
public BuildProjectWindow()
|
||||
@ -36,7 +34,7 @@ namespace BFEditor.Build
|
||||
platform = (BFPlatformOptions)EditorGUILayout.EnumPopup("", platform);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.LabelField("版本: " + versionName);
|
||||
EditorGUILayout.LabelField("版本: 0.1.0");
|
||||
EditorGUILayout.Space();
|
||||
|
||||
string packageName;
|
||||
@ -72,8 +70,7 @@ namespace BFEditor.Build
|
||||
if (GUILayout.Button("一键打包"))
|
||||
{
|
||||
var buildInfo = new BuildInfo();
|
||||
buildInfo.version = versionName;
|
||||
buildInfo.version_code = versionCode;
|
||||
buildInfo.version = "0.1.0";
|
||||
buildInfo.mode = mode;
|
||||
buildInfo.bundleName = packageName;
|
||||
buildInfo.skipVersion = skipVersion;
|
||||
|
||||
@ -366,7 +366,7 @@ namespace BFEditor.Build
|
||||
SetSpineABName(Path.Combine(Application.dataPath, "arts", "spines"), index++ / total);
|
||||
SetFirstABName(Path.Combine(Application.dataPath, "first"), index++ / total);
|
||||
// SetTimelineABName(Path.Combine(Application.dataPath, "arts", "timeline"), 16f / total);
|
||||
SetVideoABName(Path.Combine(Application.dataPath, "arts", "video"), index++ / total);
|
||||
// SetVideoABName(Path.Combine(Application.dataPath, "arts", "video"), 17f / total);
|
||||
// SetLanguageResABName(Resource.ResourceProcessConfig.LANGUAGE_PATH, 19f / total);
|
||||
// SetBakedatasABName(Path.Combine(Application.dataPath, "arts", "bakedatas"), 21f / total);
|
||||
// SetLightProbesABName(Path.Combine(Application.dataPath, "arts", "lightprobes"), 22f / total);
|
||||
|
||||
@ -3,7 +3,6 @@ using UnityEditor;
|
||||
using System.IO;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
@ -30,14 +29,8 @@ namespace BFEditor.Build
|
||||
static string GoogleCommonProjectPath = Application.dataPath + "/../BFVersions/android/google_common";
|
||||
static string GPAsProjectPath = Application.dataPath + "/../BFVersions/android/ub-gp"; // gp删档测试渠道
|
||||
static string GPOfficialAsProjectPath = Application.dataPath + "/../BFVersions/android/ub-google"; // gp正式渠道
|
||||
static string PublishAsProjectPath = Application.dataPath + "/../BFVersions/android/publish_release";
|
||||
static string SignShellPath = Application.dataPath + "/../BFFiles/androidkey";
|
||||
static string GpAlginShellPath = Application.dataPath + "/../BFFiles/androidkey";
|
||||
static HashSet<string> AABInPackageFileHashSet = new HashSet<string>()
|
||||
{
|
||||
"bin",
|
||||
"UnityServicesProjectConfiguration.json"
|
||||
};
|
||||
|
||||
static BuildAndroidUtils()
|
||||
{
|
||||
@ -138,7 +131,7 @@ namespace BFEditor.Build
|
||||
// 应用名
|
||||
if (buildInfo.IsPublish())
|
||||
{
|
||||
PlayerSettings.productName = "Knights Combo";
|
||||
PlayerSettings.productName = "Knight Connect";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -276,11 +269,6 @@ namespace BFEditor.Build
|
||||
if(buildInfo.IsDevChannel())
|
||||
{
|
||||
MergeProject(buildInfo, DevAsProjectPath);
|
||||
var dir = Path.Combine(Application.dataPath, "../", AS_PROJECT_PATH, buildInfo.mode);
|
||||
BFEditorUtils.RunCommond("gradle", " assembleDebug", dir, (msg) => {
|
||||
}, (errorMsg) => {
|
||||
Debug.LogError("[bferror] " + errorMsg);
|
||||
});
|
||||
}
|
||||
else if(buildInfo.IsLanRelease())
|
||||
{
|
||||
@ -289,7 +277,6 @@ namespace BFEditor.Build
|
||||
else if(buildInfo.IsGPChannel())
|
||||
{
|
||||
MergeProject(buildInfo, GoogleAsProjectPath);
|
||||
FixGradleVersion(buildInfo.version_code, buildInfo.version);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -399,19 +386,13 @@ namespace BFEditor.Build
|
||||
static void FixGradleVersion(int versionCode, string versionName)
|
||||
{
|
||||
Debug.Log("[bfinfo]修正build.gradle: VersionCode " + versionCode + " VersionName " + versionName);
|
||||
var gradleFilePath = Path.Combine(PublishAsProjectPath, "launcher", "build.gradle");
|
||||
var gradleFilePath = Path.Combine(GradleExcuteProjectPath, "build.gradle");
|
||||
var text = File.ReadAllText(gradleFilePath);
|
||||
var regex = new Regex("versionCode 1");
|
||||
text = regex.Replace(text, string.Format("versionCode {0}", versionCode));
|
||||
var regex2 = new Regex("versionName '0.1.0'");
|
||||
text = regex2.Replace(text, string.Format("versionName '{0}'", versionName));
|
||||
regex = new Regex("versionName '0.1'");
|
||||
text = regex.Replace(text, string.Format("versionName '{0}'", versionName));
|
||||
File.WriteAllText(gradleFilePath, text);
|
||||
|
||||
var gradleFilePath2 = Path.Combine(PublishAsProjectPath, "unityLibrary", "build.gradle");
|
||||
var text2 = File.ReadAllText(gradleFilePath2);
|
||||
text2 = regex.Replace(text2, string.Format("versionCode {0}", versionCode));
|
||||
text2 = regex2.Replace(text2, string.Format("versionName '{0}'", versionName));
|
||||
File.WriteAllText(gradleFilePath2, text2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -557,77 +538,5 @@ namespace BFEditor.Build
|
||||
tmp.Abort();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ConvertToAAB()
|
||||
{
|
||||
var installTimePackDirPath = Path.Combine(PublishAsProjectPath, "../", "dz_google_abb", "install_time_pack");
|
||||
var targetDirPath = Path.Combine(PublishAsProjectPath, "install_time_pack");
|
||||
if (Directory.Exists(targetDirPath))
|
||||
{
|
||||
Directory.Delete(targetDirPath, true);
|
||||
Directory.CreateDirectory(targetDirPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.CreateDirectory(targetDirPath);
|
||||
}
|
||||
|
||||
BFEditorUtils.CopyDir(installTimePackDirPath, targetDirPath);
|
||||
|
||||
var abDirPath = Path.Combine(PublishAsProjectPath, "unityLibrary/src/main/assets");
|
||||
var destFolderName = Path.Combine(PublishAsProjectPath, "install_time_pack/src/main/assets");
|
||||
var dirInfo = new DirectoryInfo(abDirPath);
|
||||
var floders = dirInfo.GetDirectories();
|
||||
for (var i = 0; i < floders.Length; i++)
|
||||
{
|
||||
if (AABInPackageFileHashSet.Contains(floders[i].Name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var newDir = Path.Combine(destFolderName, floders[i].Name);
|
||||
if (!Directory.Exists(newDir))
|
||||
{
|
||||
Directory.CreateDirectory(newDir);
|
||||
}
|
||||
BFEditorUtils.CopyDir(floders[i].FullName, newDir);
|
||||
Directory.Delete(floders[i].FullName, true);
|
||||
}
|
||||
|
||||
var files = dirInfo.GetFiles();
|
||||
for (var i = 0; i < files.Length; i++)
|
||||
{
|
||||
var file = files[i];
|
||||
if (AABInPackageFileHashSet.Contains(file.Name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var destFile = Path.Combine(destFolderName, file.Name);
|
||||
if (File.Exists(destFile))
|
||||
{
|
||||
File.Delete(destFile);
|
||||
}
|
||||
File.Move(file.FullName, destFile);
|
||||
}
|
||||
|
||||
var settingsGradleFilePath = Path.Combine(PublishAsProjectPath, "settings.gradle");
|
||||
var text = File.ReadAllText(settingsGradleFilePath);
|
||||
var appendText = "include ':install_time_pack'";
|
||||
if (!text.EndsWith(appendText))
|
||||
{
|
||||
text = text + "\n" + appendText;
|
||||
}
|
||||
File.WriteAllText(settingsGradleFilePath, text);
|
||||
|
||||
var buildGradlePath = Path.Combine(PublishAsProjectPath, "launcher/build.gradle");
|
||||
var buildGradleText = File.ReadAllText(buildGradlePath);
|
||||
var regex2 = new Regex("assetPacks = [\":install_time_pack\"]");
|
||||
if (!regex2.IsMatch(buildGradleText))
|
||||
{
|
||||
var regex22 = new Regex("android {");
|
||||
buildGradleText = regex22.Replace(buildGradleText, "android {\n assetPacks = [\":install_time_pack\"]");
|
||||
}
|
||||
File.WriteAllText(buildGradlePath, buildGradleText);
|
||||
Debug.Log("Android转换为AAB工程完成");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,76 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_IOS
|
||||
using UnityEditor.iOS.Xcode;
|
||||
#endif
|
||||
|
||||
public class IOSLocalizationTool
|
||||
{
|
||||
public static readonly Dictionary<SystemLanguage, string> validLanguageMap = new Dictionary<SystemLanguage, string>()
|
||||
{
|
||||
[SystemLanguage.English] = "en",
|
||||
[SystemLanguage.ChineseSimplified] = "zh-Hans",
|
||||
[SystemLanguage.ChineseTraditional] = "zh-Hant",
|
||||
[SystemLanguage.Japanese] = "ja",
|
||||
[SystemLanguage.Korean] = "ko",
|
||||
[SystemLanguage.Spanish] = "es",
|
||||
[SystemLanguage.Vietnamese] = "vi",
|
||||
[SystemLanguage.Thai] = "th",
|
||||
[SystemLanguage.Indonesian] = "id",
|
||||
[SystemLanguage.Portuguese] = "pt",
|
||||
};
|
||||
|
||||
public static void SetLocalization(string pathToBuiltProject)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
string buildPath = pathToBuiltProject;
|
||||
const string infoPlistName = "Info.plist";
|
||||
|
||||
var plistPath = Path.Combine(buildPath, infoPlistName);
|
||||
PlistDocument plist = new PlistDocument();
|
||||
plist.ReadFromFile(plistPath);
|
||||
|
||||
// url schemes
|
||||
const string bundleLocalizationKey = "CFBundleLocalizations";
|
||||
|
||||
if (!plist.root.values.TryGetValue(bundleLocalizationKey, out var localizations))
|
||||
{
|
||||
localizations = plist.root.CreateArray(bundleLocalizationKey);
|
||||
}
|
||||
|
||||
foreach (string value in validLanguageMap.Values)
|
||||
{
|
||||
localizations.AsArray().AddString(value);
|
||||
}
|
||||
|
||||
plist.WriteToFile(plistPath);
|
||||
|
||||
var projectPath = PBXProject.GetPBXProjectPath(buildPath);
|
||||
var project = new PBXProject();
|
||||
project.ReadFromFile(projectPath);
|
||||
var target = project.GetUnityMainTargetGuid();
|
||||
var resourceTarget = project.GetResourcesBuildPhaseByTarget(target);
|
||||
|
||||
foreach (string value in validLanguageMap.Values)
|
||||
{
|
||||
var path = Path.Combine(Path.Combine(Application.dataPath, "../", "BFVersions/ios/ios_common"), $"{value}.lproj");
|
||||
var inProjectPath = Path.GetFileName(path);
|
||||
project.AddFolderReference(path, inProjectPath);
|
||||
var resGUID = project.FindFileGuidByProjectPath(inProjectPath);
|
||||
project.AddFileToBuildSection(
|
||||
target,
|
||||
resourceTarget,
|
||||
resGUID);
|
||||
}
|
||||
|
||||
project.WriteToFile(projectPath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4be556fddd0e984428c0410a562496d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0db9ae993e0bba941a6bfe7227aff6bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,767 +0,0 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace BFEditor
|
||||
{
|
||||
public class BoardEditorWindow : EditorWindow {
|
||||
|
||||
// private static void ShowWindow() {
|
||||
// var window = GetWindow<BoardEditorWindow>();
|
||||
// window.titleContent = new GUIContent("BoardWindow");
|
||||
// window.Show();
|
||||
// }
|
||||
const string BOARD_EXCEL_KEY = "bf_board_excel_key";
|
||||
const string BOARD_GRID_TYPE_KEY = "bf_board_grid_type_key";
|
||||
const string BOARD_GRID_EDGE_KEY = "bf_board_grid_edge_key";
|
||||
int gridCount = 49;
|
||||
string battleImgDirectory = "Assets/arts/textures/ui/battle/";
|
||||
string boardFilepath;
|
||||
string boardGridTypePath;
|
||||
string boardGridEdgePath;
|
||||
string boardFiledName = "board";
|
||||
string boardEdgeFiledName = "grid_edge";
|
||||
string randomTypeStr = "";
|
||||
string boardEdgeStr = "";
|
||||
int curIndex = 1;
|
||||
int maxRow = 7;
|
||||
Dictionary<int, Dictionary<string, string>> boardGridTypeDict = new Dictionary<int, Dictionary<string, string>>();
|
||||
Dictionary<int, JArray> boardDict = new Dictionary<int, JArray>();
|
||||
Dictionary<int, JArray> outPutBoardDict = new Dictionary<int, JArray>();
|
||||
Dictionary<string, Texture> imgDict = new Dictionary<string, Texture>();
|
||||
Dictionary<int, Dictionary<string, string>> boardGridEdgeDict = new Dictionary<int, Dictionary<string, string>>();
|
||||
Dictionary<int, JArray> edgeDict = new Dictionary<int, JArray>();
|
||||
Dictionary<int, JArray> outPutBoardEdgeDict = new Dictionary<int, JArray>();
|
||||
bool loadExcelOver = false;
|
||||
Dictionary<int, string> elementTypeImgDict = new Dictionary<int, string>(){
|
||||
[1] = "red_1",
|
||||
[2] = "yellow_1",
|
||||
[3] = "green_1",
|
||||
[4] = "blue_1",
|
||||
[5] = "purple_1"
|
||||
};
|
||||
Texture boardImg;
|
||||
private void OnEnable()
|
||||
{
|
||||
loadExcelOver = false;
|
||||
boardFilepath = GetBoardExcelPath();
|
||||
if (boardFilepath.Equals(""))
|
||||
{
|
||||
boardFilepath = "选择配置表路径";
|
||||
}
|
||||
|
||||
boardGridTypePath = GetBoardGridTypePath();
|
||||
if (boardGridTypePath.Equals(""))
|
||||
{
|
||||
boardGridTypePath = "选择grid_type配置表路径";
|
||||
}
|
||||
|
||||
boardGridEdgePath = GetBoardGridEdgePath();
|
||||
if (boardGridEdgePath.Equals(""))
|
||||
{
|
||||
boardGridEdgePath = "选择grid_edge_type配置表路径";
|
||||
}
|
||||
string[] paths = Directory.GetFiles(battleImgDirectory);
|
||||
foreach(var path in paths)
|
||||
{
|
||||
if(!path.EndsWith(".meta"))
|
||||
{
|
||||
string formatPath = Path.GetFileNameWithoutExtension(path);
|
||||
imgDict[formatPath] = AssetDatabase.LoadAssetAtPath<Texture>(path);
|
||||
}
|
||||
}
|
||||
boardImg = AssetDatabase.LoadAssetAtPath<Texture>("Assets/arts/textures/background/battle_common/chessboard_1.png");
|
||||
}
|
||||
string GetBoardExcelPath()
|
||||
{
|
||||
return PlayerPrefs.GetString(BOARD_EXCEL_KEY, "");
|
||||
}
|
||||
|
||||
void SetBoardExcelPath(string path)
|
||||
{
|
||||
PlayerPrefs.SetString(BOARD_EXCEL_KEY, path);
|
||||
}
|
||||
|
||||
string GetBoardGridTypePath()
|
||||
{
|
||||
return PlayerPrefs.GetString(BOARD_GRID_TYPE_KEY, "");
|
||||
}
|
||||
|
||||
void SetBoardGridTypePath(string path)
|
||||
{
|
||||
PlayerPrefs.SetString(BOARD_GRID_TYPE_KEY, path);
|
||||
}
|
||||
|
||||
string GetBoardGridEdgePath()
|
||||
{
|
||||
return PlayerPrefs.GetString(BOARD_GRID_EDGE_KEY, "");
|
||||
}
|
||||
|
||||
void SetBoardGridEdgePath(string path)
|
||||
{
|
||||
PlayerPrefs.SetString(BOARD_GRID_EDGE_KEY, path);
|
||||
}
|
||||
|
||||
BoardEditorWindow()
|
||||
{
|
||||
this.titleContent = new GUIContent("棋盘编辑器");
|
||||
}
|
||||
|
||||
private void OnGUI() {
|
||||
DrawBaseInfo();
|
||||
DragBoard();
|
||||
}
|
||||
|
||||
void DrawBaseInfo()
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Space(10);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("grid_type 路径", GUILayout.Width(100));
|
||||
GUILayout.Space(10);
|
||||
GUILayout.TextField(boardGridTypePath, GUILayout.Width(300));
|
||||
if (GUILayout.Button("选择", GUILayout.Width(80)))
|
||||
{
|
||||
string openPath = EditorUtility.OpenFilePanel("选择配置表", GetBoardGridTypePath(), "");
|
||||
if (openPath.CompareTo("") != 0)
|
||||
{
|
||||
boardGridTypePath = openPath;
|
||||
SetBoardGridTypePath(openPath);
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("grid_edge 路径", GUILayout.Width(100));
|
||||
GUILayout.Space(10);
|
||||
GUILayout.TextField(boardGridEdgePath, GUILayout.Width(300));
|
||||
if (GUILayout.Button("选择", GUILayout.Width(80)))
|
||||
{
|
||||
string openPath = EditorUtility.OpenFilePanel("选择配置表", GetBoardGridEdgePath(), "");
|
||||
if (openPath.CompareTo("") != 0)
|
||||
{
|
||||
boardGridEdgePath = openPath;
|
||||
SetBoardGridEdgePath(openPath);
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(10);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("配置表路径", GUILayout.Width(100));
|
||||
GUILayout.Space(10);
|
||||
GUILayout.TextField(boardFilepath, GUILayout.Width(300));
|
||||
if (GUILayout.Button("选择", GUILayout.Width(80)))
|
||||
{
|
||||
string openPath = EditorUtility.OpenFilePanel("选择配置表", GetBoardExcelPath(), "");
|
||||
if (openPath.CompareTo("") != 0)
|
||||
{
|
||||
boardFilepath = openPath;
|
||||
SetBoardExcelPath(openPath);
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(10);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("字段名称", GUILayout.Width(100));
|
||||
GUILayout.Space(10);
|
||||
boardFiledName = GUILayout.TextField(boardFiledName, GUILayout.Width(200));
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(10);
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("加载棋盘", GUILayout.Width(80)))
|
||||
{
|
||||
LoadBoardExcel();
|
||||
}
|
||||
|
||||
GUILayout.Label("棋盘数量", GUILayout.Width(100));
|
||||
gridCount = int.Parse(GUILayout.TextField(gridCount.ToString(), GUILayout.Width(200)));
|
||||
maxRow = (int)(gridCount / 7);
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal();
|
||||
if (!IsInNewBoard())
|
||||
{
|
||||
if (GUILayout.Button("上一张", GUILayout.Width(80)))
|
||||
{
|
||||
showSwitchBoardSaveDialog(Math.Max(curIndex - 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.BeginHorizontal(GUILayout.Width(80));
|
||||
GUIStyle style = new GUIStyle(GUI.skin.label);
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
GUILayout.Label("当前编号id = ", style);
|
||||
showSwitchBoardSaveDialog(int.Parse(GUILayout.TextField(curIndex.ToString(), GUILayout.Width(40))));
|
||||
GUILayout.EndHorizontal();
|
||||
if (!IsInNewBoard())
|
||||
{
|
||||
if (GUILayout.Button("下一张", GUILayout.Width(80)))
|
||||
{
|
||||
showSwitchBoardSaveDialog(Math.Min(curIndex + 1, boardDict.Count));
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("复制当前棋盘", GUILayout.Width(80)))
|
||||
{
|
||||
if (!boardDict.ContainsKey(curIndex))
|
||||
{
|
||||
return;
|
||||
}
|
||||
JArray jo = boardDict[curIndex];
|
||||
GUIUtility.systemCopyBuffer = JsonConvert.SerializeObject(jo);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("粘贴棋盘", GUILayout.Width(80)))
|
||||
{
|
||||
JArray jo = (JArray)JsonConvert.DeserializeObject(GUIUtility.systemCopyBuffer);
|
||||
if (jo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
boardDict[curIndex] = jo;
|
||||
}
|
||||
|
||||
if (!IsInNewBoard())
|
||||
{
|
||||
if (GUILayout.Button("新建棋盘", GUILayout.Width(80)))
|
||||
{
|
||||
curIndex = outPutBoardDict.Count + 1;
|
||||
boardDict[curIndex] = new JArray();
|
||||
for (int i = 0; i < gridCount; i++)
|
||||
{
|
||||
JArray unit = (JArray)JsonConvert.DeserializeObject("[0, 0]");
|
||||
boardDict[curIndex].Add(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUILayout.Button("退出新建棋盘", GUILayout.Width(80)))
|
||||
{
|
||||
boardDict.Remove(curIndex);
|
||||
curIndex = outPutBoardDict.Count;
|
||||
}
|
||||
if (GUILayout.Button("保存当前棋盘", GUILayout.Width(80)))
|
||||
{
|
||||
SaveBoard(curIndex);
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.BeginArea(new Rect(730, 500, 500, 100));
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label("随机类型和数量[类型,数量] 空格 [类型,数量]");
|
||||
randomTypeStr = GUILayout.TextField(randomTypeStr, GUILayout.Width(500));
|
||||
GUILayout.BeginHorizontal();
|
||||
if(GUILayout.Button("生成随机棋盘", GUILayout.Width(80)))
|
||||
{
|
||||
string[] units = randomTypeStr.Split('[');
|
||||
Dictionary<int, int> dict = new Dictionary<int, int>();
|
||||
for (int i = 0; i < units.Length; i++)
|
||||
{
|
||||
string formatStr = units[i].Replace("[", "").Replace("]", "").Replace(" ", "");
|
||||
string[] unitList = formatStr.Split(',');
|
||||
if (unitList.Length >= 2)
|
||||
{
|
||||
dict[int.Parse(unitList[0])] = int.Parse(unitList[1]);
|
||||
}
|
||||
}
|
||||
List<int> list = new List<int>();
|
||||
for (int i = 0; i < gridCount; i++)
|
||||
{
|
||||
list.Add(i);
|
||||
}
|
||||
JArray ja = new JArray();
|
||||
for (int i = 0; i < gridCount; i++)
|
||||
{
|
||||
JArray unit = (JArray)JsonConvert.DeserializeObject("[0, 0]");
|
||||
ja.Add(unit);
|
||||
}
|
||||
foreach (int gridType in dict.Keys)
|
||||
{
|
||||
for(int i = 0; i < dict[gridType]; i++)
|
||||
{
|
||||
int index = UnityEngine.Random.Range(0, list.Count);
|
||||
ja[list[index]][0] = gridType;
|
||||
list.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
boardDict[curIndex] = ja;
|
||||
}
|
||||
if(GUILayout.Button("生成随机棋盘+元素", GUILayout.Width(110)))
|
||||
{
|
||||
string[] units = randomTypeStr.Split('[');
|
||||
Dictionary<int, int> dict = new Dictionary<int, int>();
|
||||
for (int i = 0; i < units.Length; i++)
|
||||
{
|
||||
string formatStr = units[i].Replace("[", "").Replace("]", "").Replace(" ", "");
|
||||
string[] unitList = formatStr.Split(',');
|
||||
if (unitList.Length >= 2)
|
||||
{
|
||||
dict[int.Parse(unitList[0])] = int.Parse(unitList[1]);
|
||||
}
|
||||
}
|
||||
List<int> list = new List<int>();
|
||||
for (int i = 0; i < gridCount; i++)
|
||||
{
|
||||
list.Add(i);
|
||||
}
|
||||
JArray ja = new JArray();
|
||||
for (int i = 0; i < gridCount; i++)
|
||||
{
|
||||
ja.Add(getNewGridUnitInfo());
|
||||
}
|
||||
foreach (int gridType in dict.Keys)
|
||||
{
|
||||
for(int i = 0; i < dict[gridType]; i++)
|
||||
{
|
||||
int index = UnityEngine.Random.Range(0, list.Count);
|
||||
ja[list[index]][0] = gridType;
|
||||
list.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < ja.Count; i++)
|
||||
{
|
||||
int gridType = (int)(ja[i][0]);
|
||||
Dictionary<string, string> gridTypeDict = boardGridTypeDict[gridType];
|
||||
if (gridTypeDict.ContainsKey("break_stay_element") || !gridTypeDict.ContainsKey("element_invalid"))
|
||||
{
|
||||
ja[i][1] = UnityEngine.Random.Range(1, 6);
|
||||
}
|
||||
}
|
||||
boardDict[curIndex] = ja;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndArea();
|
||||
GUILayout.BeginArea(new Rect(730, 650, 500, 500));
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label("棋盘边缘元素");
|
||||
boardEdgeStr = GUILayout.TextField(boardEdgeStr, GUILayout.Width(400), GUILayout.Height(100));
|
||||
if(GUILayout.Button("加载边缘元素配置", GUILayout.Width(110)))
|
||||
{
|
||||
JArray edgeJo = edgeDict[curIndex];
|
||||
string str = "[";
|
||||
for (int i = 0; i < edgeJo.Count; i++)
|
||||
{
|
||||
JArray gridInfo = (JArray)edgeJo[i];
|
||||
if (gridInfo.Count < 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string s = "{";
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
s = s + gridInfo[j].ToString();
|
||||
if(j != 2)
|
||||
{
|
||||
s = s + ", ";
|
||||
}
|
||||
}
|
||||
s = s + "}";
|
||||
str = str + s;
|
||||
if (i != edgeJo.Count)
|
||||
{
|
||||
str = str + ", ";
|
||||
}
|
||||
}
|
||||
boardEdgeStr = str;
|
||||
}
|
||||
if(GUILayout.Button("重新刷新边缘元素", GUILayout.Width(110)))
|
||||
{
|
||||
string[] units = boardEdgeStr.Split('{');
|
||||
List<string> edgeList = new List<string>();
|
||||
for (int i = 0; i < units.Length; i++)
|
||||
{
|
||||
string formatStr = units[i].Replace("[", "").Replace("]", "").Replace(" ", "").Replace("}", "");
|
||||
string[] unitList = formatStr.Split(',');
|
||||
if (unitList.Length >= 3)
|
||||
{
|
||||
string str = "[";
|
||||
for(int j = 0; j < 3; j++)
|
||||
{
|
||||
str = str + unitList[j];
|
||||
if (j != 2)
|
||||
{
|
||||
str = str + ",";
|
||||
}
|
||||
}
|
||||
str = str + "]";
|
||||
edgeList.Add(str);
|
||||
}
|
||||
}
|
||||
|
||||
JArray ja = new JArray();
|
||||
for (int i = 0; i < edgeList.Count; i++)
|
||||
{
|
||||
JArray unit = (JArray)JsonConvert.DeserializeObject(edgeList[i]);
|
||||
ja.Add(unit);
|
||||
}
|
||||
edgeDict[curIndex] = ja;
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndArea();
|
||||
if(GUI.Button(new Rect(1050, 10, 100, 30), "导出到Excel"))
|
||||
{
|
||||
if (CheckBoardChanged(curIndex))
|
||||
{
|
||||
switch (EditorUtility.DisplayDialogComplex("提示", "当前棋盘已经改变,是否保存", "确定", "放弃", "再次确认"))
|
||||
{
|
||||
case 0:
|
||||
SaveBoard(curIndex);
|
||||
SaveBoardExcel();
|
||||
break;
|
||||
case 1:
|
||||
AbortBoard(curIndex);
|
||||
SaveBoardExcel();
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveBoardExcel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoadBoardExcel()
|
||||
{
|
||||
var desktopDir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory);
|
||||
var tempPath = System.IO.Path.Combine(desktopDir, "BoardEditorTemp.txt");
|
||||
|
||||
string relitivePath = Application.dataPath;
|
||||
relitivePath = relitivePath.Remove(relitivePath.Length - 6, 6);
|
||||
string pythonToolPath = relitivePath + "Tools/tranexcel_new";
|
||||
|
||||
// 读取grid_type配置表
|
||||
BFEditorUtils.RunCommond("python", "load_board.py " + tempPath + " " + boardGridTypePath, pythonToolPath);
|
||||
string boardGridTypeJson = File.ReadAllText(tempPath);
|
||||
JObject jsonObj = (JObject)JsonConvert.DeserializeObject(boardGridTypeJson);
|
||||
foreach (var item in jsonObj)
|
||||
{
|
||||
int key = int.Parse(item.Key);
|
||||
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||
foreach (var item2 in (JObject)item.Value)
|
||||
{
|
||||
dict[item2.Key] = item2.Value.ToString();
|
||||
}
|
||||
boardGridTypeDict[key] = dict;
|
||||
}
|
||||
|
||||
// 读取grid_edge_type配置表
|
||||
BFEditorUtils.RunCommond("python", "load_board.py " + tempPath + " " + boardGridEdgePath, pythonToolPath);
|
||||
string boardGridEdgeJson = File.ReadAllText(tempPath);
|
||||
jsonObj = (JObject)JsonConvert.DeserializeObject(boardGridEdgeJson);
|
||||
foreach (var item in jsonObj)
|
||||
{
|
||||
int key = int.Parse(item.Key);
|
||||
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||
foreach (var item2 in (JObject)item.Value)
|
||||
{
|
||||
dict[item2.Key] = item2.Value.ToString();
|
||||
}
|
||||
boardGridEdgeDict[key] = dict;
|
||||
}
|
||||
|
||||
// 读取boardFile配置表
|
||||
BFEditorUtils.RunCommond("python", "load_board.py " + tempPath + " " + boardFilepath, pythonToolPath);
|
||||
string boardFileJson = File.ReadAllText(tempPath);
|
||||
|
||||
jsonObj = (JObject)JsonConvert.DeserializeObject(boardFileJson);
|
||||
foreach (var item in jsonObj){
|
||||
if (item.Value[boardFiledName] != null)
|
||||
{
|
||||
int key = int.Parse(item.Key);
|
||||
boardDict[key] = copyBoard((JArray)item.Value[boardFiledName]);
|
||||
outPutBoardDict[key] = copyBoard((JArray)item.Value[boardFiledName]);
|
||||
}
|
||||
if (item.Value[boardEdgeFiledName] != null)
|
||||
{
|
||||
int key = int.Parse(item.Key);
|
||||
edgeDict[key] = copyBoard((JArray)item.Value[boardEdgeFiledName]);
|
||||
outPutBoardEdgeDict[key] = copyBoard((JArray)item.Value[boardEdgeFiledName]);
|
||||
}
|
||||
}
|
||||
|
||||
loadExcelOver = true;
|
||||
}
|
||||
|
||||
void SaveBoardExcel()
|
||||
{
|
||||
var desktopDir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory);
|
||||
var tempPath = System.IO.Path.Combine(desktopDir, "BoardEditorTemp.txt");
|
||||
Dictionary<int, Dictionary<string, JArray>> output = new Dictionary<int, Dictionary<string, JArray>>();
|
||||
foreach(int key in outPutBoardDict.Keys)
|
||||
{
|
||||
output[key] = new Dictionary<string, JArray>();
|
||||
output[key][boardFiledName] = copyBoard(outPutBoardDict[key]);
|
||||
}
|
||||
string relitivePath = Application.dataPath;
|
||||
relitivePath = relitivePath.Remove(relitivePath.Length - 6, 6);
|
||||
string pythonToolPath = relitivePath + "Tools/tranexcel_new";
|
||||
File.WriteAllText(tempPath, JsonConvert.SerializeObject(output));
|
||||
BFEditorUtils.RunCommond("python", "save_board.py " + tempPath + " " + boardFilepath, pythonToolPath);
|
||||
}
|
||||
|
||||
void DragBoard()
|
||||
{
|
||||
Texture img;
|
||||
GUI.DrawTexture(new Rect(0, 200, 702, 702), boardImg);
|
||||
if(!loadExcelOver)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int startOffset = 22 * 7 / maxRow;
|
||||
int textureWidth = 94 * 7 / maxRow;
|
||||
if (!boardDict.ContainsKey(curIndex))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GUILayout.BeginArea(new Rect(0, 200, 702, 702));
|
||||
GUILayout.BeginVertical();
|
||||
JArray jo = boardDict[curIndex];
|
||||
int posIndex = 0;
|
||||
for (int row = 1; row <= maxRow; row++) {
|
||||
GUILayout.BeginHorizontal();
|
||||
for (int col = 1; col <= 7; col++) {
|
||||
if (jo.Count == posIndex)
|
||||
{
|
||||
jo.Add(getNewGridUnitInfo());
|
||||
}
|
||||
JArray gridInfo = (JArray)jo[posIndex];
|
||||
if(gridInfo.Count < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int gridType = (int)gridInfo[0];
|
||||
int gridElementType = (int)gridInfo[1];
|
||||
if(!boardGridTypeDict.ContainsKey(gridType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 绘制元素
|
||||
if (elementTypeImgDict.ContainsKey(gridElementType))
|
||||
{
|
||||
img = imgDict[elementTypeImgDict[gridElementType]];
|
||||
GUI.DrawTexture(new Rect(startOffset + (col - 1) * textureWidth, startOffset + (row - 1) * textureWidth, textureWidth, textureWidth), img);
|
||||
}
|
||||
|
||||
// 绘制类型
|
||||
if(boardGridTypeDict[gridType].ContainsKey("icon"))
|
||||
{
|
||||
string icon = boardGridTypeDict[gridType]["icon"];
|
||||
if (imgDict.ContainsKey(icon))
|
||||
{
|
||||
img = imgDict[icon];
|
||||
GUI.DrawTexture(new Rect(startOffset + (col - 1) * textureWidth, startOffset + (row - 1) * textureWidth, textureWidth, textureWidth), img);
|
||||
}
|
||||
}
|
||||
|
||||
posIndex++;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
if (edgeDict.ContainsKey(curIndex))
|
||||
{
|
||||
JArray edgeJo = edgeDict[curIndex];
|
||||
for (int i = 0; i < edgeJo.Count; i++)
|
||||
{
|
||||
JArray gridInfo = (JArray)edgeJo[i];
|
||||
if(gridInfo.Count < 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int posId = (int)gridInfo[0];
|
||||
int edgeType = (int)gridInfo[1];
|
||||
int dir = (int)gridInfo[2];
|
||||
// 绘制类型
|
||||
if(boardGridEdgeDict[edgeType].ContainsKey("icon"))
|
||||
{
|
||||
string icon = boardGridEdgeDict[edgeType]["icon"];
|
||||
if (imgDict.ContainsKey(icon))
|
||||
{
|
||||
int row = posId / 10;
|
||||
int col = posId % 10;
|
||||
img = imgDict[icon];
|
||||
if (dir == 1)
|
||||
{
|
||||
GUI.DrawTexture(new Rect(startOffset + (col - 1) * textureWidth, startOffset + (row - 1) * textureWidth - 16, 92, 32), img);
|
||||
}
|
||||
else if (dir == 2)
|
||||
{
|
||||
GUI.DrawTexture(new Rect(startOffset + (col - 1) * textureWidth, startOffset + (row - 1) * textureWidth - 16 + textureWidth, 92, 32), img);
|
||||
}
|
||||
else if (dir == 3)
|
||||
{
|
||||
GUI.DrawTexture(new Rect(startOffset + (col - 1) * textureWidth - 16, startOffset + (row - 1) * textureWidth - 16, 32, 92), img);
|
||||
}
|
||||
else if (dir == 4)
|
||||
{
|
||||
GUI.DrawTexture(new Rect(startOffset + (col - 1) * textureWidth - 16 + textureWidth, startOffset + (row - 1) * textureWidth - 16, 32, 92), img);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndArea();
|
||||
|
||||
GUILayout.BeginArea(new Rect(730, 200, 510 * 7, 550 / 7 * maxRow));
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("棋盘配置信息", GUILayout.Width(100), GUILayout.Height(30));
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
posIndex = 0;
|
||||
for (int row = 1; row <= maxRow; row++) {
|
||||
GUILayout.BeginHorizontal();
|
||||
for (int col = 1; col <= 7; col++) {
|
||||
JArray gridInfo = (JArray)jo[posIndex];
|
||||
if(gridInfo.Count < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
gridInfo[0] = int.Parse(GUILayout.TextField(gridInfo[0].ToString(), GUILayout.Width(25)));
|
||||
gridInfo[1] = int.Parse(GUILayout.TextField(gridInfo[1].ToString(), GUILayout.Width(25)));
|
||||
GUILayout.Space(10);
|
||||
posIndex++;
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
|
||||
bool CheckBoardChanged(int index)
|
||||
{
|
||||
if(boardDict.ContainsKey(index) && outPutBoardDict.ContainsKey(index))
|
||||
{
|
||||
if(outPutBoardDict[index].Count != boardDict[index].Count)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < boardDict[index].Count; i++)
|
||||
{
|
||||
JArray tArray = (JArray)boardDict[index][i];
|
||||
JArray tArray2 = (JArray)outPutBoardDict[index][i];
|
||||
if (tArray.Count != tArray2.Count)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
for (int j = 0; j < tArray.Count; j++)
|
||||
{
|
||||
if (tArray[j].ToString() != tArray2[j].ToString())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SaveBoard(int index)
|
||||
{
|
||||
if(!boardDict.ContainsKey(index))
|
||||
{
|
||||
return;
|
||||
}
|
||||
outPutBoardDict[index] = copyBoard(boardDict[index]);
|
||||
}
|
||||
|
||||
void AbortBoard(int index)
|
||||
{
|
||||
if(!outPutBoardDict.ContainsKey(index))
|
||||
{
|
||||
boardDict.Remove(index);
|
||||
return;
|
||||
}
|
||||
boardDict[index] = copyBoard(outPutBoardDict[index]);
|
||||
}
|
||||
|
||||
void showSwitchBoardSaveDialog(int targetIndex)
|
||||
{
|
||||
if (IsInNewBoard())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetIndex == curIndex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (CheckBoardChanged(curIndex))
|
||||
{
|
||||
switch (EditorUtility.DisplayDialogComplex("提示", "当前棋盘已经改变,是否保存", "确定", "放弃", "再次确认"))
|
||||
{
|
||||
case 0:
|
||||
SaveBoard(curIndex);
|
||||
curIndex = targetIndex;
|
||||
break;
|
||||
case 1:
|
||||
AbortBoard(curIndex);
|
||||
curIndex = targetIndex;
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
curIndex = targetIndex;
|
||||
}
|
||||
}
|
||||
|
||||
JArray copyBoard(JArray targetArray)
|
||||
{
|
||||
JArray resultArray = new JArray();
|
||||
for (int i = 0; i < targetArray.Count; i++)
|
||||
{
|
||||
JArray unit = new JArray();
|
||||
resultArray.Add(unit);
|
||||
JArray temp = (JArray)targetArray[i];
|
||||
for (int j = 0; j < temp.Count; j++)
|
||||
{
|
||||
unit.Add(int.Parse(temp[j].ToString()));
|
||||
}
|
||||
}
|
||||
return resultArray;
|
||||
}
|
||||
|
||||
bool IsInNewBoard()
|
||||
{
|
||||
if(!boardDict.ContainsKey(curIndex) && !outPutBoardDict.ContainsKey(curIndex))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return !outPutBoardDict.ContainsKey(curIndex);
|
||||
}
|
||||
|
||||
JArray getNewGridUnitInfo()
|
||||
{
|
||||
return (JArray)JsonConvert.DeserializeObject("[0, 0]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 339fc40f64b402d4bb60e77d94902487
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -123,6 +123,7 @@ namespace BFEditor
|
||||
}
|
||||
}
|
||||
|
||||
// 检查monster
|
||||
String luaConfigPath = null;
|
||||
if(isDeveloper)
|
||||
{
|
||||
@ -134,21 +135,6 @@ namespace BFEditor
|
||||
}
|
||||
var configDirInfo = new DirectoryInfo(luaConfigPath);
|
||||
var configFileInfos = configDirInfo.GetFiles(suffix, SearchOption.TopDirectoryOnly);
|
||||
|
||||
// 检查棋盘文件格式
|
||||
checkBoard("chapter_board", env, sb);
|
||||
checkBoard("chapter_board_bossrush", env, sb);
|
||||
checkBoard("chapter_board_daily_challenge", env, sb);
|
||||
checkBoard("chapter_board_dungeon_armor", env, sb);
|
||||
checkBoard("chapter_board_dungeon_equip", env, sb);
|
||||
checkBoard("chapter_board_dungeon_gold", env, sb);
|
||||
checkBoard("chapter_board_dungeon_shards", env, sb);
|
||||
checkBoard("chapter_board_rune", env, sb);
|
||||
checkBoard("activity_pvp_board", env, sb);
|
||||
checkBoard("arena_board", env, sb);
|
||||
|
||||
|
||||
// 检查monster
|
||||
string monsterConfigListLua = "{";
|
||||
foreach (var file in configFileInfos)
|
||||
{
|
||||
@ -189,122 +175,50 @@ namespace BFEditor
|
||||
}
|
||||
}
|
||||
// 检查怪物的坐标信息
|
||||
// var luaScriptString2 = @"local MONSTER_POSITION_KEY = { 'monster_1','monster_2','monster_3','monster_4','monster_5','monster_6','monster_7','monster_8','monster_9','monster_10','monster_11','monster_12'}
|
||||
// local list = {'enemy_id_1', 'enemy_id_2', 'enemy_id_3'}
|
||||
// local list2 = {'enemy_position_1', 'enemy_position_2', 'enemy_position_3'}
|
||||
// local positionConf = require('app/config/monster_position_base').data
|
||||
// local monsterPositionConf = require('app/config/monster_position').data
|
||||
// local stage = require('app/config/story_stage').data
|
||||
// local str = {}
|
||||
// for k, v in pairs(stage) do
|
||||
// for k2, v2 in ipairs(list) do
|
||||
// if v[v2] then
|
||||
// local monsterPosition = v[list2[k2]]
|
||||
// for i, monsterId in ipairs(v[v2]) do
|
||||
// local monsterPositionInfo = monsterPositionConf[monsterPosition]
|
||||
// local positionInfo = positionConf[monsterPositionInfo[MONSTER_POSITION_KEY[i]]]
|
||||
// if positionInfo == nil then
|
||||
// table.insert(str, 'stage表的id为' .. k .. '的第' .. k2 .. '波怪的坐标有问题')
|
||||
// end
|
||||
// end
|
||||
// end
|
||||
// end
|
||||
// end
|
||||
// local stage2 = require('app/config/adventure_stage').data
|
||||
// for k, v in pairs(stage2) do
|
||||
// for k2, v2 in ipairs(list) do
|
||||
// if v[v2] then
|
||||
// local monsterPosition = v[list2[k2]]
|
||||
// for i, monsterId in ipairs(v[v2]) do
|
||||
// local monsterPositionInfo = monsterPositionConf[monsterPosition]
|
||||
// local positionInfo = positionConf[monsterPositionInfo[MONSTER_POSITION_KEY[i]]]
|
||||
// if positionInfo == nil then
|
||||
// table.insert(str, 'adventure_stage表的id为' .. k .. '的第' .. k2 .. '波怪的坐标有问题')
|
||||
// end
|
||||
// end
|
||||
// end
|
||||
// end
|
||||
// end
|
||||
// if #str > 0 then
|
||||
// return table.concat(str, '\n');
|
||||
// end
|
||||
// return ''";
|
||||
// var resultStr2 = env.DoString(luaScriptString2);
|
||||
// if (resultStr2.Length > 0)
|
||||
// {
|
||||
// foreach(var strObj in resultStr2)
|
||||
// {
|
||||
// var str = Convert.ToString(strObj);
|
||||
// if(!String.IsNullOrEmpty(str))
|
||||
// {
|
||||
// sb.Append(str + "\n");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
env.Dispose();
|
||||
return sb;
|
||||
}
|
||||
|
||||
public static void checkBoard(string configName, LuaEnv env, in StringBuilder sb)
|
||||
{
|
||||
var luaScriptString = @"
|
||||
if not cfg or not cfg.data then
|
||||
return ''
|
||||
end
|
||||
cfg = cfg.data
|
||||
local tempMap = {}
|
||||
local addErrorInfo = function(errorInfo, cfgId, errorStr)
|
||||
if not tempMap[cfgId] then
|
||||
tempMap[cfgId] = true
|
||||
table.insert(errorInfo, 'cfgId = ' .. cfgId)
|
||||
end
|
||||
|
||||
table.insert(errorInfo, ' ' .. errorStr)
|
||||
end
|
||||
|
||||
local errorInfo = {}
|
||||
for k, info in pairs(cfg) do
|
||||
local board = info.board or info.board_daily_challenge
|
||||
if not board then
|
||||
addErrorInfo(errorInfo, k, configName .. ' 没有board字段,请检查')
|
||||
else
|
||||
if #board < 49 then
|
||||
addErrorInfo(errorInfo, k, configName .. ' 没有board长度不足,请检查,当前长度为' .. #board)
|
||||
end
|
||||
|
||||
for index, v in ipairs(board) do
|
||||
if not v[1] then
|
||||
addErrorInfo(errorInfo, k, configName .. ' board字段中' .. index .. '索引没有格子类型')
|
||||
end
|
||||
if not v[2] then
|
||||
addErrorInfo(errorInfo, k, configName .. ' board字段中' .. index .. '索引没有元素类型')
|
||||
elseif v[2] > 5 or v[2] < 0 then
|
||||
addErrorInfo(errorInfo, k, configName .. ' board字段中' .. index .. '元素类型不合法,当前为' .. v[2])
|
||||
end
|
||||
end
|
||||
|
||||
local mystery_box_board = info.mystery_box_board
|
||||
if mystery_box_board then
|
||||
for index, v in ipairs(mystery_box_board) do
|
||||
if not v[1] then
|
||||
addErrorInfo(errorInfo, k, configName .. ' mystery_box_board字段中' .. index .. '索引没有格子类型')
|
||||
end
|
||||
if not v[2] then
|
||||
addErrorInfo(errorInfo, k, configName .. ' mystery_box_board字段中' .. index .. '索引没有元素类型')
|
||||
var luaScriptString2 = @"local MONSTER_POSITION_KEY = { 'monster_1','monster_2','monster_3','monster_4','monster_5','monster_6','monster_7','monster_8','monster_9','monster_10','monster_11','monster_12'}
|
||||
local list = {'enemy_id_1', 'enemy_id_2', 'enemy_id_3'}
|
||||
local list2 = {'enemy_position_1', 'enemy_position_2', 'enemy_position_3'}
|
||||
local positionConf = require('app/config/monster_position_base').data
|
||||
local monsterPositionConf = require('app/config/monster_position').data
|
||||
local stage = require('app/config/story_stage').data
|
||||
local str = {}
|
||||
for k, v in pairs(stage) do
|
||||
for k2, v2 in ipairs(list) do
|
||||
if v[v2] then
|
||||
local monsterPosition = v[list2[k2]]
|
||||
for i, monsterId in ipairs(v[v2]) do
|
||||
local monsterPositionInfo = monsterPositionConf[monsterPosition]
|
||||
local positionInfo = positionConf[monsterPositionInfo[MONSTER_POSITION_KEY[i]]]
|
||||
if positionInfo == nil then
|
||||
table.insert(str, 'stage表的id为' .. k .. '的第' .. k2 .. '波怪的坐标有问题')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #errorInfo > 0 then
|
||||
return table.concat(errorInfo, '\n');
|
||||
local stage2 = require('app/config/adventure_stage').data
|
||||
for k, v in pairs(stage2) do
|
||||
for k2, v2 in ipairs(list) do
|
||||
if v[v2] then
|
||||
local monsterPosition = v[list2[k2]]
|
||||
for i, monsterId in ipairs(v[v2]) do
|
||||
local monsterPositionInfo = monsterPositionConf[monsterPosition]
|
||||
local positionInfo = positionConf[monsterPositionInfo[MONSTER_POSITION_KEY[i]]]
|
||||
if positionInfo == nil then
|
||||
table.insert(str, 'adventure_stage表的id为' .. k .. '的第' .. k2 .. '波怪的坐标有问题')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #str > 0 then
|
||||
return table.concat(str, '\n');
|
||||
end
|
||||
|
||||
return ''";
|
||||
var resultStr = env.DoString(" local cfg = require('app/config/" + configName + "')\n" + "local configName = '" + configName + "'\n" + luaScriptString);
|
||||
if (resultStr.Length > 0)
|
||||
var resultStr2 = env.DoString(luaScriptString2);
|
||||
if (resultStr2.Length > 0)
|
||||
{
|
||||
foreach(var strObj in resultStr)
|
||||
foreach(var strObj in resultStr2)
|
||||
{
|
||||
var str = Convert.ToString(strObj);
|
||||
if(!String.IsNullOrEmpty(str))
|
||||
@ -313,6 +227,8 @@ namespace BFEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
env.Dispose();
|
||||
return sb;
|
||||
}
|
||||
|
||||
public static bool FastExportExcelToLua(bool isDeveloper, string designExcelPath)
|
||||
@ -358,19 +274,19 @@ namespace BFEditor
|
||||
|
||||
// ExportExcelTools.SpecialProcessSkill(isDeveloper, SkillSpecialOnOutput);
|
||||
// ExportExcelTools.dealMonsterConfig(isDeveloper);
|
||||
var sb = ExportExcelTools.CheckLuaConfig(isDeveloper);
|
||||
if (sb.ToString().Length > 0)
|
||||
{
|
||||
failFlag = true;
|
||||
designSuccFlag = false;
|
||||
Debug.Log("导表规范检查异常!!!");
|
||||
Debug.Log(sb.ToString());
|
||||
EditorUtility.DisplayDialog("导入失败配置", sb.ToString(), "ok");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("配置规范检查通过.");
|
||||
}
|
||||
// var sb = ExportExcelTools.CheckLuaConfig(isDeveloper);
|
||||
// if (sb.ToString().Length > 0)
|
||||
// {
|
||||
// failFlag = true;
|
||||
// designSuccFlag = false;
|
||||
// Debug.Log("导表规范检查异常!!!");
|
||||
// Debug.Log(sb.ToString());
|
||||
// EditorUtility.DisplayDialog("导入失败配置", sb.ToString(), "ok");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.Log("配置规范检查通过.");
|
||||
// }
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
@ -100,12 +100,5 @@ namespace BFEditor
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("其他工具/棋盘编辑器", false, 9)]
|
||||
public static void CreateBoardEditorWindow()
|
||||
{
|
||||
var window = (BoardEditorWindow)EditorWindow.GetWindowWithRect(typeof(BoardEditorWindow), new Rect(Screen.width / 2, Screen.height / 2, 1200, 1000), true);
|
||||
window.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ using System;
|
||||
using UnityEngine.TextCore.LowLevel;
|
||||
using TMPro.EditorUtilities;
|
||||
using Object = UnityEngine.Object;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BFEditor.Resource
|
||||
{
|
||||
@ -28,8 +27,6 @@ namespace BFEditor.Resource
|
||||
private const string AssetDefaultName = "font_sdf.asset";
|
||||
private const string AssetNumberName = "font_number_sdf.asset";
|
||||
private const string AssetBattleName = "font_battle_sdf.asset";
|
||||
private const string AssetThaiName = "font_thai_sdf.asset";
|
||||
private const string AssetJaName = "font_ja_sdf.asset";
|
||||
|
||||
private const string DevStrPath = "Assets/Editor/BFResourceTools/FontTools/cn_3900.txt";
|
||||
private const string CommonCNWordsPath = "Assets/Editor/BFResourceTools/FontTools/cn_1200.txt";
|
||||
@ -156,14 +153,6 @@ namespace BFEditor.Resource
|
||||
var defaultNumberFont = AssetDatabase.LoadAssetAtPath<Font>("Assets/arts/fonts/tmpfonts/default/tmpfont/font_number.TTF");
|
||||
GenTMPFontAsset(defaultNumberFont, new TTFInfo("cn", "Assets/arts/fonts/tmpfonts/default/tmpfont", "Assets/arts/fonts/tmpfonts/default/tmpfont", 256, new List<string>()), AssetNumberName, isdevelop);
|
||||
|
||||
// 泰语
|
||||
var thaiFont = AssetDatabase.LoadAssetAtPath<Font>("Assets/arts/fonts/tmpfonts/default/tmpfont/font_thai.ttf");
|
||||
GenTMPFontAsset(thaiFont, new TTFInfo("cn", "Assets/arts/fonts/tmpfonts/default/tmpfont", "Assets/arts/fonts/tmpfonts/default/tmpfont", 512, new List<string>()), AssetThaiName, isdevelop);
|
||||
|
||||
// 日语
|
||||
// var jaFont = AssetDatabase.LoadAssetAtPath<Font>("Assets/arts/fonts/tmpfonts/default/tmpfont/font_ja.ttf");
|
||||
// GenTMPFontAsset(jaFont, new TTFInfo("cn", "Assets/arts/fonts/tmpfonts/default/tmpfont", "Assets/arts/fonts/tmpfonts/default/tmpfont", 512, new List<string>()), AssetJaName, isdevelop);
|
||||
|
||||
// 战斗用
|
||||
// var battleFont = AssetDatabase.LoadAssetAtPath<Font>("Assets/arts/fonts/tmpfonts/battle/font_battle.ttf");
|
||||
// GenTMPFontAsset(battleFont, new TTFInfo("cn", "Assets/arts/fonts/tmpfonts/battle", "Assets/arts/fonts/tmpfonts/battle", 1024, new List<string>()), AssetBattleName, isdevelop);
|
||||
@ -244,16 +233,6 @@ namespace BFEditor.Resource
|
||||
}
|
||||
}
|
||||
|
||||
static private void GetThaiWords(List<string> luaFolderPaths, out uint[] words)
|
||||
{
|
||||
words = new uint[128];
|
||||
uint begin = 3584; //0E00-0E7F
|
||||
for (uint i = 0; i < 128; i++)
|
||||
{
|
||||
words[i] = begin + i;
|
||||
}
|
||||
}
|
||||
|
||||
static private void GenTMPFontAsset(Font font, TTFInfo ttfInfo, string assetName, bool isdevelop)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("生成TMP字体", "正在生成中...", 0f);
|
||||
@ -306,20 +285,6 @@ namespace BFEditor.Resource
|
||||
EditorUtility.SetDirty(fontAsset);
|
||||
}
|
||||
|
||||
// 泰语使用静态并特殊处理
|
||||
if (assetName == AssetThaiName)
|
||||
{
|
||||
var luaFolderPaths = new List<string>();
|
||||
luaFolderPaths.Add(Application.dataPath + "/Developer/lua/app/config/strings/th");
|
||||
var words = new uint[128];//泰语
|
||||
GetThaiWords(luaFolderPaths, out words);
|
||||
Debug.Log("泰语字符集:" + words);
|
||||
fontAsset.TryAddCharacters(words);
|
||||
fontAsset.atlasPopulationMode = AtlasPopulationMode.Static;
|
||||
// 修订部分重音位置
|
||||
_Adjust(fontAsset);
|
||||
}
|
||||
|
||||
if (null != fontAsset)
|
||||
{
|
||||
// DealWithMetric(fontAsset);
|
||||
@ -329,19 +294,14 @@ namespace BFEditor.Resource
|
||||
|
||||
// DeleteSourceFontRef(fontssetPath);
|
||||
fontAsset.fallbackFontAssetTable.Clear();
|
||||
if(assetName == AssetDefaultName)
|
||||
{
|
||||
var fallbackAsset = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(Path.Combine(assetDirPath, AssetThaiName));
|
||||
if (fallbackAsset != null)
|
||||
{
|
||||
fontAsset.fallbackFontAssetTable.Add(fallbackAsset);
|
||||
}
|
||||
// fallbackAsset = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(Path.Combine(assetDirPath, AssetJaName));
|
||||
// if(assetName == AssetDefaultName)
|
||||
// {
|
||||
// var fallbackAsset = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(Path.Combine(assetDirPath, AssetCNName));
|
||||
// if (fallbackAsset != null)
|
||||
// {
|
||||
// fontAsset.fallbackFontAssetTable.Add(fallbackAsset);
|
||||
// }
|
||||
}
|
||||
// }
|
||||
}
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
@ -597,147 +557,6 @@ namespace BFEditor.Resource
|
||||
|
||||
#endregion
|
||||
|
||||
// 针对泰语处理
|
||||
static bool overrideAll = true;
|
||||
static float wannayukHeight = 10f;
|
||||
static float aumXPlacementAfter = -35f;
|
||||
static float aumXPlacementBefore = 10f;
|
||||
static void _Adjust(TMP_FontAsset fontAsset)
|
||||
{
|
||||
if (fontAsset == null)
|
||||
{
|
||||
Debug.Log("No FontAsset selected");
|
||||
return;
|
||||
}
|
||||
|
||||
var glyphPairAdjustmentRecords = new List<TMP_GlyphPairAdjustmentRecord>(fontAsset.fontFeatureTable.glyphPairAdjustmentRecords);
|
||||
var lookupTable = fontAsset.characterLookupTable;
|
||||
|
||||
var glyphPairAdjustmentRecordLookupDictionary =
|
||||
(Dictionary<uint, TMP_GlyphPairAdjustmentRecord>) fontAsset.fontFeatureTable
|
||||
.GetType()
|
||||
.GetField("m_GlyphPairAdjustmentRecordLookupDictionary", BindingFlags.NonPublic | BindingFlags.Instance)?
|
||||
.GetValue(fontAsset.fontFeatureTable);
|
||||
|
||||
int[] saras = new int[7];
|
||||
int[] wannayuks = new int[4];
|
||||
|
||||
//get sara
|
||||
saras[0] = (int) lookupTable[GetUnicodeCharacter("ิ")].glyphIndex; // อิ
|
||||
saras[1] = (int) lookupTable[GetUnicodeCharacter("ี")].glyphIndex; // อี
|
||||
saras[2] = (int) lookupTable[GetUnicodeCharacter("ึ")].glyphIndex; // อึ
|
||||
saras[3] = (int) lookupTable[GetUnicodeCharacter("ื")].glyphIndex; // อื
|
||||
saras[4] = (int) lookupTable[GetUnicodeCharacter("ำ")].glyphIndex; // ำ
|
||||
saras[5] = (int) lookupTable[GetUnicodeCharacter("ั")].glyphIndex; // ั
|
||||
saras[6] = (int) lookupTable[GetUnicodeCharacter("ํ")].glyphIndex; // ํ
|
||||
//get wanna yuk
|
||||
wannayuks[0] = (int) lookupTable[GetUnicodeCharacter("่")].glyphIndex; //เอก
|
||||
wannayuks[1] = (int) lookupTable[GetUnicodeCharacter("้")].glyphIndex; //โท
|
||||
wannayuks[2] = (int) lookupTable[GetUnicodeCharacter("๊")].glyphIndex; //ตรี
|
||||
wannayuks[3] = (int) lookupTable[GetUnicodeCharacter("๋")].glyphIndex; //จัตวา
|
||||
int recordAdd = 0;
|
||||
foreach (var sara in saras)
|
||||
{
|
||||
foreach (var wannayuk in wannayuks)
|
||||
{
|
||||
float xPlacement = sara == saras[4] || sara == saras[6] ? aumXPlacementAfter : 0;
|
||||
|
||||
TMP_GlyphValueRecord saraPosition = new TMP_GlyphValueRecord(0, 0, 0, 0);
|
||||
TMP_GlyphAdjustmentRecord saraGlyph = new TMP_GlyphAdjustmentRecord((uint) sara, saraPosition);
|
||||
|
||||
TMP_GlyphValueRecord wannayukPosition = new TMP_GlyphValueRecord(xPlacement, wannayukHeight, 0, 0);
|
||||
TMP_GlyphAdjustmentRecord wannayukGlyph = new TMP_GlyphAdjustmentRecord((uint) wannayuk, wannayukPosition);
|
||||
|
||||
var saraThenWannayukGlyphPair = new TMP_GlyphPairAdjustmentRecord(saraGlyph, wannayukGlyph);
|
||||
|
||||
if (sara == saras[4] || sara == saras[6])
|
||||
{
|
||||
xPlacement = aumXPlacementBefore;
|
||||
wannayukPosition = new TMP_GlyphValueRecord(xPlacement, wannayukHeight, 0, 0);
|
||||
wannayukGlyph = new TMP_GlyphAdjustmentRecord((uint) wannayuk, wannayukPosition);
|
||||
}
|
||||
|
||||
var wannayukThenSaraGlyphPair = new TMP_GlyphPairAdjustmentRecord(wannayukGlyph, saraGlyph);
|
||||
|
||||
uint firstPairKey = saraThenWannayukGlyphPair.firstAdjustmentRecord.glyphIndex << 16 | saraThenWannayukGlyphPair.secondAdjustmentRecord.glyphIndex;
|
||||
uint secondPairKey = wannayukThenSaraGlyphPair.firstAdjustmentRecord.glyphIndex << 16 | wannayukThenSaraGlyphPair.secondAdjustmentRecord.glyphIndex;
|
||||
|
||||
if (overrideAll)
|
||||
{
|
||||
glyphPairAdjustmentRecords.RemoveAll(record => IsGlyphPairEqual(record, saraThenWannayukGlyphPair) ||
|
||||
IsGlyphPairEqual(record, wannayukThenSaraGlyphPair));
|
||||
|
||||
glyphPairAdjustmentRecords.Add(saraThenWannayukGlyphPair);
|
||||
glyphPairAdjustmentRecords.Add(wannayukThenSaraGlyphPair);
|
||||
|
||||
if (glyphPairAdjustmentRecordLookupDictionary != null && !glyphPairAdjustmentRecordLookupDictionary.ContainsKey(firstPairKey))
|
||||
{
|
||||
glyphPairAdjustmentRecordLookupDictionary.Add(firstPairKey, saraThenWannayukGlyphPair);
|
||||
}
|
||||
|
||||
recordAdd += 2;
|
||||
}
|
||||
else if (glyphPairAdjustmentRecordLookupDictionary != null)
|
||||
{
|
||||
if (!glyphPairAdjustmentRecordLookupDictionary.ContainsKey(firstPairKey))
|
||||
{
|
||||
glyphPairAdjustmentRecords.Add(saraThenWannayukGlyphPair);
|
||||
recordAdd++;
|
||||
}
|
||||
|
||||
if (!glyphPairAdjustmentRecordLookupDictionary.ContainsKey(secondPairKey))
|
||||
{
|
||||
glyphPairAdjustmentRecords.Add(wannayukThenSaraGlyphPair);
|
||||
recordAdd++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (recordAdd > 0)
|
||||
{
|
||||
fontAsset.fontFeatureTable.glyphPairAdjustmentRecords = glyphPairAdjustmentRecords;
|
||||
fontAsset.fontFeatureTable.SortGlyphPairAdjustmentRecords();
|
||||
EditorUtility.SetDirty(fontAsset);
|
||||
AssetDatabase.SaveAssets();
|
||||
Canvas.ForceUpdateCanvases();
|
||||
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
|
||||
}
|
||||
|
||||
Debug.Log("Adjust font : <color=#2bcaff>" + fontAsset.name + "</color>" +
|
||||
" Height offset : <color=#d8ff2b>" + wannayukHeight + "</color>" +
|
||||
" Number of adjustment add : <color=#5dfa41>" + recordAdd + "</color>");
|
||||
}
|
||||
|
||||
static void _Clear(TMP_FontAsset fontAsset)
|
||||
{
|
||||
fontAsset.fontFeatureTable.glyphPairAdjustmentRecords = new List<TMP_GlyphPairAdjustmentRecord>();
|
||||
EditorUtility.SetDirty(fontAsset);
|
||||
AssetDatabase.SaveAssets();
|
||||
Canvas.ForceUpdateCanvases();
|
||||
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
|
||||
}
|
||||
|
||||
static uint GetUnicodeCharacter (string source)
|
||||
{
|
||||
uint unicode;
|
||||
|
||||
if (source.Length == 1)
|
||||
unicode = source[0];
|
||||
else if (source.Length == 6)
|
||||
unicode = (uint)TMP_TextUtilities.StringHexToInt(source.Replace("\\u", ""));
|
||||
else
|
||||
unicode = (uint)TMP_TextUtilities.StringHexToInt(source.Replace("\\U", ""));
|
||||
|
||||
return unicode;
|
||||
}
|
||||
|
||||
static bool IsGlyphPairEqual(TMP_GlyphPairAdjustmentRecord a, TMP_GlyphPairAdjustmentRecord b)
|
||||
{
|
||||
return a.firstAdjustmentRecord.glyphIndex == b.firstAdjustmentRecord.glyphIndex &&
|
||||
a.secondAdjustmentRecord.glyphIndex == b.secondAdjustmentRecord.glyphIndex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,12 +21,11 @@ namespace BFEditor.Resource
|
||||
private static string excludeDir = Application.dataPath + "/Developer/lua/app/config";
|
||||
private const char DOUBLE_QUOTES = '"';
|
||||
private const char SINGLE_QUOTE = '\'';
|
||||
|
||||
public static List<LuaCheckResult> ResultList = new List<LuaCheckResult>();
|
||||
// private static Regex reg = new Regex(@".*[\u4e00-\u9fa5]+"); // 汉字
|
||||
private static Regex reg = new Regex(@".*[\u0391-\uffe5]+"); //双字节字符(汉字+符号)
|
||||
private static HashSet<string> ExcludeFileName = new HashSet<string> {
|
||||
"first_text.lua", "gm_const.lua", "dev_tool_list_ui.lua", "gm_tool_ui.lua"
|
||||
};
|
||||
|
||||
public static void CheckAll(Action<bool> checkOverAction)
|
||||
{
|
||||
Clear();
|
||||
@ -40,11 +39,7 @@ namespace BFEditor.Resource
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (fileInfo.DirectoryName.Replace("\\", "/").Contains(excludeDir))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (ExcludeFileName.Contains(fileInfo.Name))
|
||||
if (fileInfo.DirectoryName.Contains(excludeDir))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -79,9 +74,6 @@ namespace BFEditor.Resource
|
||||
match = reg.Match(content);
|
||||
}
|
||||
if (match != Match.Empty)
|
||||
{
|
||||
index = content.IndexOf("Logger.log");
|
||||
if (index < 0)
|
||||
{
|
||||
LuaCheckResult checkResult;
|
||||
checkResult.content = content;
|
||||
@ -92,7 +84,6 @@ namespace BFEditor.Resource
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (checkOverAction != null)
|
||||
checkOverAction(ResultList.Count == 0);
|
||||
}
|
||||
|
||||
@ -14,8 +14,8 @@ namespace BFEditor.Resource
|
||||
{
|
||||
return new List<BFSubChecker>()
|
||||
{
|
||||
// new CharacterFbxChecker(),
|
||||
// new SceneFbxChecker(),
|
||||
new CharacterFbxChecker(),
|
||||
new SceneFbxChecker(),
|
||||
new EffectFbxChecker(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -15,8 +15,8 @@ namespace BFEditor.Resource
|
||||
return new List<BFSubChecker>()
|
||||
{
|
||||
new UIPrefabChecker(),
|
||||
// new CharacterPrefabChecker(),
|
||||
// new ScenePrefabChecker(),
|
||||
new CharacterPrefabChecker(),
|
||||
new ScenePrefabChecker(),
|
||||
new EffectPrefabChecker(),
|
||||
// new AutoCreatedEffectPrefabChecker(),
|
||||
};
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BFEditor.Resource
|
||||
{
|
||||
public class BFSpineChecker : BFMainChecker
|
||||
{
|
||||
protected override GUIContent InitGUIContent()
|
||||
{
|
||||
return new GUIContent("spine", BFEditorUtils.GetSystemIcon(typeof(Spine.Unity.SkeletonDataAsset)));
|
||||
}
|
||||
|
||||
protected override List<BFSubChecker> InitSubCheckers()
|
||||
{
|
||||
return new List<BFSubChecker>()
|
||||
{
|
||||
new SpineSubChecker(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9c0f8968ad84174b9bc2d446ec36e7b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using BF;
|
||||
|
||||
namespace BFEditor.Resource
|
||||
{
|
||||
@ -59,27 +58,6 @@ namespace BFEditor.Resource
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
var effectHelper = gameObject.GetComponent<EffectHelper>();
|
||||
if (effectHelper == null)
|
||||
{
|
||||
currentBadRes.AddBadLog(gameObject.name + "没有挂载EffectHelper");
|
||||
result = false;
|
||||
}
|
||||
|
||||
var ParticleSystem = gameObject.GetComponent<ParticleSystem>();
|
||||
if (ParticleSystem != null)
|
||||
{
|
||||
currentBadRes.AddBadLog(gameObject.name + "根节点挂载了ParticleSystem");
|
||||
result = false;
|
||||
}
|
||||
|
||||
var layer = gameObject.layer;
|
||||
if(layer != LayerMask.NameToLayer("UI")) //UI层
|
||||
{
|
||||
currentBadRes.AddBadLog(gameObject.name + "layer不是UI");
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e339cd1033ed11b4f9e49a9760fef963
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,109 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
|
||||
namespace BFEditor.Resource
|
||||
{
|
||||
public class SpineSubChecker : BFSubChecker
|
||||
{
|
||||
Dictionary<string, bool> mustNeedAni = new Dictionary<string, bool>(){
|
||||
{"born", true},
|
||||
{"death", true},
|
||||
{"idle", true},
|
||||
{"suffer", true},
|
||||
{"vertigo", true},
|
||||
{"frozen", true},
|
||||
{"move", true},
|
||||
};
|
||||
|
||||
Dictionary<string, bool> heroMustNeedAni = new Dictionary<string, bool>(){
|
||||
{"attack01", true},
|
||||
{"attack02", true},
|
||||
{"attack03", true},
|
||||
{"attack04", true},
|
||||
};
|
||||
|
||||
Dictionary<string, bool> monsterMustNeedAni = new Dictionary<string, bool>(){
|
||||
{"attack01", true},
|
||||
{"attack02", true},
|
||||
{"attack03", true},
|
||||
};
|
||||
|
||||
public override string InitName()
|
||||
{
|
||||
return "Spine";
|
||||
}
|
||||
|
||||
public override bool DoCheck(string assetPath, AssetImporter assetImporter, Object assetObj)
|
||||
{
|
||||
bool passed = true;
|
||||
if (assetPath.Contains("characters"))
|
||||
{
|
||||
var skeletonDataAsset = AssetDatabase.LoadAssetAtPath<Spine.Unity.SkeletonDataAsset>(assetPath);
|
||||
var animationState = skeletonDataAsset.GetAnimationStateData();
|
||||
Dictionary<string, bool> haveAni = new Dictionary<string, bool>();
|
||||
foreach (var animation in animationState.SkeletonData.Animations)
|
||||
{
|
||||
haveAni[animation.Name] = true;
|
||||
}
|
||||
foreach (var key in mustNeedAni.Keys)
|
||||
{
|
||||
if (!haveAni.ContainsKey(key))
|
||||
{
|
||||
currentBadRes.AddBadLog("没有动画" + key);
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (assetPath.Contains("characters/p"))
|
||||
{
|
||||
foreach (var key in heroMustNeedAni.Keys)
|
||||
{
|
||||
if (!haveAni.ContainsKey(key))
|
||||
{
|
||||
currentBadRes.AddBadLog("没有动画" + key);
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (assetPath.Contains("characters/m"))
|
||||
{
|
||||
foreach (var key in monsterMustNeedAni.Keys)
|
||||
{
|
||||
if (!haveAni.ContainsKey(key))
|
||||
{
|
||||
currentBadRes.AddBadLog("没有动画" + key);
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string floderPath = Path.GetDirectoryName(assetPath);
|
||||
string[] paths = Directory.GetFiles(floderPath);
|
||||
int fileCount = 0;
|
||||
foreach (string unitPath in paths)
|
||||
{
|
||||
if (Path.GetExtension(unitPath) != ".meta")
|
||||
{
|
||||
fileCount++;
|
||||
}
|
||||
}
|
||||
if (fileCount > 6) // 只能有六个文件
|
||||
{
|
||||
currentBadRes.AddBadLog("文件夹文件数量异常");
|
||||
passed = false;
|
||||
}
|
||||
|
||||
return passed;
|
||||
}
|
||||
|
||||
protected override List<string> GetAssetPathList()
|
||||
{
|
||||
return BFEditorUtils.GetAssetPathsWithSuffix(ResourceProcessConfig.SPINE_TEXTURE_PATH, ".asset", "skeletondata");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45556e9bea3af1b4b96c6e7a1fec9552
|
||||
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 UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
namespace BFEditor.Resource
|
||||
{
|
||||
public class BFSpineImporter : BFMainImporter
|
||||
{
|
||||
protected override List<BFSubImporter> InitSubImporters()
|
||||
{
|
||||
return new List<BFSubImporter>()
|
||||
{
|
||||
new BFSpineSubImporter(),
|
||||
};
|
||||
}
|
||||
|
||||
public override bool NeedDeal(string assetPath)
|
||||
{
|
||||
var suffix = Path.GetExtension(assetPath);
|
||||
return suffix == ".asset";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aec487ce03f96b141b9363cbb898e894
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.Rendering;
|
||||
using BF;
|
||||
|
||||
namespace BFEditor.Resource
|
||||
{
|
||||
@ -32,20 +31,6 @@ namespace BFEditor.Resource
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
var effectHelper = prefabObj.GetComponent<EffectHelper>();
|
||||
if (effectHelper == null)
|
||||
{
|
||||
prefabObj.AddComponent<EffectHelper>();
|
||||
SetDirty();
|
||||
}
|
||||
EffectHelperInspector.OnPrefabSaved(prefabObj);
|
||||
|
||||
var layer = prefabObj.layer;
|
||||
if(layer != LayerMask.NameToLayer("UI")) //UI层
|
||||
{
|
||||
prefabObj.layer = LayerMask.NameToLayer("UI");
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5bc4bc411f27624fa3eb792290cbd09
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,21 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace BFEditor.Resource
|
||||
{
|
||||
public class BFSpineSubImporter : BFSubImporter
|
||||
{
|
||||
public override bool NeedDeal(string assetPath)
|
||||
{
|
||||
return assetPath.Contains(ResourceProcessConfig.SPINE_TEXTURE_PATH);
|
||||
}
|
||||
|
||||
protected override void DoImport(string assetPath, AssetImporter assetImporter, bool isFix)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95690334d8b9a8b4b82d428441cc2095
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -9,7 +9,7 @@ namespace BFEditor.Resource
|
||||
{
|
||||
public override bool NeedDeal(string assetPath)
|
||||
{
|
||||
return assetPath.Contains(ResourceProcessConfig.BG_BATTLE_TEXTURE_FOLDER_PATH);
|
||||
return assetPath.Contains(ResourceProcessConfig.BG_TEXTURE_FOLDER_PATH);
|
||||
}
|
||||
|
||||
protected override void DoImport(string assetPath, TextureImporter textureImporter, bool isFix)
|
||||
|
||||
@ -133,7 +133,6 @@ namespace BFEditor.Resource
|
||||
new BFPrefabImporter(),
|
||||
new BFMaterialImporter(),
|
||||
new BFShaderImporter(),
|
||||
new BFSpineImporter(),
|
||||
};
|
||||
|
||||
//资源白名单 检查时过滤
|
||||
@ -202,7 +201,6 @@ namespace BFEditor.Resource
|
||||
new BFAudioChecker(),
|
||||
new BFMaterialChecker(),
|
||||
new BFShaderChecker(),
|
||||
new BFSpineChecker(),
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ namespace BFEditor
|
||||
PrefabStage.prefabSaving += OnPrefabSaved;
|
||||
}
|
||||
|
||||
public static void OnPrefabSaved(GameObject go)
|
||||
private static void OnPrefabSaved(GameObject go)
|
||||
{
|
||||
var effectHelper = go.GetComponent<EffectHelper>();
|
||||
if (effectHelper != null)
|
||||
|
||||
@ -11,40 +11,72 @@ public class JenkinsAdapter {
|
||||
/// 构建版本号
|
||||
/// </summary>
|
||||
private static string BuildVersion = (int.Parse(DateTime.Now.ToString("yyMMddHH"))).ToString();
|
||||
private static int versionCode = 10;
|
||||
private static string versionName = "1.4.0";
|
||||
private static bool _oldShowSplash = false;
|
||||
|
||||
/// <summary>
|
||||
/// 通用设置
|
||||
/// </summary>
|
||||
private static bool CommonSetting(BuildTargetGroup target) {
|
||||
|
||||
_oldShowSplash = PlayerSettings.SplashScreen.show;
|
||||
//去掉Unity的SplashScreen
|
||||
PlayerSettings.SplashScreen.show = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void BuildAddressable(BuildTargetGroup target, BuildTarget buildTarget) {
|
||||
// EditorUserBuildSettings.SwitchActiveBuildTarget(target, buildTarget);
|
||||
// AddressableEditor.BuildContent();
|
||||
}
|
||||
|
||||
//设置还原
|
||||
private static void recover(BuildTargetGroup target) {
|
||||
PlayerSettings.SplashScreen.show = _oldShowSplash;
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
//打包 app bundle
|
||||
|
||||
[MenuItem("Jenkins/JenkinsBuildIos")]
|
||||
public static void CommandLineBuildIos() {
|
||||
//打包
|
||||
if(!CommonSetting(BuildTargetGroup.iOS)){
|
||||
return;
|
||||
};
|
||||
BuildAddressable(BuildTargetGroup.iOS, BuildTarget.iOS);
|
||||
|
||||
var buildInfo = new BuildInfo();
|
||||
buildInfo.version = versionName;
|
||||
buildInfo.version = "0.1.0";
|
||||
buildInfo.mode = "publish_release";
|
||||
buildInfo.bundleName = "com.combo.heroes.puzzle.rpg";
|
||||
buildInfo.bundleName = "com.juzu.b6";
|
||||
buildInfo.skipVersion = false;
|
||||
BuildProjectTools.BuildResources(buildInfo, Application.streamingAssetsPath, true);
|
||||
|
||||
// 重新生成XLua
|
||||
CompileScriptsUtils.RegenerateXLuaCode(true);
|
||||
|
||||
// 设置版本号
|
||||
PlayerSettings.bundleVersion = buildInfo.version;
|
||||
//SDK要求
|
||||
PlayerSettings.iOS.targetOSVersionString = "12.0";
|
||||
//设置Build,每次需要增加
|
||||
PlayerSettings.iOS.buildNumber = versionCode.ToString();
|
||||
// 隐藏ios的横条
|
||||
PlayerSettings.iOS.hideHomeButton = false;
|
||||
// 禁止在所有边缘上延迟手势
|
||||
PlayerSettings.iOS.deferSystemGesturesMode = UnityEngine.iOS.SystemGestureDeferMode.All;
|
||||
//Jenkins要求自动构建最低ios8.0
|
||||
PlayerSettings.iOS.targetOSVersionString = "10.0";
|
||||
//设置Build为日期格式
|
||||
PlayerSettings.iOS.buildNumber = BuildVersion;
|
||||
|
||||
// 设置竖屏
|
||||
PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait;
|
||||
PlayerSettings.allowedAutorotateToPortrait = false;
|
||||
PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
|
||||
PlayerSettings.allowedAutorotateToLandscapeLeft = false;
|
||||
PlayerSettings.allowedAutorotateToLandscapeRight = false;
|
||||
|
||||
// 关闭启动动画
|
||||
PlayerSettings.SplashScreen.show = false;
|
||||
|
||||
// 设置包名
|
||||
PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, buildInfo.bundleName);
|
||||
|
||||
// 是否跳过版本控制
|
||||
var symbols = "THREAD_SAFE;USE_AB";
|
||||
if (buildInfo.skipVersion)
|
||||
@ -53,19 +85,20 @@ public class JenkinsAdapter {
|
||||
}
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, symbols);
|
||||
// 商品名称
|
||||
PlayerSettings.productName = "Knights Combo";
|
||||
PlayerSettings.productName = "Lonely Survivor";
|
||||
// BuildType设置dev/release
|
||||
EditorUserBuildSettings.iOSBuildConfigType = iOSBuildType.Release;
|
||||
EditorUserBuildSettings.development = false;
|
||||
// 使用IL2CPP
|
||||
var scriptImp = ScriptingImplementation.IL2CPP;
|
||||
PlayerSettings.SetScriptingBackend(BuildTargetGroup.iOS, scriptImp);
|
||||
// 目标平台架构,目前支持ARM64
|
||||
PlayerSettings.SetArchitecture(BuildTargetGroup.iOS, 1);
|
||||
EditorUserBuildSettings.development = false;
|
||||
|
||||
// 开始打包
|
||||
BuildPipeline.BuildPlayer(GetBuildScenes(), GetIosBuildPath(), BuildTarget.iOS, BuildOptions.None);
|
||||
Console.WriteLine("Build Complete Path:" + GetIosBuildPath());
|
||||
|
||||
recover(BuildTargetGroup.iOS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -68,8 +68,7 @@ namespace BFEditor
|
||||
"TMPro.SortingLayerHelper",
|
||||
"UnityEngine.CloudStreaming",
|
||||
"BFEditor.EditorBattleRoleAttackOperate",
|
||||
"IronSourceBannerEvents", "IronSourceEvents", "IronSourceInterstitialEvents", "IronSourceRewardedVideoEvents",
|
||||
"IronSourceAdQualityManifestTools"
|
||||
"IronSourceBannerEvents", "IronSourceEvents", "IronSourceInterstitialEvents", "IronSourceRewardedVideoEvents"
|
||||
};
|
||||
|
||||
static bool isExcluded(Type type)
|
||||
@ -347,7 +346,6 @@ namespace BFEditor
|
||||
typeof(UnityEngine.UI.GridLayoutGroup.Constraint),
|
||||
typeof(UnityEngine.UI.VerticalLayoutGroup),
|
||||
typeof(UnityEngine.UI.LayoutGroup),
|
||||
typeof(UnityEngine.GUIUtility),
|
||||
|
||||
// spine
|
||||
typeof(Spine.TrackEntry),
|
||||
@ -453,8 +451,6 @@ namespace BFEditor
|
||||
typeof(BF.ScrollRectBaseOld.ScrollbarVisibility),
|
||||
typeof(BF.NetServiceType),
|
||||
typeof(BF.NetIncomingMessageType),
|
||||
typeof(BF.BFGridLayout.Corner),
|
||||
typeof(BF.BFGridLayout.Constraint),
|
||||
};
|
||||
return unityTypes.Concat(customTypes).Concat(otherTypes);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -285,7 +285,7 @@ namespace BFEditor
|
||||
return string.Format("{0}分{1}秒", minus, second);
|
||||
}
|
||||
|
||||
public static List<string> GetAssetPathsWithSuffix(string path, string suffix, string containsStr = "")
|
||||
public static List<string> GetAssetPathsWithSuffix(string path, string suffix)
|
||||
{
|
||||
var result = new List<string>();
|
||||
var fileInfos = new List<FileInfo>();
|
||||
@ -295,18 +295,8 @@ namespace BFEditor
|
||||
{
|
||||
var resourcePath = "Assets" + fileInfos[i].FullName.Replace("\\", "/").Remove(0, Application.dataPath.Length);
|
||||
resourcePath = resourcePath.Replace('\\', '/');
|
||||
if (containsStr == "")
|
||||
{
|
||||
result.Add(resourcePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fileInfos[i].FullName.Contains(containsStr))
|
||||
{
|
||||
result.Add(resourcePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
</array> -->
|
||||
<key>com.apple.developer.associated-domains</key>
|
||||
<array>
|
||||
<string>applinks:b6-cdn.bigfoot-studio.link</string>
|
||||
<string>applinks:b2-cdn.bigfoot-studio.link</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@ -25,11 +25,11 @@
|
||||
<activity android:name="com.facebook.unity.FBUnityGameRequestActivity" />
|
||||
<activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />
|
||||
<activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />
|
||||
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb277827051329111" />
|
||||
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="cd6be8cc57dff789f3476ee1b25e2410" />
|
||||
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb222326627097275" />
|
||||
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="7ec364275c7766833d2ebace0c5a806e" />
|
||||
<meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="true" />
|
||||
<meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled" android:value="true" />
|
||||
<provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider277827051329111" android:exported="true" />
|
||||
<provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider222326627097275" android:exported="true" />
|
||||
<!-- <uses-permission android:name="com.google.android.gms.permission.AD_ID" /> -->
|
||||
<receiver android:name="com.adjust.sdk.AdjustReferrerReceiver" android:permission="android.permission.INSTALL_PACKAGES" android:exported="true">
|
||||
<intent-filter>
|
||||
|
||||
BIN
Assets/Plugins/Android/android-bridge.jar
Normal file
BIN
Assets/Plugins/Android/android-bridge.jar
Normal file
Binary file not shown.
32
Assets/Plugins/Android/android-bridge.jar.meta
Normal file
32
Assets/Plugins/Android/android-bridge.jar.meta
Normal file
@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbe75846a2b4da1459371181319ce8e3
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -8,28 +8,19 @@
|
||||
url "https://maven.google.com"
|
||||
}
|
||||
maven {
|
||||
url "https://android-sdk.is.com/" // Assets/ThirdParty/IronSource/Editor/IronSourceSDKDependencies.xml:9, Assets/ThirdParty/IronSource/Editor/ISAdColonyAdapterDependencies.xml:16, Assets/ThirdParty/IronSource/Editor/ISAdMobAdapterDependencies.xml:16, Assets/ThirdParty/IronSource/Editor/ISAppLovinAdapterDependencies.xml:8, Assets/ThirdParty/IronSource/Editor/ISChartboostAdapterDependencies.xml:8, Assets/ThirdParty/IronSource/Editor/ISFacebookAdapterDependencies.xml:16, Assets/ThirdParty/IronSource/Editor/ISFyberAdapterDependencies.xml:16, Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:48, Assets/ThirdParty/IronSource/Editor/ISPangleAdapterDependencies.xml:8, Assets/ThirdParty/IronSource/Editor/ISTapJoyAdapterDependencies.xml:8, Assets/ThirdParty/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:8, Assets/ThirdParty/IronSource/Editor/ISVungleAdapterDependencies.xml:16
|
||||
url "https://android-sdk.is.com/" // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:9, Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:16, Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:16, Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:8, Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:8, Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:16, Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:16, Assets/IronSource/Editor/ISLiftoffAdapterDependencies.xml:16, Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:8, Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:8, Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:8
|
||||
}
|
||||
maven {
|
||||
url "https://maven.google.com/" // Assets/ThirdParty/IronSource/Editor/IronSourceSDKDependencies.xml:17, Assets/ThirdParty/IronSource/Editor/IronSourceSDKDependencies.xml:25, Assets/ThirdParty/IronSource/Editor/ISAdColonyAdapterDependencies.xml:8, Assets/ThirdParty/IronSource/Editor/ISAdMobAdapterDependencies.xml:8, Assets/ThirdParty/IronSource/Editor/ISFacebookAdapterDependencies.xml:8, Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:40, Assets/ThirdParty/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:15
|
||||
url "https://maven.google.com/" // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:17, Assets/IronSource/Editor/IronSourceSDKDependencies.xml:25, Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:8, Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:8, Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:15, Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:15, Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:8, Assets/IronSource/Editor/ISLiftoffAdapterDependencies.xml:8, Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:15
|
||||
}
|
||||
maven {
|
||||
url "https://cboost.jfrog.io/artifactory/chartboost-ads/" // Assets/ThirdParty/IronSource/Editor/ISChartboostAdapterDependencies.xml:15
|
||||
url "https://repo.maven.apache.org/maven2/" // Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:8
|
||||
}
|
||||
maven {
|
||||
url "https://repo.maven.apache.org/maven2/" // Assets/ThirdParty/IronSource/Editor/ISFyberAdapterDependencies.xml:8
|
||||
url "https://artifact.bytedance.com/repository/pangle/" // Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:15
|
||||
}
|
||||
maven {
|
||||
url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea/" // Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:8, Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:16, Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:24, Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:32
|
||||
}
|
||||
maven {
|
||||
url "https://artifact.bytedance.com/repository/pangle/" // Assets/ThirdParty/IronSource/Editor/ISPangleAdapterDependencies.xml:15
|
||||
}
|
||||
maven {
|
||||
url "https://sdk.tapjoy.com/" // Assets/ThirdParty/IronSource/Editor/ISTapJoyAdapterDependencies.xml:15
|
||||
}
|
||||
maven {
|
||||
url "https://jitpack.io/" // Assets/ThirdParty/IronSource/Editor/ISVungleAdapterDependencies.xml:8
|
||||
url "https://sdk.tapjoy.com/" // Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:15
|
||||
}
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
@ -43,50 +34,42 @@ apply plugin: 'com.android.library'
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
// Android Resolver Dependencies Start
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1' // Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:40
|
||||
implementation 'com.adcolony:sdk:4.8.0' // Assets/ThirdParty/IronSource/Editor/ISAdColonyAdapterDependencies.xml:8
|
||||
implementation 'com.adcolony:sdk:4.8.0' // Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:8
|
||||
implementation 'com.android.installreferrer:installreferrer:2.1' // Assets/ThirdParty/AppsFlyer/Editor/AppsFlyerDependencies.xml:10
|
||||
implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
|
||||
implementation 'com.android.support:cardview-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
|
||||
implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
|
||||
implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
|
||||
implementation 'com.applovin:applovin-sdk:11.10.1' // Assets/ThirdParty/MaxSdk/AppLovin/Editor/Dependencies.xml:4
|
||||
implementation 'com.appsflyer:adrevenue:6.5.4' // Assets/ThirdParty/AppsFlyer/Editor/AppsFlyerAdRevenueDependencies.xml:4
|
||||
implementation 'com.applovin:applovin-sdk:11.7.1' // Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:15
|
||||
implementation 'com.appsflyer:af-android-sdk:6.4.1' // Assets/ThirdParty/AppsFlyer/Editor/AppsFlyerDependencies.xml:6
|
||||
implementation 'com.appsflyer:unity-adrevenue-generic-wrapper:6.5.4' // Assets/ThirdParty/AppsFlyer/Editor/AppsFlyerAdRevenueDependencies.xml:5
|
||||
implementation 'com.appsflyer:unity-wrapper:6.4.1' // Assets/ThirdParty/AppsFlyer/Editor/AppsFlyerDependencies.xml:8
|
||||
implementation 'com.chartboost:chartboost-sdk:9.3.1' // Assets/ThirdParty/IronSource/Editor/ISChartboostAdapterDependencies.xml:15
|
||||
implementation 'com.facebook.android:audience-network-sdk:6.16.0' // Assets/ThirdParty/IronSource/Editor/ISFacebookAdapterDependencies.xml:8
|
||||
implementation 'com.chartboost:chartboost-sdk:9.2.0' // Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:15
|
||||
implementation 'com.facebook.android:audience-network-sdk:6.12.0' // Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:8
|
||||
implementation 'com.facebook.android:facebook-applinks:[15.1,16)' // Assets/ThirdParty/FacebookSDK/Plugins/Editor/Dependencies.xml:6
|
||||
implementation 'com.facebook.android:facebook-core:[15.1,16)' // Assets/ThirdParty/FacebookSDK/Plugins/Editor/Dependencies.xml:5
|
||||
implementation 'com.facebook.android:facebook-gamingservices:[15.1,16)' // Assets/ThirdParty/FacebookSDK/Plugins/Editor/Dependencies.xml:9
|
||||
implementation 'com.facebook.android:facebook-login:[15.1,16)' // Assets/ThirdParty/FacebookSDK/Plugins/Editor/Dependencies.xml:7
|
||||
implementation 'com.facebook.android:facebook-share:[15.1,16)' // Assets/ThirdParty/FacebookSDK/Plugins/Editor/Dependencies.xml:8
|
||||
implementation 'com.fyber:marketplace-sdk:8.2.4' // Assets/ThirdParty/IronSource/Editor/ISFyberAdapterDependencies.xml:8
|
||||
implementation 'com.google.android.gms:play-services-ads:22.2.0' // Assets/ThirdParty/IronSource/Editor/ISAdMobAdapterDependencies.xml:8
|
||||
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' // Assets/ThirdParty/IronSource/Editor/IronSourceSDKDependencies.xml:17
|
||||
implementation 'com.google.android.gms:play-services-basement:18.1.0' // Assets/ThirdParty/IronSource/Editor/IronSourceSDKDependencies.xml:25
|
||||
implementation 'com.ironsource.adapters:adcolonyadapter:4.3.15' // Assets/ThirdParty/IronSource/Editor/ISAdColonyAdapterDependencies.xml:16
|
||||
implementation 'com.ironsource.adapters:admobadapter:4.3.39' // Assets/ThirdParty/IronSource/Editor/ISAdMobAdapterDependencies.xml:16
|
||||
implementation 'com.ironsource.adapters:applovinadapter:4.3.39' // Assets/ThirdParty/IronSource/Editor/ISAppLovinAdapterDependencies.xml:8
|
||||
implementation 'com.ironsource.adapters:chartboostadapter:4.3.12' // Assets/ThirdParty/IronSource/Editor/ISChartboostAdapterDependencies.xml:8
|
||||
implementation 'com.ironsource.adapters:facebookadapter:4.3.45' // Assets/ThirdParty/IronSource/Editor/ISFacebookAdapterDependencies.xml:16
|
||||
implementation 'com.ironsource.adapters:fyberadapter:4.3.28' // Assets/ThirdParty/IronSource/Editor/ISFyberAdapterDependencies.xml:16
|
||||
implementation 'com.ironsource.adapters:mintegraladapter:4.3.19' // Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:48
|
||||
implementation 'com.ironsource.adapters:pangleadapter:4.3.22' // Assets/ThirdParty/IronSource/Editor/ISPangleAdapterDependencies.xml:8
|
||||
implementation 'com.ironsource.adapters:tapjoyadapter:4.1.25' // Assets/ThirdParty/IronSource/Editor/ISTapJoyAdapterDependencies.xml:8
|
||||
implementation 'com.ironsource.adapters:unityadsadapter:4.3.33' // Assets/ThirdParty/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:8
|
||||
implementation 'com.ironsource.adapters:vungleadapter:4.3.22' // Assets/ThirdParty/IronSource/Editor/ISVungleAdapterDependencies.xml:16
|
||||
implementation 'com.ironsource.sdk:mediationsdk:7.5.1' // Assets/ThirdParty/IronSource/Editor/IronSourceSDKDependencies.xml:9
|
||||
implementation 'com.mbridge.msdk.oversea:mbbanner:16.5.21' // Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:24
|
||||
implementation 'com.mbridge.msdk.oversea:mbbid:16.5.21' // Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:32
|
||||
implementation 'com.mbridge.msdk.oversea:newinterstitial:16.5.21' // Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:8
|
||||
implementation 'com.mbridge.msdk.oversea:reward:16.5.21' // Assets/ThirdParty/IronSource/Editor/ISMintegralAdapterDependencies.xml:16
|
||||
implementation 'com.pangle.global:ads-sdk:5.5.0.5' // Assets/ThirdParty/IronSource/Editor/ISPangleAdapterDependencies.xml:15
|
||||
implementation 'com.fyber:marketplace-sdk:8.2.2' // Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:8
|
||||
implementation 'com.google.android.gms:play-services-ads:21.5.0' // Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:8
|
||||
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:17
|
||||
implementation 'com.google.android.gms:play-services-basement:18.1.0' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:25
|
||||
implementation 'com.ironsource.adapters:adcolonyadapter:4.3.14' // Assets/IronSource/Editor/ISAdColonyAdapterDependencies.xml:16
|
||||
implementation 'com.ironsource.adapters:admobadapter:4.3.35' // Assets/IronSource/Editor/ISAdMobAdapterDependencies.xml:16
|
||||
implementation 'com.ironsource.adapters:applovinadapter:4.3.37' // Assets/IronSource/Editor/ISAppLovinAdapterDependencies.xml:8
|
||||
implementation 'com.ironsource.adapters:chartboostadapter:4.3.11' // Assets/IronSource/Editor/ISChartboostAdapterDependencies.xml:8
|
||||
implementation 'com.ironsource.adapters:facebookadapter:4.3.39' // Assets/IronSource/Editor/ISFacebookAdapterDependencies.xml:16
|
||||
implementation 'com.ironsource.adapters:fyberadapter:4.3.24' // Assets/IronSource/Editor/ISFyberAdapterDependencies.xml:16
|
||||
implementation 'com.ironsource.adapters:liftoffadapter:4.3.5' // Assets/IronSource/Editor/ISLiftoffAdapterDependencies.xml:16
|
||||
implementation 'com.ironsource.adapters:pangleadapter:4.3.17' // Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:8
|
||||
implementation 'com.ironsource.adapters:tapjoyadapter:4.1.24' // Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:8
|
||||
implementation 'com.ironsource.adapters:unityadsadapter:4.3.27' // Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:8
|
||||
implementation 'com.ironsource.sdk:mediationsdk:7.3.0.1' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:9
|
||||
implementation 'com.pangle.global:ads-sdk:5.0.0.8' // Assets/IronSource/Editor/ISPangleAdapterDependencies.xml:15
|
||||
implementation 'com.parse.bolts:bolts-android:1.4.0' // Assets/ThirdParty/FacebookSDK/Plugins/Editor/Dependencies.xml:4
|
||||
implementation 'com.tapjoy:tapjoy-android-sdk:13.0.1' // Assets/ThirdParty/IronSource/Editor/ISTapJoyAdapterDependencies.xml:15
|
||||
implementation 'com.unity3d.ads:unity-ads:4.9.1' // Assets/ThirdParty/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:15
|
||||
implementation 'com.vungle:vungle-ads:7.0.0' // Assets/ThirdParty/IronSource/Editor/ISVungleAdapterDependencies.xml:8
|
||||
implementation 'com.tapjoy:tapjoy-android-sdk:12.11.1' // Assets/IronSource/Editor/ISTapJoyAdapterDependencies.xml:15
|
||||
implementation 'com.unity3d.ads:unity-ads:4.6.1' // Assets/IronSource/Editor/ISUnityAdsAdapterDependencies.xml:15
|
||||
implementation 'io.liftoff:liftoffads:1.9.1' // Assets/IronSource/Editor/ISLiftoffAdapterDependencies.xml:8
|
||||
// Android Resolver Dependencies End
|
||||
**DEPS**}
|
||||
|
||||
|
||||
@ -1,16 +1,12 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "FirebaseSDK.h"
|
||||
#import "FirebaseMessaging/FIRMessaging.h"
|
||||
#import "NativeUtils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*GetFirebaseTokenCallback)(const char* token);
|
||||
GetFirebaseTokenCallback firebaseTokenCallback;
|
||||
|
||||
// 初始化SDK
|
||||
void FIRInitialize() {
|
||||
[[FirebaseSDK getInstance] initialize];
|
||||
@ -30,21 +26,6 @@ extern "C" {
|
||||
[[FirebaseSDK getInstance] logCrash:[NSString stringWithFormat:@"%s", key] stack:[NSString stringWithFormat:@"%s", stack]];
|
||||
}
|
||||
|
||||
void FIRGetToken(GetFirebaseTokenCallback callback) {
|
||||
firebaseTokenCallback = callback;
|
||||
[[FIRMessaging messaging] tokenWithCompletion:^(NSString *token, NSError *error) {
|
||||
if (error != nil) {
|
||||
NSLog(@"Error getting FCM registration token: %@", error);
|
||||
} else {
|
||||
NSLog(@"FCM registration token: %@", token);
|
||||
if (firebaseTokenCallback){
|
||||
const char *pConstToken = [token UTF8String];
|
||||
firebaseTokenCallback(pConstToken);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3,23 +3,21 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CLIENT_ID</key>
|
||||
<string>1008416471093-78jluae6d1tdl8l4qkul3hut7lckd1kc.apps.googleusercontent.com</string>
|
||||
<string>133454098911-v67k58fn1e3ru8b4shuvs2gbpagi9t0d.apps.googleusercontent.com</string>
|
||||
<key>REVERSED_CLIENT_ID</key>
|
||||
<string>com.googleusercontent.apps.1008416471093-78jluae6d1tdl8l4qkul3hut7lckd1kc</string>
|
||||
<key>ANDROID_CLIENT_ID</key>
|
||||
<string>1008416471093-e1a8gso0q6mpangmi7lltjilfmqeqp6u.apps.googleusercontent.com</string>
|
||||
<string>com.googleusercontent.apps.133454098911-v67k58fn1e3ru8b4shuvs2gbpagi9t0d</string>
|
||||
<key>API_KEY</key>
|
||||
<string>AIzaSyD7MGAPWg5qU0RwpoHL-0Z89U5pFGrPXx4</string>
|
||||
<string>AIzaSyBA0SFUeUZ5Y5ksznpMaskf5VOsO4rSrRc</string>
|
||||
<key>GCM_SENDER_ID</key>
|
||||
<string>1008416471093</string>
|
||||
<string>133454098911</string>
|
||||
<key>PLIST_VERSION</key>
|
||||
<string>1</string>
|
||||
<key>BUNDLE_ID</key>
|
||||
<string>com.combo.heroes.puzzle.rpg</string>
|
||||
<string>com.cobby.lonelysurvivor</string>
|
||||
<key>PROJECT_ID</key>
|
||||
<string>knights-combo</string>
|
||||
<string>lonely-survivor</string>
|
||||
<key>STORAGE_BUCKET</key>
|
||||
<string>knights-combo.appspot.com</string>
|
||||
<string>lonely-survivor.appspot.com</string>
|
||||
<key>IS_ADS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_ANALYTICS_ENABLED</key>
|
||||
@ -31,6 +29,6 @@
|
||||
<key>IS_SIGNIN_ENABLED</key>
|
||||
<true></true>
|
||||
<key>GOOGLE_APP_ID</key>
|
||||
<string>1:1008416471093:ios:7bbb6d271c173ccd99d97c</string>
|
||||
<string>1:133454098911:ios:15659a02894a675ca2546a</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -17,7 +17,6 @@ namespace BF
|
||||
// 是否是单机版
|
||||
public static bool IsStandAlone = false;
|
||||
public static bool IsShenhe = false;
|
||||
public static bool IsWhite = false;
|
||||
public static bool IsGotServerTime = false;
|
||||
public const string FILE_HEAD = "for_file_head";
|
||||
public const string FILE_HEAD_BASE64 = "Zm9yX2ZpbGVfaGVhZ";
|
||||
@ -274,6 +273,21 @@ namespace BF
|
||||
}
|
||||
}
|
||||
|
||||
TimeLineManager timeLineManager;
|
||||
public TimeLineManager TimeLineManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (timeLineManager == null)
|
||||
{
|
||||
timeLineManager = TimeLineManager.Create();
|
||||
timeLineManager.Init();
|
||||
managerList.Add(timeLineManager);
|
||||
}
|
||||
return timeLineManager;
|
||||
}
|
||||
}
|
||||
|
||||
TaskManager taskMgr;
|
||||
public TaskManager TaskMgr
|
||||
{
|
||||
@ -320,6 +334,22 @@ namespace BF
|
||||
}
|
||||
}
|
||||
|
||||
BattleManager battleMgr;
|
||||
public BattleManager BattleMgr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (battleMgr == null)
|
||||
{
|
||||
battleMgr = BattleManager.Create();
|
||||
battleMgr.SetMono(this);
|
||||
battleMgr.Init();
|
||||
managerList.Add(battleMgr);
|
||||
}
|
||||
return battleMgr;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetServerTime(long serverTime)
|
||||
{
|
||||
ServerTime = serverTime;
|
||||
|
||||
8
Assets/Scripts/Common/Battle.meta
Normal file
8
Assets/Scripts/Common/Battle.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b39b5b3d98bd0da4392706cf96cedd54
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Scripts/Common/Battle/BattleConfigure.cs
Normal file
48
Assets/Scripts/Common/Battle/BattleConfigure.cs
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
namespace BF
|
||||
{
|
||||
// 由Lua层读配置更新
|
||||
public static class BattleConfigure
|
||||
{
|
||||
// 战斗加速比例
|
||||
public static float TimeScale = 1.0f;
|
||||
// 普攻移动时间
|
||||
public static float NormalMoveTime = 0.1f;
|
||||
// 后撤移动时间
|
||||
public static float NormalBackTime = 0.1f;
|
||||
// 场景相机坐标x的范围
|
||||
public static float CameraMinX = -16.0f;
|
||||
public static float CameraMaxX = 16.0f;
|
||||
// 场景范围
|
||||
public static float SceneMinX = -24.0f;
|
||||
public static float SceneMaxX = 24.0f;
|
||||
public static float SceneMinZ = -10.0f;
|
||||
public static float SceneMaxZ = 3.2f;
|
||||
// 普攻位移距离
|
||||
public static float DistanceAttack = 0.0f;
|
||||
// 冲锋攻击的距离
|
||||
public static float DistanceDash = 0.0f;
|
||||
// 后撤的距离
|
||||
public static float DistanceBack = 0.0f;
|
||||
public static float BattleCenterPosX = 0.0f;
|
||||
public static float WorldToScreenWidth = 0.0f;
|
||||
public static float CheckMonsterTowardInterval = 0.1f;
|
||||
public static float CheckAITargetPositionInterval = 0.1f;
|
||||
public static float MonsterScaleFactorXZ = 3.0f;
|
||||
public static float SceneMidX = 0.0f;
|
||||
public static float SceneMidZ = -3.4f;
|
||||
// 普攻往后飞的距离
|
||||
public static float DistanceHitBack = 1.5f;
|
||||
// 击飞往后飞的距离
|
||||
public static float DistanceHitFly = 6.25f;
|
||||
// 击飞的高度
|
||||
public static float HeightHitFly = 8.0f;
|
||||
// 击飞的从起飞到落地的时间
|
||||
public static float TimeHitFly = 1.5f;
|
||||
// 击飞后躺在地上的时间
|
||||
public static float TimeLie = 1.5f;
|
||||
// 击退的时间
|
||||
public static float HitBackTime = 0.1f;
|
||||
public static float HitBackSpeed = BattleConst.UNIT_MOVE_DISTANCE / HitBackTime;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Common/Battle/BattleConfigure.cs.meta
Normal file
11
Assets/Scripts/Common/Battle/BattleConfigure.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6c43abc555a31948b2c2c768c39c7e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
203
Assets/Scripts/Common/Battle/BattleConst.cs
Normal file
203
Assets/Scripts/Common/Battle/BattleConst.cs
Normal file
@ -0,0 +1,203 @@
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
// MonsterData的monsterType,0,1,2分别对应小怪,精英和boss,这里就加一个4:英雄
|
||||
public static class BattleUnitType
|
||||
{
|
||||
// 小怪
|
||||
public const int NORMAL = 0;
|
||||
// 精英
|
||||
public const int ELITE = 1;
|
||||
// BOSS
|
||||
public const int BOSS = 2;
|
||||
// 英雄
|
||||
public const int HERO = 4;
|
||||
}
|
||||
|
||||
public static class BattleConst
|
||||
{
|
||||
public const int SIDE_ATK = 1;
|
||||
public const int SIDE_DEF = 2;
|
||||
public const int DOTWEEN_ID_BATTLE = 2;
|
||||
public const string BATTLE_POOL_NAME = "battle_pool";
|
||||
public const string BATTLE_ROOT_NAME = "battle_root";
|
||||
public const string BATTLE_BOX_COLLIDER_NAME = "box_collider";
|
||||
public const string BATTLE_SPHERE_COLLIDER_NAME = "sphere_collider";
|
||||
public const string BATTLE_SPHERE_BULLET_NAME = "sphere_bullet";
|
||||
public const string BATTLE_BOX_BULLET_NAME = "box_bullet";
|
||||
public const string BATTLE_AIM_NAME = "aim";
|
||||
public static int LAYER_DEFAULT = LayerMask.NameToLayer("Default");
|
||||
public static int LAYER_HERO = LayerMask.NameToLayer("Hero");
|
||||
public static int LAYER_MONSTER = LayerMask.NameToLayer("Monster");
|
||||
public static int LAYER_ATK_BULLET = LayerMask.NameToLayer("AtkBullet");
|
||||
public static int LAYER_DEF_BULLET = LayerMask.NameToLayer("DefBullet");
|
||||
public const int DEFAULT_FACTOR = 10000;
|
||||
public const float DEFAULT_FACTOR_FLOAT = 10000.0f;
|
||||
public const double DEFAULT_FACTOR_DOUBLE = 10000.0;
|
||||
// 360°对应的弧度值
|
||||
public const float CircleRadians = 360.0f*Mathf.Deg2Rad;
|
||||
public const float NegativeCircleRadians = -360.0f*Mathf.Deg2Rad;
|
||||
public static MaterialPropertyBlock UnitMaterialPropertyBlock = new MaterialPropertyBlock();
|
||||
public static int UNIT_GLOW_COLOR_ID = Shader.PropertyToID("_glow_color");
|
||||
public static int UNIT_GLOW_COLOR_ENABLE_ID = Shader.PropertyToID("_glow_color_enable");
|
||||
public const float DelayRecycle = 0.35f;
|
||||
public const float DeadMoveSpeed = 5.0f;
|
||||
public const float DeadMoveDistance = 3.0f;
|
||||
public const string SPRITE_CHARACTER_SHADER_NAME = "BF/Sprites/Character";
|
||||
public const string MODEL_CHARACTER_SHADER_NAME = "BF/Models/Character";
|
||||
public const float UNIT_MOVE_DISTANCE = 1000.0f;
|
||||
public const float UNIT_MOVE_DISTANCE_OPPOSITE = -1000.0f;
|
||||
public const float ITEM_QUICK_MOVE_SPEED = 10.0f;
|
||||
public const float ITEM_QUICK_MOVE_TIME = 2.0f;
|
||||
public const float EXP_ITEM_MOVE_SPEED = 10.0f;
|
||||
public const float EXP_ITEM_MOVE_TIME = 0.2f;
|
||||
public const float CHECK_DIRECTION_TIME = 0.1f;
|
||||
public const float RADIANS_10 = 10.0f*Mathf.Deg2Rad;
|
||||
public const float RADIANS_180 = 180.0f*Mathf.Deg2Rad;
|
||||
public const float RADIANS_NEGATIVE_180 = -180.0f*Mathf.Deg2Rad;
|
||||
public const float RADIANS_360 = 360.0f*Mathf.Deg2Rad;
|
||||
public const int EFFECT_TYPE_MOVE_L = 1;
|
||||
public const int EFFECT_TYPE_MOVE_R = 2;
|
||||
public const int EFFECT_TYPE_MOVE_L_2 = 3;
|
||||
public const int EFFECT_TYPE_MOVE_R_2 = 4;
|
||||
public const int EFFECT_TYPE_CRIT = 5;
|
||||
public const int EFFECT_TYPE_BUFF = 6;
|
||||
public static Color COLOR_ICE = new Color(0.647f, 0.752f, 0.933f);
|
||||
public static Color COLOR_STAGNATE = new Color(0.7f, 0.7f, 0.1f);
|
||||
public static Color COLOR_FEAR = new Color(0.1359f, 0.4222f, 0.6132f, 0.0f);
|
||||
// 无限地图类型
|
||||
public static int MAP_TYPE_UNLIMITED = 1;
|
||||
// 竖向无限地图类型
|
||||
public static int MAP_TYPE_PORTRAIT = 2;
|
||||
// 方块地图类型
|
||||
public static int MAP_TYPE_SQUARE = 3;
|
||||
// 竖向无限地图类型2,比1小一点
|
||||
public static int MAP_TYPE_SMALL_PORTRAIT = 4;
|
||||
// 方块地图类型2,比1要小一些
|
||||
public static int MAP_TYPE_SMALL_SQUARE = 5;
|
||||
public static int ANIMATION_NAME_HASH_RUN = UnityEngine.Animator.StringToHash("run");
|
||||
public static int ANIMATION_NAME_HASH_CHARGE = UnityEngine.Animator.StringToHash("charge");
|
||||
public static int ANIMATION_NAME_HASH_CHARGE_LOOP = UnityEngine.Animator.StringToHash("charge_loop");
|
||||
public const string SFX_DJGX_01 = "assets/prefabs/effects/battle/sfx_djgx_01.prefab";
|
||||
public const string SFX_BXGZ_01 = "assets/prefabs/effects/battle/sfx_bxgz_01.prefab";
|
||||
// CS.UnityEngine.Animator.StringToHash("battle_number_move_l")结果是-526518883
|
||||
public const int ANIMATOR_HASH_NAME_NUMBER_MOVE_L = -526518883;
|
||||
// CS.UnityEngine.Animator.StringToHash("battle_number_move_r")结果是445827326
|
||||
public const int ANIMATOR_HASH_NAME_NUMBER_MOVE_R = 445827326;
|
||||
// CS.UnityEngine.Animator.StringToHash("battle_number_buff")结果是1364146828
|
||||
public const int ANIMATOR_HASH_NAME_NUMBER_BUFF = 1364146828;
|
||||
// CS.UnityEngine.Animator.StringToHash("battle_number_crit")结果是-1734531349
|
||||
public const int ANIMATOR_HASH_NAME_NUMBER_CRIT = -1734531349;
|
||||
// CS.UnityEngine.Animator.StringToHash("battle_number_move_2_l")结果是1474588660
|
||||
public const int ANIMATOR_HASH_NAME_NUMBER_MOVE_L_2 = 1474588660;
|
||||
// CS.UnityEngine.Animator.StringToHash("battle_number_move_2_r")结果是-1377086825
|
||||
public const int ANIMATOR_HASH_NAME_NUMBER_MOVE_R_2 = -1377086825;
|
||||
public const int ANIMATOR_HAS_NAME_SKILL_TOAST = -253867994;
|
||||
public const RigidbodyConstraints RIGIDBODY_CONSTRAINTS = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotation;
|
||||
}
|
||||
|
||||
public static class BattlePosition
|
||||
{
|
||||
// 预处理
|
||||
// 9 2 3
|
||||
// 8 1 4
|
||||
// 7 6 5
|
||||
public static int[] RectPositionX = new int[121] {
|
||||
0, 0, 1, 1, 1, 0, -1, -1, -1,
|
||||
-1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2,
|
||||
-2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3,
|
||||
-3, -2, -1, 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0, -1, -2, -3, -4, -4, -4, -4, -4, -4, -4, -4, -4,
|
||||
-4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5
|
||||
};
|
||||
|
||||
public static int[] RectPositionZ = new int[121] {
|
||||
0, 1, 1, 0, -1, -1, -1, 0, 1,
|
||||
2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2,
|
||||
3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1, 0, 1, 2, 3,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0, -1, -2, -3, -4, -4, -4, -4, -4, -4, -4, -4, -4, -3, -2, -1, 0, 1, 2, 3, 4,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5
|
||||
};
|
||||
}
|
||||
|
||||
public static class BattleTMPNumber
|
||||
{
|
||||
public const float PUT_BACK_TIME = 1.367f;
|
||||
//dmg number
|
||||
public static readonly Dictionary<int, char[]> dmgNumber2StrDic = new Dictionary<int, char[]>()
|
||||
{
|
||||
{0 , new char[]{'<','s','p','r','i','t','e','=','1','6','>'}},
|
||||
{1 , new char[]{'<','s','p','r','i','t','e','=','1','7','>'}},
|
||||
{2 , new char[]{'<','s','p','r', 'i','t','e','=','1','8','>'}},
|
||||
{3 , new char[]{'<','s','p','r', 'i','t','e','=','1','9','>'}},
|
||||
{4 , new char[]{'<','s','p','r', 'i','t','e','=','2','0','>'}},
|
||||
{5 , new char[]{'<','s','p','r', 'i','t','e','=','2','1','>'}},
|
||||
{6 , new char[]{'<','s','p', 'r', 'i','t','e','=','2','2','>'}},
|
||||
{7 , new char[]{'<','s','p', 'r', 'i','t','e','=','2','3','>'}},
|
||||
{8 , new char[]{'<','s','p', 'r', 'i','t','e','=','2','4','>'}},
|
||||
{9 , new char[]{'<','s','p','r', 'i','t','e','=','2','5','>'}},
|
||||
};
|
||||
public static readonly char[] dmgAdd = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '2', '7', '>' };
|
||||
public static readonly char[] dmgSub = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '1', '4', '>' };
|
||||
// public static readonly char[] dmgK = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '2', '6', '>' };
|
||||
// public static readonly char[] dmgM = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '1', '5', '>' };
|
||||
|
||||
//crit number
|
||||
public static readonly Dictionary<int, char[]> critNumber2StrDic = new Dictionary<int, char[]>()
|
||||
{
|
||||
{0 , new char[]{'<','s','p', 'r', 'i','t','e','=','7','>'}},
|
||||
{1 , new char[]{'<','s','p', 'r', 'i','t','e','=','2','>'}},
|
||||
{2 , new char[]{'<','s','p', 'r', 'i','t','e','=','3','>'}},
|
||||
{3 , new char[]{'<','s','p', 'r', 'i','t','e','=','8','>'}},
|
||||
{4 , new char[]{'<','s','p', 'r', 'i','t','e','=','4','>'}},
|
||||
{5 , new char[]{'<','s','p', 'r', 'i','t','e','=','9','>'}},
|
||||
{6 , new char[]{'<','s','p', 'r', 'i','t','e','=','1','0','>'}},
|
||||
{7 , new char[]{'<','s','p', 'r', 'i','t','e','=','5','>'}},
|
||||
{8 , new char[]{'<','s','p', 'r', 'i','t','e','=','1','1','>'}},
|
||||
{9 , new char[]{'<','s','p', 'r', 'i','t','e','=','1','2','>'}},
|
||||
};
|
||||
public static readonly char[] critFlag = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '1', '3', '>' };
|
||||
public static readonly char[] critAdd = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '1', '>' };
|
||||
public static readonly char[] critSub = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '0', '>' };
|
||||
// public static readonly char[] critK = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '6', '>' };
|
||||
// public static readonly char[] critM = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '2', '8', '>' };
|
||||
|
||||
//heal number
|
||||
public static readonly Dictionary<int, char[]> healNumber2StrDic = new Dictionary<int, char[]>()
|
||||
{
|
||||
{0 , new char[]{'<','s','p', 'r', 'i','t','e','=','3','1','>'}},
|
||||
{1 , new char[]{'<','s','p', 'r', 'i','t','e','=','3','2','>'}},
|
||||
{2 , new char[]{'<','s','p', 'r', 'i','t','e','=','3','3','>'}},
|
||||
{3 , new char[]{'<','s','p', 'r', 'i','t','e','=','3','4','>'}},
|
||||
{4 , new char[]{'<','s','p', 'r', 'i','t','e','=','3','5','>'}},
|
||||
{5 , new char[]{'<','s','p', 'r', 'i','t','e','=','3','6','>'}},
|
||||
{6 , new char[]{'<','s','p', 'r', 'i','t','e','=','3','7','>'}},
|
||||
{7 , new char[]{'<','s','p', 'r', 'i','t','e','=','3','8','>'}},
|
||||
{8 , new char[]{'<','s','p', 'r', 'i','t','e','=','3','9','>'}},
|
||||
{9 , new char[]{'<','s','p', 'r', 'i','t','e','=','4','0','>'}},
|
||||
};
|
||||
public static readonly char[] healAdd = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '4', '3', '>' };
|
||||
public static readonly char[] healSub = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '4', '2', '>' };
|
||||
// public static readonly char[] healK = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '4', '1', '>' };
|
||||
// public static readonly char[] healM = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '4', '1', '>' };
|
||||
|
||||
//red number
|
||||
public static readonly Dictionary<int, char[]> redNumber2StrDic = new Dictionary<int, char[]>()
|
||||
{
|
||||
{0 , new char[]{'<','s','p', 'r', 'i','t','e','=','5','6','>'}},
|
||||
{1 , new char[]{'<','s','p', 'r', 'i','t','e','=','4','5','>'}},
|
||||
{2 , new char[]{'<','s','p', 'r', 'i','t','e','=','4','6','>'}},
|
||||
{3 , new char[]{'<','s','p', 'r', 'i','t','e','=','4','7','>'}},
|
||||
{4 , new char[]{'<','s','p', 'r', 'i','t','e','=','4','8','>'}},
|
||||
{5 , new char[]{'<','s','p', 'r', 'i','t','e','=','5','1','>'}},
|
||||
{6 , new char[]{'<','s','p', 'r', 'i','t','e','=','5','2','>'}},
|
||||
{7 , new char[]{'<','s','p', 'r', 'i','t','e','=','4','9','>'}},
|
||||
{8 , new char[]{'<','s','p', 'r', 'i','t','e','=','5','3','>'}},
|
||||
{9 , new char[]{'<','s','p', 'r', 'i','t','e','=','5','4','>'}},
|
||||
};
|
||||
public static readonly char[] redAdd = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '2', '9', '>' };
|
||||
public static readonly char[] redSub = new char[] { '<', 's', 'p', 'r', 'i', 't', 'e', '=', '5', '5', '>' };
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Common/Battle/BattleConst.cs.meta
Normal file
11
Assets/Scripts/Common/Battle/BattleConst.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd30dfddee1ea7d4cb02a404da4cd797
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/Scripts/Common/Battle/BattleHelper.cs
Normal file
40
Assets/Scripts/Common/Battle/BattleHelper.cs
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
using DG.Tweening;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public static class BattleHelper
|
||||
{
|
||||
public static bool pause = false;
|
||||
public static void Init()
|
||||
{
|
||||
pause = false;
|
||||
}
|
||||
|
||||
public static void Pause()
|
||||
{
|
||||
pause = true;
|
||||
}
|
||||
|
||||
public static void Resume()
|
||||
{
|
||||
pause = false;
|
||||
}
|
||||
|
||||
public static Sequence CreateSequence()
|
||||
{
|
||||
var seq = DG.Tweening.DOTween.Sequence();
|
||||
seq.intId = BattleConst.DOTWEEN_ID_BATTLE;
|
||||
if (pause)
|
||||
{
|
||||
seq.timeScale = 0;
|
||||
}
|
||||
return seq;
|
||||
}
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
pause = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Common/Battle/BattleHelper.cs.meta
Normal file
11
Assets/Scripts/Common/Battle/BattleHelper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8e96bdc549a1b749b69c3c93f10a1af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
479
Assets/Scripts/Common/Battle/BattleManager.cs
Normal file
479
Assets/Scripts/Common/Battle/BattleManager.cs
Normal file
@ -0,0 +1,479 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleManager : ManagerBase
|
||||
{
|
||||
public BattlePool PoolHelper { get; private set; }
|
||||
private bool battleStart = false;
|
||||
public bool UpdateEnabled { get; private set; }
|
||||
public GameObject BattleRoot { get; private set; }
|
||||
private Vector2 vector2A = Vector2.zero;
|
||||
private Vector2 vector2B = Vector2.zero;
|
||||
private BattleControlHero MainHero;
|
||||
private Camera uiCamera;
|
||||
private Camera battleCamera;
|
||||
private GameObject numberRoot;
|
||||
private RectTransform hpBarRootTransform;
|
||||
private RectTransform skillToastRootTransform;
|
||||
public List<BattleControlUnit> AtkUnitsList = new List<BattleControlUnit>();
|
||||
public List<BattleControlUnit> DefUnitsList = new List<BattleControlUnit>();
|
||||
public bool IsAutoUpdateNumberRootPosition = false;
|
||||
private Action<int, int, float, float> luaOnPlayFxFunc;
|
||||
private Action<int, int> luaOnWarningHeroNumChangedFunc;
|
||||
private Action<int, int> luaOnWarningNumChangedFunc;
|
||||
private HashSet<int> effectHeroWarningSet = new HashSet<int>(); // 包含了玩家的所有预警
|
||||
private HashSet<int> effectWarningSet = new HashSet<int>(); // 场上显示的预警
|
||||
private HashSet<BattleSkillToast> skillToastSet = new HashSet<BattleSkillToast>();
|
||||
|
||||
#region override
|
||||
static BattleManager instance;
|
||||
public static BattleManager Create()
|
||||
{
|
||||
BFLog.LogAssert(instance == null, "This method only allows BFMain to call once");
|
||||
instance = new BattleManager();
|
||||
return instance;
|
||||
}
|
||||
BattleManager() { }
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
PoolHelper = new BattlePool();
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destroy();
|
||||
instance = null;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if(!UpdateEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetMono(MonoBehaviour mono)
|
||||
{
|
||||
base.SetMono(mono);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void InitBattle(Transform sceneNode, Camera uiCamera, Camera battleCamera)
|
||||
{
|
||||
if (ReferenceEquals(BattleRoot, null))
|
||||
{
|
||||
BattleRoot = new GameObject(BattleConst.BATTLE_ROOT_NAME);
|
||||
}
|
||||
BattleRoot.transform.SetParent(sceneNode, false);
|
||||
PoolHelper.SetSceneNode(BattleRoot.transform);
|
||||
PoolHelper.Init();
|
||||
this.uiCamera = uiCamera;
|
||||
this.battleCamera = battleCamera;
|
||||
BattleConfigure.BattleCenterPosX = 0.0f;
|
||||
}
|
||||
|
||||
public void SetMainHero(BattleControlHero mainHero)
|
||||
{
|
||||
MainHero = mainHero;
|
||||
}
|
||||
|
||||
public void StartFight()
|
||||
{
|
||||
battleStart = true;
|
||||
UpdateEnabled = true;
|
||||
}
|
||||
|
||||
public void EndFight()
|
||||
{
|
||||
battleStart = false;
|
||||
UpdateEnabled = false;
|
||||
}
|
||||
|
||||
public void PauseFight()
|
||||
{
|
||||
UpdateEnabled = false;
|
||||
PoolHelper.Pause();
|
||||
BattleHelper.Pause();
|
||||
}
|
||||
|
||||
public void ResumeFight()
|
||||
{
|
||||
UpdateEnabled = true;
|
||||
PoolHelper.Resume();
|
||||
BattleHelper.Resume();
|
||||
}
|
||||
|
||||
public void SetShadow(GameObject shadow)
|
||||
{
|
||||
PoolHelper.SetShadow(shadow);
|
||||
}
|
||||
|
||||
public void SetHpBar(GameObject hpBarRoot, GameObject hpAtk, GameObject hpDef)
|
||||
{
|
||||
hpBarRootTransform = hpBarRoot.transform as RectTransform;
|
||||
PoolHelper.SetHpBar(hpAtk, hpDef, hpBarRoot.transform);
|
||||
}
|
||||
|
||||
public void SetSkillToast(GameObject skillToastRoot, GameObject skillToast)
|
||||
{
|
||||
skillToastRootTransform = skillToastRoot.transform as RectTransform;
|
||||
PoolHelper.SetSkillToast(skillToast, skillToastRoot.transform);
|
||||
}
|
||||
|
||||
public void ShowNormalSkillToast(string iconName, string str, float x, float y, float z, float addY)
|
||||
{
|
||||
var skillToast = PoolHelper.GetSkillToast();
|
||||
skillToast.transform.SetAsLastSibling();
|
||||
skillToast.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
|
||||
skillToast.ShowNormalSkillToast(iconName, str);
|
||||
var screenPosition = battleCamera.WorldToScreenPoint(new Vector3(x, y, z));
|
||||
Vector2 lp;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.skillToastRootTransform.transform as RectTransform, new Vector2(screenPosition.x, screenPosition.y), uiCamera, out lp);
|
||||
var rectTransform = skillToast.transform as RectTransform;
|
||||
rectTransform.anchoredPosition = new Vector2(lp.x, lp.y + addY);
|
||||
|
||||
skillToastSet.Add(skillToast);
|
||||
}
|
||||
|
||||
public void ShowLegacySkillToast(string qltName, string iconName, string str, float x, float y, float z, float addY)
|
||||
{
|
||||
var skillToast = PoolHelper.GetSkillToast();
|
||||
skillToast.transform.SetAsLastSibling();
|
||||
skillToast.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
|
||||
skillToast.ShowLegacySkillToast(qltName, iconName, str);
|
||||
var screenPosition = battleCamera.WorldToScreenPoint(new Vector3(x, y, z));
|
||||
Vector2 lp;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.skillToastRootTransform.transform as RectTransform, new Vector2(screenPosition.x, screenPosition.y), uiCamera, out lp);
|
||||
var rectTransform = skillToast.transform as RectTransform;
|
||||
rectTransform.anchoredPosition = new Vector2(lp.x, lp.y + addY);
|
||||
|
||||
skillToastSet.Add(skillToast);
|
||||
}
|
||||
|
||||
public void RemoveSkillToastSet(BattleSkillToast skillToast)
|
||||
{
|
||||
skillToastSet.Remove(skillToast);
|
||||
}
|
||||
|
||||
public void SetEffectTextParent(GameObject numberRoot, GameObject effectText, GameObject effectTextRed, GameObject effectTextGreen, GameObject effectTextYellow)
|
||||
{
|
||||
this.numberRoot = numberRoot;
|
||||
PoolHelper.SetEffectText(effectText, effectTextRed, effectTextGreen, effectTextYellow, numberRoot.transform);
|
||||
IsAutoUpdateNumberRootPosition = true;
|
||||
}
|
||||
|
||||
public void ShowEffectNumber(int colorType, int effectType, string effectNumber, float x, float y, float z, float addY)
|
||||
{
|
||||
var effectText = PoolHelper.GetEffectText(colorType);
|
||||
effectText.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
|
||||
effectText.ShowEffectNumber(effectType, effectNumber);
|
||||
var screenPosition = battleCamera.WorldToScreenPoint(new Vector3(x, y, z));
|
||||
Vector2 lp;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.numberRoot.transform as RectTransform, new Vector2(screenPosition.x, screenPosition.y), uiCamera, out lp);
|
||||
var rectTransform = effectText.transform as RectTransform;
|
||||
rectTransform.anchoredPosition = new Vector2(lp.x, lp.y + addY);
|
||||
}
|
||||
|
||||
public void UpdateEffectTextRootNode()
|
||||
{
|
||||
if (IsAutoUpdateNumberRootPosition)
|
||||
{
|
||||
numberRoot.transform.localPosition = new Vector3(-BattleConfigure.BattleCenterPosX * BattleConfigure.WorldToScreenWidth, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateUIPosition(Vector3 worldPosition, float addY, RectTransform uiTransform)
|
||||
{
|
||||
var screenPosition = battleCamera.WorldToScreenPoint(worldPosition);
|
||||
Vector2 lp;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(hpBarRootTransform, new Vector2(screenPosition.x, screenPosition.y), uiCamera, out lp);
|
||||
uiTransform.anchoredPosition = new Vector2(lp.x, lp.y + addY);
|
||||
}
|
||||
|
||||
public void AddLuaOnPlayFxFunc(Action<int, int, float, float> luaFunc)
|
||||
{
|
||||
luaOnPlayFxFunc = luaFunc;
|
||||
}
|
||||
|
||||
public void PlayFx(int fxId, int direction, float x, float z)
|
||||
{
|
||||
luaOnPlayFxFunc?.Invoke(fxId, direction, x, z);
|
||||
}
|
||||
|
||||
public void AddLuaOnWarningHeroNumChangedFunc(Action<int, int> luaFunc)
|
||||
{
|
||||
luaOnWarningHeroNumChangedFunc = luaFunc;
|
||||
}
|
||||
|
||||
public void WarningHeroNumChanged(int changedNum, int totalNum)
|
||||
{
|
||||
luaOnWarningHeroNumChangedFunc?.Invoke(changedNum, totalNum);
|
||||
}
|
||||
|
||||
public void AddEffectHeroWarning(int uniqueId)
|
||||
{
|
||||
var success = effectHeroWarningSet.Add(uniqueId);
|
||||
if (success)
|
||||
{
|
||||
WarningHeroNumChanged(1, GetEffectHeroWarningCount());
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveEffectHeroWarning(int uniqueId)
|
||||
{
|
||||
var success = effectHeroWarningSet.Remove(uniqueId);
|
||||
if (success)
|
||||
{
|
||||
WarningHeroNumChanged(-1, GetEffectHeroWarningCount());
|
||||
}
|
||||
}
|
||||
|
||||
public int GetEffectHeroWarningCount()
|
||||
{
|
||||
return effectHeroWarningSet.Count;
|
||||
}
|
||||
|
||||
public void AddLuaOnWarningNumChangedFunc(Action<int, int> luaFunc)
|
||||
{
|
||||
luaOnWarningNumChangedFunc = luaFunc;
|
||||
}
|
||||
|
||||
public void WarningNumChanged(int changedNum, int totalNum)
|
||||
{
|
||||
luaOnWarningNumChangedFunc?.Invoke(changedNum, totalNum);
|
||||
}
|
||||
|
||||
public void AddEffectWarning(int uniqueId)
|
||||
{
|
||||
var success = effectWarningSet.Add(uniqueId);
|
||||
if (success)
|
||||
{
|
||||
WarningNumChanged(1, GetEffectWarningCount());
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveEffectWarning(int uniqueId)
|
||||
{
|
||||
var success = effectWarningSet.Remove(uniqueId);
|
||||
if (success)
|
||||
{
|
||||
WarningNumChanged(-1, GetEffectWarningCount());
|
||||
}
|
||||
}
|
||||
|
||||
public int GetEffectWarningCount()
|
||||
{
|
||||
return effectWarningSet.Count;
|
||||
}
|
||||
|
||||
public void AddToAtkUnitsList(BattleControlUnit unit)
|
||||
{
|
||||
AtkUnitsList.Add(unit);
|
||||
}
|
||||
|
||||
public void RemoveFromAtkUnitsList(BattleControlUnit unit)
|
||||
{
|
||||
AtkUnitsList.Remove(unit);
|
||||
}
|
||||
|
||||
|
||||
public void AddToDefUnitsList(BattleControlUnit unit)
|
||||
{
|
||||
DefUnitsList.Add(unit);
|
||||
}
|
||||
|
||||
public void RemoveFromDefUnitsList(BattleControlUnit unit)
|
||||
{
|
||||
DefUnitsList.Remove(unit);
|
||||
}
|
||||
|
||||
public List<BattleControlUnit> GetUnitsList(int side)
|
||||
{
|
||||
if (side == BattleConst.SIDE_ATK)
|
||||
{
|
||||
return DefUnitsList;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AtkUnitsList;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetDefUnitsCount()
|
||||
{
|
||||
return DefUnitsList.Count;
|
||||
}
|
||||
|
||||
public BattleControlUnit GetNearestUnit(int side)
|
||||
{
|
||||
BattleControlUnit unit = null;
|
||||
if (side == BattleConst.SIDE_ATK)
|
||||
{
|
||||
var countDef = DefUnitsList.Count;
|
||||
if(countDef <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var position = MainHero.transform.position;
|
||||
vector2A.Set(position.x, position.z);
|
||||
float minDis = float.MaxValue;
|
||||
for(int j = 0; j < countDef; j++)
|
||||
{
|
||||
var objB = DefUnitsList[j];
|
||||
if (!objB.IsCollisionEnabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
vector2B.Set(objB.transform.position.x, objB.transform.position.z);
|
||||
var dis = (vector2B - vector2A).sqrMagnitude;
|
||||
if (dis < minDis)
|
||||
{
|
||||
minDis = dis;
|
||||
unit = objB;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return MainHero;
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void GetNearestDefUnit(float x, float z, out BattleControlUnit leftUnit, out BattleControlUnit rightUnit)
|
||||
{
|
||||
leftUnit = null;
|
||||
rightUnit = null;
|
||||
var count = DefUnitsList.Count;
|
||||
if (count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
float leftMinX = float.MaxValue;
|
||||
float rightMinX = float.MaxValue;
|
||||
float leftDisZ = 0.0f;
|
||||
float rightDisZ = 0.0f;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var defUnit = DefUnitsList[i];
|
||||
var defX = defUnit.transform.position.x;
|
||||
if (defX >= x)
|
||||
{
|
||||
var diffX = defX - x;
|
||||
if (Mathf.Abs(diffX - rightMinX) < 0.000001f)
|
||||
{
|
||||
var newDisZ = Mathf.Abs(defUnit.transform.position.z - z);
|
||||
if (newDisZ < rightDisZ)
|
||||
{
|
||||
rightMinX = diffX;
|
||||
rightDisZ = newDisZ;
|
||||
rightUnit = defUnit;
|
||||
}
|
||||
}
|
||||
else if (diffX < rightMinX)
|
||||
{
|
||||
rightMinX = diffX;
|
||||
rightDisZ = Mathf.Abs(defUnit.transform.position.z - z);
|
||||
rightUnit = defUnit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var diffX = x - defX;
|
||||
if (Mathf.Abs(diffX - leftMinX) < 0.000001f)
|
||||
{
|
||||
var newDisZ = Mathf.Abs(defUnit.transform.position.z - z);
|
||||
if (newDisZ < leftDisZ)
|
||||
{
|
||||
leftMinX = diffX;
|
||||
leftDisZ = newDisZ;
|
||||
leftUnit = defUnit;
|
||||
}
|
||||
}
|
||||
else if (diffX < leftMinX)
|
||||
{
|
||||
leftMinX = diffX;
|
||||
leftDisZ = Mathf.Abs(defUnit.transform.position.z - z);
|
||||
leftUnit = defUnit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BattleControlUnit GetNearestDefUnitOnCurrDirection(float x, float z, int direction)
|
||||
{
|
||||
BattleControlUnit unit = null;
|
||||
var countDef = DefUnitsList.Count;
|
||||
if(countDef <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
vector2A.Set(x, z);
|
||||
float minDis = float.MaxValue;
|
||||
if (direction == 1) // 找右边的
|
||||
{
|
||||
for(int j = 0; j < countDef; j++)
|
||||
{
|
||||
var objB = DefUnitsList[j];
|
||||
if (objB.transform.position.x >= x)
|
||||
{
|
||||
vector2B.Set(objB.transform.position.x, objB.transform.position.z);
|
||||
var dis = (vector2B - vector2A).sqrMagnitude;
|
||||
if (dis < minDis)
|
||||
{
|
||||
minDis = dis;
|
||||
unit = objB;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else // 找左边的
|
||||
{
|
||||
for(int j = 0; j < countDef; j++)
|
||||
{
|
||||
var objB = DefUnitsList[j];
|
||||
if (objB.transform.position.x <= x)
|
||||
{
|
||||
vector2B.Set(objB.transform.position.x, objB.transform.position.z);
|
||||
var dis = (vector2B - vector2A).sqrMagnitude;
|
||||
if (dis < minDis)
|
||||
{
|
||||
minDis = dis;
|
||||
unit = objB;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
battleStart = false;
|
||||
UpdateEnabled = false;
|
||||
AtkUnitsList.Clear();
|
||||
DefUnitsList.Clear();
|
||||
PoolHelper.Clear();
|
||||
MainHero = null;
|
||||
luaOnPlayFxFunc = null;
|
||||
luaOnWarningHeroNumChangedFunc = null;
|
||||
effectHeroWarningSet.Clear();
|
||||
effectWarningSet.Clear();
|
||||
skillToastSet.Clear();
|
||||
if (!ReferenceEquals(BattleRoot, null))
|
||||
{
|
||||
GameObject.Destroy(BattleRoot);
|
||||
BattleRoot = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Common/Battle/BattleManager.cs.meta
Normal file
11
Assets/Scripts/Common/Battle/BattleManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13af7ece17b38f3468a5b7af927be14a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
81
Assets/Scripts/Common/Battle/BattleMonsterData.cs
Normal file
81
Assets/Scripts/Common/Battle/BattleMonsterData.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using System.Collections.Generic;
|
||||
namespace BF
|
||||
{
|
||||
public class BattleMonsterData
|
||||
{
|
||||
public bool IsInit = false;
|
||||
public string Res = string.Empty;
|
||||
// 碰撞半径
|
||||
public float CollisionRadius = 0.0f;
|
||||
// 血量
|
||||
public long Hp = 0;
|
||||
// 攻击力
|
||||
public long Atk = 0;
|
||||
public float Spd = 0;
|
||||
public float CD = 0;
|
||||
// 击退抗性
|
||||
public int HitBackResist = 0;
|
||||
// 模型缩放比例
|
||||
public float ModelScale = 1.0f;
|
||||
// 怪物掉落的经验的id
|
||||
public int ExpId = 0;
|
||||
// 怪物掉落的经验的值
|
||||
public int ExpValue = 0;
|
||||
// 怪物掉落的经验的概率
|
||||
public int ExpProbability = 0;
|
||||
// 怪物类型0:普通,1:精英,2:BOSS
|
||||
public int MonsterType = 0;
|
||||
// 是否能被技能击退
|
||||
public bool IsHitBack = true;
|
||||
// 行为逻辑
|
||||
public int ActionType = 0;
|
||||
// 行为逻辑参数1
|
||||
public int ActionValue1 = 0;
|
||||
// 行为逻辑参数2
|
||||
public int ActionValue2 = 0;
|
||||
// 主动技能
|
||||
public int ActiveSkillId = 0;
|
||||
// 主动技能cd
|
||||
public float ActiveSkillCD = 0.0f;
|
||||
// 主动技能是否有开场cd
|
||||
public float ActiveSkillCDStart = 0.0f;
|
||||
// 特殊怪物标识
|
||||
public int SpecialMonster = 0;
|
||||
// 攻击公式
|
||||
public int AttackFormula = 0;
|
||||
// 受到攻击的公式
|
||||
public int BeAttackedFormula = 0;
|
||||
// 免疫减速
|
||||
public bool IgnoreSlow = false;
|
||||
// 免疫冰冻
|
||||
public bool IgnoreIce = false;
|
||||
// 免疫击飞
|
||||
public bool IgnoreAirborne = false;
|
||||
// 免疫吸附
|
||||
public bool IgnoreAdsorb = false;
|
||||
// 免疫停滞
|
||||
public bool IgnoreStagnate = false;
|
||||
// 免疫恐惧
|
||||
public bool IgnoreFear = false;
|
||||
// 免疫掉血
|
||||
public bool IgnoreReduceHp = false;
|
||||
// 死亡时释放的技能id
|
||||
public int TriggerDeadSkillId = 0;
|
||||
// 死亡时有一定概率掉落爱心,炸弹,吸铁石
|
||||
public int DropItemProbability = 0;
|
||||
// 死亡掉落列表
|
||||
public List<int> DropList;
|
||||
public List<int> TryGetEmptyDropList()
|
||||
{
|
||||
if (ReferenceEquals(DropList, null))
|
||||
{
|
||||
DropList = new List<int>();
|
||||
}
|
||||
else
|
||||
{
|
||||
DropList.Clear();
|
||||
}
|
||||
return DropList;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Common/Battle/BattleMonsterData.cs.meta
Normal file
11
Assets/Scripts/Common/Battle/BattleMonsterData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d611bf2197928c4eb06c1b638496727
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Scripts/Common/Battle/BattlePetData.cs
Normal file
10
Assets/Scripts/Common/Battle/BattlePetData.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
namespace BF
|
||||
{
|
||||
public class BattlePetData
|
||||
{
|
||||
public bool IsInit = false;
|
||||
public string Res = string.Empty;
|
||||
public int Follow = 0;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Common/Battle/BattlePetData.cs.meta
Normal file
11
Assets/Scripts/Common/Battle/BattlePetData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a9ebe41d982fa5478156b39e5f16606
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
668
Assets/Scripts/Common/Battle/BattlePool.cs
Normal file
668
Assets/Scripts/Common/Battle/BattlePool.cs
Normal file
@ -0,0 +1,668 @@
|
||||
|
||||
using System.Net.Security;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattlePool
|
||||
{
|
||||
private bool isClear = false;
|
||||
private List<BattleControlBoxCollider> boxColliderList;
|
||||
private List<BattleControlSphereCollider> sphereColliderList;
|
||||
private List<BattleControlBoxBullet> boxBulletList;
|
||||
private List<BattleControlSphereBullet> sphereBulletList;
|
||||
private List<BattleContinuousTarget> continuousTargeList;
|
||||
private List<BattleControlColliderContainer> colliderContainerList;
|
||||
private List<BattleEffectNumber> allEffectNumberList;
|
||||
private List<BattleSkillToast> allSkillToastList;
|
||||
private List<BattleEffectNumber> effectNumberList;
|
||||
private List<BattleEffectNumber> effectNumberRedList;
|
||||
private List<BattleEffectNumber> effectNumberGreenList;
|
||||
private List<BattleEffectNumber> effectNumberYellowList;
|
||||
private List<BattleHpBar> hpBarAtkList;
|
||||
private List<BattleHpBar> hpBarDefList;
|
||||
private List<BattleSkillToast> skillToastList;
|
||||
private GameObject poolNode;
|
||||
private Transform sceneNode;
|
||||
private GameObject cacheEffectText;
|
||||
private GameObject cacheEffectTextRed;
|
||||
private GameObject cacheEffectTextGreen;
|
||||
private GameObject cacheEffectTextYellow;
|
||||
private GameObject cacheShadow;
|
||||
private Transform numberRoot;
|
||||
private GameObject cacheHpAtk;
|
||||
private GameObject cacheHpDef;
|
||||
private Transform hpRoot;
|
||||
private GameObject cacheSkillToast;
|
||||
private Transform skillToastRoot;
|
||||
private static int colliderUniqueId;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
isClear = false;
|
||||
if (poolNode == null)
|
||||
{
|
||||
poolNode = new GameObject(BattleConst.BATTLE_POOL_NAME);
|
||||
poolNode.SetActive(false);
|
||||
GameObject.DontDestroyOnLoad(poolNode);
|
||||
}
|
||||
if (ReferenceEquals(boxColliderList, null))
|
||||
{
|
||||
boxColliderList = new List<BattleControlBoxCollider>();
|
||||
}
|
||||
if (ReferenceEquals(sphereColliderList, null))
|
||||
{
|
||||
sphereColliderList = new List<BattleControlSphereCollider>();
|
||||
}
|
||||
if (ReferenceEquals(boxBulletList, null))
|
||||
{
|
||||
boxBulletList = new List<BattleControlBoxBullet>();
|
||||
}
|
||||
if (ReferenceEquals(sphereBulletList, null))
|
||||
{
|
||||
sphereBulletList = new List<BattleControlSphereBullet>();
|
||||
}
|
||||
if (ReferenceEquals(continuousTargeList, null))
|
||||
{
|
||||
continuousTargeList = new List<BattleContinuousTarget>();
|
||||
}
|
||||
if (ReferenceEquals(colliderContainerList, null))
|
||||
{
|
||||
colliderContainerList = new List<BattleControlColliderContainer>();
|
||||
}
|
||||
if (ReferenceEquals(effectNumberList, null))
|
||||
{
|
||||
effectNumberList = new List<BattleEffectNumber>();
|
||||
}
|
||||
if (ReferenceEquals(effectNumberYellowList, null))
|
||||
{
|
||||
effectNumberYellowList = new List<BattleEffectNumber>();
|
||||
}
|
||||
if (ReferenceEquals(effectNumberGreenList, null))
|
||||
{
|
||||
effectNumberGreenList = new List<BattleEffectNumber>();
|
||||
}
|
||||
if (ReferenceEquals(effectNumberRedList, null))
|
||||
{
|
||||
effectNumberRedList = new List<BattleEffectNumber>();
|
||||
}
|
||||
if (ReferenceEquals(allEffectNumberList, null))
|
||||
{
|
||||
allEffectNumberList = new List<BattleEffectNumber>();
|
||||
}
|
||||
if (ReferenceEquals(allSkillToastList, null))
|
||||
{
|
||||
allSkillToastList = new List<BattleSkillToast>();
|
||||
}
|
||||
if (ReferenceEquals(hpBarAtkList, null))
|
||||
{
|
||||
hpBarAtkList = new List<BattleHpBar>();
|
||||
}
|
||||
if (ReferenceEquals(hpBarDefList, null))
|
||||
{
|
||||
hpBarDefList = new List<BattleHpBar>();
|
||||
}
|
||||
if (ReferenceEquals(skillToastList, null))
|
||||
{
|
||||
skillToastList = new List<BattleSkillToast>();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSceneNode(Transform sceneNode)
|
||||
{
|
||||
this.sceneNode = sceneNode;
|
||||
}
|
||||
|
||||
public void SetShadow(GameObject shadow)
|
||||
{
|
||||
this.cacheShadow = shadow;
|
||||
}
|
||||
|
||||
public GameObject GetShadow()
|
||||
{
|
||||
return GameObject.Instantiate(this.cacheShadow);
|
||||
}
|
||||
|
||||
public void SetEffectText(GameObject effectText, GameObject effectTextRed, GameObject effectTextGreen, GameObject effectTextYellow, Transform numberRoot)
|
||||
{
|
||||
this.cacheEffectText = effectText;
|
||||
this.cacheEffectTextRed = effectTextRed;
|
||||
this.cacheEffectTextGreen = effectTextGreen;
|
||||
this.cacheEffectTextYellow = effectTextYellow;
|
||||
this.numberRoot = numberRoot;
|
||||
}
|
||||
|
||||
public void SetHpBar(GameObject hpAtk, GameObject hpDef, Transform numberRoot)
|
||||
{
|
||||
this.cacheHpAtk = hpAtk;
|
||||
this.cacheHpDef = hpDef;
|
||||
this.hpRoot = numberRoot;
|
||||
}
|
||||
|
||||
public void SetSkillToast(GameObject skillToast, Transform skillToastRoot)
|
||||
{
|
||||
this.cacheSkillToast = skillToast;
|
||||
this.skillToastRoot = skillToastRoot;
|
||||
}
|
||||
|
||||
public BattleControlBoxCollider GetSkillBoxCollider()
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (boxColliderList.Count > 0)
|
||||
{
|
||||
var box = boxColliderList[boxColliderList.Count - 1];
|
||||
boxColliderList.RemoveAt(boxColliderList.Count - 1);
|
||||
box.gameObject.SetActive(true);
|
||||
box.IsRecycle = false;
|
||||
return box;
|
||||
}
|
||||
else
|
||||
{
|
||||
var gameObject = new GameObject(BattleConst.BATTLE_BOX_COLLIDER_NAME);
|
||||
gameObject.transform.SetParent(sceneNode);
|
||||
var box = gameObject.AddComponent<BattleControlBoxCollider>();
|
||||
box.IsRecycle = false;
|
||||
box.SetColliderEnabled(false);
|
||||
return box;
|
||||
}
|
||||
}
|
||||
|
||||
public void RecycleSkillBoxCollider(BattleControlBoxCollider box)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
GameObject.Destroy(box.gameObject);
|
||||
return;
|
||||
}
|
||||
box.uniqueId = GetColliderUniqueId();
|
||||
box.IsRecycle = true;
|
||||
boxColliderList.Add(box);
|
||||
box.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public BattleControlSphereCollider GetSkillSphereCollider()
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (sphereColliderList.Count > 0)
|
||||
{
|
||||
var sphere = sphereColliderList[sphereColliderList.Count - 1];
|
||||
sphereColliderList.RemoveAt(sphereColliderList.Count - 1);
|
||||
sphere.gameObject.SetActive(true);
|
||||
sphere.IsRecycle = false;
|
||||
return sphere;
|
||||
}
|
||||
else
|
||||
{
|
||||
var gameObject = new GameObject(BattleConst.BATTLE_SPHERE_COLLIDER_NAME);
|
||||
gameObject.transform.SetParent(sceneNode);
|
||||
var sphere = gameObject.AddComponent<BattleControlSphereCollider>();
|
||||
sphere.IsRecycle = false;
|
||||
sphere.SetColliderEnabled(false);
|
||||
return sphere;
|
||||
}
|
||||
}
|
||||
|
||||
public void RecycleSkillSphereCollider(BattleControlSphereCollider sphere)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
GameObject.Destroy(sphere.gameObject);
|
||||
return;
|
||||
}
|
||||
sphere.uniqueId = GetColliderUniqueId();
|
||||
sphere.IsRecycle = true;
|
||||
sphereColliderList.Add(sphere);
|
||||
sphere.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public BattleContinuousTarget GetContinuousTarge()
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (continuousTargeList.Count > 0)
|
||||
{
|
||||
var target = continuousTargeList[continuousTargeList.Count - 1];
|
||||
continuousTargeList.RemoveAt(continuousTargeList.Count - 1);
|
||||
return target;
|
||||
}
|
||||
else
|
||||
{
|
||||
var target = new BattleContinuousTarget();
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
public void RecycleContinuousTarge(BattleContinuousTarget target)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
target.Unit = null;
|
||||
return;
|
||||
}
|
||||
continuousTargeList.Add(target);
|
||||
}
|
||||
|
||||
public BattleControlColliderContainer GetColliderContainer()
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (colliderContainerList.Count > 0)
|
||||
{
|
||||
var container = colliderContainerList[colliderContainerList.Count - 1];
|
||||
colliderContainerList.RemoveAt(colliderContainerList.Count - 1);
|
||||
container.IsRecycle = false;
|
||||
return container;
|
||||
}
|
||||
else
|
||||
{
|
||||
var container = new BattleControlColliderContainer();
|
||||
container.IsRecycle = false;
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
public void RecycleColliderContainer(BattleControlColliderContainer container)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
return;
|
||||
}
|
||||
container.IsRecycle = true;
|
||||
colliderContainerList.Add(container);
|
||||
}
|
||||
|
||||
public BattleControlSphereBullet GetSphereBullet()
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (sphereBulletList.Count > 0)
|
||||
{
|
||||
var bullet = sphereBulletList[sphereBulletList.Count - 1];
|
||||
sphereBulletList.RemoveAt(sphereBulletList.Count - 1);
|
||||
bullet.gameObject.SetActive(true);
|
||||
bullet.IsRecycle = false;
|
||||
return bullet;
|
||||
}
|
||||
else
|
||||
{
|
||||
var gameObject = new GameObject(BattleConst.BATTLE_SPHERE_BULLET_NAME);
|
||||
gameObject.transform.SetParent(sceneNode);
|
||||
var bullet = gameObject.AddComponent<BattleControlSphereBullet>();
|
||||
bullet.IsRecycle = false;
|
||||
bullet.SetColliderEnabled(false);
|
||||
return bullet;
|
||||
}
|
||||
}
|
||||
|
||||
public void RecycleSphereBullet(BattleControlSphereBullet bullet)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
GameObject.Destroy(bullet.gameObject);
|
||||
return;
|
||||
}
|
||||
bullet.IsRecycle = true;
|
||||
sphereBulletList.Add(bullet);
|
||||
bullet.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public BattleControlBoxBullet GetBoxBullet()
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (boxBulletList.Count > 0)
|
||||
{
|
||||
var bullet = boxBulletList[boxBulletList.Count - 1];
|
||||
boxBulletList.RemoveAt(boxBulletList.Count - 1);
|
||||
bullet.gameObject.SetActive(true);
|
||||
bullet.IsRecycle = false;
|
||||
return bullet;
|
||||
}
|
||||
else
|
||||
{
|
||||
var gameObject = new GameObject(BattleConst.BATTLE_BOX_BULLET_NAME);
|
||||
gameObject.transform.SetParent(sceneNode);
|
||||
var bullet = gameObject.AddComponent<BattleControlBoxBullet>();
|
||||
bullet.IsRecycle = false;
|
||||
bullet.SetColliderEnabled(false);
|
||||
return bullet;
|
||||
}
|
||||
}
|
||||
|
||||
public void RecycleBoxBullet(BattleControlBoxBullet bullet)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
GameObject.Destroy(bullet.gameObject);
|
||||
return;
|
||||
}
|
||||
bullet.IsRecycle = true;
|
||||
boxBulletList.Add(bullet);
|
||||
bullet.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public BattleEffectNumber GetEffectText(int colorType)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (colorType == 1)
|
||||
{
|
||||
if (effectNumberRedList.Count > 0)
|
||||
{
|
||||
var cachedComp = effectNumberRedList[effectNumberRedList.Count - 1];
|
||||
effectNumberRedList.RemoveAt(effectNumberRedList.Count - 1);
|
||||
cachedComp.SetEnabled(true);
|
||||
return cachedComp;
|
||||
}
|
||||
var obj = GameObject.Instantiate(cacheEffectTextRed, numberRoot, false);
|
||||
var comp = obj.GetComponent<BattleEffectNumber>();
|
||||
comp.ColorType = colorType;
|
||||
allEffectNumberList.Add(comp);
|
||||
return comp;
|
||||
}
|
||||
else if (colorType == 2)
|
||||
{
|
||||
if (effectNumberYellowList.Count > 0)
|
||||
{
|
||||
var cachedComp = effectNumberYellowList[effectNumberYellowList.Count - 1];
|
||||
effectNumberYellowList.RemoveAt(effectNumberYellowList.Count - 1);
|
||||
cachedComp.SetEnabled(true);
|
||||
return cachedComp;
|
||||
}
|
||||
var obj = GameObject.Instantiate(cacheEffectTextYellow, numberRoot, false);
|
||||
var comp = obj.GetComponent<BattleEffectNumber>();
|
||||
comp.ColorType = colorType;
|
||||
allEffectNumberList.Add(comp);
|
||||
return comp;
|
||||
}
|
||||
else if (colorType == 3)
|
||||
{
|
||||
if (effectNumberGreenList.Count > 0)
|
||||
{
|
||||
var cachedComp = effectNumberGreenList[effectNumberGreenList.Count - 1];
|
||||
effectNumberGreenList.RemoveAt(effectNumberGreenList.Count - 1);
|
||||
cachedComp.SetEnabled(true);
|
||||
return cachedComp;
|
||||
}
|
||||
var obj = GameObject.Instantiate(cacheEffectTextGreen, numberRoot, false);
|
||||
var comp = obj.GetComponent<BattleEffectNumber>();
|
||||
comp.ColorType = colorType;
|
||||
allEffectNumberList.Add(comp);
|
||||
return comp;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (effectNumberList.Count > 0)
|
||||
{
|
||||
var cachedComp = effectNumberList[effectNumberList.Count - 1];
|
||||
effectNumberList.RemoveAt(effectNumberList.Count - 1);
|
||||
cachedComp.SetEnabled(true);
|
||||
return cachedComp;
|
||||
}
|
||||
var obj = GameObject.Instantiate(cacheEffectText, numberRoot, false);
|
||||
var comp = obj.GetComponent<BattleEffectNumber>();
|
||||
comp.ColorType = 0;
|
||||
allEffectNumberList.Add(comp);
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
public void PutBackEffectText(BattleEffectNumber comp, int colorType)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
GameObject.Destroy(comp.gameObject);
|
||||
return;
|
||||
}
|
||||
comp.transform.localScale = Vector3.zero;
|
||||
comp.SetEnabled(false);
|
||||
if (colorType == 1)
|
||||
{
|
||||
effectNumberRedList.Add(comp);
|
||||
}
|
||||
else if (colorType == 2)
|
||||
{
|
||||
effectNumberYellowList.Add(comp);
|
||||
}
|
||||
else if (colorType == 3)
|
||||
{
|
||||
effectNumberGreenList.Add(comp);
|
||||
}
|
||||
else
|
||||
{
|
||||
effectNumberList.Add(comp);
|
||||
}
|
||||
}
|
||||
|
||||
public BattleHpBar GetHpBar(int side)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (side == 2)
|
||||
{
|
||||
if (hpBarDefList.Count > 0)
|
||||
{
|
||||
var cachedComp = hpBarDefList[hpBarDefList.Count - 1];
|
||||
hpBarDefList.RemoveAt(hpBarDefList.Count - 1);
|
||||
cachedComp.enabled = true;
|
||||
return cachedComp;
|
||||
}
|
||||
var obj = GameObject.Instantiate(cacheHpDef, hpRoot, false);
|
||||
var comp = obj.GetComponent<BattleHpBar>();
|
||||
return comp;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hpBarAtkList.Count > 0)
|
||||
{
|
||||
var cachedComp = hpBarAtkList[hpBarAtkList.Count - 1];
|
||||
hpBarAtkList.RemoveAt(hpBarAtkList.Count - 1);
|
||||
cachedComp.enabled = true;
|
||||
return cachedComp;
|
||||
}
|
||||
var obj = GameObject.Instantiate(cacheHpAtk, hpRoot, false);
|
||||
var comp = obj.GetComponent<BattleHpBar>();
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
public void PutBackHpBar(BattleHpBar comp, int side)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
GameObject.Destroy(comp.gameObject);
|
||||
return;
|
||||
}
|
||||
comp.transform.localScale = Vector3.zero;
|
||||
comp.enabled = false;
|
||||
if (side == 2)
|
||||
{
|
||||
hpBarDefList.Add(comp);
|
||||
}
|
||||
else
|
||||
{
|
||||
hpBarAtkList.Add(comp);
|
||||
}
|
||||
}
|
||||
|
||||
public BattleSkillToast GetSkillToast()
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (skillToastList.Count > 0)
|
||||
{
|
||||
var cachedComp = skillToastList[skillToastList.Count - 1];
|
||||
skillToastList.RemoveAt(skillToastList.Count - 1);
|
||||
cachedComp.enabled = true;
|
||||
return cachedComp;
|
||||
}
|
||||
var obj = GameObject.Instantiate(cacheSkillToast, skillToastRoot, false);
|
||||
var comp = obj.GetComponent<BattleSkillToast>();
|
||||
allSkillToastList.Add(comp);
|
||||
return comp;
|
||||
}
|
||||
|
||||
public void PutBackSkillToast(BattleSkillToast comp)
|
||||
{
|
||||
if(isClear)
|
||||
{
|
||||
GameObject.Destroy(comp.gameObject);
|
||||
return;
|
||||
}
|
||||
comp.transform.localScale = Vector3.zero;
|
||||
comp.SetEnabled(false);
|
||||
skillToastList.Add(comp);
|
||||
|
||||
BFMain.Instance.BattleMgr.RemoveSkillToastSet(comp);
|
||||
}
|
||||
|
||||
public static int GetColliderUniqueId()
|
||||
{
|
||||
return colliderUniqueId ++;
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (!ReferenceEquals(allEffectNumberList, null))
|
||||
{
|
||||
int count = allEffectNumberList.Count;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
allEffectNumberList[i].SetPause();
|
||||
}
|
||||
}
|
||||
if (!ReferenceEquals(allSkillToastList, null))
|
||||
{
|
||||
int count = allSkillToastList.Count;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
allSkillToastList[i].SetPause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
if (!ReferenceEquals(allEffectNumberList, null))
|
||||
{
|
||||
int count = allEffectNumberList.Count;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
allEffectNumberList[i].SetResume();
|
||||
}
|
||||
}
|
||||
if (!ReferenceEquals(allSkillToastList, null))
|
||||
{
|
||||
int count = allSkillToastList.Count;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
allSkillToastList[i].SetResume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
isClear = true;
|
||||
if (!ReferenceEquals(boxColliderList, null))
|
||||
{
|
||||
boxColliderList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(sphereColliderList, null))
|
||||
{
|
||||
sphereColliderList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(boxBulletList, null))
|
||||
{
|
||||
boxBulletList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(sphereBulletList, null))
|
||||
{
|
||||
sphereBulletList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(continuousTargeList, null))
|
||||
{
|
||||
continuousTargeList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(colliderContainerList, null))
|
||||
{
|
||||
colliderContainerList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(effectNumberList, null))
|
||||
{
|
||||
effectNumberList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(effectNumberGreenList, null))
|
||||
{
|
||||
effectNumberGreenList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(effectNumberRedList, null))
|
||||
{
|
||||
effectNumberRedList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(effectNumberYellowList, null))
|
||||
{
|
||||
effectNumberYellowList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(allEffectNumberList, null))
|
||||
{
|
||||
int count = allEffectNumberList.Count;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
GameObject.Destroy(allEffectNumberList[i].gameObject);
|
||||
}
|
||||
allEffectNumberList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(allSkillToastList, null))
|
||||
{
|
||||
int count = allSkillToastList.Count;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
GameObject.Destroy(allSkillToastList[i].gameObject);
|
||||
}
|
||||
allSkillToastList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(hpBarAtkList, null))
|
||||
{
|
||||
hpBarAtkList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(hpBarDefList, null))
|
||||
{
|
||||
hpBarDefList.Clear();
|
||||
}
|
||||
if (!ReferenceEquals(skillToastList, null))
|
||||
{
|
||||
skillToastList.Clear();
|
||||
}
|
||||
if (poolNode != null)
|
||||
{
|
||||
GameObject.Destroy(poolNode);
|
||||
poolNode = null;
|
||||
}
|
||||
sceneNode = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Common/Battle/BattlePool.cs.meta
Normal file
11
Assets/Scripts/Common/Battle/BattlePool.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7a4ede0d91b42f41b6d8f8cdad9764a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
126
Assets/Scripts/Common/Battle/BattleSkillData.cs
Normal file
126
Assets/Scripts/Common/Battle/BattleSkillData.cs
Normal file
@ -0,0 +1,126 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleSkillData
|
||||
{
|
||||
public bool IsInit = false;
|
||||
public int SkillId = 0;
|
||||
// 子弹资源路径
|
||||
public string Res = string.Empty;
|
||||
public int DirectionType = 0;
|
||||
// 子弹数量
|
||||
public int BulletCount = 0;
|
||||
// 是否享受英雄的子弹数量加成
|
||||
public bool WithUnitBulletCount = false;
|
||||
// 扩散角度
|
||||
public int Diffusion = 0;
|
||||
public int Kind = 0;
|
||||
// 子弹飞行速度
|
||||
public float BulletSpeed = 0.0f;
|
||||
// 是否享受英雄的子弹飞行速度加成
|
||||
public bool WithUnitBulletSpeed = false;
|
||||
// 穿透数量
|
||||
public int MaxHitCount = 0;
|
||||
// 是否享受英雄的子弹穿透数量加成
|
||||
public bool WithUnitBulletHitCount = false;
|
||||
// 无限的穿透次数
|
||||
public bool UnlimitedHitCount = false;
|
||||
// 碰撞类型
|
||||
public int CollisionType = 0;
|
||||
// 基础碰撞半径
|
||||
public float BaseCollisionRadius = 0.0f;
|
||||
// 碰撞半径
|
||||
public float CollisionRadius = 0.0f;
|
||||
// 基础碰撞宽
|
||||
public float BaseCollisionWidth = 0.0f;
|
||||
// 碰撞宽
|
||||
public float CollisionWidth = 0.0f;
|
||||
// 基础碰撞宽
|
||||
public float BaseCollisionHeight = 0.0f;
|
||||
// 碰撞高
|
||||
public float CollisionHeight = 0.0f;
|
||||
// 持续时间
|
||||
public float Lifetime = 0.0f;
|
||||
// 是否永久存在
|
||||
public bool Forever = false;
|
||||
// 是否享受英雄的子弹持续时间加成
|
||||
public bool WithUnitBulletLifetime = false;
|
||||
// 圆型技能的攻击半径
|
||||
public float Range = 0.0f;
|
||||
// 攻击距离
|
||||
public float AtkDistance = 0.0f;
|
||||
// 是否享受英雄的攻击距离加成
|
||||
public bool WithUnitBulletRange = false;
|
||||
// 是否享受英雄减CD效果
|
||||
public bool WithUnitSkillCD = false;
|
||||
// 是否是地面技能
|
||||
public bool IsFloor = false;
|
||||
// 生效间隔
|
||||
public float EffectInterval = 0.0f;
|
||||
// 延迟生效
|
||||
public float EffectDelay = 0.0f;
|
||||
// 技能倍率
|
||||
public double HurtFactor = 0.0f;
|
||||
// 子弹发射间隔
|
||||
public float BulletSendInterval = 0.0f;
|
||||
// 子弹音效ID
|
||||
public int BulletSoundID = 0;
|
||||
// 子弹音效延迟播放时间
|
||||
public float BulletSoundDelay = 0.0f;
|
||||
// 子弹特效延迟播放
|
||||
public float BulletFxDelay = 0.0f;
|
||||
// 击退距离
|
||||
public float HitBack = 0.0f;
|
||||
// 生效次数
|
||||
public int WorkTime = 0;
|
||||
// 控制类型
|
||||
public int ControlType = 0;
|
||||
// 控制参数
|
||||
public int ControlParam = 0;
|
||||
// 控制持续时间
|
||||
public float ControlDuration = 0.0f;
|
||||
// 目标效果
|
||||
public int TargetEffect = 0;
|
||||
// 目标效果值
|
||||
public long TargetEffectValue = 0;
|
||||
// 目标效果时间
|
||||
public float TargetEffectTime = 0.0f;
|
||||
// 子技能id
|
||||
public int SkillSub = 0;
|
||||
// 子技能触发条件
|
||||
public int SkillSubTrigger = 0;
|
||||
// 子技能触发参数
|
||||
public int SkillSubTriggerValue = 0;
|
||||
// 子弹高度
|
||||
public float BulletShootHeight = -1.0f;
|
||||
// 额外伤害类型
|
||||
public int HurtExtraType = 0;
|
||||
// 额外伤害参数
|
||||
public long HurtExtraValue = 0;
|
||||
// 特殊伤害值
|
||||
public long HurtSpecial = 0;
|
||||
// 坐标偏移
|
||||
public float OffsetX = 0.0f;
|
||||
public float OffsetY = 0.0f;
|
||||
public float OffsetZ = 0.0f;
|
||||
// 特殊表现的特效
|
||||
public string SpecialFx = string.Empty;
|
||||
// 特殊表现的特效是否是地面特效
|
||||
public bool IsSpecialFxFloor = false;
|
||||
// 特殊表现的参数
|
||||
public List<int> SpecialFxParams;
|
||||
public List<int> TryGetEmptySpecialFxParams()
|
||||
{
|
||||
if (ReferenceEquals(SpecialFxParams, null))
|
||||
{
|
||||
SpecialFxParams = new List<int>();
|
||||
}
|
||||
else
|
||||
{
|
||||
SpecialFxParams.Clear();
|
||||
}
|
||||
return SpecialFxParams;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Common/Battle/BattleSkillData.cs.meta
Normal file
11
Assets/Scripts/Common/Battle/BattleSkillData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1ddab01af970d448b974c3c147d413f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
72
Assets/Scripts/Common/Battle/BattleUnitData.cs
Normal file
72
Assets/Scripts/Common/Battle/BattleUnitData.cs
Normal file
@ -0,0 +1,72 @@
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleUnitData
|
||||
{
|
||||
// 血量
|
||||
public long Hp = 0;
|
||||
// 最大血量
|
||||
public long MaxHp = 0;
|
||||
// 生命恢复
|
||||
public int Recover = 0;
|
||||
// 攻击力
|
||||
public long Atk = 0;
|
||||
// 移动速度
|
||||
public float MoveSpeed = 0;
|
||||
// 暴击率
|
||||
public int Crit = 0;
|
||||
// 暴击伤害加成
|
||||
public double CritDmgAddition = 0;
|
||||
// 子弹数量
|
||||
public int BulletCount = 0;
|
||||
// 子弹额外穿透数量
|
||||
public int HitCount = 0;
|
||||
// 子弹飞行速度加成
|
||||
public int BulletSpeed = 0;
|
||||
// 技能持续时间加成
|
||||
public float Lifetime = 0.0f;
|
||||
// 冷却加成
|
||||
public float Cooldown = 0.0f;
|
||||
// 攻击范围加成
|
||||
public float AtkRange = 0.0f;
|
||||
// 道具拾取范围加成
|
||||
public float PickupRange = 0.0f;
|
||||
// 经验获取倍率增加
|
||||
public float ExpAddition = 0.0f;
|
||||
// 金币获取加成
|
||||
public float CoinAddition = 0.0f;
|
||||
// 受到普通怪伤害减少
|
||||
public int DmgDec1 = 0;
|
||||
// 受到精英怪伤害减少
|
||||
public int DmgDec2 = 0;
|
||||
// 受到BOSS伤减少
|
||||
public int DmgDec3 = 0;
|
||||
// 伤害减免,在伤害计算的最后按百分比减少
|
||||
public double DmgDecAll = 0.0f;
|
||||
// 治疗效果(捡爱心和技能回血,不包括自动回血)
|
||||
public double Cured = 0.0f;
|
||||
// 对boss和精英怪的伤害提升
|
||||
public double HurtBossTime = 0.0f;
|
||||
// 自身伤害加成
|
||||
public double DmgAddition = 0.0f;
|
||||
// 对精英和首领伤害提高(固定值)
|
||||
public long HurtBoss = 0;
|
||||
// 对小怪伤害提高(固定值)
|
||||
public long HurtMonster = 0;
|
||||
// 所有伤害提高(固定值)
|
||||
public long HurtAll = 0;
|
||||
// 子弹伤害减免(固定值)
|
||||
public long BulletDecValue = 0;
|
||||
// 碰撞伤害减免(固定值)
|
||||
public long TouchDecValue = 0;
|
||||
// 所有伤害减免(固定值)
|
||||
public long AllDecValue = 0;
|
||||
// 对目标异常状态下的伤害加成
|
||||
public double DmgAdditionControl = 0.0;
|
||||
// 爱心道具的恢复比例提升
|
||||
public double HeartCure = 0.0;
|
||||
// 特殊伤害值
|
||||
public long AtkSpecial = 0;
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Common/Battle/BattleUnitData.cs.meta
Normal file
11
Assets/Scripts/Common/Battle/BattleUnitData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f87530f348764a49aa6df5fefd6e8ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -17,8 +17,6 @@ namespace BF
|
||||
public string env;
|
||||
public string cdn_url;
|
||||
public List<Dictionary<string, string>> game_urls = new List<Dictionary<string, string>>();
|
||||
public long open_at;
|
||||
public long now;
|
||||
public string notice;
|
||||
public long open_time;
|
||||
}
|
||||
}
|
||||
@ -111,7 +111,7 @@ namespace BF
|
||||
if (sendHeartBeatCount > ownerConnection.configuration.MaxHeartBeatMissCount)
|
||||
{
|
||||
LogDebug("Miss heart beat max count, try reconnect.");
|
||||
StartSmartReconnectCountdown();
|
||||
// StartSmartReconnectCountdown();
|
||||
ResetHeartBeatStatus();
|
||||
return;
|
||||
}
|
||||
@ -121,7 +121,7 @@ namespace BF
|
||||
if (waitHeartBeatInterval > maxHeartBeatMissTime)
|
||||
{
|
||||
LogDebug("Miss heart beat max time, try reconnect.");
|
||||
StartSmartReconnectCountdown();
|
||||
// StartSmartReconnectCountdown();
|
||||
ResetHeartBeatStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ public partial class AdManager : BF.MonoSingleton<AdManager>
|
||||
private const string Key = "9uHgeBwag3NXva9MC23ToO3q11Ve59bF1uwg4qGltdGmCQ7OSByFZ_3b1ZF7krMlkHQo5gXzIokVDsvg1rwbr-";
|
||||
string bannerAdUnitId = "YOUR_BANNER_AD_UNIT_ID"; // Retrieve the ID from your account
|
||||
string adInterstitialUnitId = "YOUR_AD_UNIT_ID";
|
||||
string adRewardUnitId = "e54f27e345da90df";
|
||||
string adRewardUnitId = "e0fc2e3efef362de";
|
||||
|
||||
// Start is called before the first frame update
|
||||
public void Init(string init = "")
|
||||
|
||||
@ -2,7 +2,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public partial class AdManager
|
||||
{
|
||||
@ -10,7 +9,6 @@ public partial class AdManager
|
||||
|
||||
private Action<int> _rewardCallback;
|
||||
private bool _rewardOK = false;
|
||||
public Action<string> luaAdRevenuePaidEventCallback;
|
||||
|
||||
public void InitializeRewardedAds()
|
||||
{
|
||||
@ -28,11 +26,6 @@ public partial class AdManager
|
||||
LoadRewardedAd();
|
||||
}
|
||||
|
||||
public void SetAdRevenuePaidEventCallback(Action<string> callback)
|
||||
{
|
||||
luaAdRevenuePaidEventCallback = callback;
|
||||
}
|
||||
|
||||
private void LoadRewardedAd()
|
||||
{
|
||||
MaxSdk.LoadRewardedAd(adRewardUnitId);
|
||||
@ -98,29 +91,6 @@ public partial class AdManager
|
||||
|
||||
private void OnRewardedAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
if (luaAdRevenuePaidEventCallback == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
double revenue = adInfo.Revenue;
|
||||
// Miscellaneous data
|
||||
string countryCode = MaxSdk.GetSdkConfiguration().CountryCode; // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD" in most cases!
|
||||
string networkName = adInfo.NetworkName; // Display name of the network that showed the ad (e.g. "AdColony")
|
||||
string adUnitIdentifier = adInfo.AdUnitIdentifier; // The MAX Ad Unit ID
|
||||
string placement = adInfo.Placement; // The placement this ad's postbacks are tied to
|
||||
string networkPlacement = adInfo.NetworkPlacement; // The placement ID from the network that showed the ad
|
||||
string adFormat = adInfo.AdFormat;
|
||||
|
||||
var dict = new Dictionary<string, System.Object>();
|
||||
dict.Add("revenue", revenue);
|
||||
dict.Add("country_code", countryCode);
|
||||
dict.Add("network_name", networkName);
|
||||
dict.Add("ad_unit_Id", adUnitId);
|
||||
dict.Add("ad_unit_identifier", adUnitIdentifier);
|
||||
dict.Add("placement", placement);
|
||||
dict.Add("network_placement", networkPlacement);
|
||||
dict.Add("ad_format", adFormat);
|
||||
var result = JsonConvert.SerializeObject(dict);
|
||||
luaAdRevenuePaidEventCallback(result);
|
||||
// Ad revenue paid. Use this callback to track user revenue.
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using com.adjust.sdk;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
@ -13,7 +12,6 @@ namespace BF
|
||||
public Action<int> luaShowCallback;
|
||||
public Action<int> luaLoadedCallback;
|
||||
public Action<int, string> luaEarnedRewardCallback;
|
||||
public Action<string> luaAdRevenuePaidEventCallback;
|
||||
public bool AdLoaded = false;
|
||||
public bool AdInitialized = false;
|
||||
|
||||
@ -22,7 +20,7 @@ namespace BF
|
||||
|
||||
#if UNITY_ANDROID
|
||||
// string appKey = "85460dcd";
|
||||
string appKey = "1a6aacc25";
|
||||
string appKey = "19b1b4f1d";
|
||||
|
||||
BFLog.Log("unity-script: IronSource.Agent.validateIntegration");
|
||||
IronSource.Agent.validateIntegration();
|
||||
@ -31,22 +29,10 @@ namespace BF
|
||||
|
||||
// SDK init
|
||||
BFLog.Log("unity-script: IronSource.Agent.init");
|
||||
// IronSource.Agent.setMetaData("is_test_suite", "enable");
|
||||
IronSource.Agent.init(appKey);
|
||||
IronSource.Agent.setManualLoadRewardedVideo(true);
|
||||
|
||||
// 初始化之前先设置一下用户id
|
||||
// ISAdQualityConfig adQualityConfig = new ISAdQualityConfig();
|
||||
// adQualityConfig.UserId = SystemInfo.deviceUniqueIdentifier;
|
||||
// // adQualityConfig.TestMode = true;
|
||||
// // adQualityConfig.LogLevel = ISAdQualityLogLevel.INFO;
|
||||
// IronSourceAdQuality.Initialize(appKey, adQualityConfig);
|
||||
#elif UNITY_IPHONE
|
||||
// string appKey = "8545d445";
|
||||
// 初始化之前先设置一下用户id
|
||||
// ISAdQualityConfig adQualityConfig = new ISAdQualityConfig();
|
||||
// adQualityConfig.UserId = SystemInfo.deviceUniqueIdentifier;
|
||||
// IronSourceAdQuality.Initialize(appKey, adQualityConfig);
|
||||
#else
|
||||
// string appKey = "unexpected_platform";
|
||||
#endif
|
||||
@ -92,11 +78,6 @@ namespace BF
|
||||
IronSourceRewardedVideoEvents.onAdClickedEvent += ReardedVideoOnAdClickedEvent;
|
||||
}
|
||||
|
||||
public void SetAdRevenuePaidEventCallback(Action<string> callback)
|
||||
{
|
||||
luaAdRevenuePaidEventCallback = callback;
|
||||
}
|
||||
|
||||
void OnApplicationPause(bool isPaused)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
@ -156,8 +137,6 @@ namespace BF
|
||||
void SdkInitializationCompletedEvent()
|
||||
{
|
||||
BFLog.Log("unity-script: I got SdkInitializationCompletedEvent");
|
||||
//Launch test suite
|
||||
// IronSource.Agent.launchTestSuite();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -258,21 +237,16 @@ namespace BF
|
||||
|
||||
void ImpressionSuccessEvent(IronSourceImpressionData impressionData)
|
||||
{
|
||||
// BFLog.Log("unity - script: I got ImpressionSuccessEvent ToString(): " + impressionData.ToString());
|
||||
// BFLog.Log("unity - script: I got ImpressionSuccessEvent allData: " + impressionData.allData);
|
||||
BFLog.Log("unity - script: I got ImpressionSuccessEvent ToString(): " + impressionData.ToString());
|
||||
BFLog.Log("unity - script: I got ImpressionSuccessEvent allData: " + impressionData.allData);
|
||||
}
|
||||
|
||||
void ImpressionDataReadyEvent(IronSourceImpressionData impressionData)
|
||||
{
|
||||
if (impressionData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ReferenceEquals(impressionData.revenue, null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
double revenue = (double)impressionData.revenue;
|
||||
BFLog.Log("unity - script: I got ImpressionDataReadyEvent ToString(): " + impressionData.ToString());
|
||||
BFLog.Log("unity - script: I got ImpressionDataReadyEvent revenue.ToString(): " + revenue.ToString());
|
||||
BFLog.Log("unity - script: I got ImpressionDataReadyEvent allData: " + impressionData.allData);
|
||||
AdjustAdRevenue adjustAdRevenue = new AdjustAdRevenue(AdjustConfig.AdjustAdRevenueSourceIronSource);
|
||||
adjustAdRevenue.setRevenue(revenue, "USD");
|
||||
// optional fields
|
||||
@ -281,36 +255,6 @@ namespace BF
|
||||
adjustAdRevenue.setAdRevenuePlacement(impressionData.placement);
|
||||
// track Adjust ad revenue
|
||||
Adjust.trackAdRevenue(adjustAdRevenue);
|
||||
|
||||
if (luaAdRevenuePaidEventCallback == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var dict = new Dictionary<string, System.Object>();
|
||||
dict.Add("revenue", revenue);
|
||||
dict.Add("auction_id", impressionData.auctionId);
|
||||
dict.Add("country_code", impressionData.country);
|
||||
dict.Add("network_name", impressionData.adNetwork);
|
||||
dict.Add("ad_unit_Id", impressionData.adUnit);
|
||||
dict.Add("placement", impressionData.placement);
|
||||
dict.Add("ad_format_name", impressionData.instanceName);
|
||||
dict.Add("ad_format_id", impressionData.instanceId);
|
||||
if (!string.IsNullOrEmpty(impressionData.segmentName))
|
||||
{
|
||||
dict.Add("segment_name", impressionData.segmentName);
|
||||
}
|
||||
if (!ReferenceEquals(impressionData.lifetimeRevenue, null))
|
||||
{
|
||||
dict.Add("lifetime_revenue", impressionData.lifetimeRevenue);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(impressionData.encryptedCPM))
|
||||
{
|
||||
dict.Add("encrypted_cpm", impressionData.encryptedCPM);
|
||||
}
|
||||
dict.Add("currency", "USD");
|
||||
dict.Add("precision", impressionData.precision);
|
||||
var result = JsonConvert.SerializeObject(dict);
|
||||
luaAdRevenuePaidEventCallback(result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -89,6 +89,17 @@ namespace BF
|
||||
|
||||
public void InitListener()
|
||||
{
|
||||
// string url = BFPlatform.GetLoginCenterURL();
|
||||
// BFLog.Log("初始化登陆SDK URL:" + url);
|
||||
|
||||
// Dictionary<string, string> gameInfo = new Dictionary<string, string>();
|
||||
// gameInfo["channel"] = CHANNEL;//预留字段 暂无用
|
||||
// gameInfo["language"] = LANGUAGE;//预留字段 暂无用
|
||||
// gameInfo["game_cd"] = GAME_CD;//game_cd 地址 AOD约定为1004
|
||||
// ULogin.Initialize(url, gameInfo);
|
||||
// ULogin.UseOnceBFIdForInstall(USE_ONCE_BFID_FOR_INSTALL);
|
||||
// ULogin.SetULoginListener(this);
|
||||
|
||||
// google
|
||||
BFMain.Instance.SDKMgr.BFNativeSDKMgr.InitGoogleLogin();
|
||||
}
|
||||
@ -135,6 +146,7 @@ namespace BF
|
||||
/// <param name="type"></param>
|
||||
public void Login(LoginType type)
|
||||
{
|
||||
BFLog.Log("新版 登陆中心 Login:" + type);
|
||||
if (type == LoginType.Facebook)
|
||||
{
|
||||
FBSdk.Login();
|
||||
|
||||
@ -2,7 +2,6 @@ using System.Collections.Generic;
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using AOT;
|
||||
|
||||
#if UNITY_IOS
|
||||
using System.Runtime.InteropServices;
|
||||
@ -50,14 +49,10 @@ namespace BF
|
||||
#endif
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
private delegate void GetFirebaseTokenCompleted(string token);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void FIRLogEvent(string eventName, string properties);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void FIRGetToken(IntPtr callback);
|
||||
#endif
|
||||
|
||||
[Serializable]
|
||||
public class NativeResultMsg
|
||||
{
|
||||
@ -143,29 +138,11 @@ namespace BF
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[MonoPInvokeCallback(typeof(GetFirebaseTokenCompleted))]
|
||||
private static void GetFirebaseTokenCallback(string token)
|
||||
{
|
||||
BFMain.Instance.LoomMgr.QueueOnMainThread(() =>
|
||||
{
|
||||
BFMain.Instance.SDKMgr.BFLoginSDKMgr.SetFirebaseToken(token);
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
public void GetFirebaseToken()
|
||||
{
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
androidJavaClass.CallStatic("getFirebaseToken");
|
||||
#endif
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
IntPtr cback = IntPtr.Zero;
|
||||
GetFirebaseTokenCompleted d = GetFirebaseTokenCallback;
|
||||
cback = Marshal.GetFunctionPointerForDelegate(d);
|
||||
FIRGetToken(cback);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void ShowFullScreenAds()
|
||||
|
||||
@ -3,7 +3,6 @@ using UnityEngine;
|
||||
using BF.NativeCore.ThirdPlatform;
|
||||
using Newtonsoft.Json;
|
||||
using com.adjust.sdk;
|
||||
using AppsFlyerSDK;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
@ -11,7 +10,6 @@ namespace BF
|
||||
{
|
||||
private ThinkingAnalyticsSdk TASdk = new ThinkingAnalyticsSdk();
|
||||
private AppsFlyerSdk AFSdk = new AppsFlyerSdk();
|
||||
private bool isInitAFAdRevenue = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@ -29,17 +27,6 @@ namespace BF
|
||||
public void SetThinkingAnalyticsAccountId(string id)
|
||||
{
|
||||
TASdk.SetAccountId(id);
|
||||
AFSdk.SetTaAccountId(id);
|
||||
}
|
||||
|
||||
public void InitAppsFlyerAdRevenue()
|
||||
{
|
||||
if (isInitAFAdRevenue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isInitAFAdRevenue = true;
|
||||
AppsFlyerAdRevenue.start();
|
||||
}
|
||||
|
||||
// 清除账户id
|
||||
@ -141,27 +128,5 @@ namespace BF
|
||||
// BFLog.Log("PostAdjustPartnerTrackEvent");
|
||||
Adjust.trackEvent(adjustEvent);
|
||||
}
|
||||
|
||||
public void PostAdjustAdRevenueAppLovinMAX(double revenue, string networkName, string adUnitIdentifier, string placement)
|
||||
{
|
||||
var adRevenue = new AdjustAdRevenue(AdjustConfig.AdjustAdRevenueSourceAppLovinMAX);
|
||||
adRevenue.setRevenue(revenue, "USD");
|
||||
adRevenue.setAdRevenueNetwork(networkName);
|
||||
adRevenue.setAdRevenueUnit(adUnitIdentifier);
|
||||
adRevenue.setAdRevenuePlacement(placement);
|
||||
Adjust.trackAdRevenue(adRevenue);
|
||||
}
|
||||
|
||||
public void AdjustSetDeviceToken(string token)
|
||||
{
|
||||
Adjust.setDeviceToken(token);
|
||||
}
|
||||
|
||||
public void LogAppsFlyerAdRevenue(int mediationNetwork, string monetizationNetwork, double eventRevenue, string data)
|
||||
{
|
||||
var properties = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
|
||||
var mediationNetworkType = (AppsFlyerAdRevenueMediationNetworkType)mediationNetwork;
|
||||
AppsFlyerAdRevenue.logAdRevenue(monetizationNetwork, mediationNetworkType, eventRevenue, "USD", properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,116 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
// using BF.NativeCore.Platform;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
//copy from sdk
|
||||
public enum NotchType
|
||||
{
|
||||
NONE,
|
||||
ANDROID,
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class NotchScreenInfo
|
||||
{
|
||||
public NotchType notchType = NotchType.NONE;
|
||||
public bool enabled = false;
|
||||
public int width = 0;
|
||||
public int height = 0;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("notchType:{0} showNotch:{1} width:{2} height:{3}", notchType, enabled, width, height);
|
||||
}
|
||||
}
|
||||
public class DZSDKManager : MonoBehaviour
|
||||
{
|
||||
|
||||
#if UNITY_ANDROID
|
||||
/// <summary>
|
||||
/// android原生代码对象
|
||||
/// </summary>
|
||||
AndroidJavaObject ajc;
|
||||
#endif
|
||||
//解析的数据
|
||||
private NotchScreenInfo notchScreenInfo = new NotchScreenInfo();
|
||||
private bool initNotchScreen = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
//通过该API来实例化导入的arr中对应的类
|
||||
ajc = new AndroidJavaObject("com.droidhang.aod.AODHelper");
|
||||
#endif
|
||||
}
|
||||
|
||||
public void CSGetNotchScreenInfo()
|
||||
{
|
||||
if (initNotchScreen) return;
|
||||
BFLog.Log("尝试获取适配信息 CSGetNotchScreenInfo");
|
||||
#if UNITY_ANDROID
|
||||
//通过API来调用原生代码的方法
|
||||
bool success = ajc.Call<bool>("getNotchScreen");
|
||||
if (success)
|
||||
{
|
||||
initNotchScreen = true;
|
||||
//请求成功
|
||||
BFLog.Log("获取安卓刘海屏成功");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 原生层通过该方法传回信息
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
public void GetNotchScreen(string content)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
BFLog.Log("获取NotchInfo:" + content);
|
||||
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
//解析刘海屏数据
|
||||
notchScreenInfo = JsonUtility.FromJson<NotchScreenInfo>(content);
|
||||
|
||||
BFLog.Log("解析 NotchScreen:" + notchScreenInfo.ToString());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对外接口 获取刘海屏信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public NotchScreenInfo GetNotchScreenInfo()
|
||||
{
|
||||
return notchScreenInfo;
|
||||
}
|
||||
|
||||
// 刘海屏信息 ***************************************************************************************************
|
||||
|
||||
public NotchType GetNotchScreenType()
|
||||
{
|
||||
return notchScreenInfo.notchType;
|
||||
}
|
||||
|
||||
public bool GetNotchScreenEnable()
|
||||
{
|
||||
return notchScreenInfo.enabled;
|
||||
}
|
||||
|
||||
public int GetNotchScreenWidth()
|
||||
{
|
||||
return notchScreenInfo.width;
|
||||
}
|
||||
|
||||
public int GetNotchScreenHeight()
|
||||
{
|
||||
return notchScreenInfo.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ced1766fcb78b314db1ae240a0e27a9f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -5,7 +5,6 @@ using AppsFlyerSDK;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Purchasing;
|
||||
using UnityEngine.Purchasing.Security;
|
||||
using UnityEngine.Purchasing.Extension;
|
||||
|
||||
|
||||
public struct ProductInfo {
|
||||
@ -13,7 +12,7 @@ public struct ProductInfo {
|
||||
public ProductType type;
|
||||
}
|
||||
|
||||
public class IAPManager : /* MonoBehaviour, */ IDetailedStoreListener {
|
||||
public class IAPManager : /* MonoBehaviour, */ IStoreListener {
|
||||
public Action<bool, Product[], string> initCallback;
|
||||
public Action<bool, Product, string> buyCallback;
|
||||
public static IAPManager instance;
|
||||
@ -78,12 +77,6 @@ public class IAPManager : /* MonoBehaviour, */ IDetailedStoreListener {
|
||||
IAPDebug($"init fail: {er}");
|
||||
initCallback?.Invoke(false, null, er);
|
||||
}
|
||||
|
||||
public void OnInitializeFailed(InitializationFailureReason error, string message) {
|
||||
string er = error.ToString("G");
|
||||
IAPDebug($"init fail2: {er}");
|
||||
initCallback?.Invoke(false, null, er);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ================================================== 购买 ==================================================
|
||||
@ -99,6 +92,7 @@ public class IAPManager : /* MonoBehaviour, */ IDetailedStoreListener {
|
||||
IAPDebug($"ID:{productId}.Not found or is not available for purchase");
|
||||
return false;
|
||||
}
|
||||
|
||||
_storeC.InitiatePurchase(productId, payload);
|
||||
return true;
|
||||
}
|
||||
@ -110,11 +104,6 @@ public class IAPManager : /* MonoBehaviour, */ IDetailedStoreListener {
|
||||
buyCallback?.Invoke(false, pro, er);
|
||||
}
|
||||
|
||||
public void OnPurchaseFailed(Product pro, PurchaseFailureDescription p) {
|
||||
IAPDebug($"ID:{pro.definition.id}. purchase fail: {p.message}");
|
||||
buyCallback?.Invoke(false, pro, p.message);
|
||||
}
|
||||
|
||||
//购买成功
|
||||
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) {
|
||||
#if UNITY_EDITOR
|
||||
@ -206,6 +195,7 @@ public class IAPManager : /* MonoBehaviour, */ IDetailedStoreListener {
|
||||
private void _appsFlyerChecking(Product product) {
|
||||
|
||||
IAPDebug($"CURRENCY:{product.metadata.isoCurrencyCode} REVENUE:{product.metadata.localizedPrice.ToString()} CONTENT_TYPE:{product.transactionID} CONTENT_ID:{product.definition.id}");
|
||||
|
||||
// Dictionary<string, string> da = new Dictionary<string, string> {
|
||||
// { AFInAppEventParameterName.CURRENCY, product.metadata.isoCurrencyCode },
|
||||
// { AFInAppEventParameterName.REVENUE, product.metadata.localizedPrice.ToString() },
|
||||
@ -219,6 +209,7 @@ public class IAPManager : /* MonoBehaviour, */ IDetailedStoreListener {
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================================================== 订阅 ==================================================
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -9,10 +9,7 @@ namespace BF.NativeCore.ThirdPlatform
|
||||
{
|
||||
public void Init()
|
||||
{
|
||||
// 打通TA和AF的设置,要在AF初始化之前执行
|
||||
var customData = new Dictionary<string, string>();
|
||||
customData.Add("ta_distinct_id", ThinkingAnalyticsAPI.GetDistinctId());
|
||||
AppsFlyer.setAdditionalData(customData);
|
||||
// Debug.Log("AppsFlyerSdk Init version = " + AppsFlyer.getSdkVersion());
|
||||
AppsFlyer.setCustomerIdAndStartSDK(ThinkingAnalyticsAPI.GetDeviceId());
|
||||
}
|
||||
|
||||
@ -20,13 +17,5 @@ namespace BF.NativeCore.ThirdPlatform
|
||||
{
|
||||
AppsFlyer.sendEvent(eventName, properties);
|
||||
}
|
||||
|
||||
public void SetTaAccountId(string accountId)
|
||||
{
|
||||
var customData = new Dictionary<string, string>();
|
||||
customData.Add("ta_distinct_id", ThinkingAnalyticsAPI.GetDistinctId());
|
||||
customData.Add("ta_account_id", accountId);
|
||||
AppsFlyer.setAdditionalData(customData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,10 +40,5 @@ namespace BF.NativeCore.ThirdPlatform
|
||||
{
|
||||
ThinkingAnalyticsAPI.Track(eventName, properties, date, appId);
|
||||
}
|
||||
|
||||
public string GetDistinctId()
|
||||
{
|
||||
return ThinkingAnalyticsAPI.GetDistinctId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
Assets/Scripts/Component/Battle/BattleControlBase.cs
Normal file
36
Assets/Scripts/Component/Battle/BattleControlBase.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public enum BattleControlType {
|
||||
Default = 0,
|
||||
Hero,
|
||||
Monster,
|
||||
Bullet,
|
||||
Item,
|
||||
HalloweenSkillItem,
|
||||
HalloweenEventItem
|
||||
}
|
||||
public class BattleControlBase : MonoBehaviour
|
||||
{
|
||||
[System.NonSerialized]
|
||||
public bool IsCollisionEnabled = true;
|
||||
[System.NonSerialized]
|
||||
public bool WaitRemove = false;
|
||||
[System.NonSerialized]
|
||||
public int Side = 0;
|
||||
[System.NonSerialized]
|
||||
public string Res = string.Empty;
|
||||
[System.NonSerialized]
|
||||
public bool IsInCollision = false;
|
||||
private Vector2 vector2A = Vector2.zero;
|
||||
private Vector2 vector2B = Vector2.zero;
|
||||
public virtual BattleControlType ControlType { get {return BattleControlType.Default;} }
|
||||
public virtual void AddExp(int exp) { }
|
||||
public virtual void AddHpPercent(double percent) { }
|
||||
public virtual void AddGold(int count) { }
|
||||
public virtual void OnHitBack(float distance, Vector3 atkerPos) {}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Component/Battle/BattleControlBase.cs.meta
Normal file
11
Assets/Scripts/Component/Battle/BattleControlBase.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a383ef95b1042844b2d6de77db05cb7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/Scripts/Component/Battle/BattleControlBoxBullet.cs
Normal file
35
Assets/Scripts/Component/Battle/BattleControlBoxBullet.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleControlBoxBullet : BattleControlBullet
|
||||
{
|
||||
private BoxCollider boxCollider;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
boxCollider = gameObject.AddComponent<BoxCollider>();
|
||||
}
|
||||
|
||||
public override void SetupBoxCollisionBody(float collisionWidth, float collisionHeight)
|
||||
{
|
||||
boxCollider.center = new Vector3(collisionWidth/2.0f, 0.0f, 0.0f);
|
||||
boxCollider.size = new Vector3(collisionWidth, 1.0f, collisionHeight);
|
||||
}
|
||||
|
||||
public override void SetColliderEnabled(bool enabled)
|
||||
{
|
||||
boxCollider.enabled = enabled;
|
||||
}
|
||||
|
||||
public override void Recycle()
|
||||
{
|
||||
if (IsRecycle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
boxCollider.enabled = false;
|
||||
BFMain.Instance.BattleMgr.PoolHelper.RecycleBoxBullet(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9dbfb1c0f5da60d43a230becd5e02348
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/Scripts/Component/Battle/BattleControlBoxCollider.cs
Normal file
50
Assets/Scripts/Component/Battle/BattleControlBoxCollider.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleControlBoxCollider : BattleControlCollider
|
||||
{
|
||||
private BoxCollider boxCollider;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
boxCollider = gameObject.AddComponent<BoxCollider>();
|
||||
}
|
||||
|
||||
public void SetupCollisionBody(float collisionWidth, float collisionHeight, float x, float z)
|
||||
{
|
||||
boxCollider.center = new Vector3(collisionWidth/2.0f, 0.0f, 0.0f);
|
||||
boxCollider.size = new Vector3(collisionWidth, 1.0f, collisionHeight);
|
||||
offset = new Vector3(x, 0.0f, z);
|
||||
}
|
||||
|
||||
public override void SetColliderEnabled(bool enabled)
|
||||
{
|
||||
boxCollider.enabled = enabled;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!isActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CheckCollider();
|
||||
}
|
||||
|
||||
public override void Recycle()
|
||||
{
|
||||
if (IsRecycle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!ReferenceEquals(container, null))
|
||||
{
|
||||
container.Remove(this);
|
||||
}
|
||||
boxCollider.enabled = false;
|
||||
isActive = false;
|
||||
BFMain.Instance.BattleMgr.PoolHelper.RecycleSkillBoxCollider(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d5e7fd63c962eb4abb773fe87d22418
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
399
Assets/Scripts/Component/Battle/BattleControlBullet.cs
Normal file
399
Assets/Scripts/Component/Battle/BattleControlBullet.cs
Normal file
@ -0,0 +1,399 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleControlBullet : MonoBehaviour
|
||||
{
|
||||
protected BattleControlUnit admin;
|
||||
protected int bulletType = 0;
|
||||
protected int bulletFinishType = 0;
|
||||
protected int bulletOriginType = 0;
|
||||
protected int searchType = 0;
|
||||
protected float radius = 0.0f;
|
||||
protected float duration = 0.0f;
|
||||
protected float width = 0.0f;
|
||||
protected float height = 0.0f;
|
||||
protected float speed = 0.0f;
|
||||
protected float offsetX = 0.0f;
|
||||
protected float offsetZ = 0.0f;
|
||||
protected float checkInterval = 0.0f;
|
||||
protected float checkDuration = 0.0f;
|
||||
protected int skillId = 0;
|
||||
protected int cloneIndex = 0;
|
||||
protected int skillEffectIndex = 0;
|
||||
protected Vector3 offset = Vector3.zero;
|
||||
protected Vector3 targetPosition = Vector3.zero;
|
||||
protected BattleControlUnit targetUnit;
|
||||
protected HashSet<int> CheckTargetDict = new HashSet<int>();
|
||||
protected List<GameObject> CheckTargetList = new List<GameObject>();
|
||||
protected List<BattleContinuousTarget> ContinuousTargetsList = new List<BattleContinuousTarget>();
|
||||
[System.NonSerialized]
|
||||
public float CacheX = 0.0f;
|
||||
[System.NonSerialized]
|
||||
public float CacheY = 0.0f;
|
||||
[System.NonSerialized]
|
||||
public float CacheZ = 0.0f;
|
||||
[System.NonSerialized]
|
||||
public bool IsRecycle = false;
|
||||
private bool endWithTime = false;
|
||||
private bool endWithArrive = false;
|
||||
private bool waitNextFixedFrame = false;
|
||||
private bool nextFixedFrameTakeEffect = false;
|
||||
private bool isOver = false;
|
||||
private bool lockTarget = false;
|
||||
private int fxId = 0;
|
||||
private float fxDelayTime = 0.0f;
|
||||
private bool checkFx = false;
|
||||
public virtual void SetColliderEnabled(bool enabled) {}
|
||||
public virtual void Recycle() {}
|
||||
public virtual void SetupBoxCollisionBody(float collisionWidth, float collisionHeight) {}
|
||||
public virtual void SetupSphereCollisionBody(float collisionRadius) {}
|
||||
public void SetAdmin(BattleControlUnit unit)
|
||||
{
|
||||
admin = unit;
|
||||
if (admin.Side == 1)
|
||||
{
|
||||
gameObject.layer = BattleConst.LAYER_ATK_BULLET;
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.layer = BattleConst.LAYER_DEF_BULLET;
|
||||
}
|
||||
}
|
||||
|
||||
public void CachePosition()
|
||||
{
|
||||
var position = transform.position;
|
||||
CacheX = position.x;
|
||||
CacheY = position.y;
|
||||
CacheZ = position.z;
|
||||
}
|
||||
|
||||
public void CacheTargetPosition()
|
||||
{
|
||||
CacheX = targetPosition.x;
|
||||
CacheZ = targetPosition.z;
|
||||
}
|
||||
|
||||
public void InitSphereBullet(int skillId, int cloneIndex, int skillEffectIndex, int bulletType, int bulletFinishType, int bulletOriginType, int searchType, float radius, float duration, float speed, float offsetX, float offsetZ)
|
||||
{
|
||||
this.skillId = skillId;
|
||||
this.cloneIndex = cloneIndex;
|
||||
this.skillEffectIndex = skillEffectIndex;
|
||||
this.bulletType = bulletType;
|
||||
this.bulletFinishType = bulletFinishType;
|
||||
this.bulletOriginType = bulletOriginType;
|
||||
this.searchType = searchType;
|
||||
this.radius = radius;
|
||||
this.duration = duration;
|
||||
this.speed = speed;
|
||||
this.offsetX = offsetX;
|
||||
this.offsetZ = offsetZ;
|
||||
offset = new Vector3(offsetX, 0.0f, offsetZ);
|
||||
if (bulletFinishType == 1) // 飞到目标点才算完成,此时有速度和时间互斥
|
||||
{
|
||||
if (speed < 0.000001f)
|
||||
{
|
||||
endWithTime = true;
|
||||
endWithArrive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
endWithTime = false;
|
||||
endWithArrive = true;
|
||||
}
|
||||
}
|
||||
else // 按时间算结束
|
||||
{
|
||||
endWithTime = true;
|
||||
endWithArrive = false;
|
||||
}
|
||||
SetupSphereCollisionBody(radius);
|
||||
InitBase();
|
||||
StartSearch();
|
||||
}
|
||||
|
||||
public void InitBoxBullet(int skillId, int cloneIndex, int skillEffectIndex, int bulletType, int bulletFinishType, int bulletOriginType, int searchType, float w, float h, float duration, float speed, float offsetX, float offsetZ)
|
||||
{
|
||||
this.skillId = skillId;
|
||||
this.skillEffectIndex = skillEffectIndex;
|
||||
this.bulletType = bulletType;
|
||||
this.bulletFinishType = bulletFinishType;
|
||||
this.bulletOriginType = bulletOriginType;
|
||||
this.searchType = searchType;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.duration = duration;
|
||||
this.speed = speed;
|
||||
this.offsetX = offsetX;
|
||||
this.offsetZ = offsetZ;
|
||||
offset = new Vector3(offsetX, 0.0f, offsetZ);
|
||||
if (bulletFinishType == 1) // 飞到目标点才算完成,此时有速度和时间互斥
|
||||
{
|
||||
if (speed < 0.000001f)
|
||||
{
|
||||
endWithTime = true;
|
||||
endWithArrive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
endWithTime = false;
|
||||
endWithArrive = true;
|
||||
}
|
||||
}
|
||||
else // 按时间算结束
|
||||
{
|
||||
endWithTime = true;
|
||||
endWithArrive = false;
|
||||
}
|
||||
SetupBoxCollisionBody(w, h);
|
||||
InitBase();
|
||||
StartSearch();
|
||||
}
|
||||
|
||||
private void InitBase()
|
||||
{
|
||||
CheckTargetDict.Clear();
|
||||
CheckTargetList.Clear();
|
||||
ContinuousTargetsList.Clear();
|
||||
waitNextFixedFrame = false;
|
||||
nextFixedFrameTakeEffect = false;
|
||||
isOver = false;
|
||||
targetUnit = null;
|
||||
lockTarget = false;
|
||||
checkFx = false;
|
||||
}
|
||||
|
||||
private void StartSearch()
|
||||
{
|
||||
if (bulletOriginType == 2)
|
||||
{
|
||||
transform.position = admin.transform.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ReferenceEquals(admin.Target, null))
|
||||
{
|
||||
transform.position = admin.Target.transform.position;
|
||||
}
|
||||
}
|
||||
switch (searchType)
|
||||
{
|
||||
case 1: // 以目标为目标点
|
||||
SearchWithTarget();
|
||||
break;
|
||||
case 2: // 以自身为目标点
|
||||
SearchWitchSelf();
|
||||
break;
|
||||
case 3: // 以目标为目标
|
||||
lockTarget = true;
|
||||
targetUnit = admin.Target;
|
||||
targetPosition = targetUnit.transform.position;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (endWithTime && speed < 0.000001f)
|
||||
{
|
||||
speed = (targetPosition - transform.position).magnitude / duration;
|
||||
}
|
||||
if (bulletType == 1) // 立即开始检测碰撞
|
||||
{
|
||||
SetColliderEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchWithTarget()
|
||||
{
|
||||
if (admin.Direction == 1)
|
||||
{
|
||||
targetPosition = admin.Target.transform.position + new Vector3(offsetX, 0.0f, offsetZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPosition = admin.Target.transform.position + new Vector3(-offsetX, 0.0f, offsetZ);
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchWitchSelf()
|
||||
{
|
||||
if (admin.Direction == 1)
|
||||
{
|
||||
targetPosition = admin.transform.position + new Vector3(offsetX, 0.0f, offsetZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPosition = admin.transform.position + new Vector3(-offsetX, 0.0f, offsetZ);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
var id = other.gameObject.GetInstanceID();
|
||||
if (!CheckTargetDict.TryAdd(id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
admin.OnHitTarget(other.gameObject, skillId, cloneIndex, skillEffectIndex);
|
||||
CheckTargetList.Add(other.gameObject);
|
||||
if (checkInterval > 0.000001f) // 持续型范围技能,进入范围的时候立即生效一次
|
||||
{
|
||||
var target = BF.BFMain.Instance.BattleMgr.PoolHelper.GetContinuousTarge();
|
||||
target.Unit = other.gameObject;
|
||||
target.Time = checkInterval;
|
||||
ContinuousTargetsList.Add(target);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
var gameObject = other.gameObject;
|
||||
var id = gameObject.GetInstanceID();
|
||||
if (CheckTargetDict.Contains(id))
|
||||
{
|
||||
CheckTargetList.Remove(gameObject);
|
||||
if (checkInterval > 0.000001f) // 持续型范围技能,进入范围的时候立即生效一次
|
||||
{
|
||||
var count = ContinuousTargetsList.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (gameObject == ContinuousTargetsList[i].Unit)
|
||||
{
|
||||
ContinuousTargetsList.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int GetSearchTargetsCount()
|
||||
{
|
||||
return CheckTargetList.Count;
|
||||
}
|
||||
|
||||
public int GetTargetId(int index)
|
||||
{
|
||||
if (index >= 0 && index < CheckTargetList.Count)
|
||||
{
|
||||
return CheckTargetList[index].GetInstanceID();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (checkFx)
|
||||
{
|
||||
fxDelayTime -= Time.deltaTime*BattleConfigure.TimeScale;
|
||||
if (fxDelayTime < 0.0f)
|
||||
{
|
||||
checkFx = false;
|
||||
BF.BFMain.Instance.BattleMgr.PlayFx(fxId, admin.Direction, transform.position.x, transform.position.z);
|
||||
}
|
||||
}
|
||||
|
||||
if (endWithTime) // 按时间结束
|
||||
{
|
||||
duration -= Time.deltaTime*BattleConfigure.TimeScale;
|
||||
if (duration < 0.0f)
|
||||
{
|
||||
if (bulletType == 1)
|
||||
{
|
||||
Recycle();
|
||||
}
|
||||
else if(bulletType == 2)
|
||||
{
|
||||
if (waitNextFixedFrame)
|
||||
{
|
||||
if (nextFixedFrameTakeEffect)
|
||||
{
|
||||
Recycle();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
waitNextFixedFrame = true;
|
||||
SetColliderEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else // 按飞行速度到达目标点后结束
|
||||
{
|
||||
if (!isOver)
|
||||
{
|
||||
if ((transform.position - targetPosition).sqrMagnitude < 0.0001f)
|
||||
{
|
||||
isOver = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bulletType == 1)
|
||||
{
|
||||
Recycle();
|
||||
}
|
||||
else if(bulletType == 2)
|
||||
{
|
||||
if (waitNextFixedFrame)
|
||||
{
|
||||
if (nextFixedFrameTakeEffect)
|
||||
{
|
||||
Recycle();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
waitNextFixedFrame = true;
|
||||
SetColliderEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (waitNextFixedFrame)
|
||||
{
|
||||
nextFixedFrameTakeEffect = true;
|
||||
}
|
||||
Vector3 moveToPosition;
|
||||
if (lockTarget)
|
||||
{
|
||||
targetPosition = admin.Target.transform.position;
|
||||
moveToPosition = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.fixedDeltaTime * BattleConfigure.TimeScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
moveToPosition = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.fixedDeltaTime * BattleConfigure.TimeScale);
|
||||
}
|
||||
if (moveToPosition.x < BattleConfigure.SceneMinX) // 撞左边墙了
|
||||
{
|
||||
moveToPosition.x = BattleConfigure.SceneMinX;
|
||||
}
|
||||
else if (moveToPosition.x > BattleConfigure.SceneMaxX) // 撞右边墙了
|
||||
{
|
||||
moveToPosition.x = BattleConfigure.SceneMaxX;
|
||||
}
|
||||
if (moveToPosition.z < BattleConfigure.SceneMinZ) // 撞下面墙了
|
||||
{
|
||||
moveToPosition.z = BattleConfigure.SceneMinZ;
|
||||
}
|
||||
else if (moveToPosition.z > BattleConfigure.SceneMaxZ) // 撞上面墙了
|
||||
{
|
||||
moveToPosition.z = BattleConfigure.SceneMaxZ;
|
||||
}
|
||||
transform.position = moveToPosition;
|
||||
}
|
||||
|
||||
public void PlayTargetPointFx(int id, float delay)
|
||||
{
|
||||
checkFx = true;
|
||||
fxId = id;
|
||||
fxDelayTime = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Component/Battle/BattleControlBullet.cs.meta
Normal file
11
Assets/Scripts/Component/Battle/BattleControlBullet.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33df849147f3f1e40985f1151c997135
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
488
Assets/Scripts/Component/Battle/BattleControlCollider.cs
Normal file
488
Assets/Scripts/Component/Battle/BattleControlCollider.cs
Normal file
@ -0,0 +1,488 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleContinuousTarget
|
||||
{
|
||||
public GameObject Unit;
|
||||
public float Time;
|
||||
}
|
||||
|
||||
public class BattleControlCollider : MonoBehaviour
|
||||
{
|
||||
protected BattleControlUnit admin;
|
||||
public int uniqueId = 0;
|
||||
protected bool isActive = false;
|
||||
protected int checkType = 0;
|
||||
protected float checkInterval = 0.0f;
|
||||
protected float checkDuration = 0.0f;
|
||||
protected int skillId = 0;
|
||||
protected int cloneIndex = 0;
|
||||
protected int skillEffectIndex = 0;
|
||||
protected bool unlimitCount = false;
|
||||
protected float delayAimTime = 0.0f;
|
||||
protected float aimFollowTime = 0.0f;
|
||||
protected float aimFollowSpeed = 0.0f;
|
||||
protected bool aimFollow = false;
|
||||
protected bool delayAim = false;
|
||||
protected bool effectOver = false;
|
||||
protected bool waitRecycle = false;
|
||||
protected Vector3 offset = Vector3.zero;
|
||||
protected Vector3 targetPosition = Vector3.zero;
|
||||
protected BattleControlUnit lockTarget;
|
||||
protected bool isLockTarget = false;
|
||||
protected HashSet<int> CheckTargetDict = new HashSet<int>();
|
||||
protected List<GameObject> CheckTargetList = new List<GameObject>();
|
||||
protected bool IsSearchByCollider = false;
|
||||
protected List<BattleContinuousTarget> ContinuousTargetsList = new List<BattleContinuousTarget>();
|
||||
protected BattleControlColliderContainer container;
|
||||
private bool updatePositionWithLockTarget = false;
|
||||
[System.NonSerialized]
|
||||
public float CacheX = 0.0f;
|
||||
[System.NonSerialized]
|
||||
public float CacheY = 0.0f;
|
||||
[System.NonSerialized]
|
||||
public float CacheZ = 0.0f;
|
||||
[System.NonSerialized]
|
||||
private static Vector2 Vector2A = Vector2.zero;
|
||||
private static Vector2 Vector2B = Vector2.zero;
|
||||
[System.NonSerialized]
|
||||
public bool IsRecycle = false;
|
||||
public virtual void SetColliderEnabled(bool enabled) {}
|
||||
public virtual void Recycle() {}
|
||||
|
||||
public void SetContainer(BattleControlColliderContainer container)
|
||||
{
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public void RemoveFromContainer()
|
||||
{
|
||||
this.container = null;
|
||||
}
|
||||
|
||||
public void SetIsSearchByCollider(bool isSearchByCollider)
|
||||
{
|
||||
IsSearchByCollider = isSearchByCollider;
|
||||
}
|
||||
|
||||
public void SetAdmin(BattleControlUnit unit)
|
||||
{
|
||||
admin = unit;
|
||||
if (admin.Side == 1)
|
||||
{
|
||||
gameObject.layer = BattleConst.LAYER_ATK_BULLET;
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.layer = BattleConst.LAYER_DEF_BULLET;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetUniqueId()
|
||||
{
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
public void SetTargetPosition(Vector3 position)
|
||||
{
|
||||
targetPosition = position;
|
||||
}
|
||||
|
||||
public void SetLockTarget(BattleControlUnit unit)
|
||||
{
|
||||
lockTarget = unit;
|
||||
isLockTarget = true;
|
||||
}
|
||||
|
||||
public void SetUpdatePositionWithLockTarget(bool updatePositionWithLockTarget)
|
||||
{
|
||||
this.updatePositionWithLockTarget = updatePositionWithLockTarget;
|
||||
}
|
||||
|
||||
public void InitPosition(float x, float y, float z)
|
||||
{
|
||||
if (admin.Direction == 1)
|
||||
{
|
||||
transform.position = new Vector3(x, y, z) + offset;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = new Vector3(x, y, z) - offset;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveToLockTargetPosition(float deltaTime)
|
||||
{
|
||||
if (admin.Direction == 1)
|
||||
{
|
||||
var position = lockTarget.transform.position + offset;
|
||||
var moveToPosition = Vector3.MoveTowards(transform.position, position, aimFollowSpeed * deltaTime);
|
||||
transform.position = moveToPosition;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
var position = lockTarget.transform.position - offset;
|
||||
var moveToPosition = Vector3.MoveTowards(transform.position, position, aimFollowSpeed * deltaTime);
|
||||
transform.position = moveToPosition;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveToTargetPosition(float deltaTime)
|
||||
{
|
||||
if (admin.Direction == 1)
|
||||
{
|
||||
var position = targetPosition + offset;
|
||||
var moveToPosition = Vector3.MoveTowards(transform.position, position, aimFollowSpeed * deltaTime);
|
||||
transform.position = moveToPosition;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
var position = targetPosition - offset;
|
||||
var moveToPosition = Vector3.MoveTowards(transform.position, position, aimFollowSpeed * deltaTime);
|
||||
transform.position = moveToPosition;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePositionByTargetPosition()
|
||||
{
|
||||
if (admin.Direction == 1)
|
||||
{
|
||||
transform.position = targetPosition + offset;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = targetPosition - offset;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePositionByLockTargetPosition()
|
||||
{
|
||||
if (admin.Direction == 1)
|
||||
{
|
||||
transform.position = lockTarget.transform.position + offset;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = lockTarget.transform.position - offset;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePositionByAdminPosition()
|
||||
{
|
||||
if (admin.Direction == 1)
|
||||
{
|
||||
transform.position = admin.transform.position + offset;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = admin.transform.position - offset;
|
||||
transform.localEulerAngles = new Vector3(0.0f, 180.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void CachePosition()
|
||||
{
|
||||
var position = transform.position;
|
||||
CacheX = position.x;
|
||||
CacheY = position.y;
|
||||
CacheZ = position.z;
|
||||
}
|
||||
|
||||
private void FollowTarget(float deltaTime)
|
||||
{
|
||||
if (isLockTarget)
|
||||
{
|
||||
MoveToLockTargetPosition(deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveToTargetPosition(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void InitBase()
|
||||
{
|
||||
CheckTargetDict.Clear();
|
||||
CheckTargetList.Clear();
|
||||
ContinuousTargetsList.Clear();
|
||||
effectOver = false;
|
||||
waitRecycle = false;
|
||||
lockTarget = null;
|
||||
isLockTarget = false;
|
||||
updatePositionWithLockTarget = false;
|
||||
}
|
||||
|
||||
public void Search(int checkType, float interval, float duration, int skillId, int cloneIndex, int skillEffectIndex, bool unlimitCount, float delayAimTime, float aimFollowTime, float aimFollowSpeed, bool disposable)
|
||||
{
|
||||
this.checkType = checkType;
|
||||
this.checkInterval = interval;
|
||||
this.checkDuration = duration;
|
||||
this.skillId = skillId;
|
||||
this.cloneIndex = cloneIndex;
|
||||
this.skillEffectIndex = skillEffectIndex;
|
||||
this.unlimitCount = unlimitCount;
|
||||
this.delayAimTime = delayAimTime;
|
||||
this.aimFollowTime = aimFollowTime;
|
||||
this.aimFollowSpeed = aimFollowSpeed;
|
||||
if (aimFollowTime > 0.0f)
|
||||
{
|
||||
aimFollow = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
aimFollow = false;
|
||||
}
|
||||
if (isLockTarget)
|
||||
{
|
||||
UpdatePositionByLockTargetPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePositionByTargetPosition();
|
||||
}
|
||||
if (disposable)
|
||||
{
|
||||
delayAim = false;
|
||||
StartSearch();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (delayAimTime > 0.0f) // 延迟
|
||||
{
|
||||
delayAim = true;
|
||||
}
|
||||
else // 立即
|
||||
{
|
||||
delayAim = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StartSearch()
|
||||
{
|
||||
if (IsSearchByCollider)
|
||||
{
|
||||
isActive = true;
|
||||
effectOver = false;
|
||||
waitRecycle = false;
|
||||
SetColliderEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
var id = other.gameObject.GetInstanceID();
|
||||
if (!CheckTargetDict.TryAdd(id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
CheckTargetList.Add(other.gameObject);
|
||||
if (checkInterval > 0.000001f) // 持续型范围技能,进入范围的时候立即生效一次
|
||||
{
|
||||
admin.OnHitTarget(other.gameObject, skillId, cloneIndex, skillEffectIndex);
|
||||
var target = BF.BFMain.Instance.BattleMgr.PoolHelper.GetContinuousTarge();
|
||||
target.Unit = other.gameObject;
|
||||
target.Time = checkInterval;
|
||||
ContinuousTargetsList.Add(target);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
var gameObject = other.gameObject;
|
||||
var id = gameObject.GetInstanceID();
|
||||
if (CheckTargetDict.Contains(id))
|
||||
{
|
||||
CheckTargetList.Remove(gameObject);
|
||||
if (checkInterval > 0.000001f) // 持续型范围技能,进入范围的时候立即生效一次
|
||||
{
|
||||
var count = ContinuousTargetsList.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (gameObject == ContinuousTargetsList[i].Unit)
|
||||
{
|
||||
ContinuousTargetsList.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddCheckTargetList(GameObject gameObject)
|
||||
{
|
||||
CheckTargetList.Add(gameObject);
|
||||
}
|
||||
|
||||
private void SearchNearestTarget()
|
||||
{
|
||||
var control = BF.BFMain.Instance.BattleMgr.GetNearestUnit(admin.Side);
|
||||
if(ReferenceEquals(control, null))
|
||||
{
|
||||
Recycle();
|
||||
return;
|
||||
}
|
||||
CheckTargetList.Add(control.gameObject);
|
||||
}
|
||||
|
||||
private void SearchAllTargets()
|
||||
{
|
||||
var unitsList = BF.BFMain.Instance.BattleMgr.GetUnitsList(admin.Side);
|
||||
for (int i = 0; i < unitsList.Count; i++)
|
||||
{
|
||||
CheckTargetList.Add(unitsList[i].gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
protected void CheckCollider()
|
||||
{
|
||||
CheckSurroundingTargets();
|
||||
}
|
||||
|
||||
private void CheckSurroundingTargets()
|
||||
{
|
||||
if (checkInterval <= 0.000001f)
|
||||
{
|
||||
if (effectOver)
|
||||
{
|
||||
if (waitRecycle)
|
||||
{
|
||||
if (!unlimitCount)
|
||||
{
|
||||
FindNearestAndHit();
|
||||
}
|
||||
else
|
||||
{
|
||||
HitTargets();
|
||||
}
|
||||
Recycle();
|
||||
}
|
||||
else
|
||||
{
|
||||
waitRecycle = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
effectOver = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void FindNearestAndHit()
|
||||
{
|
||||
var count = CheckTargetList.Count;
|
||||
if (count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GameObject unit = null;
|
||||
var position = admin.transform.position;
|
||||
Vector2A.Set(position.x, position.z);
|
||||
float minDis = float.MaxValue;
|
||||
for(int j = 0; j < count; j++)
|
||||
{
|
||||
var objB = CheckTargetList[j];
|
||||
Vector2B.Set(objB.transform.position.x, objB.transform.position.z);
|
||||
var dis = (Vector2B - Vector2A).sqrMagnitude;
|
||||
if (dis < minDis)
|
||||
{
|
||||
minDis = dis;
|
||||
unit = objB;
|
||||
}
|
||||
}
|
||||
if (!ReferenceEquals(unit, null))
|
||||
{
|
||||
admin.OnHitTarget(unit, skillId, cloneIndex, skillEffectIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void HitTargets()
|
||||
{
|
||||
var count = CheckTargetList.Count;
|
||||
if (count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = count - 1; i >= 0; i--)
|
||||
{
|
||||
admin.OnHitTarget(CheckTargetList[i], skillId, cloneIndex, skillEffectIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetSearchTargetsCount()
|
||||
{
|
||||
return CheckTargetList.Count;
|
||||
}
|
||||
|
||||
public int GetTargetId(int index)
|
||||
{
|
||||
if (index >= 0 && index < CheckTargetList.Count)
|
||||
{
|
||||
return CheckTargetList[index].GetInstanceID();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (delayAim)
|
||||
{
|
||||
delayAimTime -= Time.deltaTime*BattleConfigure.TimeScale;
|
||||
if (delayAimTime < 0.0f)
|
||||
{
|
||||
delayAim = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (aimFollow)
|
||||
{
|
||||
var deltaTime = Time.deltaTime*BattleConfigure.TimeScale;
|
||||
aimFollowTime -= deltaTime;
|
||||
if (aimFollowTime < 0.0f)
|
||||
{
|
||||
aimFollow = false;
|
||||
}
|
||||
FollowTarget(deltaTime);
|
||||
}
|
||||
if (!isActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (updatePositionWithLockTarget)
|
||||
{
|
||||
UpdatePositionByLockTargetPosition();
|
||||
}
|
||||
var count = ContinuousTargetsList.Count;
|
||||
if (count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
BattleContinuousTarget target = null;
|
||||
var deltaTime2 = Time.deltaTime*BattleConfigure.TimeScale;
|
||||
for (int i = count - 1; i >= 0; i--)
|
||||
{
|
||||
target = ContinuousTargetsList[i];
|
||||
target.Time -= deltaTime2;
|
||||
if (target.Time <= 0.0f)
|
||||
{
|
||||
target.Time = checkInterval;
|
||||
admin.OnHitTarget(target.Unit, skillId, cloneIndex, skillEffectIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4fb90d05a9d73b438f7fa1e4d7baf32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,103 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleControlColliderContainer
|
||||
{
|
||||
[System.NonSerialized]
|
||||
public bool IsRecycle = false;
|
||||
[System.NonSerialized]
|
||||
public bool IsSearchByCollider = false;
|
||||
private List<BattleControlCollider> colliderList = new List<BattleControlCollider>();
|
||||
|
||||
public void InitBase()
|
||||
{
|
||||
colliderList.Clear();
|
||||
}
|
||||
|
||||
public void SetIsSearchByCollider(bool isSearchByCollider)
|
||||
{
|
||||
IsSearchByCollider = isSearchByCollider;
|
||||
}
|
||||
|
||||
public void Add(BattleControlCollider collider)
|
||||
{
|
||||
colliderList.Add(collider);
|
||||
collider.SetContainer(this);
|
||||
}
|
||||
|
||||
public void Remove(BattleControlCollider collider)
|
||||
{
|
||||
colliderList.Remove(collider);
|
||||
}
|
||||
|
||||
public int GetSearchTargetsCount()
|
||||
{
|
||||
var count = 0;
|
||||
for (int i = 0; i < colliderList.Count; i++)
|
||||
{
|
||||
count += colliderList[i].GetSearchTargetsCount();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int GetCollidersCount()
|
||||
{
|
||||
return colliderList.Count;
|
||||
}
|
||||
|
||||
public BattleControlCollider GetCollider(int colliderIndex)
|
||||
{
|
||||
return colliderList[colliderIndex];
|
||||
}
|
||||
|
||||
public int GetTargetId(int colliderIndex, int index)
|
||||
{
|
||||
return colliderList[colliderIndex].GetTargetId(index);
|
||||
}
|
||||
|
||||
public void CachePosition(int index)
|
||||
{
|
||||
colliderList[index].CachePosition();
|
||||
}
|
||||
|
||||
public float FastGetColliderX(int index)
|
||||
{
|
||||
return colliderList[index].CacheX;
|
||||
}
|
||||
|
||||
public float FastGetColliderZ(int index)
|
||||
{
|
||||
return colliderList[index].CacheZ;
|
||||
}
|
||||
|
||||
public void StartSearch()
|
||||
{
|
||||
for (int i = 0; i < colliderList.Count; i++)
|
||||
{
|
||||
colliderList[i].StartSearch();
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetIsFinished()
|
||||
{
|
||||
if (IsSearchByCollider && colliderList.Count > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Recycle()
|
||||
{
|
||||
for (int i = 0; i < colliderList.Count; i++)
|
||||
{
|
||||
colliderList[i].RemoveFromContainer();
|
||||
colliderList[i].Recycle();
|
||||
}
|
||||
colliderList.Clear();
|
||||
BFMain.Instance.BattleMgr.PoolHelper.RecycleColliderContainer(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5a2f8c0b2efbbf4ca08b2f87f287b92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
344
Assets/Scripts/Component/Battle/BattleControlHero.cs
Normal file
344
Assets/Scripts/Component/Battle/BattleControlHero.cs
Normal file
@ -0,0 +1,344 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleControlHero : BattleControlUnit
|
||||
{
|
||||
private Camera mainCamera;
|
||||
private Rigidbody unitRigidbody;
|
||||
private bool isMoving = false;
|
||||
private float TargetX = 0.0f;
|
||||
private float TargetZ = 0.0f;
|
||||
private float moveSpeed = 1.0f;
|
||||
private Vector3 targetPosition = Vector3.zero;
|
||||
// 摄像机相关
|
||||
public bool IsCameraFollowWithHero = true;
|
||||
private Vector3 cameraOriginPosition = Vector3.zero;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
mainCamera = Camera.main;
|
||||
InitRigidbody();
|
||||
}
|
||||
|
||||
private void InitRigidbody()
|
||||
{
|
||||
if (!gameObject.TryGetComponent<Rigidbody>(out unitRigidbody))
|
||||
{
|
||||
unitRigidbody = gameObject.AddComponent<Rigidbody>();
|
||||
}
|
||||
unitRigidbody.angularDrag = 0;
|
||||
unitRigidbody.useGravity = false;
|
||||
unitRigidbody.isKinematic = true;
|
||||
unitRigidbody.constraints = BattleConst.RIGIDBODY_CONSTRAINTS;
|
||||
bodyCollider = gameObject.AddComponent<SphereCollider>();
|
||||
bodyCollider.isTrigger = true;
|
||||
}
|
||||
|
||||
public void InitHero(int side, CharacterSpineHelper helper)
|
||||
{
|
||||
Side = side;
|
||||
BattleMgr = BF.BFMain.Instance.BattleMgr;
|
||||
Direction = 1;
|
||||
gameObject.layer = BattleConst.LAYER_HERO;
|
||||
ReuseFlag++;
|
||||
IsDead = false;
|
||||
IsInGroundState = false;
|
||||
IsDisappear = false;
|
||||
BattleMgr.AddToAtkUnitsList(this);
|
||||
}
|
||||
|
||||
public override void InitHpBar()
|
||||
{
|
||||
if (isHaveHpBar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hpBar = BattleMgr.PoolHelper.GetHpBar(Side);
|
||||
hpBar.transform.localScale = Vector3.one;
|
||||
hpBar.RefreshHpBar(1.0f);
|
||||
hpBar.SetShieldVisible(false);
|
||||
BattleMgr.UpdateUIPosition(transform.position, HpBarAddY, hpBar.transform as RectTransform);
|
||||
isHaveHpBar = true;
|
||||
}
|
||||
|
||||
public override void RefreshHpBar(float percent)
|
||||
{
|
||||
if (!isHaveHpBar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hpBar.RefreshHpBar(percent);
|
||||
}
|
||||
|
||||
public override void RefreshShieldBar(float percent, bool visible)
|
||||
{
|
||||
if (!isHaveHpBar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (visible)
|
||||
{
|
||||
hpBar.RefreshShieldBar(percent);
|
||||
}
|
||||
hpBar.SetShieldVisible(visible);
|
||||
}
|
||||
|
||||
public void SetCameraStartPosition(Vector3 originPosition)
|
||||
{
|
||||
cameraOriginPosition = originPosition;
|
||||
}
|
||||
|
||||
public bool MoveAndAttack(int direction)
|
||||
{
|
||||
isMoving = true;
|
||||
bool isAttack = true;
|
||||
var x = transform.position.x;
|
||||
var z = transform.position.z;
|
||||
if (direction == 1) // 朝向右边
|
||||
{
|
||||
BattleControlUnit leftTarget = null;
|
||||
BattleControlUnit rightTarget = null;
|
||||
BattleMgr.GetNearestDefUnit(x, z, out leftTarget, out rightTarget);
|
||||
if (ReferenceEquals(rightTarget, null)) // 右边没有敌人
|
||||
{
|
||||
if (ReferenceEquals(leftTarget, null)) // 左边也没有敌人则向该方向进行常规攻击,同时推进
|
||||
{
|
||||
if (BattleMgr.GetEffectWarningCount() <= 0)
|
||||
{
|
||||
TargetX = x + BattleConfigure.DistanceAttack;
|
||||
TargetZ = z;
|
||||
Direction = direction;
|
||||
}
|
||||
else // 找不到人,但是有预警的话就往该方向后撤
|
||||
{
|
||||
TargetX = x + BattleConfigure.DistanceBack;
|
||||
TargetZ = z;
|
||||
isAttack = false;
|
||||
}
|
||||
}
|
||||
else // 左边有敌人,则向该方向进行后撤,并且当前朝向不变
|
||||
{
|
||||
TargetX = x + BattleConfigure.DistanceBack;
|
||||
TargetZ = z;
|
||||
isAttack = false;
|
||||
}
|
||||
}
|
||||
else // 右边有敌人,向目标进行冲锋推进攻击
|
||||
{
|
||||
TargetX = rightTarget.transform.position.x - rightTarget.BodyRadius - BodyRadius;
|
||||
if (TargetX - x > BattleConfigure.DistanceDash)
|
||||
{
|
||||
TargetX = x + BattleConfigure.DistanceDash;
|
||||
}
|
||||
TargetZ = rightTarget.transform.position.z;
|
||||
Direction = direction;
|
||||
}
|
||||
targetPosition = new Vector3(TargetX, 0.0f, TargetZ);
|
||||
var distance = (targetPosition - transform.position).magnitude;
|
||||
if (isAttack)
|
||||
{
|
||||
moveSpeed = Math.Abs(distance / BattleConfigure.NormalMoveTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
moveSpeed = Math.Abs(distance / BattleConfigure.NormalBackTime);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BattleControlUnit leftTarget = null;
|
||||
BattleControlUnit rightTarget = null;
|
||||
BattleMgr.GetNearestDefUnit(x, z, out leftTarget, out rightTarget);
|
||||
if (ReferenceEquals(leftTarget, null)) // 左边没有敌人
|
||||
{
|
||||
if (ReferenceEquals(rightTarget, null)) // 右边也没有敌人则向该方向进行常规攻击,同时推进
|
||||
{
|
||||
if (BattleMgr.GetEffectWarningCount() <= 0)
|
||||
{
|
||||
TargetX = x - BattleConfigure.DistanceAttack;
|
||||
TargetZ = transform.position.z;
|
||||
Direction = direction;
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetX = x - BattleConfigure.DistanceBack;
|
||||
TargetZ = transform.position.z;
|
||||
isAttack = false;
|
||||
}
|
||||
}
|
||||
else // 右边有敌人,则向该方向进行后撤,并且当前朝向不变
|
||||
{
|
||||
TargetX = x - BattleConfigure.DistanceBack;
|
||||
TargetZ = transform.position.z;
|
||||
isAttack = false;
|
||||
}
|
||||
}
|
||||
else // 左边有敌人,向目标进行冲锋推进攻击
|
||||
{
|
||||
TargetX = leftTarget.transform.position.x + leftTarget.BodyRadius + BodyRadius;
|
||||
if (x - TargetX > BattleConfigure.DistanceDash)
|
||||
{
|
||||
TargetX = x - BattleConfigure.DistanceDash;
|
||||
}
|
||||
TargetZ = leftTarget.transform.position.z;
|
||||
Direction = direction;
|
||||
}
|
||||
targetPosition = new Vector3(TargetX, 0.0f, TargetZ);
|
||||
var distance = (targetPosition - transform.position).magnitude;
|
||||
if (isAttack)
|
||||
{
|
||||
moveSpeed = Math.Abs(distance / BattleConfigure.NormalMoveTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
moveSpeed = Math.Abs(distance / BattleConfigure.NormalBackTime);
|
||||
}
|
||||
}
|
||||
return isAttack;
|
||||
}
|
||||
|
||||
public int GetNearestLeftRightUnit()
|
||||
{
|
||||
BattleControlUnit leftTarget = null;
|
||||
BattleControlUnit rightTarget = null;
|
||||
BattleMgr.GetNearestDefUnit(transform.position.x, transform.position.z, out leftTarget, out rightTarget);
|
||||
if (ReferenceEquals(leftTarget, null))
|
||||
{
|
||||
if (ReferenceEquals(rightTarget, null))
|
||||
{
|
||||
return 0; // 两边都没有敌人
|
||||
}
|
||||
else
|
||||
{
|
||||
return 2; // 只有右边有敌人
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ReferenceEquals(rightTarget, null))
|
||||
{
|
||||
return 1; // 只有左边有敌人
|
||||
}
|
||||
else
|
||||
{
|
||||
var leftDistance = Mathf.Abs(transform.position.x - leftTarget.transform.position.x);
|
||||
var rightDistance = Mathf.Abs(transform.position.x - rightTarget.transform.position.x);
|
||||
if (leftDistance < rightDistance)
|
||||
{
|
||||
return 1; // 左边的敌人离得更近
|
||||
}
|
||||
else
|
||||
{
|
||||
return 2; // 右边的敌人离得更近
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetWhetherUseGroundSkill()
|
||||
{
|
||||
var unit = BattleMgr.GetNearestDefUnitOnCurrDirection(transform.position.x, transform.position.z, Direction);
|
||||
if (ReferenceEquals(unit, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return unit.IsInGroundState;
|
||||
}
|
||||
|
||||
public void StopMove()
|
||||
{
|
||||
isMoving = false;
|
||||
}
|
||||
|
||||
public void StartMove()
|
||||
{
|
||||
isMoving = true;
|
||||
}
|
||||
|
||||
private float GetMoveSpeed()
|
||||
{
|
||||
return moveSpeed;
|
||||
}
|
||||
|
||||
public override void OnDead()
|
||||
{
|
||||
IsDead = true;
|
||||
IsInGroundState = false;
|
||||
}
|
||||
|
||||
public override void Reborn()
|
||||
{
|
||||
IsDead = false;
|
||||
}
|
||||
|
||||
public override void Revive()
|
||||
{
|
||||
IsDead = false;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
luaOnHitTargetFunc = null;
|
||||
if (isHaveHpBar)
|
||||
{
|
||||
BattleMgr.PoolHelper.PutBackHpBar(hpBar, Side);
|
||||
hpBar = null;
|
||||
isHaveHpBar = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!isMoving)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((transform.position - targetPosition).sqrMagnitude < 0.0001)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var moveToPosition = Vector3.MoveTowards(transform.position, targetPosition, GetMoveSpeed() * Time.deltaTime*BattleConfigure.TimeScale);
|
||||
if (moveToPosition.x < BattleConfigure.SceneMinX)
|
||||
{
|
||||
moveToPosition.x = BattleConfigure.SceneMinX;
|
||||
}
|
||||
else if (moveToPosition.x > BattleConfigure.SceneMaxX)
|
||||
{
|
||||
moveToPosition.x = BattleConfigure.SceneMaxX;
|
||||
}
|
||||
transform.position = moveToPosition;
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (IsCameraFollowWithHero)
|
||||
{
|
||||
var position = cameraOriginPosition + new Vector3(transform.localPosition.x, 0.0f, 0.0f);
|
||||
if (position.x < BattleConfigure.CameraMinX)
|
||||
{
|
||||
position.x = BattleConfigure.CameraMinX;
|
||||
}
|
||||
else if (position.x > BattleConfigure.CameraMaxX)
|
||||
{
|
||||
position.x = BattleConfigure.CameraMaxX;
|
||||
}
|
||||
mainCamera.transform.position = position;
|
||||
BattleConfigure.BattleCenterPosX = position.x;
|
||||
BattleMgr.UpdateEffectTextRootNode();
|
||||
}
|
||||
if (isHaveHpBar && isMoving)
|
||||
{
|
||||
BattleMgr.UpdateUIPosition(transform.position, HpBarAddY, hpBar.transform as RectTransform);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
luaOnHitTargetFunc = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Component/Battle/BattleControlHero.cs.meta
Normal file
11
Assets/Scripts/Component/Battle/BattleControlHero.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2f0a4037a9edf24dab741e7424bf814
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
581
Assets/Scripts/Component/Battle/BattleControlMonster.cs
Normal file
581
Assets/Scripts/Component/Battle/BattleControlMonster.cs
Normal file
@ -0,0 +1,581 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleControlMonster : BattleControlUnit
|
||||
{
|
||||
private CharacterSpineHelper spineHelper;
|
||||
private Rigidbody unitRigidbody;
|
||||
private Transform mainBody;
|
||||
private bool isMoving = false;
|
||||
private float checkTowardTime = 0.1f;
|
||||
private float checkAITargetPositionTime = 0.1f;
|
||||
private int horizontalTypeAI = 0;
|
||||
private float offsetXAI = 0.0f;
|
||||
private float offsetZAI = 0.0f;
|
||||
private Sequence airborneSeq;
|
||||
private bool isHitBack = true;
|
||||
private float hitBackTime = 0.0f;
|
||||
private float hitBackSpeed = 0.0f;
|
||||
void Awake()
|
||||
{
|
||||
InitRigidbody();
|
||||
}
|
||||
|
||||
private void InitRigidbody()
|
||||
{
|
||||
if (!gameObject.TryGetComponent<Rigidbody>(out unitRigidbody))
|
||||
{
|
||||
unitRigidbody = gameObject.AddComponent<Rigidbody>();
|
||||
}
|
||||
unitRigidbody.angularDrag = 0;
|
||||
unitRigidbody.useGravity = false;
|
||||
unitRigidbody.isKinematic = true;
|
||||
unitRigidbody.constraints = BattleConst.RIGIDBODY_CONSTRAINTS;
|
||||
bodyCollider = gameObject.AddComponent<SphereCollider>();
|
||||
bodyCollider.isTrigger = true;
|
||||
}
|
||||
|
||||
public void InitMonster(int side, CharacterSpineHelper helper, Transform body)
|
||||
{
|
||||
Side = side;
|
||||
BattleMgr = BF.BFMain.Instance.BattleMgr;
|
||||
spineHelper = helper;
|
||||
mainBody = body;
|
||||
if (ReferenceEquals(mainBody, null))
|
||||
{
|
||||
mainBody = transform.GetChild(0);
|
||||
}
|
||||
Direction = 1;
|
||||
isMoving = false;
|
||||
IsDead = false;
|
||||
IsInGroundState = false;
|
||||
Target = null;
|
||||
IsDisappear = false;
|
||||
BattleMgr.AddToDefUnitsList(this);
|
||||
gameObject.layer = BattleConst.LAYER_MONSTER;
|
||||
}
|
||||
|
||||
public override void InitHpBar()
|
||||
{
|
||||
if (isHaveHpBar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hpBar = BattleMgr.PoolHelper.GetHpBar(Side);
|
||||
hpBar.transform.localScale = Vector3.one;
|
||||
hpBar.RefreshHpBar(1.0f);
|
||||
BattleMgr.UpdateUIPosition(transform.position, HpBarAddY, hpBar.transform as RectTransform);
|
||||
isHaveHpBar = true;
|
||||
}
|
||||
|
||||
public override void RefreshHpBar(float percent)
|
||||
{
|
||||
if (!isHaveHpBar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hpBar.RefreshHpBar(percent);
|
||||
}
|
||||
|
||||
public void InitPosition(float x, float y, float z)
|
||||
{
|
||||
transform.position = new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
public override void EnterDisappear()
|
||||
{
|
||||
gameObject.layer = BattleConst.LAYER_DEFAULT;
|
||||
BattleMgr.RemoveFromDefUnitsList(this);
|
||||
if (isHaveHpBar)
|
||||
{
|
||||
hpBar.transform.localScale = Vector3.zero;
|
||||
}
|
||||
if (IsHaveShadow)
|
||||
{
|
||||
shadow.transform.localScale = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExitDisappear()
|
||||
{
|
||||
gameObject.layer = BattleConst.LAYER_MONSTER;
|
||||
BattleMgr.AddToDefUnitsList(this);
|
||||
if (isHaveHpBar)
|
||||
{
|
||||
hpBar.transform.localScale = Vector3.one;
|
||||
}
|
||||
if (IsHaveShadow)
|
||||
{
|
||||
shadow.transform.localScale = Vector3.one*BodyRadius*2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTarget(BattleControlUnit target)
|
||||
{
|
||||
Target = target;
|
||||
}
|
||||
|
||||
public bool GetIsNormalMonster()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool GetIsBOSS()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void StopMove()
|
||||
{
|
||||
isMoving = false;
|
||||
}
|
||||
|
||||
public void StartMove()
|
||||
{
|
||||
isMoving = true;
|
||||
}
|
||||
|
||||
// 秒杀
|
||||
public void InstantKill()
|
||||
{
|
||||
OnDead();
|
||||
}
|
||||
|
||||
public override void PlayAirborne()
|
||||
{
|
||||
if (ReferenceEquals(airborneSeq, null))
|
||||
{
|
||||
airborneSeq = BattleHelper.CreateSequence();
|
||||
var time = BattleConfigure.TimeHitFly;
|
||||
var tween1 = mainBody.DOLocalMoveY(BattleConfigure.HeightHitFly, time*3.0f/5.0f).SetEase(Ease.OutQuart);
|
||||
tween1.intId = BattleConst.DOTWEEN_ID_BATTLE;
|
||||
var tween2 = mainBody.DOLocalMoveY(0.0f, time*2.0f/5.0f);
|
||||
tween2.intId = BattleConst.DOTWEEN_ID_BATTLE;
|
||||
airborneSeq.Append(tween1);
|
||||
airborneSeq.Append(tween2);
|
||||
airborneSeq.SetAutoKill(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
airborneSeq.Restart();
|
||||
}
|
||||
isHitBack = true;
|
||||
hitBackTime = BattleConfigure.TimeHitFly;
|
||||
hitBackSpeed = BattleConfigure.DistanceHitFly / hitBackTime;
|
||||
}
|
||||
|
||||
public override void StopAirborne()
|
||||
{
|
||||
if (!ReferenceEquals(airborneSeq, null))
|
||||
{
|
||||
airborneSeq.Pause();
|
||||
}
|
||||
mainBody.localPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
public override void MoveWithSkillAI(int target, int horizontal, float x, float z, int refresh, int across, float speed, int endType, float endValue, int collisionType)
|
||||
{
|
||||
StartMove();
|
||||
targetTypeAI = target;
|
||||
horizontalTypeAI = horizontal;
|
||||
offsetXAI = x;
|
||||
offsetZAI = z;
|
||||
keepUpdateTargetPositionAI = refresh == 1;
|
||||
isCanAcrossTarget = across == 1;
|
||||
moveSpeedAI = speed;
|
||||
isTeleport = moveSpeedAI < 0.000001f;
|
||||
endTypeAI = endType;
|
||||
if (endTypeAI == 1)
|
||||
{
|
||||
endValueAI = endValue*endValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
endValueAI = endValue;
|
||||
}
|
||||
collisionTypeAI = collisionType;
|
||||
FindTargetPosition();
|
||||
}
|
||||
|
||||
private void FindTargetPosition()
|
||||
{
|
||||
if (targetTypeAI == 1) // 自身
|
||||
{
|
||||
FindTargetPositionAISelf();
|
||||
CheckTargetPositionAIOutWall();
|
||||
}
|
||||
else if(targetTypeAI == 2) // 目标
|
||||
{
|
||||
FindTargetPositionAITarget();
|
||||
CheckTargetPositionAIOutWall();
|
||||
}
|
||||
else if(targetTypeAI == 3) // 场地中央
|
||||
{
|
||||
FindTargetPositionAIMiddle();
|
||||
CheckTargetPositionAIOutWall();
|
||||
}
|
||||
else
|
||||
{
|
||||
StopMove();
|
||||
}
|
||||
}
|
||||
|
||||
private void FindTargetPositionAITarget()
|
||||
{
|
||||
if (horizontalTypeAI == 1)
|
||||
{
|
||||
if (Target.transform.position.x < transform.position.x) // 目标在自己的左边
|
||||
{
|
||||
targetPositionAI = Target.transform.position + new Vector3(-offsetXAI, 0.0f, offsetZAI);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPositionAI = Target.transform.position + new Vector3(offsetXAI, 0.0f, offsetZAI);
|
||||
}
|
||||
}
|
||||
else if(horizontalTypeAI == 2)
|
||||
{
|
||||
var deltaX = transform.position.x - Target.transform.position.x;
|
||||
var deltaZ = transform.position.z - Target.transform.position.z;
|
||||
var radian = Mathf.Atan2(deltaZ, deltaX);
|
||||
var x = -offsetXAI*Mathf.Cos(radian);
|
||||
var z = -offsetXAI*Mathf.Sin(radian);
|
||||
targetPositionAI = new Vector3(Target.transform.position.x + x, 0.0f, Target.transform.position.z + z);
|
||||
}
|
||||
}
|
||||
|
||||
private void FindTargetPositionAISelf()
|
||||
{
|
||||
if (Direction == 1)
|
||||
{
|
||||
targetPositionAI = transform.position + new Vector3(offsetXAI, 0.0f, offsetZAI);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPositionAI = transform.position + new Vector3(-offsetXAI, 0.0f, offsetZAI);
|
||||
}
|
||||
}
|
||||
|
||||
private void FindTargetPositionAIMiddle()
|
||||
{
|
||||
if (horizontalTypeAI == 1)
|
||||
{
|
||||
if (BattleConfigure.SceneMidX < transform.position.x) // 自己在场景右边
|
||||
{
|
||||
targetPositionAI = new Vector3(-offsetXAI + BattleConfigure.SceneMidX, 0.0f, offsetZAI + BattleConfigure.SceneMidZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPositionAI = transform.position + new Vector3(offsetXAI + BattleConfigure.SceneMidX, 0.0f, offsetZAI + BattleConfigure.SceneMidZ);
|
||||
}
|
||||
}
|
||||
else if(horizontalTypeAI == 2)
|
||||
{
|
||||
var deltaX = transform.position.x - BattleConfigure.SceneMidX;
|
||||
var deltaZ = transform.position.z - BattleConfigure.SceneMidZ;
|
||||
var radian = Mathf.Atan2(deltaZ, deltaX);
|
||||
var x = -offsetXAI*Mathf.Cos(radian);
|
||||
var z = -offsetXAI*Mathf.Sin(radian);
|
||||
targetPositionAI = new Vector3(Target.transform.position.x + x, 0.0f, Target.transform.position.z + z);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckTargetPositionAIOutWall()
|
||||
{
|
||||
if (targetPositionAI.x < BattleConfigure.SceneMinX) // 撞左边墙了
|
||||
{
|
||||
targetPositionAI.x = BattleConfigure.SceneMinX;
|
||||
}
|
||||
else if (targetPositionAI.x > BattleConfigure.SceneMaxX) // 撞右边墙了
|
||||
{
|
||||
targetPositionAI.x = BattleConfigure.SceneMaxX;
|
||||
}
|
||||
if (targetPositionAI.z < BattleConfigure.SceneMinZ) // 撞左边墙了
|
||||
{
|
||||
targetPositionAI.z = BattleConfigure.SceneMinZ;
|
||||
}
|
||||
else if (targetPositionAI.z > BattleConfigure.SceneMaxZ) // 撞右边墙了
|
||||
{
|
||||
targetPositionAI.z = BattleConfigure.SceneMaxZ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
var deltaTime = Time.deltaTime*BattleConfigure.TimeScale;
|
||||
if (!isMoving)
|
||||
{
|
||||
if (isHitBack)
|
||||
{
|
||||
UpdateHitBackMove(deltaTime);
|
||||
}
|
||||
CheckToward(deltaTime);
|
||||
return;
|
||||
}
|
||||
UpdateAIMoveing(deltaTime);
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
// TODO 后续可以优化成怪物移动或者相机移动的时候更新
|
||||
if (isHaveHpBar)
|
||||
{
|
||||
BattleMgr.UpdateUIPosition(transform.position, HpBarAddY, hpBar.transform as RectTransform);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckToward(float deltaTime)
|
||||
{
|
||||
if (IsDead)
|
||||
{
|
||||
return;
|
||||
}
|
||||
checkTowardTime -= deltaTime;
|
||||
if (checkTowardTime < 0.0f)
|
||||
{
|
||||
checkTowardTime = BattleConfigure.CheckMonsterTowardInterval;
|
||||
TowardToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
public override void TowardToTarget()
|
||||
{
|
||||
if (Target.transform.position.x <= transform.position.x)
|
||||
{
|
||||
if (Direction != -1)
|
||||
{
|
||||
Direction = -1;
|
||||
var bodyTransform = spineHelper.GetSpineObject().transform.parent;
|
||||
bodyTransform.localScale = new Vector3(BattleConfigure.MonsterScaleFactorXZ*Direction, bodyTransform.localScale.y, bodyTransform.localScale.z);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Direction != 1)
|
||||
{
|
||||
Direction = 1;
|
||||
var bodyTransform = spineHelper.GetSpineObject().transform.parent;
|
||||
bodyTransform.localScale = new Vector3(BattleConfigure.MonsterScaleFactorXZ*Direction, bodyTransform.localScale.y, bodyTransform.localScale.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ForceTowardToTarget()
|
||||
{
|
||||
if (Target.transform.position.x <= transform.position.x)
|
||||
{
|
||||
Direction = -1;
|
||||
var bodyTransform = spineHelper.GetSpineObject().transform.parent;
|
||||
bodyTransform.localScale = new Vector3(BattleConfigure.MonsterScaleFactorXZ*Direction, bodyTransform.localScale.y, bodyTransform.localScale.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
Direction = 1;
|
||||
var bodyTransform = spineHelper.GetSpineObject().transform.parent;
|
||||
bodyTransform.localScale = new Vector3(BattleConfigure.MonsterScaleFactorXZ*Direction, bodyTransform.localScale.y, bodyTransform.localScale.z);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAIMoveing(float deltaTime)
|
||||
{
|
||||
if (endTypeAI == 1) // 按距离结束
|
||||
{
|
||||
if ((transform.position - targetPositionAI).sqrMagnitude < endValueAI)
|
||||
{
|
||||
FinishAIMove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(endTypeAI == 2) // 按时间结束
|
||||
{
|
||||
endValueAI -= deltaTime;
|
||||
if (endValueAI < 0.0f)
|
||||
{
|
||||
FinishAIMove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((transform.position - targetPositionAI).sqrMagnitude < 0.0001)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
MoveToTarget(deltaTime);
|
||||
if (keepUpdateTargetPositionAI)
|
||||
{
|
||||
checkAITargetPositionTime -= deltaTime;
|
||||
if (checkAITargetPositionTime < 0.0f)
|
||||
{
|
||||
checkAITargetPositionTime = BattleConfigure.CheckAITargetPositionInterval;
|
||||
FindTargetPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveToTarget(float deltaTime)
|
||||
{
|
||||
Vector3 moveToPosition;
|
||||
if (isTeleport)
|
||||
{
|
||||
if (isHitBack)
|
||||
{
|
||||
hitBackTime -= deltaTime;
|
||||
if (hitBackTime < 0.0f)
|
||||
{
|
||||
isHitBack = false;
|
||||
}
|
||||
}
|
||||
moveToPosition = targetPositionAI;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isHitBack)
|
||||
{
|
||||
hitBackTime -= deltaTime;
|
||||
if (hitBackTime < 0.0f)
|
||||
{
|
||||
isHitBack = false;
|
||||
}
|
||||
moveToPosition = Vector3.MoveTowards(transform.position, transform.position + new Vector3(BattleConst.UNIT_MOVE_DISTANCE_OPPOSITE*Direction, 0.0f, 0.0f), hitBackSpeed * deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
moveToPosition = Vector3.MoveTowards(transform.position, targetPositionAI, moveSpeedAI * deltaTime);
|
||||
}
|
||||
}
|
||||
if (!isCanAcrossTarget) // 不能穿过目标
|
||||
{
|
||||
if (Target.transform.position.x <= transform.position.x) // 在目标左边
|
||||
{
|
||||
var limitX = Target.transform.position.x + Target.BodyRadius + BodyRadius;
|
||||
if (moveToPosition.x < limitX)
|
||||
{
|
||||
moveToPosition.x = limitX;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var limitX = Target.transform.position.x - Target.BodyRadius - BodyRadius;
|
||||
if (moveToPosition.x > limitX)
|
||||
{
|
||||
moveToPosition.x = limitX;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (moveToPosition.x < BattleConfigure.SceneMinX) // 撞左边墙了
|
||||
{
|
||||
moveToPosition.x = BattleConfigure.SceneMinX;
|
||||
}
|
||||
else if (moveToPosition.x > BattleConfigure.SceneMaxX) // 撞右边墙了
|
||||
{
|
||||
moveToPosition.x = BattleConfigure.SceneMaxX;
|
||||
}
|
||||
if (moveToPosition.z < BattleConfigure.SceneMinZ) // 撞左边墙了
|
||||
{
|
||||
moveToPosition.z = BattleConfigure.SceneMinZ;
|
||||
}
|
||||
else if (moveToPosition.z > BattleConfigure.SceneMaxZ) // 撞右边墙了
|
||||
{
|
||||
moveToPosition.z = BattleConfigure.SceneMaxZ;
|
||||
}
|
||||
transform.position = moveToPosition;
|
||||
}
|
||||
|
||||
private void UpdateHitBackMove(float deltaTime)
|
||||
{
|
||||
hitBackTime -= deltaTime;
|
||||
if (hitBackTime < 0.0f)
|
||||
{
|
||||
isHitBack = false;
|
||||
}
|
||||
var moveToPosition = Vector3.MoveTowards(transform.position, transform.position + new Vector3(BattleConst.UNIT_MOVE_DISTANCE_OPPOSITE*Direction, 0.0f, 0.0f), hitBackSpeed * deltaTime);
|
||||
if (Target.transform.position.x <= transform.position.x) // 在目标左边
|
||||
{
|
||||
var limitX = Target.transform.position.x + Target.BodyRadius + BodyRadius;
|
||||
if (moveToPosition.x < limitX)
|
||||
{
|
||||
moveToPosition.x = limitX;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var limitX = Target.transform.position.x - Target.BodyRadius - BodyRadius;
|
||||
if (moveToPosition.x > limitX)
|
||||
{
|
||||
moveToPosition.x = limitX;
|
||||
}
|
||||
}
|
||||
if (moveToPosition.x < BattleConfigure.SceneMinX) // 撞左边墙了
|
||||
{
|
||||
moveToPosition.x = BattleConfigure.SceneMinX;
|
||||
}
|
||||
else if (moveToPosition.x > BattleConfigure.SceneMaxX) // 撞右边墙了
|
||||
{
|
||||
moveToPosition.x = BattleConfigure.SceneMaxX;
|
||||
}
|
||||
if (moveToPosition.z < BattleConfigure.SceneMinZ) // 撞左边墙了
|
||||
{
|
||||
moveToPosition.z = BattleConfigure.SceneMinZ;
|
||||
}
|
||||
else if (moveToPosition.z > BattleConfigure.SceneMaxZ) // 撞右边墙了
|
||||
{
|
||||
moveToPosition.z = BattleConfigure.SceneMaxZ;
|
||||
}
|
||||
transform.position = moveToPosition;
|
||||
}
|
||||
|
||||
public override void BeHitBack()
|
||||
{
|
||||
if (isHitBack)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isHitBack = true;
|
||||
hitBackTime = BattleConfigure.HitBackTime;
|
||||
hitBackSpeed = BattleConfigure.DistanceHitBack / hitBackTime;
|
||||
}
|
||||
|
||||
private void FinishAIMove()
|
||||
{
|
||||
StopMove();
|
||||
luaOnFinishAIMoveFunc?.Invoke();
|
||||
}
|
||||
|
||||
public override void OnDead()
|
||||
{
|
||||
IsDead = true;
|
||||
IsInGroundState = false;
|
||||
BattleMgr.RemoveFromDefUnitsList(this);
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
luaOnHitTargetFunc = null;
|
||||
luaOnFinishAIMoveFunc = null;
|
||||
if (isHaveHpBar)
|
||||
{
|
||||
BattleMgr.PoolHelper.PutBackHpBar(hpBar, Side);
|
||||
hpBar = null;
|
||||
isHaveHpBar = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
luaOnHitTargetFunc = null;
|
||||
luaOnFinishAIMoveFunc = null;
|
||||
if (!ReferenceEquals(airborneSeq, null))
|
||||
{
|
||||
airborneSeq.Kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Component/Battle/BattleControlMonster.cs.meta
Normal file
11
Assets/Scripts/Component/Battle/BattleControlMonster.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8b7c8b3bf2a99041abe55b41965f017
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleControlMonsterExtend : MonoBehaviour
|
||||
{
|
||||
protected BattleControlMonster mainControl;
|
||||
public void SetControl(BattleControlMonster control)
|
||||
{
|
||||
mainControl = control;
|
||||
}
|
||||
|
||||
public virtual void Init(long id) {}
|
||||
|
||||
public virtual void OnRecycle() {}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 418c7fd8773d75544906e43496dd4481
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/Scripts/Component/Battle/BattleControlSphereBullet.cs
Normal file
34
Assets/Scripts/Component/Battle/BattleControlSphereBullet.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleControlSphereBullet : BattleControlBullet
|
||||
{
|
||||
private SphereCollider sphereCollider;
|
||||
private void Awake()
|
||||
{
|
||||
sphereCollider = gameObject.AddComponent<SphereCollider>();
|
||||
}
|
||||
|
||||
public override void SetupSphereCollisionBody(float collisionRadius)
|
||||
{
|
||||
sphereCollider.center = Vector3.zero;
|
||||
sphereCollider.radius = collisionRadius;
|
||||
}
|
||||
|
||||
public override void SetColliderEnabled(bool enabled)
|
||||
{
|
||||
sphereCollider.enabled = enabled;
|
||||
}
|
||||
|
||||
public override void Recycle()
|
||||
{
|
||||
if (IsRecycle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sphereCollider.enabled = false;
|
||||
BFMain.Instance.BattleMgr.PoolHelper.RecycleSphereBullet(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 886b166ecb4cc23459744e47400ee1b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace BF
|
||||
{
|
||||
public class BattleControlSphereCollider : BattleControlCollider
|
||||
{
|
||||
private SphereCollider sphereCollider;
|
||||
private void Awake()
|
||||
{
|
||||
sphereCollider = gameObject.AddComponent<SphereCollider>();
|
||||
}
|
||||
|
||||
public void SetupCollisionBody(float collisionRadius, float x, float z)
|
||||
{
|
||||
sphereCollider.center = Vector3.zero;
|
||||
sphereCollider.radius = collisionRadius;
|
||||
offset = new Vector3(x, 0.0f, z);
|
||||
}
|
||||
|
||||
public override void SetColliderEnabled(bool enabled)
|
||||
{
|
||||
sphereCollider.enabled = enabled;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!isActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CheckCollider();
|
||||
}
|
||||
|
||||
public override void Recycle()
|
||||
{
|
||||
if (IsRecycle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!ReferenceEquals(container, null))
|
||||
{
|
||||
container.Remove(this);
|
||||
}
|
||||
sphereCollider.enabled = false;
|
||||
isActive = false;
|
||||
BFMain.Instance.BattleMgr.PoolHelper.RecycleSkillSphereCollider(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67d6001006b358b45b93f603662c2086
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user