Commit 6de17c3f authored by 赤子奈落's avatar 赤子奈落

atk change effects and summon light

parent 4482e904
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using YGOSharp;
using YGOSharp.OCGWrapper.Enums;
public class CardHintHandler : MonoBehaviour
{
public gameCard card;
Card data_raw;
bool changed;
float atk;
float def;
string atk_pre = "";
string atk_after = "";
string def_pre = "";
string def_after = "";
string greaterFormat = "<#05C5F7><size=45>";
string lessFormat = "<#FB3E08><size=45>";
string grayFormat = "<#888888><size=30>";
public void OnEnable()
{
atk = -3;
def = -3;
}
public void setHint()
{
string raw = "";
data_raw = CardsManager.Get(card.get_data().Id);
if ((card.get_data().Type & (uint)CardType.Link) > 0)
{
if (card.get_data().Attack > data_raw.Attack)
{
atk_pre = greaterFormat;
atk_after = "</size></color>";
}
else if (card.get_data().Attack < data_raw.Attack)
{
atk_pre = lessFormat;
atk_after = "</size></color>";
}
else
{
atk_pre = "<size=45>";
atk_after = "</size>";
}
raw = atk_pre + card.get_data().Attack + atk_after;
set_text(raw.Replace("-2", "?"));
}
else
{
if ((card.p.position & (int)CardPosition.Attack) > 0)
{
if (card.get_data().Attack > data_raw.Attack)
{
atk_pre = greaterFormat;
atk_after = "</size></color>";
}
else if (card.get_data().Attack < data_raw.Attack)
{
atk_pre = lessFormat;
atk_after = "</size></color>";
}
else
{
atk_pre = "<size=45>";
atk_after = "</size>";
}
def_pre = grayFormat;
def_after = "</size></color>";
}
else
{
atk_pre = grayFormat;
atk_after = "</size></color>";
if (card.get_data().Defense > data_raw.Defense)
{
def_pre = greaterFormat;
def_after = "</size></color>";
}
else if (card.get_data().Defense < data_raw.Defense)
{
def_pre = lessFormat;
def_after = "</size></color>";
}
else
{
def_pre = "<size=45>";
def_after = "</size>";
}
}
raw = atk_pre + card.get_data().Attack + atk_after + "<size=45>" + "/" + "</size>" + def_pre + card.get_data().Defense + def_after;
set_text(raw.Replace("-2", "?"));
}
}
void set_text(string hint)
{
changed = true;
if(atk == -3)
atk = data_raw.Attack;
if(def == -3)
def = data_raw.Defense;
if(atk != card.get_data().Attack)
{
DOTween.To(() => atk, x => atk = x, card.get_data().Attack, changeTime);
if ((card.p.position & (uint)CardPosition.Attack) > 0)
{
if (atk > card.get_data().Attack)
{
SEHandler.PlaySingle("SE_DUEL/SE_DEBUFF_ATTACK");
var decoration = ABLoader.LoadAB("effects/eff_prm/fxp_cardparm_down_001");
decoration.transform.position = card.gameObject.transform.position;
Destroy(decoration, 2f);
}
if (atk < card.get_data().Attack)
{
SEHandler.PlaySingle("SE_DUEL/SE_BUFF_ATTACK");
var decoration = ABLoader.LoadAB("effects/eff_prm/fxp_cardparm_up_001");
decoration.transform.position = card.gameObject.transform.position;
Destroy(decoration, 2f);
}
}
}
if ((card.get_data().Type & (uint)CardType.Link) == 0 &&def != card.get_data().Defense)
{
DOTween.To(() => def, x => def = x, card.get_data().Defense, changeTime);
if (def > card.get_data().Defense)
{
//SEHandler.PlaySingle("SE_DUEL/SE_DEBUFF_ATTACK");
//var decoration = ABLoader.LoadAB("effects/eff_prm/fxp_cardparm_down_001");
//decoration.transform.position = card.gameObject.transform.position;
//Destroy(decoration, 2f);
}
else
{
//SEHandler.PlaySingle("SE_DUEL/SE_BUFF_ATTACK");
//var decoration = ABLoader.LoadAB("effects/eff_prm/fxp_cardparm_up_001");
//decoration.transform.position = card.gameObject.transform.position;
//Destroy(decoration, 2f);
}
}
}
float changeTime = 0.6f;
float time = 0f;
private void Update()
{
if (changed)
{
if ((card.get_data().Type & (uint)CardType.Link) > 0)
GetComponent<TextMeshPro>().text = atk_pre + (int)atk + atk_after;
else
GetComponent<TextMeshPro>().text = atk_pre + (int)atk + atk_after + "<size=45>" + "/" + "</size>" + def_pre + (int)def + def_after;
time += Time.deltaTime;
if(time > changeTime)
{
changed = false;
time = 0f;
atk = card.get_data().Attack;
if ((card.get_data().Type & (uint)CardType.Link) > 0)
GetComponent<TextMeshPro>().text = atk_pre + (int)atk + atk_after;
else
{
def = card.get_data().Defense;
GetComponent<TextMeshPro>().text = atk_pre + (int)atk + atk_after + "<size=45>" + "/" + "</size>" + def_pre + (int)def + def_after;
}
}
}
}
}
fileFormatVersion: 2 fileFormatVersion: 2
guid: 49f544b2bc615ca42831ec5e420adada guid: 5de8064983513f54689af7b3040a329c
PrefabImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
...@@ -4,19 +4,19 @@ using UnityEngine; ...@@ -4,19 +4,19 @@ using UnityEngine;
public class SEHandler : MonoBehaviour public class SEHandler : MonoBehaviour
{ {
public static void Play(string p) public static void Play(string clip)
{ {
AudioSource audioSource = Instantiate(Program.I().mod_audio_effect).GetComponent<AudioSource>(); AudioSource audioSource = Instantiate(Program.I().mod_audio_effect).GetComponent<AudioSource>();
audioSource.volume = int.Parse(Config.Get("seVol_", "750")) / 1000f; audioSource.volume = Program.I().setting.seVol;
audioSource.clip = GetClip(p); audioSource.clip = GetClip(clip);
Destroy(audioSource, 5f); Destroy(audioSource, 5f);
} }
public static void PlayInternalAudio(string name) public static void PlayInternalAudio(string clip)
{ {
AudioSource audioSource = Instantiate(Program.I().mod_audio_effect).GetComponent<AudioSource>(); AudioSource audioSource = Instantiate(Program.I().mod_audio_effect).GetComponent<AudioSource>();
audioSource.volume = int.Parse(Config.Get("seVol_", "750")) / 1000f; audioSource.volume = Program.I().setting.seVol;
audioSource.clip = Resources.Load<AudioClip>("Sound/" + name); audioSource.clip = Resources.Load<AudioClip>("Sound/" + clip);
Destroy(audioSource.gameObject, 5f); Destroy(audioSource.gameObject, 5f);
} }
...@@ -24,6 +24,17 @@ public class SEHandler : MonoBehaviour ...@@ -24,6 +24,17 @@ public class SEHandler : MonoBehaviour
{ {
GameObject.Find("SE").GetComponent<AudioSource>().Stop(); GameObject.Find("SE").GetComponent<AudioSource>().Stop();
} }
public static void PlaySingle(string clip)
{
AudioSource audioSource = GameObject.Find("SE").GetComponent<AudioSource>();
//if (audioSource.isPlaying)
// return;
audioSource.volume = Program.I().setting.seVol;
audioSource.clip = GetClip(clip);
audioSource.Play();
}
static AudioClip GetClip(string p) static AudioClip GetClip(string p)
{ {
var path = "sound/" + p + ".mp3"; var path = "sound/" + p + ".mp3";
......
...@@ -11,7 +11,7 @@ public class TestLoad : MonoBehaviour ...@@ -11,7 +11,7 @@ public class TestLoad : MonoBehaviour
{ {
void Start() void Start()
{ {
var a1 = ABLoader.LoadAB("effects/other/fxp_arrow_aim_001"); var a1 = ABLoader.LoadAB("effects/summon/fxp_somldg/hand/fxp_somldg_hand_001");
} }
} }
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5690241711044997232
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5690241711044997233}
- component: {fileID: 5690241711044997238}
m_Layer: 8
m_Name: icon_1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5690241711044997233
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5690241711044997232}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -580, y: 32, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5690241711044997238
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5690241711044997232}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96b31ce75e592f45a1cff563a4869db, type: 3}
m_Name:
m_EditorClassIdentifier:
leftAnchor:
target: {fileID: 0}
relative: 0
absolute: 30
rightAnchor:
target: {fileID: 0}
relative: 0
absolute: 70
bottomAnchor:
target: {fileID: 0}
relative: 1
absolute: -70
topAnchor:
target: {fileID: 0}
relative: 1
absolute: -30
updateAnchors: 1
mColor: {r: 1, g: 1, b: 1, a: 1}
mPivot: 4
mWidth: 40
mHeight: 40
mDepth: 10005
autoResizeBoxCollider: 0
hideIfOffScreen: 0
keepAspectRatio: 0
aspectRatio: 1
mType: 0
mFillDirection: 4
mFillAmount: 1
mInvert: 0
mFlip: 0
centerType: 1
leftType: 1
rightType: 1
bottomType: 1
topType: 1
mSprite: {fileID: 21300000, guid: 09dc7978b81155b44983890468205eec, type: 2}
mMat: {fileID: 0}
mShader: {fileID: 4800000, guid: e75727d9555d9d14ca51d91908c681bc, type: 3}
mBorder: {x: 0, y: 0, z: 0, w: 0}
mFixedAspect: 0
mPixelSize: 1
nextSprite: {fileID: 0}
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -315,7 +315,7 @@ public class gameCard : OCGobject ...@@ -315,7 +315,7 @@ public class gameCard : OCGobject
del_all_decoration(); del_all_decoration();
for (var i = 0; i < allObjects.Count; i++) Object.Destroy(allObjects[i]); for (var i = 0; i < allObjects.Count; i++) Object.Destroy(allObjects[i]);
allObjects.Clear(); allObjects.Clear();
set_text(""); set_text("", false);
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -1522,7 +1522,7 @@ public class gameCard : OCGobject ...@@ -1522,7 +1522,7 @@ public class gameCard : OCGobject
refreshFunctions.Remove(monster_cloude_handler); refreshFunctions.Remove(monster_cloude_handler);
refreshFunctions.Remove(card_floating_text_handler); refreshFunctions.Remove(card_floating_text_handler);
gameObject.transform.Find("card").transform.localPosition = Vector3.zero; gameObject.transform.Find("card").transform.localPosition = Vector3.zero;
set_text(""); set_text("", false);
//caculateAbility(); //caculateAbility();
} }
...@@ -1574,7 +1574,7 @@ public class gameCard : OCGobject ...@@ -1574,7 +1574,7 @@ public class gameCard : OCGobject
} }
if (p.controller == 1 && loc != "") loc = "<#ff8888>" + loc + "</color>"; if (p.controller == 1 && loc != "") loc = "<#ff8888>" + loc + "</color>";
set_text(loc); set_text(loc, false);
} }
} }
...@@ -1903,46 +1903,7 @@ public class gameCard : OCGobject ...@@ -1903,46 +1903,7 @@ public class gameCard : OCGobject
loaded_verticaldef = data.Defense; loaded_verticaldef = data.Defense;
loaded_verticalpos = p.position; loaded_verticalpos = p.position;
loaded_verticalcon = (int) p.controller; loaded_verticalcon = (int) p.controller;
if ((data.Type & (uint) CardType.Link) > 0) set_text("0", true);
{
var raw = "";
var data_raw = CardsManager.Get(data.Id);
if (data.Attack > data_raw.Attack) raw += "<#7fff00><size=45>" + data.Attack + "</size></color>";
if (data.Attack < data_raw.Attack) raw += "<#dda0dd><size=45>" + data.Attack + "</size></color>";
if (data.Attack == data_raw.Attack) raw += data.Attack.ToString();
//if (p.sequence == 5 || p.sequence == 6)
// raw += "(" + (p.controller == 0 ? GameStringHelper._wofang : GameStringHelper._duifang) + ")";
set_text(raw.Replace("-2", "?"));
}
else
{
var raw = "";
var data_raw = CardsManager.Get(data.Id);
if ((loaded_verticalpos & (int) CardPosition.Attack) > 0)
{
if (data.Attack > data_raw.Attack) raw += "<#7fff00><size=45>" + data.Attack + "</size></color>";
if (data.Attack < data_raw.Attack) raw += "<#dda0dd><size=45>" + data.Attack + "</size></color>";
if (data.Attack == data_raw.Attack) raw += data.Attack.ToString();
raw += "<size=45>" + "/" + "</size>";
raw += "<#888888><size=30>" + data.Defense + "</size></color>";
//if (p.sequence == 5 || p.sequence == 6)
// raw += "(" + (p.controller == 0 ? GameStringHelper._wofang : GameStringHelper._duifang) +
// ")";
set_text(raw.Replace("-2", "?"));
}
else
{
raw += "<#888888><size=30>" + data.Attack + "</size></color>";
raw += "<size=45>" + "/" + "</size>";
if (data.Defense > data_raw.Defense) raw += "<#7fff00><size=45>" + data.Defense + "</size></color>";
if (data.Defense < data_raw.Defense) raw += "<#dda0dd><size=45>" + data.Defense + "</size></color>";
if (data.Defense == data_raw.Defense) raw += data.Defense.ToString();
//if (p.sequence == 5 || p.sequence == 6)
// raw += "(" + (p.controller == 0 ? GameStringHelper._wofang : GameStringHelper._duifang) +
// ")";
set_text(raw.Replace("-2", "?"));
}
}
} }
} }
} }
...@@ -2142,10 +2103,18 @@ public class gameCard : OCGobject ...@@ -2142,10 +2103,18 @@ public class gameCard : OCGobject
return false; return false;
} }
public void set_text(string s) public void set_text(string s, bool isNumber = true)
{ {
cardHint.gameObject.SetActive(s != ""); if (isNumber)
cardHint.text = s; {
cardHint.gameObject.SetActive(true);
cardHint.GetComponent<CardHintHandler>().card = this;
cardHint.GetComponent<CardHintHandler>().setHint();
}
else
{
cardHint.gameObject.SetActive(false);
}
} }
private int get_color_num_int() private int get_color_num_int()
...@@ -2619,7 +2588,7 @@ public class gameCard : OCGobject ...@@ -2619,7 +2588,7 @@ public class gameCard : OCGobject
// SOH_nSum(); // SOH_nSum();
// Program.I().ocgcore.Sleep(30); // Program.I().ocgcore.Sleep(30);
//} //}
Program.I().ocgcore.Sleep(72); Program.I().ocgcore.Sleep(30);
} }
else else
{ {
......
...@@ -4436,6 +4436,14 @@ public class Ocgcore : ServantWithCardDescription ...@@ -4436,6 +4436,14 @@ public class Ocgcore : ServantWithCardDescription
LoadSFX.DelayDecoration(card.UA_get_accurate_position(), gps.position, "effects/summon/fxp_som_mgctrpfld_001", "SE_DUEL/SE_LAND_NORMAL", landDelay, true); LoadSFX.DelayDecoration(card.UA_get_accurate_position(), gps.position, "effects/summon/fxp_som_mgctrpfld_001", "SE_DUEL/SE_LAND_NORMAL", landDelay, true);
CameraControl.ShakeCamera(0.2f, false); CameraControl.ShakeCamera(0.2f, false);
} }
var light = ABLoader.LoadAB("effects/summon/fxp_somldg/hand/fxp_somldg_hand_001");
light.transform.position = card.gameObject.transform.position;
if ((gps.position & (uint)CardPosition.Attack) > 0)
Object.Destroy(light.transform.GetChild(1).gameObject);
else
Object.Destroy(light.transform.GetChild(0).gameObject);
Object.Destroy(light, 2f);
card.animation_show_off(true); card.animation_show_off(true);
LoadSFX.spType = "SPECIAL"; LoadSFX.spType = "SPECIAL";
LoadSFX.materials.Clear(); LoadSFX.materials.Clear();
...@@ -4555,6 +4563,15 @@ public class Ocgcore : ServantWithCardDescription ...@@ -4555,6 +4563,15 @@ public class Ocgcore : ServantWithCardDescription
CameraControl.ShakeCamera(0.2f, false); CameraControl.ShakeCamera(0.2f, false);
} }
} }
var light = ABLoader.LoadAB("effects/summon/fxp_somldg/hand/fxp_somldg_hand_001");
light.transform.position = card.gameObject.transform.position;
if ((gps.position & (uint)CardPosition.Attack) > 0)
Object.Destroy(light.transform.GetChild(1).gameObject);
else
Object.Destroy(light.transform.GetChild(0).gameObject);
Object.Destroy(light, 2f);
card.animation_show_off(true); card.animation_show_off(true);
LoadSFX.spType = "SPECIAL"; LoadSFX.spType = "SPECIAL";
LoadSFX.materials.Clear(); LoadSFX.materials.Clear();
......
...@@ -230,6 +230,7 @@ GameObject: ...@@ -230,6 +230,7 @@ GameObject:
- component: {fileID: 2352360} - component: {fileID: 2352360}
- component: {fileID: 11498002} - component: {fileID: 11498002}
- component: {fileID: 11494548} - component: {fileID: 11494548}
- component: {fileID: 2198693824251617441}
m_Layer: 0 m_Layer: 0
m_Name: text m_Name: text
m_TagString: Untagged m_TagString: Untagged
...@@ -407,6 +408,18 @@ MonoBehaviour: ...@@ -407,6 +408,18 @@ MonoBehaviour:
m_maskType: 0 m_maskType: 0
m_isNewTextObject: 0 m_isNewTextObject: 0
m_enableAutoSizing: 1 m_enableAutoSizing: 1
--- !u!114 &2198693824251617441
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 165420}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5de8064983513f54689af7b3040a329c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &177152 --- !u!1 &177152
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
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