Commit 77b93c7e authored by hex's avatar hex

reomve iTween

parent 07ad0480
Pipeline #38584 failed
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using DG.Tweening;
public class pro1CardShower : MonoBehaviour { public class pro1CardShower : MonoBehaviour {
public UITexture card; public UITexture card;
public UITexture mask; public UITexture mask;
public UITexture disable; public UITexture disable;
public TweenAlpha t;
public void run() public void run()
{ {
mask.gameObject.transform.localPosition = new Vector3(-140, 0, 0); // 1. 将mask的初始位置设置好
iTween.MoveToLocal(mask.gameObject, new Vector3(140, 0, 0), 0.7f); mask.transform.localPosition = new Vector3(-140, 0, 0);
// 2. 使用 DOTween 执行移动动画
// 由于只改变X轴,使用 DOLocalMoveX 意图更明确,性能也略好
mask.transform.DOLocalMoveX(140, 0.7f);
} }
public void Dis() public void Dis()
{ {
iTween.ScaleTo(disable.gameObject, new Vector3(1, 1, 1), 0.7f);
t.duration = 0.7f; // 1. 缩放动画
t.enabled = true; disable.transform.DOScale(Vector3.one, 0.7f);
// 2. Alpha 透明度动画
// 使用 DOTween 的通用数值渐变来替代 NGUI 的 TweenAlpha 组件
// 这让所有动画都由 DOTween 控制,代码更统一,也移除了对 TweenAlpha 的依赖
// 假设目标 alpha 是 1 (完全不透明)
DOTween.To(() => disable.alpha, x => disable.alpha = x, 1f, 0.7f);
} }
} }
...@@ -102,14 +102,6 @@ public class MonoCardInDeckManager : MonoBehaviour ...@@ -102,14 +102,6 @@ public class MonoCardInDeckManager : MonoBehaviour
physicalOFF(); physicalOFF();
physicalHalfON(); physicalHalfON();
isDraging = true; isDraging = true;
// Program.go(
// 1,
// () =>
// {
// iTween.RotateTo(gameObject, new Vector3(90, 0, 0), 0.6f);
// }
// );
transform.DORotate(new Vector3(90, 0, 0), 0.6f).SetDelay(0); transform.DORotate(new Vector3(90, 0, 0), 0.6f).SetDelay(0);
} }
......
using UnityEngine; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
public class gameUIbutton public class gameUIbutton
{ {
...@@ -71,7 +73,7 @@ public class gameInfo : MonoBehaviour ...@@ -71,7 +73,7 @@ public class gameInfo : MonoBehaviour
me.transform.SetParent(gameObject.transform); me.transform.SetParent(gameObject.transform);
opponent = ((GameObject)MonoBehaviour.Instantiate(mod_healthBar, new Vector3(1000, 0, 0), Quaternion.identity)).GetComponent<barPngLoader>(); opponent = ((GameObject)MonoBehaviour.Instantiate(mod_healthBar, new Vector3(1000, 0, 0), Quaternion.identity)).GetComponent<barPngLoader>();
opponent.transform.SetParent(gameObject.transform); opponent.transform.SetParent(gameObject.transform);
Transform[] Transforms = me.GetComponentsInChildren<Transform>(); Transform[] Transforms = me.GetComponentsInChildren<Transform>();
foreach (Transform child in Transforms) foreach (Transform child in Transforms)
{ {
...@@ -93,7 +95,7 @@ public class gameInfo : MonoBehaviour ...@@ -93,7 +95,7 @@ public class gameInfo : MonoBehaviour
{ {
k = 1.2f; k = 1.2f;
} }
if (k <0.8f) if (k < 0.8f)
{ {
k = 0.8f; k = 0.8f;
} }
...@@ -111,7 +113,7 @@ public class gameInfo : MonoBehaviour ...@@ -111,7 +113,7 @@ public class gameInfo : MonoBehaviour
instance_btnPan.gameObject.transform.localScale = ksb; instance_btnPan.gameObject.transform.localScale = ksb;
opponent.transform.localScale = ks; opponent.transform.localScale = ks;
me.transform.localScale = ks; me.transform.localScale = ks;
if (!swaped) if (!swaped)
{ {
opponent.transform.localPosition = new Vector3(Screen.width / 2 - 14, Screen.height / 2 - 14); opponent.transform.localPosition = new Vector3(Screen.width / 2 - 14, Screen.height / 2 - 14);
me.transform.localPosition = new Vector3(Screen.width / 2 - 14, Screen.height / 2 - 14 - k * (float)(opponent.under.height)); me.transform.localPosition = new Vector3(Screen.width / 2 - 14, Screen.height / 2 - 14 - k * (float)(opponent.under.height));
...@@ -187,11 +189,11 @@ public class gameInfo : MonoBehaviour ...@@ -187,11 +189,11 @@ public class gameInfo : MonoBehaviour
{ {
child.gameObject.layer = instance_btnPan.gameObject.layer; child.gameObject.layer = instance_btnPan.gameObject.layer;
} }
hashedButton.gameObject.transform.SetParent(instance_btnPan.transform,false); hashedButton.gameObject.transform.SetParent(instance_btnPan.transform, false);
hashedButton.gameObject.transform.localScale = Vector3.zero; hashedButton.gameObject.transform.localScale = Vector3.zero;
hashedButton.gameObject.transform.localPosition= new Vector3(0, -120, 0); hashedButton.gameObject.transform.localPosition = new Vector3(0, -120, 0);
hashedButton.gameObject.transform.localEulerAngles = Vector3.zero; hashedButton.gameObject.transform.localEulerAngles = Vector3.zero;
iTween.ScaleTo(hashedButton.gameObject, new Vector3(0.9f, 0.9f, 0.9f), 0.3f); hashedButton.gameObject.transform.DOScale(new Vector3(0.9f, 0.9f, 0.9f), 0.3f);
hashedButton.dying = false; hashedButton.dying = false;
HashedButtons.Add(hashedButton); HashedButtons.Add(hashedButton);
refreshLine(); refreshLine();
...@@ -347,28 +349,34 @@ public class gameInfo : MonoBehaviour ...@@ -347,28 +349,34 @@ public class gameInfo : MonoBehaviour
return time[0] < Program.I().ocgcore.timeLimit / 3; return time[0] < Program.I().ocgcore.timeLimit / 3;
} }
void setTimeAbsolutely(int player, int t) private void setTimeAbsolutely(int player, int t)
{ {
if (Program.I().ocgcore.timeLimit == 0) if (Program.I().ocgcore.timeLimit == 0)
{ {
return; return;
} }
if (player == 0) if (player == 0)
{ {
me.api_timeHint.text = t.ToString() + "/" + Program.I().ocgcore.timeLimit.ToString(); me.api_timeHint.text = t.ToString() + "/" + Program.I().ocgcore.timeLimit.ToString();
opponent.api_timeHint.text = "waiting"; opponent.api_timeHint.text = "waiting";
UIHelper.clearITWeen(me.api_healthBar.gameObject);
iTween.MoveToLocal(me.api_timeBar.gameObject, new Vector3((float)(me.api_timeBar.width) - (float)t / (float)Program.I().ocgcore.timeLimit * (float)(me.api_timeBar.width), me.api_healthBar.gameObject.transform.localPosition.y, me.api_healthBar.gameObject.transform.localPosition.z), 1f); // 停止之前的动画并开始新动画
me.api_timeBar.transform.DOKill();
me.api_timeBar.transform.DOLocalMoveX((float)(me.api_timeBar.width) - (float)t / (float)Program.I().ocgcore.timeLimit * (float)(me.api_timeBar.width), 1f);
} }
if (player == 1) if (player == 1)
{ {
opponent.api_timeHint.text = t.ToString() + "/" + Program.I().ocgcore.timeLimit.ToString(); opponent.api_timeHint.text = t.ToString() + "/" + Program.I().ocgcore.timeLimit.ToString();
me.api_timeHint.text = "waiting"; me.api_timeHint.text = "waiting";
UIHelper.clearITWeen(opponent.api_healthBar.gameObject);
iTween.MoveToLocal(opponent.api_timeBar.gameObject, new Vector3((float)(opponent.api_timeBar.width) - (float)t / (float)Program.I().ocgcore.timeLimit * (float)(opponent.api_timeBar.width), opponent.api_healthBar.gameObject.transform.localPosition.y, opponent.api_healthBar.gameObject.transform.localPosition.z), 1f); // 停止之前的动画并开始新动画
opponent.api_timeBar.transform.DOKill();
opponent.api_timeBar.transform.DOLocalMoveX((float)(opponent.api_timeBar.width) - (float)t / (float)Program.I().ocgcore.timeLimit * (float)(opponent.api_timeBar.width), 1f);
} }
} }
public void realize() public void realize()
{ {
me.api_healthHint.text = ((float)Program.I().ocgcore.life_0 > 0 ? Program.I().ocgcore.life_0 : 0).ToString(); me.api_healthHint.text = ((float)Program.I().ocgcore.life_0 > 0 ? Program.I().ocgcore.life_0 : 0).ToString();
...@@ -377,20 +385,22 @@ public class gameInfo : MonoBehaviour ...@@ -377,20 +385,22 @@ public class gameInfo : MonoBehaviour
opponent.api_name.text = Program.I().ocgcore.name_1_c; opponent.api_name.text = Program.I().ocgcore.name_1_c;
me.api_face.mainTexture = UIHelper.getFace(Program.I().ocgcore.name_0_c); me.api_face.mainTexture = UIHelper.getFace(Program.I().ocgcore.name_0_c);
opponent.api_face.mainTexture = UIHelper.getFace(Program.I().ocgcore.name_1_c); opponent.api_face.mainTexture = UIHelper.getFace(Program.I().ocgcore.name_1_c);
iTween.MoveToLocal(me.api_healthBar.gameObject, new Vector3(
(float)(me.api_healthBar.width) - getRealLife(Program.I().ocgcore.life_0) / ((float)Program.I().ocgcore.lpLimit) * (float)(me.api_healthBar.width), // 玩家自己
me.api_healthBar.gameObject.transform.localPosition.y, me.api_healthBar.transform.DOKill();
me.api_healthBar.gameObject.transform.localPosition.z), 1f); float myLpTargetX = (float)(me.api_healthBar.width) - getRealLife(Program.I().ocgcore.life_0) / ((float)Program.I().ocgcore.lpLimit) * (float)(me.api_healthBar.width);
iTween.MoveToLocal(opponent.api_healthBar.gameObject, new Vector3( me.api_healthBar.transform.DOLocalMoveX(myLpTargetX, 1f);
(float)(opponent.api_healthBar.width) - getRealLife(Program.I().ocgcore.life_1) / ((float)Program.I().ocgcore.lpLimit) * (float)(opponent.api_healthBar.width), // 对手
opponent.api_healthBar.gameObject.transform.localPosition.y, opponent.api_healthBar.transform.DOKill();
opponent.api_healthBar.gameObject.transform.localPosition.z), 1f); float opLpTargetX = (float)(opponent.api_healthBar.width) - getRealLife(Program.I().ocgcore.life_1) / ((float)Program.I().ocgcore.lpLimit) * (float)(opponent.api_healthBar.width);
opponent.api_healthBar.transform.DOLocalMoveX(opLpTargetX, 1f);
instance_lab.Clear(); instance_lab.Clear();
if (Program.I().ocgcore.confirmedCards.Count>0) if (Program.I().ocgcore.confirmedCards.Count > 0)
{ {
instance_lab.Add(GameStringHelper.yijingqueren); instance_lab.Add(GameStringHelper.yijingqueren);
} }
foreach (var item in Program.I().ocgcore.confirmedCards) foreach (var item in Program.I().ocgcore.confirmedCards)
{ {
instance_lab.Add(item); instance_lab.Add(item);
} }
...@@ -417,7 +427,7 @@ public class gameInfo : MonoBehaviour ...@@ -417,7 +427,7 @@ public class gameInfo : MonoBehaviour
{ {
time[0]--; time[0]--;
} }
if (amIdanger()) if (amIdanger())
{ {
if (Program.I().ocgcore != null) if (Program.I().ocgcore != null)
{ {
...@@ -438,12 +448,12 @@ public class gameInfo : MonoBehaviour ...@@ -438,12 +448,12 @@ public class gameInfo : MonoBehaviour
public enum chainCondition public enum chainCondition
{ {
standard,no,all,smart standard, no, all, smart
} }
public void set_condition(chainCondition c) public void set_condition(chainCondition c)
{ {
switch (c) switch (c)
{ {
case chainCondition.standard: case chainCondition.standard:
toggle_all.value = false; toggle_all.value = false;
......
using UnityEngine; using System.Collections;
using System.Collections; using DG.Tweening;
using UnityEngine;
public class faceShower : MonoBehaviour {
void Start () { public class faceShower : MonoBehaviour
gameObject.transform.position = Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width/2,Screen.height*1.5f,0)); {
iTween.MoveToAction(gameObject, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height/2, 0)),0.6f,()=>{
iTween.ScaleToAction(gameObject,Vector3.zero, 0.6f, () => { void Start()
Destroy(gameObject); {
}, 1f); // 预先计算目标位置,使代码更清晰
},0); Vector3 screenCenterWorldPos = Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, 0));
} // 设置初始位置(这一行与动画无关,保持不变)
gameObject.transform.position = Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height * 1.5f, 0));
// 使用 DOTween 的 Sequence 来创建一个动画链
Sequence mySequence = DOTween.Sequence();
// 1. 第一个动画:移动到屏幕中心,耗时 0.6 秒
mySequence.Append(transform.DOMove(screenCenterWorldPos, 0.6f));
// 2. 插入一个 1 秒的延迟
mySequence.AppendInterval(1f);
// 3. 第二个动画:缩小到0,耗时 0.6 秒
mySequence.Append(transform.DOScale(Vector3.zero, 0.6f));
// 4. 设置整个序列完成后的回调:销毁游戏对象
// OnComplete 在序列所有动画和延迟都执行完毕后触发
mySequence.OnComplete(() =>
{
Destroy(gameObject);
});
}
} }
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using DG.Tweening;
public class handShower : MonoBehaviour public class handShower : MonoBehaviour
{ {
...@@ -17,14 +19,35 @@ public class handShower : MonoBehaviour ...@@ -17,14 +19,35 @@ public class handShower : MonoBehaviour
pics[2] = GameTextureManager.get("bu"); pics[2] = GameTextureManager.get("bu");
texture_0.mainTexture = pics[me]; texture_0.mainTexture = pics[me];
texture_1.mainTexture = pics[op]; texture_1.mainTexture = pics[op];
GameObject_0.transform.position = Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, -Screen.height * 1.5f, 0));
iTween.MoveToAction(GameObject_0, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2 - 80, 0)), 1f, () => { // --- 核心修改:使用本地坐标和 DOLocalMove ---
Destroy(GameObject_0,0.3f); // 1. 设置初始位置 (在屏幕外)
}, 0); // NGUI的坐标系通常中心是(0,0),单位接近像素。
GameObject_1.transform.position = Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height * 1.5f, 0)); // 我们把它们放在屏幕的上下方很远的地方。
iTween.MoveToAction(GameObject_1, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2 + 80, 0)), 1f, () => { GameObject_0.transform.localPosition = new Vector3(0, -1000, 0); // 从下方来
Destroy(GameObject_1, 0.3f); GameObject_1.transform.localPosition = new Vector3(0, 1000, 0); // 从上方来
}, 0); // 2. 定义目标本地坐标
// 不再需要复杂的ScreenToWorldPoint!直接使用像素偏移值。
Vector3 targetPos0 = new Vector3(0, -150, 0); // 停在中心点下方150像素
Vector3 targetPos1 = new Vector3(0, 150, 0); // 停在中心点上方150像素
// 注意:我将80改成了150,因为80的间距可能太小,你可以根据效果调整。
// 3. 执行动画
// 使用 DOLocalMove 而不是 DOMove
GameObject_0.transform.DOLocalMove(targetPos0, 1f).SetEase(Ease.OutCubic).OnComplete(() =>
{
// 添加一个空值检查,这是一个好习惯
if (GameObject_0 != null)
{
Destroy(GameObject_0, 0.3f);
}
});
GameObject_1.transform.DOLocalMove(targetPos1, 1f).SetEase(Ease.OutCubic).OnComplete(() =>
{
if (GameObject_1 != null)
{
Destroy(GameObject_1, 0.3f);
}
});
} }
} }
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using DG.Tweening;
public class toolShift : MonoBehaviour { public class toolShift : MonoBehaviour {
public GameObject ObjectMust = null; public GameObject ObjectMust = null;
...@@ -40,32 +42,31 @@ public class toolShift : MonoBehaviour { ...@@ -40,32 +42,31 @@ public class toolShift : MonoBehaviour {
} }
public void shift() public void shift()
{
// 获取当前对象的本地坐标
Vector3 va = ObjectMust.transform.localPosition;
const float duration = 0.6f;
if (ObjectOption == null)
{
// 目标Y坐标,根据当前位置在 0 和 -100 之间切换
float targetY = (va.y >= 0) ? -100f : 0f;
// 使用 DOTween 的 DOLocalMoveY,因为它只改变Y轴,意图更明确且性能稍好
ObjectMust.transform.DOLocalMoveY(targetY, duration);
}
else
{ {
Vector3 va = ObjectMust.transform.localPosition; Vector3 vb = ObjectOption.transform.localPosition;
if (ObjectOption == null)
if (va.y > vb.y)
{ {
if (va.y >= 0) ObjectMust.transform.DOLocalMoveY(-100f, duration);
{ ObjectOption.transform.DOLocalMoveY(0f, duration);
iTween.MoveToLocal(ObjectMust, new Vector3(va.x, -100, va.z), 0.6f);
}
else
{
iTween.MoveToLocal(ObjectMust, new Vector3(va.x, 0, va.z), 0.6f);
}
} }
else else
{ {
Vector3 vb = ObjectOption.transform.localPosition; ObjectMust.transform.DOLocalMoveY(0f, duration);
if (va.y > vb.y) ObjectOption.transform.DOLocalMoveY(-100f, duration);
{
iTween.MoveToLocal(ObjectMust, new Vector3(va.x, -100, va.z), 0.6f);
iTween.MoveToLocal(ObjectOption, new Vector3(vb.x, 0, vb.z), 0.6f);
}
else
{
iTween.MoveToLocal(ObjectMust, new Vector3(va.x, 0, va.z), 0.6f);
iTween.MoveToLocal(ObjectOption, new Vector3(vb.x, -100, vb.z), 0.6f);
}
} }
} }
} }
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
using DG.Tweening;
public class CardDescription : Servant public class CardDescription : Servant
{ {
...@@ -100,13 +101,14 @@ public class CardDescription : Servant ...@@ -100,13 +101,14 @@ public class CardDescription : Servant
if (gameObject != null) if (gameObject != null)
{ {
underSprite.height = Screen.height + 4; underSprite.height = Screen.height + 4;
iTween.MoveTo(
gameObject, // 计算目标世界坐标
Program.camera_main_2d.ScreenToWorldPoint( Vector3 hidePosition = Program.camera_main_2d.ScreenToWorldPoint(
new Vector3(-underSprite.width - 20, Screen.height / 2, 0) new Vector3(-underSprite.width - 20, Screen.height / 2, 0)
),
1.2f
); );
// 使用 DOTween 的 DOMove 方法,并添加一个缓动效果使动画更平滑
gameObject.transform.DOMove(hidePosition, 1.2f).SetEase(Ease.OutCubic);
setTitle(""); setTitle("");
resizer.gameObject.GetComponent<BoxCollider>().enabled = false; resizer.gameObject.GetComponent<BoxCollider>().enabled = false;
} }
...@@ -124,13 +126,13 @@ public class CardDescription : Servant ...@@ -124,13 +126,13 @@ public class CardDescription : Servant
offset = 66; offset = 66;
} }
iTween.MoveTo( // 计算目标世界坐标
gameObject, Vector3 showPosition = Program.camera_main_2d.ScreenToWorldPoint(
Program.camera_main_2d.ScreenToWorldPoint( new Vector3(offset, Screen.height / 2, 0)
new Vector3(offset, Screen.height / 2, 0)
),
1.2f
); );
// 执行显示动画
gameObject.transform.DOMove(showPosition, 1.2f).SetEase(Ease.OutCubic);
resizer.gameObject.GetComponent<BoxCollider>().enabled = true; resizer.gameObject.GetComponent<BoxCollider>().enabled = true;
} }
} }
......
using System; using System;
using UnityEngine; using UnityEngine;
using DG.Tweening;
public class TextMaster public class TextMaster
{ {
...@@ -18,8 +20,10 @@ public class TextMaster ...@@ -18,8 +20,10 @@ public class TextMaster
Program.ui_main_3d, Program.ui_main_3d,
false false
); );
UIHelper.clearITWeen(gameObject);
iTween.ScaleTo(gameObject, new Vector3(0.03f, 0.03f, 0.03f), 0.6f); gameObject.transform.DOKill();
gameObject.transform.DOScale(new Vector3(0.03f, 0.03f, 0.03f), 0.6f);
} }
else else
{ {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using UnityEngine; using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
...@@ -21,7 +21,7 @@ public static class UIHelper ...@@ -21,7 +21,7 @@ public static class UIHelper
[DllImport("user32")] [DllImport("user32")]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, ref IntPtr lpdwProcessId); static extern uint GetWindowThreadProcessId(IntPtr hWnd, ref IntPtr lpdwProcessId);
[DllImport("user32")] [DllImport("user32")]
static extern int GetClassNameW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder lpString, int nMaxCount); static extern int GetClassNameW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpString, int nMaxCount);
[DllImport("user32")] [DllImport("user32")]
static extern bool IsZoomed(IntPtr hWnd); static extern bool IsZoomed(IntPtr hWnd);
[DllImport("user32")] [DllImport("user32")]
...@@ -46,7 +46,7 @@ public static class UIHelper ...@@ -46,7 +46,7 @@ public static class UIHelper
StringBuilder ClassName = new StringBuilder(256); StringBuilder ClassName = new StringBuilder(256);
GetClassNameW(hwnd, ClassName, ClassName.Capacity); GetClassNameW(hwnd, ClassName, ClassName.Capacity);
if (string.Compare(ClassName.ToString(), "UnityWndClass", true, System.Globalization.CultureInfo.InvariantCulture) == 0) if (string.Compare(ClassName.ToString(), "UnityWndClass", true, System.Globalization.CultureInfo.InvariantCulture) == 0)
{ {
GetWindowThreadProcessId(hwnd, ref id); GetWindowThreadProcessId(hwnd, ref id);
...@@ -697,15 +697,6 @@ public static class UIHelper ...@@ -697,15 +697,6 @@ public static class UIHelper
return return_value; return return_value;
} }
internal static void clearITWeen(GameObject gameObject)
{
iTween[] iTweens = gameObject.GetComponents<iTween>();
for (int i = 0; i < iTweens.Length; i++)
{
MonoBehaviour.DestroyImmediate(iTweens[i]);
}
}
internal static float get_left_right_index(float left, float right, int i, int count) internal static float get_left_right_index(float left, float right, int i, int count)
{ {
float return_value = 0; float return_value = 0;
......
using System; using System;
using UnityEngine; using UnityEngine;
using DG.Tweening;
public class gameButton : OCGobject public class gameButton : OCGobject
{ {
...@@ -36,7 +37,9 @@ public class gameButton : OCGobject ...@@ -36,7 +37,9 @@ public class gameButton : OCGobject
gameObject.GetComponent<iconSetForButton>().setTexture(type); gameObject.GetComponent<iconSetForButton>().setTexture(type);
gameObject.GetComponent<iconSetForButton>().setText(hint); gameObject.GetComponent<iconSetForButton>().setText(hint);
gameObject.transform.localScale = Vector3.zero; gameObject.transform.localScale = Vector3.zero;
iTween.ScaleTo(gameObject, new Vector3(0.7f * (float)Screen.height / 700f, 0.7f * (float)Screen.height / 700f, 0.7f * (float)Screen.height / 700f), 0.2f);
float targetScale = 0.7f * (float)Screen.height / 700f;
gameObject.transform.DOScale(targetScale, 0.2f);
} }
gameObject.transform.position = Program.camera_main_2d.ScreenToWorldPoint(v); gameObject.transform.position = Program.camera_main_2d.ScreenToWorldPoint(v);
} }
......
...@@ -453,16 +453,12 @@ public class GameField : OCGobject ...@@ -453,16 +453,12 @@ public class GameField : OCGobject
if (tex != null) if (tex != null)
{ {
UIHelper.getByName<UITexture>(gameObject, "field_" + player.ToString()).mainTexture = tex; UIHelper.getByName<UITexture>(gameObject, "field_" + player.ToString()).mainTexture = tex;
// UIHelper.clearITWeen(UIHelper.getByName(gameObject, "obj_" + player.ToString()));
// iTween.ScaleTo(UIHelper.getByName(gameObject, "obj_" + player.ToString()), new Vector3(1, 1, 1), 0.5f);
var obj = UIHelper.getByName(gameObject, "obj_" + player.ToString()); var obj = UIHelper.getByName(gameObject, "obj_" + player.ToString());
DOTween.Kill(obj.transform); DOTween.Kill(obj.transform);
obj.transform.DOScale(new Vector3(1, 1, 1), 0.5f); obj.transform.DOScale(new Vector3(1, 1, 1), 0.5f);
} }
else else
{ {
// UIHelper.clearITWeen(UIHelper.getByName(gameObject, "obj_" + player.ToString()));
// iTween.ScaleTo(UIHelper.getByName(gameObject, "obj_" + player.ToString()), new Vector3(0, 0, 0), 0.5f);
var obj = UIHelper.getByName(gameObject, "obj_" + player.ToString()); var obj = UIHelper.getByName(gameObject, "obj_" + player.ToString());
DOTween.Kill(obj.transform); DOTween.Kill(obj.transform);
obj.transform.DOScale(Vector3.zero, 0.5f); obj.transform.DOScale(Vector3.zero, 0.5f);
...@@ -470,8 +466,6 @@ public class GameField : OCGobject ...@@ -470,8 +466,6 @@ public class GameField : OCGobject
} }
else else
{ {
// UIHelper.clearITWeen(UIHelper.getByName(gameObject, "obj_" + player.ToString()));
// iTween.ScaleTo(UIHelper.getByName(gameObject, "obj_" + player.ToString()), new Vector3(0, 0, 0), 0.5f);
var obj = UIHelper.getByName(gameObject, "obj_" + player.ToString()); var obj = UIHelper.getByName(gameObject, "obj_" + player.ToString());
DOTween.Kill(obj.transform); DOTween.Kill(obj.transform);
obj.transform.DOScale(Vector3.zero, 0.5f); obj.transform.DOScale(Vector3.zero, 0.5f);
...@@ -508,7 +502,6 @@ public class GameField : OCGobject ...@@ -508,7 +502,6 @@ public class GameField : OCGobject
{ {
Program.I().mod_ocgcore_ss_dark_hole.transform.localScale = Vector3.zero; Program.I().mod_ocgcore_ss_dark_hole.transform.localScale = Vector3.zero;
cookie_dark_hole = create(Program.I().mod_ocgcore_ss_dark_hole, v); cookie_dark_hole = create(Program.I().mod_ocgcore_ss_dark_hole, v);
// iTween.ScaleTo(cookie_dark_hole, new Vector3(6, 6, 6), 1f);
cookie_dark_hole.transform.DOScale(new Vector3(6, 6, 6), 1f); cookie_dark_hole.transform.DOScale(new Vector3(6, 6, 6), 1f);
cookie_dark_hole.transform.eulerAngles = new Vector3(90, 0, 0); cookie_dark_hole.transform.eulerAngles = new Vector3(90, 0, 0);
} }
...@@ -517,20 +510,6 @@ public class GameField : OCGobject ...@@ -517,20 +510,6 @@ public class GameField : OCGobject
{ {
if (cookie_dark_hole != null) if (cookie_dark_hole != null)
{ {
// iTween.ScaleTo(cookie_dark_hole, iTween.Hash(
// "delay", 1f,
// "x", 0,
// "y", 0,
// "z", 0,
// "time", 1f
// ));
// iTween.MoveTo(cookie_dark_hole, iTween.Hash(
// "delay", 1f,
// "position", v,
// "time", 1f
// ));
// destroy(cookie_dark_hole, 1.4f);
// 使用 DOTween 的序列来实现延迟和组合动画
Sequence seq = DOTween.Sequence(); Sequence seq = DOTween.Sequence();
seq.AppendInterval(1f); // 延迟1秒 seq.AppendInterval(1f); // 延迟1秒
seq.Append(cookie_dark_hole.transform.DOScale(Vector3.zero, 1f)); seq.Append(cookie_dark_hole.transform.DOScale(Vector3.zero, 1f));
...@@ -798,12 +777,6 @@ public class GameField : OCGobject ...@@ -798,12 +777,6 @@ public class GameField : OCGobject
if (player == 0) if (player == 0)
{ {
Program.I().ocgcore.Sleep((int)(60 * (float)amount / 2500f)); Program.I().ocgcore.Sleep((int)(60 * (float)amount / 2500f));
// iTween.ShakePosition(Program.camera_game_main.gameObject, iTween.Hash(
// "x", (float)amount / 1500f,
// "y", (float)amount / 1500f,
// "z", (float)amount / 1500f,
// "time", (float)amount / 2500f
// ));
float duration = (float)amount / 2500f; float duration = (float)amount / 2500f;
float strength = (float)amount / 1500f; float strength = (float)amount / 1500f;
......
using System; using System;
using UnityEngine; using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
public class gameHiddenButton : OCGobject public class gameHiddenButton : OCGobject
{ {
public CardLocation location; public CardLocation location;
...@@ -291,8 +291,6 @@ public class gameHiddenButton : OCGobject ...@@ -291,8 +291,6 @@ public class gameHiddenButton : OCGobject
qidian qidian
+ +
((float)index / (float)(gezi - 1)) * (zhongdian - qidian); ((float)index / (float)(gezi - 1)) * (zhongdian - qidian);
//iTween.MoveTo(Program.I().ocgcore.cards[i].gameObject, Camera.main.ScreenToWorldPoint(screen_vector_to_move), 0.5f);
//iTween.RotateTo(Program.I().ocgcore.cards[i].gameObject, new Vector3(-30, 0, 0), 0.1f);
Program.I().ocgcore.cards[i].TweenTo(Camera.main.ScreenToWorldPoint(screen_vector_to_move), new Vector3(-30, 0, 0),true); Program.I().ocgcore.cards[i].TweenTo(Camera.main.ScreenToWorldPoint(screen_vector_to_move), new Vector3(-30, 0, 0),true);
} }
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using DG.Tweening;
using UnityEngine; using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
using DG.Tweening;
public class Ocgcore : ServantWithCardDescription public class Ocgcore : ServantWithCardDescription
...@@ -466,7 +466,6 @@ public class Ocgcore : ServantWithCardDescription ...@@ -466,7 +466,6 @@ public class Ocgcore : ServantWithCardDescription
{ {
gameInfo.gameObject.transform.localPosition = new Vector3(300, 0, 0); gameInfo.gameObject.transform.localPosition = new Vector3(300, 0, 0);
gameInfo.gameObject.SetActive(true); gameInfo.gameObject.SetActive(true);
// iTween.MoveToLocal(gameInfo.gameObject, Vector3.zero, 0.6f);
gameInfo.gameObject.transform.DOLocalMove(Vector3.zero, 0.6f); gameInfo.gameObject.transform.DOLocalMove(Vector3.zero, 0.6f);
gameInfo.ini(); gameInfo.ini();
UIHelper.getByName<UIToggle>(gameInfo.gameObject, "ignore_").value = false; UIHelper.getByName<UIToggle>(gameInfo.gameObject, "ignore_").value = false;
...@@ -1261,24 +1260,24 @@ public class Ocgcore : ServantWithCardDescription ...@@ -1261,24 +1260,24 @@ public class Ocgcore : ServantWithCardDescription
return true; return true;
case GameMessage.Attack: case GameMessage.Attack:
return true; return true;
//case GameMessage.Attack: //case GameMessage.Attack:
// if (Program.I().setting.setting.Vbattle.value) // if (Program.I().setting.setting.Vbattle.value)
// { // {
// return true; // return true;
// } // }
// else // else
// { // {
// return false; // return false;
// } // }
//case GameMessage.Battle: //case GameMessage.Battle:
// if (Program.I().setting.setting.Vbattle.value) // if (Program.I().setting.setting.Vbattle.value)
// { // {
// return false; // return false;
// } // }
// else // else
// { // {
// return true; // return true;
// } // }
} }
return false; return false;
} }
...@@ -5804,22 +5803,11 @@ public class Ocgcore : ServantWithCardDescription ...@@ -5804,22 +5803,11 @@ public class Ocgcore : ServantWithCardDescription
r.ReadByte(); r.ReadByte();
UIHelper.playSound("explode", 0.4f); UIHelper.playSound("explode", 0.4f);
int amount = (int)(Mathf.Clamp(attackCard.get_data().Attack, 0, 3500) * 0.8f); int amount = (int)(Mathf.Clamp(attackCard.get_data().Attack, 0, 3500) * 0.8f);
// iTween.ShakePosition(
// Program.camera_game_main.gameObject,
// iTween.Hash(
// "x",
// (float)amount / 1500f,
// "y",
// (float)amount / 1500f,
// "z",
// (float)amount / 1500f,
// "time",
// (float)amount / 2500f
// )
// );
float duration = (float)amount / 2500f; float duration = (float)amount / 2500f;
float strength = (float)amount / 1500f; float strength = (float)amount / 1500f;
Program.camera_game_main.transform.DOShakePosition(duration, strength); Program.camera_game_main.transform.DOShakePosition(duration, strength);
VectorAttackCard = get_point_worldposition(gpsAttacker); VectorAttackCard = get_point_worldposition(gpsAttacker);
if (attackedCard == null || gpsAttacked.location == 0) if (attackedCard == null || gpsAttacked.location == 0)
{ {
...@@ -5873,7 +5861,7 @@ public class Ocgcore : ServantWithCardDescription ...@@ -5873,7 +5861,7 @@ public class Ocgcore : ServantWithCardDescription
case GameMessage.ReleaseRelation: case GameMessage.ReleaseRelation:
break; break;
case GameMessage.TossCoin: case GameMessage.TossCoin:
player = r.ReadByte(); player = localPlayer(r.ReadByte());
count = r.ReadByte(); count = r.ReadByte();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
...@@ -5897,19 +5885,17 @@ public class Ocgcore : ServantWithCardDescription ...@@ -5897,19 +5885,17 @@ public class Ocgcore : ServantWithCardDescription
} }
destroy(tempobj, 7); destroy(tempobj, 7);
} }
if (data == 0) // 1. 根据玩家选择格式模板
{ string formatKey = (player == 0) ? "我方硬币结果:" : "对方硬币结果:";
RMSshow_none(InterString.Get("硬币反面")); // 2. 根据数据选择结果
} string resultKey = (data == 0) ? "反面" : "正面";
else // 3. 组合并显示提示
{ RMSshow_none($"{formatKey}{resultKey}");
RMSshow_none(InterString.Get("硬币正面"));
}
} }
Sleep(280); Sleep(280);
break; break;
case GameMessage.TossDice: case GameMessage.TossDice:
player = r.ReadByte(); player = localPlayer(r.ReadByte());
count = r.ReadByte(); count = r.ReadByte();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
...@@ -5926,7 +5912,14 @@ public class Ocgcore : ServantWithCardDescription ...@@ -5926,7 +5912,14 @@ public class Ocgcore : ServantWithCardDescription
tempobj.GetComponent<coiner>().todice(data); tempobj.GetComponent<coiner>().todice(data);
destroy(tempobj, 7); destroy(tempobj, 7);
} }
RMSshow_none(InterString.Get("骰子结果:[?]", data.ToString())); if (player == 0)
{
RMSshow_none($"我方骰子结果:{data}");
}
else
{
RMSshow_none($"对方骰子结果:{data}");
}
} }
Sleep(280); Sleep(280);
break; break;
......
...@@ -7,6 +7,7 @@ using System.Threading; ...@@ -7,6 +7,7 @@ using System.Threading;
using ICSharpCode.SharpZipLib.Core; using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Zip;
using UnityEngine; using UnityEngine;
using DG.Tweening;
public class Program : MonoBehaviour public class Program : MonoBehaviour
{ {
...@@ -907,8 +908,10 @@ public class Program : MonoBehaviour ...@@ -907,8 +908,10 @@ public class Program : MonoBehaviour
} }
if (fade == true) if (fade == true)
{ {
// 先将初始缩放设为0
return_value.transform.localScale = Vector3.zero; return_value.transform.localScale = Vector3.zero;
iTween.ScaleToE(return_value, scale, 0.3f); // 使用 DOTween 的 DOScale 方法,并添加一个更生动的 EaseType
return_value.transform.DOScale(scale, 0.3f).SetEase(Ease.OutBack);
} }
return return_value; return return_value;
} }
...@@ -921,7 +924,8 @@ public class Program : MonoBehaviour ...@@ -921,7 +924,8 @@ public class Program : MonoBehaviour
{ {
if (fade) if (fade)
{ {
iTween.ScaleTo(obj, Vector3.zero, 0.4f); // 使用 DOTween 执行缩放动画
obj.transform.DOScale(Vector3.zero, 0.4f);
MonoBehaviour.Destroy(obj, 0.6f); MonoBehaviour.Destroy(obj, 0.6f);
} }
else else
...@@ -943,21 +947,6 @@ public class Program : MonoBehaviour ...@@ -943,21 +947,6 @@ public class Program : MonoBehaviour
} }
} }
//public static void shiftCameraPan(Camera camera, bool enabled)
//{
// cameraPaning = enabled;
// PanWithMouse panWithMouse = camera.gameObject.GetComponent<PanWithMouse>();
// if (panWithMouse == null)
// {
// panWithMouse = camera.gameObject.AddComponent<PanWithMouse>();
// }
// panWithMouse.enabled = enabled;
// if (enabled == false)
// {
// iTween.RotateTo(camera.gameObject, new Vector3(60, 0, 0), 0.6f);
// }
//}
public static void reMoveCam(float xINscreen) public static void reMoveCam(float xINscreen)
{ {
float all = (float)Screen.width / 2f; float all = (float)Screen.width / 2f;
......
...@@ -3,6 +3,8 @@ using System.Collections.Generic; ...@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using UnityEngine; using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
using DG.Tweening;
public class Servant public class Servant
{ {
...@@ -106,16 +108,14 @@ public class Servant ...@@ -106,16 +108,14 @@ public class Servant
buttomToScreen, buttomToScreen,
0 0
); );
iTween.MoveTo(
toolBar, Vector3 targetWorldPosition = Program.camera_back_ground_2d.ScreenToWorldPoint(vectorOfShowedBar_Screen);
Program.camera_back_ground_2d.ScreenToWorldPoint(vectorOfShowedBar_Screen), // 使用 DOTween 执行移动动画
0.6f toolBar.transform.DOMove(targetWorldPosition, 0.6f);
); // 缩放操作与动画库无关,保持不变
toolBar.transform.localScale = new Vector3( float scaleFactor = Screen.height / 700f;
((float)Screen.height) / 700f, toolBar.transform.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor);
((float)Screen.height) / 700f,
((float)Screen.height) / 700f
);
var items = toolBar.GetComponentsInChildren<toolShift>(); var items = toolBar.GetComponentsInChildren<toolShift>();
for (int i = 0; i < items.Length; i++) for (int i = 0; i < items.Length; i++)
{ {
...@@ -124,21 +124,20 @@ public class Servant ...@@ -124,21 +124,20 @@ public class Servant
} }
} }
public void hideBarOnly() public void hideBarOnly()
{ {
if (toolBar != null) if (toolBar != null)
{ {
Vector3 vectorOfHidedBar_Screen = new Vector3(Screen.width - RightToScreen, -100, 0); Vector3 vectorOfHidedBar_Screen = new Vector3(Screen.width - RightToScreen, -100, 0);
iTween.MoveTo(
toolBar, Vector3 targetWorldPosition = Program.camera_back_ground_2d.ScreenToWorldPoint(vectorOfHidedBar_Screen);
Program.camera_back_ground_2d.ScreenToWorldPoint(vectorOfHidedBar_Screen),
0.6f // 使用 DOTween 执行移动动画
); toolBar.transform.DOMove(targetWorldPosition, 0.6f);
toolBar.transform.localScale = new Vector3( // 缩放操作与动画库无关,保持不变
((float)Screen.height) / 700f, float scaleFactor = Screen.height / 700f;
((float)Screen.height) / 700f, toolBar.transform.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor);
((float)Screen.height) / 700f
);
var items = toolBar.GetComponentsInChildren<toolShift>(); var items = toolBar.GetComponentsInChildren<toolShift>();
for (int i = 0; i < items.Length; i++) for (int i = 0; i < items.Length; i++)
{ {
......
using System; using System;
using DG.Tweening;
using UnityEngine; using UnityEngine;
public class WindowServant2D : Servant public class WindowServant2D : Servant
{ {
public override void applyHideArrangement() public override void applyHideArrangement()
{ {
if (gameObject != null) if (gameObject != null)
{ {
UIHelper.clearITWeen(gameObject); gameObject.transform.DOKill();
iTween.MoveTo(gameObject, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height * 1.5f, 0)), 0.6f); Vector3 hidePosition = Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height * 1.5f, 0));
gameObject.transform.DOMove(hidePosition, 0.6f);
} }
resize(); resize();
} }
public override void applyShowArrangement() public override void applyShowArrangement()
{ {
if (gameObject != null) if (gameObject != null)
{ {
UIHelper.clearITWeen(gameObject); gameObject.transform.DOKill();
iTween.MoveTo(gameObject, Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, 0)), 0.6f);
Vector3 showPosition = Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, 0));
gameObject.transform.DOMove(showPosition, 0.6f);
} }
resize(); resize();
} }
void resize() void resize()
{ {
if (gameObject != null) if (gameObject != null)
......
...@@ -4,6 +4,8 @@ using System.IO; ...@@ -4,6 +4,8 @@ using System.IO;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
using DG.Tweening;
public class DeckManager : ServantWithCardDescription public class DeckManager : ServantWithCardDescription
{ {
...@@ -185,13 +187,10 @@ public class DeckManager : ServantWithCardDescription ...@@ -185,13 +187,10 @@ public class DeckManager : ServantWithCardDescription
{ {
base.applyHideArrangement(); base.applyHideArrangement();
Program.cameraFacing = false; Program.cameraFacing = false;
iTween.MoveTo( Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
gameObjectSearch, new Vector3(Screen.width + 600, Screen.height / 2, 600)
Program.camera_main_2d.ScreenToWorldPoint( );
new Vector3(Screen.width + 600, Screen.height / 2, 600) gameObjectSearch.transform.DOMove(targetPos, 0.6f);
),
0.6f
);
refreshDetail(); refreshDetail();
} }
...@@ -201,13 +200,10 @@ public class DeckManager : ServantWithCardDescription ...@@ -201,13 +200,10 @@ public class DeckManager : ServantWithCardDescription
Program.cameraFacing = true; Program.cameraFacing = true;
UITexture tex = UIHelper.getByName<UITexture>(gameObjectSearch, "under_"); UITexture tex = UIHelper.getByName<UITexture>(gameObjectSearch, "under_");
tex.height = Screen.height; tex.height = Screen.height;
iTween.MoveTo( Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
gameObjectSearch, new Vector3(Screen.width - MAIN_PANEL_MARGIN_RIGHT, Screen.height / 2, 0)
Program.camera_main_2d.ScreenToWorldPoint( );
new Vector3(Screen.width - MAIN_PANEL_MARGIN_RIGHT, Screen.height / 2, 0) gameObjectSearch.transform.DOMove(targetPos, 0.6f);
),
0.6f
);
refreshDetail(); refreshDetail();
} }
...@@ -405,7 +401,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -405,7 +401,7 @@ public class DeckManager : ServantWithCardDescription
{ {
try try
{ {
UIHelper.clearITWeen(item.gameObject); item.gameObject.transform.DOKill();
var rid = item.gameObject.GetComponent<Rigidbody>(); var rid = item.gameObject.GetComponent<Rigidbody>();
if (rid == null) if (rid == null)
{ {
...@@ -517,20 +513,19 @@ public class DeckManager : ServantWithCardDescription ...@@ -517,20 +513,19 @@ public class DeckManager : ServantWithCardDescription
if (detailShowed) if (detailShowed)
{ {
gameObjectDetailedSearch.GetComponent<UITexture>().height = 700; gameObjectDetailedSearch.GetComponent<UITexture>().height = 700;
iTween.MoveTo(
gameObjectDetailedSearch, Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
Program.camera_main_2d.ScreenToWorldPoint( new Vector3(
new Vector3( Screen.width
Screen.width - MAIN_SEARCH_PANEL_WIDTH
- MAIN_SEARCH_PANEL_WIDTH - DETAILED_SEARCH_PANEL_WIDTH
- DETAILED_SEARCH_PANEL_WIDTH - 115f * Screen.height / 700f,
- 115f * Screen.height / 700f, Screen.height * 0.5f,
Screen.height * 0.5f, 0
0 )
)
),
0.6f
); );
gameObjectDetailedSearch.transform.DOMove(targetPos, 0.6f);
reShowBar( reShowBar(
0, 0,
MAIN_SEARCH_PANEL_WIDTH MAIN_SEARCH_PANEL_WIDTH
...@@ -540,20 +535,19 @@ public class DeckManager : ServantWithCardDescription ...@@ -540,20 +535,19 @@ public class DeckManager : ServantWithCardDescription
else else
{ {
gameObjectDetailedSearch.GetComponent<UITexture>().height = 700; gameObjectDetailedSearch.GetComponent<UITexture>().height = 700;
iTween.MoveTo(
gameObjectDetailedSearch, Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
Program.camera_main_2d.ScreenToWorldPoint( new Vector3(
new Vector3( Screen.width
Screen.width - MAIN_SEARCH_PANEL_WIDTH
- MAIN_SEARCH_PANEL_WIDTH - DETAILED_SEARCH_PANEL_WIDTH
- DETAILED_SEARCH_PANEL_WIDTH - 115f * Screen.height / 700f,
- 115f * Screen.height / 700f, Screen.height * 1.5f,
Screen.height * 1.5f, 0
0 )
)
),
0.6f
); );
gameObjectDetailedSearch.transform.DOMove(targetPos, 0.6f);
reShowBar(0, CAMERA_MARGIN_RIGHT_NORMAL); reShowBar(0, CAMERA_MARGIN_RIGHT_NORMAL);
} }
} }
...@@ -563,37 +557,29 @@ public class DeckManager : ServantWithCardDescription ...@@ -563,37 +557,29 @@ public class DeckManager : ServantWithCardDescription
if (detailShowed) if (detailShowed)
{ {
gameObjectDetailedSearch.GetComponent<UITexture>().height = Screen.height; gameObjectDetailedSearch.GetComponent<UITexture>().height = Screen.height;
// [修改] 使用常量替换硬编码的 575f
iTween.MoveTo( Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
gameObjectDetailedSearch, new Vector3(
Program.camera_main_2d.ScreenToWorldPoint( Screen.width - COMBINED_PANEL_WIDTH,
new Vector3( Screen.height * 0.5f,
Screen.width - COMBINED_PANEL_WIDTH, 0
Screen.height * 0.5f, )
0
)
),
0.6f
); );
// 使用常量替换硬编码的 460*2 gameObjectDetailedSearch.transform.DOMove(targetPos, 0.6f);
reShowBar(0, MAIN_SEARCH_PANEL_WIDTH + DETAILED_SEARCH_PANEL_WIDTH); reShowBar(0, MAIN_SEARCH_PANEL_WIDTH + DETAILED_SEARCH_PANEL_WIDTH);
} }
else else
{ {
gameObjectDetailedSearch.GetComponent<UITexture>().height = Screen.height; gameObjectDetailedSearch.GetComponent<UITexture>().height = Screen.height;
// 使用常量替换硬编码的 575f Vector3 targetPos = Program.camera_main_2d.ScreenToWorldPoint(
iTween.MoveTo( new Vector3(
gameObjectDetailedSearch, Screen.width - COMBINED_PANEL_WIDTH,
Program.camera_main_2d.ScreenToWorldPoint( Screen.height * 1.5f,
new Vector3( 0
Screen.width - COMBINED_PANEL_WIDTH, )
Screen.height * 1.5f,
0
)
),
0.6f
); );
// 使用常量替换硬编码的 230 gameObjectDetailedSearch.transform.DOMove(targetPos, 0.6f);
reShowBar(0, CAMERA_MARGIN_RIGHT_NORMAL); reShowBar(0, CAMERA_MARGIN_RIGHT_NORMAL);
} }
} }
...@@ -2058,7 +2044,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -2058,7 +2044,7 @@ public class DeckManager : ServantWithCardDescription
r.gameObject.transform.position = new Vector3(0, 5, 0); r.gameObject.transform.position = new Vector3(0, 5, 0);
r.gameObject.transform.eulerAngles = new Vector3(90, 0, 0); r.gameObject.transform.eulerAngles = new Vector3(90, 0, 0);
r.gameObject.transform.localScale = new Vector3(0, 0, 0); r.gameObject.transform.localScale = new Vector3(0, 0, 0);
iTween.ScaleTo(r.gameObject, new Vector3(3, 4, 1), 0.4f); r.gameObject.transform.DOScale(new Vector3(3, 4, 1), 0.4f);
r.gameObject.SetActive(true); r.gameObject.SetActive(true);
return r; return r;
} }
......
using UnityEngine; using UnityEngine;
using System.Collections; using DG.Tweening;
public class screenFader : MonoBehaviour public class screenFader : MonoBehaviour
{ {
...@@ -30,19 +31,18 @@ public class screenFader : MonoBehaviour ...@@ -30,19 +31,18 @@ public class screenFader : MonoBehaviour
Vector3 to = Program.camera_game_main.ScreenToWorldPoint(screen_point); Vector3 to = Program.camera_game_main.ScreenToWorldPoint(screen_point);
deltaTimeCloseUp += Time.deltaTime; deltaTimeCloseUp += Time.deltaTime;
if (deltaTimeCloseUp > time) if (deltaTimeCloseUp > time)
{ {
deltaTimeCloseUp = time; deltaTimeCloseUp = time;
} }
gameObject.transform.position = new Vector3 float progress = (time > 0) ? Mathf.Clamp01(deltaTimeCloseUp / time) : 1f;
(
iTween.easeOutQuad(from.x, to.x, deltaTimeCloseUp / time), // 分别计算 x, y, z 各个轴上的缓动值
iTween.easeOutQuad(from.y, to.y, deltaTimeCloseUp / time), float newX = DOVirtual.EasedValue(from.x, to.x, progress, Ease.OutQuad);
iTween.easeOutQuad(from.z, to.z, deltaTimeCloseUp / time) float newY = DOVirtual.EasedValue(from.y, to.y, progress, Ease.OutQuad);
); float newZ = DOVirtual.EasedValue(from.z, to.z, progress, Ease.OutQuad);
gameObject.transform.position = new Vector3(newX, newY, newZ);
} }
} }
using UnityEngine; using System.Collections.Generic;
using System.Collections; using DG.Tweening; // 1. 引入 DOTween 命名空间
using System.Collections.Generic; using UnityEngine;
public class number_loader : MonoBehaviour {
// 类名保持不变
public class number_loader : MonoBehaviour
{
public Sprite[] sps = new Sprite[60]; public Sprite[] sps = new Sprite[60];
public GameObject mod; public GameObject mod;
// Use this for initialization
void Start ()
{
}
List<GameObject> obj_nums = new List<GameObject>(); private List<GameObject> obj_nums = new List<GameObject>();
Color ccc = Color.white; private int n = -1;
int n = -1; private int _currentColorIndex = -1;
public void set_number(int number,int color)
public void set_number(int number, int color)
{ {
if (n!=number) if (n == number && _currentColorIndex == color)
{
return;
}
n = number;
_currentColorIndex = color;
foreach (GameObject digitObject in obj_nums)
{
GameObject objToDestroy = digitObject;
objToDestroy.transform.DOScale(Vector3.zero, 0.6f)
.SetEase(Ease.InBack)
.OnComplete(() =>
{
if (objToDestroy != null) Destroy(objToDestroy);
});
}
obj_nums.Clear();
if (number < 0)
{ {
n = number; return;
string number_strig = number.ToString(); }
for (int i = 0; i < obj_nums.Count; i++)
string number_strig = number.ToString();
for (int i = 0; i < number_strig.Length; i++)
{
if (!int.TryParse(number_strig[i].ToString(), out int digitValue)) continue;
int spriteIndex = color * 10 + digitValue;
if (mod == null)
{ {
iTween.ScaleTo(obj_nums[i], Vector3.zero, 0.6f); Debug.LogError("预设体 'mod' 未在 Inspector 中指定!", this);
Destroy(obj_nums[i], 0.6f); return; // 关键资源缺失,终止执行
} }
obj_nums.Clear(); if (spriteIndex >= sps.Length || sps[spriteIndex] == null)
if (number > -1)
{ {
for (int i = 0; i < number_strig.Length; i++) Debug.LogWarning($"精灵索引 '{spriteIndex}' 超出范围或对应的精灵为空。", this);
{ continue; // 跳过这个无效的数字位
if (color * 10 + int.Parse(number_strig[i].ToString()) < 60)
{
Sprite sprite = sps[color * 10 + int.Parse(number_strig[i].ToString())];
GameObject obj = (GameObject)MonoBehaviour.Instantiate(mod, Vector3.zero, Quaternion.identity);
obj.transform.SetParent(gameObject.transform, false);
obj.GetComponent<SpriteRenderer>().sprite = sprite;
obj.transform.localPosition = new Vector3(-(float)number_strig.Length / 2f + 0.5f + i, 0, 0);
obj.transform.localScale = Vector3.zero;
iTween.ScaleTo(obj, new Vector3(1, 1, 1), 0.6f);
obj_nums.Add(obj);
}
}
} }
set_color(ccc);
}
}
public void set_color(Color c) GameObject obj = (GameObject)Instantiate(mod, transform);
{
ccc = c; obj.transform.localPosition = new Vector3(-(float)number_strig.Length / 2f + 0.5f + i, 0, 0);
//var sps=GetComponentsInChildren<SpriteRenderer>();
//for (int i = 0; i < sps.Length;i++ ) var spriteRenderer = obj.GetComponent<SpriteRenderer>();
//{ if (spriteRenderer != null)
// Color aaa = c; {
// aaa.a = 0.8f; spriteRenderer.sprite = sps[spriteIndex];
// sps[i].color = aaa; }
//} else
{
Debug.LogError("预设体 'mod' 上缺少 SpriteRenderer 组件!", this);
Destroy(obj);
continue;
}
obj.transform.localScale = Vector3.zero;
obj.transform.DOScale(Vector3.one, 0.6f)
.SetEase(Ease.OutBack);
obj_nums.Add(obj);
}
} }
// Update is called once per frame
void Update ()
{
}
} }
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using DG.Tweening;
public class fade_died : MonoBehaviour { public class fade_died : MonoBehaviour {
public float time = 3; public float time = 3;
public Vector3 scale = new Vector3(1,1,1); public Vector3 scale = new Vector3(1,1,1);
// Use this for initialization // Use this for initialization
void Start () { void Start () {
// 初始缩放设为0
gameObject.transform.localScale = Vector3.zero; gameObject.transform.localScale = Vector3.zero;
iTween.ScaleTo(gameObject, scale, 0.6f); // 2. 创建一个 DOTween 序列来管理整个动画生命周期
iTween.ScaleTo(gameObject, iTween.Hash( Sequence mySequence = DOTween.Sequence();
"delay",time, // 3. 将动画按顺序添加到序列中
"x", 0, mySequence.Append(transform.DOScale(scale, 0.6f)) // 第一步:放大出现
"y", 0, .AppendInterval(time) // 第二步:等待'time'秒
"z", 0, .Append(transform.DOScale(Vector3.zero, 0.6f)) // 第三步:缩小消失
"time", 0.6f .OnComplete(() => // 第四步:动画序列完成后执行
)); {
Destroy(gameObject, time + 0.6f); Destroy(gameObject); // 安全地销毁对象
});
} }
// Update is called once per frame // Update is called once per frame
......
using UnityEngine; using System;
using System.Collections; using DG.Tweening;
using System; using UnityEngine;
public class sorder : MonoBehaviour { public class sorder : MonoBehaviour
int time; {
int time;
// Use this for initialization // Use this for initialization
void Start () { void Start()
time = Program.TimePassed(); {
iTween.ScaleTo(gameObject,new Vector3(3,3,3),1); time = Program.TimePassed();
transform.DOScale(3f, 1f);
} }
// Update is called once per frame // Update is called once per frame
void Update () { void Update()
int delta_time = Program.TimePassed() - time; {
int delta_time = Program.TimePassed() - time;
//gameObject.transform.Rotate((new Vector3(0, 0, 1)) * Time.deltaTime * 50); gameObject.transform.localPosition = new Vector3(gameObject.transform.localPosition.x, gameObject.transform.localPosition.y, gameObject.transform.localPosition.z + (float)(
gameObject.transform.localPosition = new Vector3(gameObject.transform.localPosition.x, gameObject.transform.localPosition.y, gameObject.transform.localPosition.z + (float)( Math.Sin((float)delta_time / 150f) / 40f
Math.Sin((float)delta_time / 150f) / 40f
)); ));
} }
} }
using UnityEngine; using UnityEngine;
using System.Collections; using DG.Tweening;
using System; using System;
public class coiner : MonoBehaviour {
int time;
// Use this for initialization
void Start () {
gameObject.transform.localScale = Vector3.zero;
gameObject.transform.eulerAngles = new Vector3(60, 0, 0);
time = Program.TimePassed();
}
public void coin_app()
{
iTween.ScaleTo(gameObject, new Vector3(10, 10, 8.743f), 1f);
}
public void dice_app()
{
iTween.ScaleTo(gameObject, new Vector3(0.2f, 0.2f, 0.2f), 1f);
}
public void disapp()
{
iTween.ScaleTo(gameObject, new Vector3(0,0,0), 1f);
}
public void tocoin(bool up)
{
if (up)
{
iTween.RotateTo(gameObject, new Vector3(60, 0, 0) + (new Vector3(360, 0, 0)) * 15, 3f);
}
else
{
iTween.RotateTo(gameObject, new Vector3(240, 0, 0) + (new Vector3(360, 0, 0)) * 15, 3f);
}
}
public void todice(int num)
{
switch (num)
{
case 1: iTween.RotateTo(gameObject, new Vector3(-60, 180, 180) + (new Vector3(360, 360, 360)) * 15, 3f);
break;
case 2: iTween.RotateTo(gameObject, new Vector3(40, 180, 180) + (new Vector3(360, 360, 360)) * 15, 3f);
break;
case 3: iTween.RotateTo(gameObject, new Vector3(-30, 0, -90) + (new Vector3(360, 360, 360)) * 15, 3f);
break;
case 4: iTween.RotateTo(gameObject, new Vector3(-30, 0, 90) + (new Vector3(360, 360, 360)) * 15, 3f);
break;
case 5: iTween.RotateTo(gameObject, new Vector3(-30, 0, 0) + (new Vector3(360, 360, 360)) * 15, 3f);
break;
case 6: iTween.RotateTo(gameObject, new Vector3(60, 0, 0) + (new Vector3(360, 360, 360)) * 15, 3f);
break;
} public class coiner : MonoBehaviour
{
} private int time;
// Update is called once per frame private const float fastDuration = 1.5f;
void Update () {
if(Program.TimePassed()-time>4000){ void Start()
time = Program.TimePassed(); {
Destroy(gameObject, 3000); transform.localScale = Vector3.zero;
iTween.ScaleTo(gameObject, Vector3.zero, 1f); transform.eulerAngles = new Vector3(60, 0, 0);
}
} time = Program.TimePassed();
}
public void coin_app()
{
transform.DOScale(new Vector3(10, 10, 8.743f), 1f);
}
public void dice_app()
{
transform.DOScale(new Vector3(0.2f, 0.2f, 0.2f), 1f);
}
public void disapp()
{
transform.DOScale(Vector3.zero, 1f);
}
public void tocoin(bool up)
{
if (up)
{
transform.DORotate(new Vector3(60, 0, 0) + new Vector3(360, 0, 0) * 15, fastDuration, RotateMode.FastBeyond360);
}
else
{
transform.DORotate(new Vector3(240, 0, 0) + new Vector3(360, 0, 0) * 15, fastDuration, RotateMode.FastBeyond360);
}
}
public void todice(int num)
{
switch (num)
{
case 1:
transform.DORotate(new Vector3(-60, 180, 180) + new Vector3(360, 360, 360) * 15, fastDuration, RotateMode.FastBeyond360);
break;
case 2:
transform.DORotate(new Vector3(40, 180, 180) + new Vector3(360, 360, 360) * 15, fastDuration, RotateMode.FastBeyond360);
break;
case 3:
transform.DORotate(new Vector3(-30, 0, -90) + new Vector3(360, 360, 360) * 15, fastDuration, RotateMode.FastBeyond360);
break;
case 4:
transform.DORotate(new Vector3(-30, 0, 90) + new Vector3(360, 360, 360) * 15, fastDuration, RotateMode.FastBeyond360);
break;
case 5:
transform.DORotate(new Vector3(-30, 0, 0) + new Vector3(360, 360, 360) * 15, fastDuration, RotateMode.FastBeyond360);
break;
case 6:
transform.DORotate(new Vector3(60, 0, 0) + new Vector3(360, 360, 360) * 15, fastDuration, RotateMode.FastBeyond360);
break;
}
}
void Update()
{
if (Program.TimePassed() - time > 4000)
{
time = Program.TimePassed();
transform.DOScale(Vector3.zero, 1f);
Destroy(gameObject, 3f);
}
}
} }
...@@ -18,18 +18,18 @@ public class LightningBolt : MonoBehaviour ...@@ -18,18 +18,18 @@ public class LightningBolt : MonoBehaviour
Perlin noise; Perlin noise;
float oneOverZigs; float oneOverZigs;
private ParticleSystem ps; // private ParticleSystem ps;
private Particle[] particles; // private Particle[] particles;
void Start() void Start()
{ {
oneOverZigs = 1f / (float)zigs; oneOverZigs = 1f / (float)zigs;
ps = GetComponent<ParticleSystem>(); // ps = GetComponent<ParticleSystem>();
particles = new Particle[zigs]; // particles = new Particle[zigs];
var em = ps.emission; // var em = ps.emission;
em.enabled = false; // em.enabled = false;
ps.Emit(zigs); // ps.Emit(zigs);
ps.GetParticles(particles); // ps.GetParticles(particles);
} }
void Update () void Update ()
...@@ -41,27 +41,27 @@ public class LightningBolt : MonoBehaviour ...@@ -41,27 +41,27 @@ public class LightningBolt : MonoBehaviour
float timey = Time.time * speed * 1.21688f; float timey = Time.time * speed * 1.21688f;
float timez = Time.time * speed * 2.5564f; float timez = Time.time * speed * 2.5564f;
for (int i = 0; i < particles.Length; i++) // for (int i = 0; i < particles.Length; i++)
{ // {
Vector3 position = Vector3.Lerp(transform.position, target.position, oneOverZigs * (float)i); // Vector3 position = Vector3.Lerp(transform.position, target.position, oneOverZigs * (float)i);
Vector3 offset = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z), // Vector3 offset = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z),
noise.Noise(timey + position.x, timey + position.y, timey + position.z), // noise.Noise(timey + position.x, timey + position.y, timey + position.z),
noise.Noise(timez + position.x, timez + position.y, timez + position.z)); // noise.Noise(timez + position.x, timez + position.y, timez + position.z));
position += (offset * scale * ((float)i * oneOverZigs)); // position += (offset * scale * ((float)i * oneOverZigs));
particles[i].position = position; // particles[i].position = position;
particles[i].startColor = Color.white; // particles[i].startColor = Color.white;
//particles[i].energy = 1f; // //particles[i].energy = 1f;
} // }
ps.SetParticles(particles); // ps.SetParticles(particles);
if (ps.particleCount >= 2) // if (ps.particleCount >= 2)
{ // {
if (startLight) // if (startLight)
startLight.transform.position = particles[0].position; // startLight.transform.position = particles[0].position;
if (endLight) // if (endLight)
endLight.transform.position = particles[particles.Length - 1].position; // endLight.transform.position = particles[particles.Length - 1].position;
} // }
} }
} }
\ No newline at end of file
fileFormatVersion: 2
guid: e778ea66df9cae740a9957b2cadd6b72
folderAsset: yes
timeCreated: 1469182548
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: 092d0bff4e926854aa2558f53e14ee34
timeCreated: 1469174736
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment