Commit 6f2a7aa4 authored by 神楽坂玲奈's avatar 神楽坂玲奈

code reformat

parent 5771b093
using UnityEngine; using UnityEngine;
using System.Collections;
public class ContinuesButton : MonoBehaviour { public class ContinuesButton : MonoBehaviour
UIButton btn; {
// Use this for initialization private UIButton btn;
void Start ()
private bool isTrigging;
// Update is called once per frame
private float time;
// Use this for initialization
private void Start()
{ {
btn = GetComponentInChildren<UIButton>(); btn = GetComponentInChildren<UIButton>();
UIEventTrigger trigger= gameObject.GetComponentInChildren<UIEventTrigger>(); var trigger = gameObject.GetComponentInChildren<UIEventTrigger>();
if (trigger==null) if (trigger == null) trigger = gameObject.AddComponent<UIEventTrigger>();
{
trigger = gameObject.AddComponent<UIEventTrigger>();
}
trigger.onRelease.Add(new EventDelegate(this, "off")); trigger.onRelease.Add(new EventDelegate(this, "off"));
trigger.onPress.Add(new EventDelegate(this, "on")); trigger.onPress.Add(new EventDelegate(this, "on"));
} }
void on() private void Update()
{
isTrigging = true;
time = 0;
}
void off()
{ {
isTrigging = false; if (isTrigging)
time = 0; if (btn != null)
}
bool isTrigging = false;
// Update is called once per frame
float time = 0;
void Update () {
if (isTrigging)
{
if (btn!=null)
{ {
time += Time.deltaTime; time += Time.deltaTime;
if (time > 0.2f) if (time > 0.2f)
...@@ -43,6 +31,17 @@ public class ContinuesButton : MonoBehaviour { ...@@ -43,6 +31,17 @@ public class ContinuesButton : MonoBehaviour {
EventDelegate.Execute(btn.onClick); EventDelegate.Execute(btn.onClick);
} }
} }
}
} }
}
private void on()
{
isTrigging = true;
time = 0;
}
private void off()
{
isTrigging = false;
time = 0;
}
}
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class MONO_wait : MonoBehaviour { public class MONO_wait : MonoBehaviour
{
public UILabel lab; public UILabel lab;
string s = ""; private float a;
// Use this for initialization
void Start () private string s = "";
// Use this for initialization
private void Start()
{ {
s = InterString.Get("等待对方行动中"); s = InterString.Get("等待对方行动中");
} }
float a = 0;
// Update is called once per frame // Update is called once per frame
void Update () { private void Update()
{
a += Time.deltaTime; a += Time.deltaTime;
string t = ""; var t = "";
for (int i = 0; i < (((int)(a * 60)) / 20) % 4; i++) for (var i = 0; i < (int) (a * 60) / 20 % 4; i++) t += InterString.Get("…");
{
t += InterString.Get("…");
}
lab.text = t + s + t; lab.text = t + s + t;
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class lazyBTNMOVER : MonoBehaviour {
public class lazyBTNMOVER : MonoBehaviour
{
public UILabel g1; public UILabel g1;
public UILabel g2; public UILabel g2;
public UILabel g3; public UILabel g3;
...@@ -47,4 +46,4 @@ public class lazyBTNMOVER : MonoBehaviour { ...@@ -47,4 +46,4 @@ public class lazyBTNMOVER : MonoBehaviour {
g5.text = "MP2"; g5.text = "MP2";
} }
} }
} }
\ No newline at end of file
using UnityEngine; using System;
using System.Collections; using UnityEngine;
using System;
public class phaser : MonoBehaviour {
public Action mp2Action;
public Action bpAction;
public Action epAction;
public class phaser : MonoBehaviour
{
public BoxCollider colliderMp2; public BoxCollider colliderMp2;
public BoxCollider colliderBp; public BoxCollider colliderBp;
public BoxCollider colliderEp; public BoxCollider colliderEp;
public UILabel labDp; public UILabel labDp;
public UILabel labSp; public UILabel labSp;
public UILabel labMp1; public UILabel labMp1;
public UILabel labBp; public UILabel labBp;
public UILabel labMp2; public UILabel labMp2;
public UILabel labEp; public UILabel labEp;
public Action bpAction;
public Action epAction;
public Action mp2Action;
// Use this for initialization // Use this for initialization
void Start () { private void Start()
{
} }
// Update is called once per frame // Update is called once per frame
void Update () { private void Update()
{
if (Program.InputGetMouseButtonUp_0) if (Program.InputGetMouseButtonUp_0)
{ {
if (Program.pointedCollider== colliderMp2) if (Program.pointedCollider == colliderMp2)
{ if (mp2Action != null)
if (mp2Action!=null)
{
mp2Action(); mp2Action();
}
}
if (Program.pointedCollider == colliderBp) if (Program.pointedCollider == colliderBp)
{
if (bpAction != null) if (bpAction != null)
{
bpAction(); bpAction();
}
}
if (Program.pointedCollider == colliderEp) if (Program.pointedCollider == colliderEp)
{
if (epAction != null) if (epAction != null)
{
epAction(); epAction();
}
}
} }
}
} }
} \ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class pngSord : MonoBehaviour { public class pngSord : MonoBehaviour
{
// Use this for initialization // Use this for initialization
void Start () { private void Start()
{
gameObject.GetComponent<Renderer>().material.mainTexture = GameTextureManager.attack; gameObject.GetComponent<Renderer>().material.mainTexture = GameTextureManager.attack;
gameObject.transform.localScale = new Vector3(1, 1f / (float)GameTextureManager.attack.width * (float)GameTextureManager.attack.height, 1); gameObject.transform.localScale =
new Vector3(1, 1f / GameTextureManager.attack.width * GameTextureManager.attack.height, 1);
} }
// Update is called once per frame // Update is called once per frame
void Update () { private void Update()
{
} }
} }
\ No newline at end of file
using UnityEngine; using System;
using UnityEngine;
using YGOSharp;
public class OpenCardOnClick : MonoBehaviour public class OpenCardOnClick : MonoBehaviour
{ {
void OnClick() private void OnClick()
{ {
UILabel lbl = GetComponent<UILabel>(); var lbl = GetComponent<UILabel>();
if (lbl != null) if (lbl != null)
{
try try
{ {
string s = lbl.GetUrlAtPosition(UICamera.lastWorldPosition); var s = lbl.GetUrlAtPosition(UICamera.lastWorldPosition);
if (string.IsNullOrEmpty(s)) if (string.IsNullOrEmpty(s)) return;
{ var code = int.Parse(s);
return; Program.I().cardDescription.setData(CardsManager.Get(code), GameTextureManager.myBack, "", true);
}
int code = int.Parse(s);
((CardDescription)(Program.I().cardDescription)).setData(YGOSharp.CardsManager.Get(code), GameTextureManager.myBack,"",true);
} }
catch (System.Exception e) catch (Exception e)
{ {
Debug.Log(e); Debug.Log(e);
} }
}
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class smartSelection : MonoBehaviour { public class smartSelection : MonoBehaviour
{
public UILabel name_lable; public UILabel name_lable;
public UITexture under_; public UITexture under_;
...@@ -10,24 +10,24 @@ public class smartSelection : MonoBehaviour { ...@@ -10,24 +10,24 @@ public class smartSelection : MonoBehaviour {
public GameObject obj; public GameObject obj;
public void setName(string s) public void setName(string s)
{ {
name_lable.text = s; name_lable.text = s;
} }
public void setSelected(bool s) public void setSelected(bool s)
{ {
under_.color = s ? Color.white : (new Color(0, 0, 0, 0)); under_.color = s ? Color.white : new Color(0, 0, 0, 0);
} }
public string getNmae() public string getNmae()
{ {
return name_lable.text; return name_lable.text;
} }
public void set_width(int width) public void set_width(int width)
{ {
int w = width + 80; var w = width + 80;
under_.width = w; under_.width = w;
collider.size = new Vector3(w, under_.height + 5, 1); collider.size = new Vector3(w, under_.height + 5, 1);
collider.center = new Vector3(0, -2.5f, 0); collider.center = new Vector3(0, -2.5f, 0);
...@@ -36,10 +36,7 @@ public class smartSelection : MonoBehaviour { ...@@ -36,10 +36,7 @@ public class smartSelection : MonoBehaviour {
public static void IselectedSetter(GameObject obj, bool selected) public static void IselectedSetter(GameObject obj, bool selected)
{ {
smartSelection smartSelection = obj.GetComponent<smartSelection>(); var smartSelection = obj.GetComponent<smartSelection>();
if (smartSelection != null) if (smartSelection != null) smartSelection.setSelected(selected);
{
smartSelection.setSelected(selected);
}
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class LAZYsetting : MonoBehaviour { public class LAZYsetting : MonoBehaviour
{
public UISlider sliderVolum; public UISlider sliderVolum;
public UISlider sliderSizeDrawing; public UISlider sliderSizeDrawing;
public UISlider sliderSize; public UISlider sliderSize;
...@@ -12,7 +12,7 @@ public class LAZYsetting : MonoBehaviour { ...@@ -12,7 +12,7 @@ public class LAZYsetting : MonoBehaviour {
public UIToggle closeUp; public UIToggle closeUp;
public UIToggle showoff; public UIToggle showoff;
public UIToggle showoffWhenActived; public UIToggle showoffWhenActived;
public UIToggle cloud; public UIToggle cloud;
public UIToggle Vbattle; public UIToggle Vbattle;
public UIToggle Vmove; public UIToggle Vmove;
public UIToggle Vchain; public UIToggle Vchain;
...@@ -42,12 +42,12 @@ public class LAZYsetting : MonoBehaviour { ...@@ -42,12 +42,12 @@ public class LAZYsetting : MonoBehaviour {
public UIToggle spyer; public UIToggle spyer;
// Use this for initialization // Use this for initialization
void Start () { private void Start()
{
} }
// Update is called once per frame // Update is called once per frame
void Update () { private void Update()
{
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class YGO1superShower : MonoBehaviour { public class YGO1superShower : MonoBehaviour
{
public UITexture card; public UITexture card;
public UITexture closeup; public UITexture closeup;
// Use this for initialization // Use this for initialization
void Start () { private void Start()
{
} }
// Update is called once per frame // Update is called once per frame
void Update () { private void Update()
{
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
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;
...@@ -19,4 +19,4 @@ public class pro1CardShower : MonoBehaviour { ...@@ -19,4 +19,4 @@ public class pro1CardShower : MonoBehaviour {
t.duration = 0.7f; t.duration = 0.7f;
t.enabled = true; t.enabled = true;
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class rotatotr : MonoBehaviour { public class rotatotr : MonoBehaviour
{
// Use this for initialization // Use this for initialization
void Start () { private void Start()
{
} }
// Update is called once per frame // Update is called once per frame
void Update() private void Update()
{ {
transform.Rotate(Vector3.forward * Time.deltaTime * 80); transform.Rotate(Vector3.forward * Time.deltaTime * 80);
} }
} }
\ No newline at end of file
 using UnityEngine;
using UnityEngine;
using System.Collections;
public class AnimUnit : MonoBehaviour public class AnimUnit : MonoBehaviour
{ {
public float m_fspeed = 1; public float m_fspeed = 1;
private MegaWorldPathDeform m_kMWPD = null;
private MegaShapeArc m_kShapeArc = null; private float m_fAccumAnimOffset;
private float m_fAccumAnimOffset = 0.0f; private readonly float m_fArrowHeadLenth = 0.57f;
private float m_fArrowHeadLenth = 0.57f;
//private float m_fRGB = 1/255.0f; //private float m_fRGB = 1/255.0f;
private float m_fHigh = 1.0f; //画线高度定值 --CardGame private readonly float m_fHigh = 1.0f; //画线高度定值 --CardGame
void Start() private MegaWorldPathDeform m_kMWPD;
{ private MegaShapeArc m_kShapeArc;
m_kMWPD = GetComponent<MegaWorldPathDeform> ();
m_fAccumAnimOffset = m_kMWPD.Offset.z; private void Start()
//Debug.Log ("offset val is " + m_kAccumAnimOffset + " when init"); {
m_kMWPD = GetComponent<MegaWorldPathDeform>();
// this.gameObject.renderer.material = m_fAccumAnimOffset = m_kMWPD.Offset.z;
// new Material(Shader.Find("Custom/CardSeriesShader")); //Debug.Log ("offset val is " + m_kAccumAnimOffset + " when init");
// this.gameObject.renderer.material.mainTexture=(Texture)Resources.Load("Texture/arrow");
// this.gameObject.renderer.material =
//Color color = new Color(141* m_fRGB, m_fRGB, m_fRGB); // new Material(Shader.Find("Custom/CardSeriesShader"));
//this.gameObject.renderer.material.SetColor("_BlendColor",color); // this.gameObject.renderer.material.mainTexture=(Texture)Resources.Load("Texture/arrow");
this.gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha",0);
} //Color color = new Color(141* m_fRGB, m_fRGB, m_fRGB);
//this.gameObject.renderer.material.SetColor("_BlendColor",color);
void Update() gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", 0);
{ }
private void Update()
{
// float fnowoffset = m_kShapeArc.GetCurveLength (0) - m_fAccumAnimOffset; // float fnowoffset = m_kShapeArc.GetCurveLength (0) - m_fAccumAnimOffset;
// //
// float linelenth = (m_kShapeArc.GetCurveLength (0) - (m_fArrowHeadLenth*0.04f)/2 + 0.764f)/5; // float linelenth = (m_kShapeArc.GetCurveLength (0) - (m_fArrowHeadLenth*0.04f)/2 + 0.764f)/5;
...@@ -53,37 +51,23 @@ public class AnimUnit : MonoBehaviour ...@@ -53,37 +51,23 @@ public class AnimUnit : MonoBehaviour
// { // {
// this.gameObject.renderer.material.SetFloat("_Alpha",0); // this.gameObject.renderer.material.SetFloat("_Alpha",0);
// } // }
} }
// void AlphaSet()
// {
// m_kShapeArc.GetCurveLength (0);
// }
public void SetAllAlphaZero()
{
this.gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha",0);
}
private void FixedUpdate()
{
if (m_kShapeArc == null) return;
void FixedUpdate() m_fAccumAnimOffset += -m_fspeed * Time.deltaTime;
{ //if (m_fAccumAnimOffset >= m_kShapeArc.GetCurveLength (0)-(m_fArrowHeadLenth*0.02f)/2 - 0.382f)
if (m_kShapeArc == null) if (m_fAccumAnimOffset <= m_fArrowHeadLenth * 0.04f / 2 + 0.764f)
{ {
return; //m_fAccumAnimOffset = 0.0f;
} gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", 0);
m_kShapeArc.GetComponent<LoopPathAnim>().moveToTail(m_kMWPD);
}
m_fAccumAnimOffset += -m_fspeed * Time.deltaTime; m_kMWPD.Offset.z = m_fAccumAnimOffset;
//if (m_fAccumAnimOffset >= m_kShapeArc.GetCurveLength (0)-(m_fArrowHeadLenth*0.02f)/2 - 0.382f)
if (m_fAccumAnimOffset <= (m_fArrowHeadLenth*0.04f)/2 + 0.764f)
{
//m_fAccumAnimOffset = 0.0f;
this.gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha",0);
m_kShapeArc.GetComponent<LoopPathAnim>().moveToTail(m_kMWPD);
}
m_kMWPD.Offset.z = m_fAccumAnimOffset;
// float linelenth = (m_kShapeArc.GetCurveLength (0) - (m_fArrowHeadLenth*0.04f)/2 + 0.764f)/5; // float linelenth = (m_kShapeArc.GetCurveLength (0) - (m_fArrowHeadLenth*0.04f)/2 + 0.764f)/5;
// float lineMax = m_kShapeArc.GetCurveLength (0); // float lineMax = m_kShapeArc.GetCurveLength (0);
...@@ -105,38 +89,37 @@ public class AnimUnit : MonoBehaviour ...@@ -105,38 +89,37 @@ public class AnimUnit : MonoBehaviour
// } // }
float fnowoffset = m_kShapeArc.GetCurveLength (0) - m_fAccumAnimOffset; var fnowoffset = m_kShapeArc.GetCurveLength(0) - m_fAccumAnimOffset;
float linelenth = (m_fArrowHeadLenth*0.04f)/2 + 0.764f; var linelenth = m_fArrowHeadLenth * 0.04f / 2 + 0.764f;
if(fnowoffset>0&&fnowoffset<= m_fHigh) if (fnowoffset > 0 && fnowoffset <= m_fHigh)
{ {
this.gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha",fnowoffset/m_fHigh); gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", fnowoffset / m_fHigh);
} }
else if(fnowoffset>m_fHigh && fnowoffset<=m_kShapeArc.GetCurveLength (0) - m_fHigh - linelenth) else if (fnowoffset > m_fHigh && fnowoffset <= m_kShapeArc.GetCurveLength(0) - m_fHigh - linelenth)
{ {
this.gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha",0.7f); gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", 0.7f);
} }
else if(fnowoffset>m_kShapeArc.GetCurveLength (0) - m_fHigh - linelenth && fnowoffset<=m_kShapeArc.GetCurveLength (0)) else if (fnowoffset > m_kShapeArc.GetCurveLength(0) - m_fHigh - linelenth &&
{ fnowoffset <= m_kShapeArc.GetCurveLength(0))
float f = (1 - ((fnowoffset - m_kShapeArc.GetCurveLength(0) + m_fHigh + linelenth) / m_fHigh)) * 0.7f; {
var f = (1 - (fnowoffset - m_kShapeArc.GetCurveLength(0) + m_fHigh + linelenth) / m_fHigh) * 0.7f;
//if (f > 0.05f) //if (f > 0.05f)
//{ //{
// f = 1; // f = 1;
//} //}
this.gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha",f); gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", f);
} }
else else
{ {
this.gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha",0); gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", 0);
} }
//float linelenth = m_kShapeArc.GetCurveLength (0)/5; //float linelenth = m_kShapeArc.GetCurveLength (0)/5;
//设置alpha //设置alpha
// if(fnowoffset>0&&fnowoffset<= linelenth) // if(fnowoffset>0&&fnowoffset<= linelenth)
// { // {
// this.gameObject.renderer.material.SetFloat("_Alpha",fnowoffset/linelenth); // this.gameObject.renderer.material.SetFloat("_Alpha",fnowoffset/linelenth);
...@@ -153,21 +136,31 @@ public class AnimUnit : MonoBehaviour ...@@ -153,21 +136,31 @@ public class AnimUnit : MonoBehaviour
// { // {
// this.gameObject.renderer.material.SetFloat("_Alpha",0); // this.gameObject.renderer.material.SetFloat("_Alpha",0);
// } // }
} }
public void setMegaShape(MegaShapeArc msa)
{ // void AlphaSet()
m_kShapeArc = msa; // {
} // m_kShapeArc.GetCurveLength (0);
// }
public float getAccumOffset()
{
return m_fAccumAnimOffset;
}
public void setAccumOffset(float val)
{
m_fAccumAnimOffset = val;
}
}
public void SetAllAlphaZero()
{
gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", 0);
}
public void setMegaShape(MegaShapeArc msa)
{
m_kShapeArc = msa;
}
public float getAccumOffset()
{
return m_fAccumAnimOffset;
}
public void setAccumOffset(float val)
{
m_fAccumAnimOffset = val;
}
}
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class LoopMegaCtrl : MonoBehaviour
public class LoopMegaCtrl : MonoBehaviour { {
public GameObject Path;
// Use this for initialization public int m_iID;
private float m_offsetZ; public GameObject m_kFirstOb;
private float m_offsetpercent; public int m_iCount;
private float m_pathLenth; private bool m_bneedtoFollow = true;
public GameObject Path = null; private float m_fBeforeLenth;
float m_ObjectLenth; private float m_ObjectLenth;
float m_fBeforeLenth = 0.0f; private float m_offsetpercent;
public int m_iID;
public GameObject m_kFirstOb = null; // Use this for initialization
bool m_bneedtoFollow = true; private float m_offsetZ;
public int m_iCount = 0; private float m_pathLenth;
void Start () {
//物体长度 --CardGame private void Start()
m_ObjectLenth = 0.9f*0.02f; {
//this.GetComponent<MegaWorldPathDeform>().animate = false; //物体长度 --CardGame
//this.GetComponent<MegaWorldPathDeform>().percent = 0; m_ObjectLenth = 0.9f * 0.02f;
} //this.GetComponent<MegaWorldPathDeform>().animate = false;
//this.GetComponent<MegaWorldPathDeform>().percent = 0;
// Update is called once per frame }
void Update () {
// Update is called once per frame
private void Update()
} {
}
void LateUpdate()
{ private void LateUpdate()
LoopMegaAntmation(); {
} LoopMegaAntmation();
}
void LoopMegaAntmation()
{ private void LoopMegaAntmation()
{
//if(m_offsetZ>0) //if(m_offsetZ>0)
//{ //{
//获得线段长度 --CardGame //获得线段长度 --CardGame
if(m_bneedtoFollow && m_kFirstOb!=null ) if (m_bneedtoFollow && m_kFirstOb != null)
{ {
this.GetComponent<MegaWorldPathDeform>().percent = m_kFirstOb.GetComponent<MegaWorldPathDeform>().percent; GetComponent<MegaWorldPathDeform>().percent = m_kFirstOb.GetComponent<MegaWorldPathDeform>().percent;
m_bneedtoFollow = false; m_bneedtoFollow = false;
} }
// if(m_iCount>=5) // if(m_iCount>=5)
// { // {
...@@ -51,8 +51,7 @@ public class LoopMegaCtrl : MonoBehaviour { ...@@ -51,8 +51,7 @@ public class LoopMegaCtrl : MonoBehaviour {
// } // }
m_pathLenth = Path.GetComponent<MegaShapeArc>().GetCurveLength(0);
m_pathLenth=Path.GetComponent<MegaShapeArc>().GetCurveLength(0);
// if(m_fBeforeLenth>m_pathLenth) // if(m_fBeforeLenth>m_pathLenth)
// { // {
...@@ -70,37 +69,31 @@ public class LoopMegaCtrl : MonoBehaviour { ...@@ -70,37 +69,31 @@ public class LoopMegaCtrl : MonoBehaviour {
// { // {
// this.GetComponent<MegaWorldPathDeform>().animate = true; // this.GetComponent<MegaWorldPathDeform>().animate = true;
// } // }
m_fBeforeLenth = m_pathLenth; m_fBeforeLenth = m_pathLenth;
m_offsetZ = -this.GetComponent<MegaWorldPathDeform>().Offset.z; m_offsetZ = -GetComponent<MegaWorldPathDeform>().Offset.z;
m_offsetpercent = ((m_ObjectLenth + m_offsetZ)/m_pathLenth)*100; m_offsetpercent = (m_ObjectLenth + m_offsetZ) / m_pathLenth * 100;
//Debug.Log(this.name+":" + m_offsetpercent); //Debug.Log(this.name+":" + m_offsetpercent);
this.GetComponent<MegaWorldPathDeform>().path = Path.GetComponent<MegaShapeArc>(); GetComponent<MegaWorldPathDeform>().path = Path.GetComponent<MegaShapeArc>();
if(this.GetComponent<MegaWorldPathDeform>().percent >= 100+m_offsetpercent) if (GetComponent<MegaWorldPathDeform>().percent >= 100 + m_offsetpercent)
{ {
//调整位置方法 --CardGame
if (m_kFirstOb != null)
{
//调整位置方法 --CardGame Debug.Log("else follow first");
if(m_kFirstOb!=null)
{ GetComponent<MegaWorldPathDeform>().percent = m_kFirstOb.GetComponent<MegaWorldPathDeform>().percent;
Debug.Log ("else follow first"); m_bneedtoFollow = true;
}
this.GetComponent<MegaWorldPathDeform>().percent = m_kFirstOb.GetComponent<MegaWorldPathDeform>().percent; else
m_bneedtoFollow = true; {
Debug.Log("first to 0");
} GetComponent<MegaWorldPathDeform>().percent = 0;
else }
{ }
Debug.Log ("first to 0"); }
this.GetComponent<MegaWorldPathDeform>().percent = 0; }
\ No newline at end of file
}
}
}
}
 using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class LoopPathAnim : MonoBehaviour public class LoopPathAnim : MonoBehaviour
{ {
public List<MegaWorldPathDeform> m_kMWPD_List =
new List<MegaWorldPathDeform>();
public float m_fOffsetValueStep = 1.0f;
// public GameObject m_kStartObject = null; // public GameObject m_kStartObject = null;
// public GameObject m_kEndObject = null; // public GameObject m_kEndObject = null;
private MegaShapeArc m_kShapeArc = null; private MegaShapeArc m_kShapeArc;
public List<MegaWorldPathDeform> m_kMWPD_List =
new List<MegaWorldPathDeform>();
public float m_fOffsetValueStep = 1.0f;
void Start () private void Start()
{ {
m_kShapeArc = GetComponent<MegaShapeArc> (); m_kShapeArc = GetComponent<MegaShapeArc>();
// m_kStartObject.transform.position = m_kShapeArc.splines [0].knots [0].p; // m_kStartObject.transform.position = m_kShapeArc.splines [0].knots [0].p;
// m_kEndObject.transform.position = // m_kEndObject.transform.position =
// m_kShapeArc.splines [0].knots[ m_kShapeArc.splines [0].knots.Count-1 ].p; // m_kShapeArc.splines [0].knots[ m_kShapeArc.splines [0].knots.Count-1 ].p;
foreach(MegaWorldPathDeform iter in m_kMWPD_List) foreach (var iter in m_kMWPD_List)
{ if (iter.GetComponent<AnimUnit>())
if( iter.GetComponent<AnimUnit>() ) iter.GetComponent<AnimUnit>().setMegaShape(m_kShapeArc);
{ //Debug.Log("set shaps...");
iter.GetComponent<AnimUnit>().setMegaShape(m_kShapeArc); }
//Debug.Log("set shaps...");
}
}
}
void Update ()
{
} private void Update()
{
}
void LateUpdate() private void LateUpdate()
{ {
// m_kShapeArc.splines [0].knots [0].p = m_kStartObject.transform.position; // m_kShapeArc.splines [0].knots [0].p = m_kStartObject.transform.position;
// //
// m_kShapeArc.splines [0].knots [m_kShapeArc.splines [0].knots.Count - 1].p = // m_kShapeArc.splines [0].knots [m_kShapeArc.splines [0].knots.Count - 1].p =
// m_kEndObject.transform.position; // m_kEndObject.transform.position;
} }
//得到曲线路径长度 --CardGame //得到曲线路径长度 --CardGame
public float getShapeLen() public float getShapeLen()
{ {
return m_kShapeArc.GetCurveLength(0); return m_kShapeArc.GetCurveLength(0);
} }
//添加到箭头组成尾部 --CardGame //添加到箭头组成尾部 --CardGame
public void moveToTail(MegaWorldPathDeform mwpd) public void moveToTail(MegaWorldPathDeform mwpd)
{ {
if( m_kMWPD_List.Contains(mwpd) ) if (m_kMWPD_List.Contains(mwpd))
{ {
float val = var val =
m_kMWPD_List[m_kMWPD_List.Count-1]. m_kMWPD_List[m_kMWPD_List.Count - 1].GetComponent<AnimUnit>().getAccumOffset() + m_fOffsetValueStep;
GetComponent<AnimUnit>().getAccumOffset() + m_fOffsetValueStep; mwpd.GetComponent<AnimUnit>().setAccumOffset(val);
mwpd.GetComponent<AnimUnit>().setAccumOffset(val);
m_kMWPD_List.Remove(mwpd);
m_kMWPD_List.Remove(mwpd); m_kMWPD_List.Add(mwpd);
m_kMWPD_List.Add(mwpd); }
} }
} }
\ No newline at end of file
}
using UnityEngine; using UnityEngine;
using System.Collections;
public class RendMega : MonoBehaviour { public class RendMega : MonoBehaviour
{
public Vector3 StartPosition = Vector3.zero;
public Vector3 FingerPosition = Vector3.zero;
public Transform SkillPosition;
public Transform SkillPositionForm;
public GameObject m_kPath;
public Vector3 StartPosition = Vector3.zero;
public Vector3 FingerPosition = Vector3.zero;
public Transform SkillPosition = null;
public Transform SkillPositionForm = null;
public GameObject m_kPath = null;
public float k = 3f; public float k = 3f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update()
{
MyRenderPath(); // Use this for initialization
private void Start()
{
}
} // Update is called once per frame
private void Update()
{
MyRenderPath();
}
public void MyRenderPath() public void MyRenderPath()
{ {
m_kPath.transform.localScale = new Vector3(k, k, k); m_kPath.transform.localScale = new Vector3(k, k, k);
Vector3 v3FromPos = SkillPosition.position/k; var v3FromPos = SkillPosition.position / k;
Vector3 v3TargetPos = SkillPositionForm.position/k; var v3TargetPos = SkillPositionForm.position / k;
Vector3 v3MidPos = (v3FromPos + v3TargetPos)/2; var v3MidPos = (v3FromPos + v3TargetPos) / 2;
v3MidPos += new Vector3(0, Vector3.Distance(v3TargetPos, v3FromPos) / 10f * 3f, 0); v3MidPos += new Vector3(0, Vector3.Distance(v3TargetPos, v3FromPos) / 10f * 3f, 0);
v3MidPos += (v3TargetPos - v3FromPos) / 10f * 3f; v3MidPos += (v3TargetPos - v3FromPos) / 10f * 3f;
Vector3 V3Midvect = (v3TargetPos - v3FromPos)/4; var V3Midvect = (v3TargetPos - v3FromPos) / 4;
Vector3 v3FromAnchorIn = v3FromPos+new Vector3(0,-(v3MidPos.y/3),0) ; var v3FromAnchorIn = v3FromPos + new Vector3(0, -(v3MidPos.y / 3), 0);
//Vector3 v3FromAnchorOut = v3FromPos+new Vector3(0,(v3MidPos.y/3),0) ; //Vector3 v3FromAnchorOut = v3FromPos+new Vector3(0,(v3MidPos.y/3),0) ;
Vector3 v3FromAnchorOut = v3FromPos + V3Midvect; var v3FromAnchorOut = v3FromPos + V3Midvect;
//Vector3 v3TarGetAnchorIn = v3TargetPos +new Vector3(0,(v3MidPos.y/3),0) ; //Vector3 v3TarGetAnchorIn = v3TargetPos +new Vector3(0,(v3MidPos.y/3),0) ;
Vector3 v3TarGetAnchorIn = v3TargetPos + new Vector3(0, (v3MidPos.y / 3), 0) - V3Midvect/10; var v3TarGetAnchorIn = v3TargetPos + new Vector3(0, v3MidPos.y / 3, 0) - V3Midvect / 10;
Vector3 v3TarGetAnchorOut = v3TargetPos + new Vector3(0, -(v3MidPos.y / 3), 0); var v3TarGetAnchorOut = v3TargetPos + new Vector3(0, -(v3MidPos.y / 3), 0);
Vector3 v3MidAnchorIn = v3MidPos - V3Midvect; var v3MidAnchorIn = v3MidPos - V3Midvect;
Vector3 v3MidAnchorOut = v3MidPos + V3Midvect ; var v3MidAnchorOut = v3MidPos + V3Midvect;
m_kPath.GetComponent<MegaShapeArc>().SetKnotEx(0, 0, v3FromPos, v3FromAnchorIn, v3FromAnchorOut);
m_kPath.GetComponent<MegaShapeArc>().SetKnotEx(0,0,v3FromPos,v3FromAnchorIn,v3FromAnchorOut); m_kPath.GetComponent<MegaShapeArc>().SetKnotEx(0, 1, v3MidPos, v3MidAnchorIn, v3MidAnchorOut);
m_kPath.GetComponent<MegaShapeArc>().SetKnotEx(0,1,v3MidPos,v3MidAnchorIn,v3MidAnchorOut); m_kPath.GetComponent<MegaShapeArc>().SetKnotEx(0, 2, v3TargetPos, v3TarGetAnchorIn, v3TarGetAnchorOut);
m_kPath.GetComponent<MegaShapeArc>().SetKnotEx(0,2,v3TargetPos,v3TarGetAnchorIn,v3TarGetAnchorOut); }
}
} \ No newline at end of file
}
using UnityEngine; using UnityEngine;
using System.Collections;
public class arrowCtrl : MonoBehaviour { public class arrowCtrl : MonoBehaviour
{
public GameObject[] m_karrow;
public GameObject[] m_karrow; // Use this for initialization
// Use this for initialization private void Start()
void Start () { {
}
}
public void AllAlphaZero()
{
for(int i = 0;i<m_karrow.Length;i++)
{
if(m_karrow[i].GetComponent<AnimUnit>()!=null)
{
m_karrow[i].GetComponent<AnimUnit>().SetAllAlphaZero();
}
}
}
} public void AllAlphaZero()
{
for (var i = 0; i < m_karrow.Length; i++)
if (m_karrow[i].GetComponent<AnimUnit>() != null)
m_karrow[i].GetComponent<AnimUnit>().SetAllAlphaZero();
}
}
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class blinding : MonoBehaviour { public class blinding : MonoBehaviour
{
// Use this for initialization
private void Start()
{
}
// Use this for initialization // Update is called once per frame
void Start () { private void Update()
{
} gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", (1f + Mathf.Sin(Time.time * 10)) / 2f);
// Update is called once per frame
void Update () {
this.gameObject.GetComponent<Renderer>().material.SetFloat("_Alpha", (1f + Mathf.Sin(Time.time*10)) / 2f);
} }
} }
\ No newline at end of file
fileFormatVersion: 2
guid: b71b024f995aa0843a87af2b3fae595e
folderAsset: yes
timeCreated: 1482167356
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine; using UnityEngine;
using System.Collections;
public class arrow : MonoBehaviour { public class arrow : MonoBehaviour
{
public float speed = 1; public float speed = 1;
public Transform from; public Transform from;
public Transform to; public Transform to;
public RendMega mega; public RendMega mega;
public MegaShapeArc arc; public MegaShapeArc arc;
// Use this for initialization // Use this for initialization
void Start () private void Start()
{ {
updateSpeed(); updateSpeed();
} }
// Update is called once per frame
private void Update()
{
}
public void updateSpeed() public void updateSpeed()
{ {
var list = GetComponentsInChildren<AnimUnit>(); var list = GetComponentsInChildren<AnimUnit>();
foreach (var item in list) foreach (var item in list) item.m_fspeed = speed;
{
item.m_fspeed = speed;
}
} }
}
// Update is called once per frame \ No newline at end of file
void Update () {
}
}
 using UnityEngine;
using UnityEngine;
using System.Collections;
//设置在编辑模式下也执行该脚本 //设置在编辑模式下也执行该脚本
[ExecuteInEditMode] [ExecuteInEditMode]
...@@ -8,11 +6,32 @@ using System.Collections; ...@@ -8,11 +6,32 @@ using System.Collections;
[AddComponentMenu("Learning Unity Shader/Lecture 15/RapidBlurEffect")] [AddComponentMenu("Learning Unity Shader/Lecture 15/RapidBlurEffect")]
public class RapidBlurEffect : MonoBehaviour public class RapidBlurEffect : MonoBehaviour
{ {
//-------------------------材质的get&set----------------------------
#region MaterialGetAndSet
private Material material
{
get
{
if (CurMaterial == null)
{
CurMaterial = new Material(CurShader);
CurMaterial.hideFlags = HideFlags.HideAndDontSave;
}
return CurMaterial;
}
}
#endregion
//-------------------变量声明部分------------------- //-------------------变量声明部分-------------------
#region Variables #region Variables
//指定Shader名称 //指定Shader名称
private string ShaderName = "Learning Unity Shader/Lecture 15/RapidBlurEffect"; private readonly string ShaderName = "Learning Unity Shader/Lecture 15/RapidBlurEffect";
//着色器和材质实例 //着色器和材质实例
public Shader CurShader; public Shader CurShader;
...@@ -24,38 +43,25 @@ public class RapidBlurEffect : MonoBehaviour ...@@ -24,38 +43,25 @@ public class RapidBlurEffect : MonoBehaviour
public static int ChangeValue3; public static int ChangeValue3;
//降采样次数 //降采样次数
[Range(0, 6), Tooltip("[降采样次数]向下采样的次数。此值越大,则采样间隔越大,需要处理的像素点越少,运行速度越快。")] [Range(0, 6)] [Tooltip("[降采样次数]向下采样的次数。此值越大,则采样间隔越大,需要处理的像素点越少,运行速度越快。")]
public int DownSampleNum = 2; public int DownSampleNum = 2;
//模糊扩散度 //模糊扩散度
[Range(0.0f, 20.0f), Tooltip("[模糊扩散度]进行高斯模糊时,相邻像素点的间隔。此值越大相邻像素间隔越远,图像越模糊。但过大的值会导致失真。")] [Range(0.0f, 20.0f)] [Tooltip("[模糊扩散度]进行高斯模糊时,相邻像素点的间隔。此值越大相邻像素间隔越远,图像越模糊。但过大的值会导致失真。")]
public float BlurSpreadSize = 3.0f; public float BlurSpreadSize = 3.0f;
//迭代次数 //迭代次数
[Range(0, 8), Tooltip("[迭代次数]此值越大,则模糊操作的迭代次数越多,模糊效果越好,但消耗越大。")] [Range(0, 8)] [Tooltip("[迭代次数]此值越大,则模糊操作的迭代次数越多,模糊效果越好,但消耗越大。")]
public int BlurIterations = 3; public int BlurIterations = 3;
#endregion #endregion
//-------------------------材质的get&set----------------------------
#region MaterialGetAndSet
Material material
{
get
{
if (CurMaterial == null)
{
CurMaterial = new Material(CurShader);
CurMaterial.hideFlags = HideFlags.HideAndDontSave;
}
return CurMaterial;
}
}
#endregion
#region Functions #region Functions
//-----------------------------------------【Start()函数】--------------------------------------------- //-----------------------------------------【Start()函数】---------------------------------------------
// 说明:此函数仅在Update函数第一次被调用前被调用 // 说明:此函数仅在Update函数第一次被调用前被调用
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------
void Start() private void Start()
{ {
//依次赋值 //依次赋值
ChangeValue = DownSampleNum; ChangeValue = DownSampleNum;
...@@ -69,55 +75,54 @@ public class RapidBlurEffect : MonoBehaviour ...@@ -69,55 +75,54 @@ public class RapidBlurEffect : MonoBehaviour
if (!SystemInfo.supportsImageEffects) if (!SystemInfo.supportsImageEffects)
{ {
enabled = false; enabled = false;
return;
} }
} }
//-------------------------------------【OnRenderImage()函数】------------------------------------ //-------------------------------------【OnRenderImage()函数】------------------------------------
// 说明:此函数在当完成所有渲染图片后被调用,用来渲染图片后期效果 // 说明:此函数在当完成所有渲染图片后被调用,用来渲染图片后期效果
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------
void OnRenderImage(RenderTexture sourceTexture, RenderTexture destTexture) private void OnRenderImage(RenderTexture sourceTexture, RenderTexture destTexture)
{ {
//着色器实例不为空,就进行参数设置 //着色器实例不为空,就进行参数设置
if (CurShader != null) if (CurShader != null)
{ {
//【0】参数准备 //【0】参数准备
//根据向下采样的次数确定宽度系数。用于控制降采样后相邻像素的间隔 //根据向下采样的次数确定宽度系数。用于控制降采样后相邻像素的间隔
float widthMod = 1.0f / (1.0f * (1 << DownSampleNum)); var widthMod = 1.0f / (1.0f * (1 << DownSampleNum));
//Shader的降采样参数赋值 //Shader的降采样参数赋值
material.SetFloat("_DownSampleValue", BlurSpreadSize * widthMod); material.SetFloat("_DownSampleValue", BlurSpreadSize * widthMod);
//设置渲染模式:双线性 //设置渲染模式:双线性
sourceTexture.filterMode = FilterMode.Bilinear; sourceTexture.filterMode = FilterMode.Bilinear;
//通过右移,准备长、宽参数值 //通过右移,准备长、宽参数值
int renderWidth = sourceTexture.width >> DownSampleNum; var renderWidth = sourceTexture.width >> DownSampleNum;
int renderHeight = sourceTexture.height >> DownSampleNum; var renderHeight = sourceTexture.height >> DownSampleNum;
// 【1】处理Shader的通道0,用于降采样 ||Pass 0,for down sample // 【1】处理Shader的通道0,用于降采样 ||Pass 0,for down sample
//准备一个缓存renderBuffer,用于准备存放最终数据 //准备一个缓存renderBuffer,用于准备存放最终数据
RenderTexture renderBuffer = RenderTexture.GetTemporary(renderWidth, renderHeight, 0, sourceTexture.format); var renderBuffer = RenderTexture.GetTemporary(renderWidth, renderHeight, 0, sourceTexture.format);
//设置渲染模式:双线性 //设置渲染模式:双线性
renderBuffer.filterMode = FilterMode.Bilinear; renderBuffer.filterMode = FilterMode.Bilinear;
//拷贝sourceTexture中的渲染数据到renderBuffer,并仅绘制指定的pass0的纹理数据 //拷贝sourceTexture中的渲染数据到renderBuffer,并仅绘制指定的pass0的纹理数据
Graphics.Blit(sourceTexture, renderBuffer, material, 0); Graphics.Blit(sourceTexture, renderBuffer, material, 0);
//【2】根据BlurIterations(迭代次数),来进行指定次数的迭代操作 //【2】根据BlurIterations(迭代次数),来进行指定次数的迭代操作
for (int i = 0; i < BlurIterations; i++) for (var i = 0; i < BlurIterations; i++)
{ {
//【2.1】Shader参数赋值 //【2.1】Shader参数赋值
//迭代偏移量参数 //迭代偏移量参数
float iterationOffs = (i * 1.0f); var iterationOffs = i * 1.0f;
//Shader的降采样参数赋值 //Shader的降采样参数赋值
material.SetFloat("_DownSampleValue", BlurSpreadSize * widthMod + iterationOffs); material.SetFloat("_DownSampleValue", BlurSpreadSize * widthMod + iterationOffs);
// 【2.2】处理Shader的通道1,垂直方向模糊处理 || Pass1,for vertical blur // 【2.2】处理Shader的通道1,垂直方向模糊处理 || Pass1,for vertical blur
// 定义一个临时渲染的缓存tempBuffer // 定义一个临时渲染的缓存tempBuffer
RenderTexture tempBuffer = RenderTexture.GetTemporary(renderWidth, renderHeight, 0, sourceTexture.format); var tempBuffer = RenderTexture.GetTemporary(renderWidth, renderHeight, 0, sourceTexture.format);
// 拷贝renderBuffer中的渲染数据到tempBuffer,并仅绘制指定的pass1的纹理数据 // 拷贝renderBuffer中的渲染数据到tempBuffer,并仅绘制指定的pass1的纹理数据
Graphics.Blit(renderBuffer, tempBuffer, material, 1); Graphics.Blit(renderBuffer, tempBuffer, material, 1);
// 清空renderBuffer // 清空renderBuffer
RenderTexture.ReleaseTemporary(renderBuffer); RenderTexture.ReleaseTemporary(renderBuffer);
// 将tempBuffer赋给renderBuffer,此时renderBuffer里面pass0和pass1的数据已经准备好 // 将tempBuffer赋给renderBuffer,此时renderBuffer里面pass0和pass1的数据已经准备好
renderBuffer = tempBuffer; renderBuffer = tempBuffer;
// 【2.3】处理Shader的通道2,竖直方向模糊处理 || Pass2,for horizontal blur // 【2.3】处理Shader的通道2,竖直方向模糊处理 || Pass2,for horizontal blur
// 获取临时渲染纹理 // 获取临时渲染纹理
...@@ -136,7 +141,6 @@ public class RapidBlurEffect : MonoBehaviour ...@@ -136,7 +141,6 @@ public class RapidBlurEffect : MonoBehaviour
Graphics.Blit(renderBuffer, destTexture); Graphics.Blit(renderBuffer, destTexture);
//清空renderBuffer //清空renderBuffer
RenderTexture.ReleaseTemporary(renderBuffer); RenderTexture.ReleaseTemporary(renderBuffer);
} }
//着色器实例为空,直接拷贝屏幕上的效果。此情况下是没有实现屏幕特效的 //着色器实例为空,直接拷贝屏幕上的效果。此情况下是没有实现屏幕特效的
...@@ -151,7 +155,7 @@ public class RapidBlurEffect : MonoBehaviour ...@@ -151,7 +155,7 @@ public class RapidBlurEffect : MonoBehaviour
//-----------------------------------------【OnValidate()函数】-------------------------------------- //-----------------------------------------【OnValidate()函数】--------------------------------------
// 说明:此函数在编辑器中该脚本的某个值发生了改变后被调用 // 说明:此函数在编辑器中该脚本的某个值发生了改变后被调用
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------
void OnValidate() private void OnValidate()
{ {
//将编辑器中的值赋值回来,确保在编辑器中值的改变立刻让结果生效 //将编辑器中的值赋值回来,确保在编辑器中值的改变立刻让结果生效
ChangeValue = DownSampleNum; ChangeValue = DownSampleNum;
...@@ -162,7 +166,7 @@ public class RapidBlurEffect : MonoBehaviour ...@@ -162,7 +166,7 @@ public class RapidBlurEffect : MonoBehaviour
//-----------------------------------------【Update()函数】-------------------------------------- //-----------------------------------------【Update()函数】--------------------------------------
// 说明:此函数每帧都会被调用 // 说明:此函数每帧都会被调用
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------
void Update() private void Update()
{ {
//若程序在运行,进行赋值 //若程序在运行,进行赋值
if (Application.isPlaying) if (Application.isPlaying)
...@@ -174,27 +178,19 @@ public class RapidBlurEffect : MonoBehaviour ...@@ -174,27 +178,19 @@ public class RapidBlurEffect : MonoBehaviour
} }
//若程序没有在运行,去寻找对应的Shader文件 //若程序没有在运行,去寻找对应的Shader文件
#if UNITY_EDITOR #if UNITY_EDITOR
if (Application.isPlaying != true) if (Application.isPlaying != true) CurShader = Shader.Find(ShaderName);
{
CurShader = Shader.Find(ShaderName);
}
#endif #endif
} }
//-----------------------------------------【OnDisable()函数】--------------------------------------- //-----------------------------------------【OnDisable()函数】---------------------------------------
// 说明:当对象变为不可用或非激活状态时此函数便被调用 // 说明:当对象变为不可用或非激活状态时此函数便被调用
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------
void OnDisable() private void OnDisable()
{ {
if (CurMaterial) if (CurMaterial)
{
//立即销毁材质实例 //立即销毁材质实例
DestroyImmediate(CurMaterial); DestroyImmediate(CurMaterial);
}
} }
#endregion #endregion
} }
\ No newline at end of file
using UnityEngine; using System;
using System.Collections; using UnityEngine;
public class UImouseHint : MonoBehaviour { public class UImouseHint : MonoBehaviour
{
public GameObject point; public GameObject point;
public Camera cam; public Camera cam;
// Use this for initialization
void Start () {
private bool drag;
// Use this for initialization
private void Start()
{
try try
{ {
cam = gameObject.transform.GetComponentInParent<UIRoot>().GetComponentInChildren<Camera>(); cam = gameObject.transform.GetComponentInParent<UIRoot>().GetComponentInChildren<Camera>();
} }
catch (System.Exception) catch (Exception)
{ {
} }
} }
// Update is called once per frame // Update is called once per frame
void Update() private void Update()
{ {
if (drag) if (drag)
{
point.transform.position = cam.ScreenToWorldPoint(new Vector3( point.transform.position = cam.ScreenToWorldPoint(new Vector3(
Input.mousePosition.x+5, Input.mousePosition.x + 5,
Input.mousePosition.y-25,0 Input.mousePosition.y - 25, 0
)); ));
}
} }
bool drag = false;
public void begin() public void begin()
{ {
drag = true; drag = true;
...@@ -41,4 +42,4 @@ public class UImouseHint : MonoBehaviour { ...@@ -41,4 +42,4 @@ public class UImouseHint : MonoBehaviour {
drag = false; drag = false;
point.SetActive(false); point.SetActive(false);
} }
} }
\ No newline at end of file
using UnityEngine; using TMPro;
using System; using UnityEngine;
public class chainMono : MonoBehaviour { public class chainMono : MonoBehaviour
{
public Renderer circle; public Renderer circle;
public TMPro.TextMeshPro text; public TextMeshPro text;
public bool flashing = true; public bool flashing = true;
float all = 0; private float all;
bool p = true; private bool p = true;
void Update()
private void Update()
{ {
if (flashing) if (flashing)
{ {
all += Program.deltaTime; all += Program.deltaTime;
if (all>0.05) if (all > 0.05)
{ {
all = 0; all = 0;
p = !p; p = !p;
...@@ -29,4 +31,4 @@ public class chainMono : MonoBehaviour { ...@@ -29,4 +31,4 @@ public class chainMono : MonoBehaviour {
} }
} }
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEditor;
using UnityEditor; using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[CustomEditor(typeof(ParticleScale))] [CustomEditor(typeof(ParticleScale))]
public class ParticleScaleEditor : Editor { public class ParticleScaleEditor : Editor
{
public ParticleScale tgt => target as ParticleScale;
void Awake() {
foreach(Transform tr in tgt.transform) {
if(tr.gameObject.GetComponent<ParticleScale>() == null) {
tr.gameObject.AddComponent<ParticleScale>();
}
}
}
public override void OnInspectorGUI() {
tgt.scaleStep = EditorGUILayout.FloatField("Scale Step", tgt.scaleStep); private void Awake()
{
foreach (Transform tr in tgt.transform)
if (tr.gameObject.GetComponent<ParticleScale>() == null)
tr.gameObject.AddComponent<ParticleScale>();
}
EditorGUILayout.BeginHorizontal(); public override void OnInspectorGUI()
GUILayout.FlexibleSpace(); {
tgt.scaleStep = EditorGUILayout.FloatField("Scale Step", tgt.scaleStep);
if(GUILayout.Button(new GUIContent("Scale Up"), GUILayout.Width(80))) { EditorGUILayout.BeginHorizontal();
UpdateScale(tgt.scaleStep); GUILayout.FlexibleSpace();
}
if(GUILayout.Button(new GUIContent("Scale Down"), GUILayout.Width(80))) {
ReduceScale(tgt.scaleStep);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
} if (GUILayout.Button(new GUIContent("Scale Up"), GUILayout.Width(80))) UpdateScale(tgt.scaleStep);
private void UpdateScale(float mod) { if (GUILayout.Button(new GUIContent("Scale Down"), GUILayout.Width(80))) ReduceScale(tgt.scaleStep);
tgt.UpdateScale(mod);
foreach(Transform tr in tgt.transform) {
if(tr.gameObject.GetComponent<ParticleScale>() == null) {
tr.gameObject.AddComponent<ParticleScale>();
}
tr.gameObject.GetComponent<ParticleScale>().UpdateScale(mod);
}
}
private void ReduceScale(float mod) { EditorGUILayout.EndHorizontal();
tgt.ReduceScale(mod); EditorGUILayout.Separator();
foreach(Transform tr in tgt.transform) { }
if(tr.gameObject.GetComponent<ParticleScale>() == null) {
tr.gameObject.AddComponent<ParticleScale>();
}
tr.gameObject.GetComponent<ParticleScale>().ReduceScale(mod);
}
}
public ParticleScale tgt { private void UpdateScale(float mod)
get { {
return target as ParticleScale; tgt.UpdateScale(mod);
} foreach (Transform tr in tgt.transform)
} {
if (tr.gameObject.GetComponent<ParticleScale>() == null) tr.gameObject.AddComponent<ParticleScale>();
tr.gameObject.GetComponent<ParticleScale>().UpdateScale(mod);
}
}
private void ReduceScale(float mod)
{
tgt.ReduceScale(mod);
foreach (Transform tr in tgt.transform)
{
if (tr.gameObject.GetComponent<ParticleScale>() == null) tr.gameObject.AddComponent<ParticleScale>();
} tr.gameObject.GetComponent<ParticleScale>().ReduceScale(mod);
}
}
}
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class ParticleScale : MonoBehaviour { public class ParticleScale : MonoBehaviour
{
public float scaleStep = 0.1f;
public float scaleStep = 0.1f; private ParticleSystem _particle;
private ParticleSystem _particle = null;
public ParticleSystem particle
{
get
{
if (_particle == null) _particle = GetComponent<ParticleSystem>();
return _particle;
}
}
public void UpdateScale(float mod) {
if(particle == null) { public void UpdateScale(float mod)
return; {
} if (particle == null) return;
particle.startSize = particle.startSize + particle.startSize * mod; particle.startSize = particle.startSize + particle.startSize * mod;
particle.startSpeed = particle.startSpeed + particle.startSpeed * mod; particle.startSpeed = particle.startSpeed + particle.startSpeed * mod;
}
}
public void ReduceScale(float mod) { public void ReduceScale(float mod)
{
if(particle == null) { if (particle == null) return;
return;
}
particle.startSize = particle.startSize - particle.startSize * mod; particle.startSize = particle.startSize - particle.startSize * mod;
particle.startSpeed = particle.startSpeed - particle.startSpeed * mod; particle.startSpeed = particle.startSpeed - particle.startSpeed * mod;
}
} }
\ No newline at end of file
public ParticleSystem particle {
get {
if(_particle == null) {
_particle = GetComponent<ParticleSystem>();
}
return _particle;
}
}
}
using UnityEngine; using UnityEngine;
using System.Collections;
public class Galaxy_Rotation_01 : MonoBehaviour { public class Galaxy_Rotation_01 : MonoBehaviour
{
// Use this for initialization
private void Start()
{
}
// Use this for initialization // Update is called once per frame
void Start () { private void Update()
{
} // Slowly rotate the object around its X axis at 1 degree/second.
transform.Rotate(Vector3.forward * Time.deltaTime * -10);
// Update is called once per frame }
void Update () { }
\ No newline at end of file
// Slowly rotate the object around its X axis at 1 degree/second.
transform.Rotate(Vector3.forward * Time.deltaTime*-10);
}
}
using UnityEngine; using DG.Tweening;
using System.Collections; using UnityEngine;
using System; using YGOSharp;
using DG.Tweening;
public class MonoCardInDeckManager : MonoBehaviour
public class MonoCardInDeckManager : MonoBehaviour { {
int loadedPicCode = 0; public bool dying;
YGOSharp.Banlist loaded_banlist = null;
public bool dying = false; private bool bool_physicalON;
bool died = false; public Card cardData = new Card();
public YGOSharp.Card cardData=new YGOSharp.Card(); private bool died;
void Update () private bool isDraging;
private Banlist loaded_banlist;
private int loadedPicCode;
private void Update()
{ {
if (loadedPicCode != cardData.Id) if (loadedPicCode != cardData.Id)
{ {
Texture2D pic = GameTextureManager.get(cardData.Id,GameTextureType.card_picture); var pic = GameTextureManager.get(cardData.Id, GameTextureType.card_picture);
if (pic != null) if (pic != null)
{ {
loadedPicCode = cardData.Id; loadedPicCode = cardData.Id;
gameObject.transform.Find("face").GetComponent<Renderer>().material.mainTexture = pic; gameObject.transform.Find("face").GetComponent<Renderer>().material.mainTexture = pic;
} }
} }
if (Program.I().deckManager.currentBanlist != loaded_banlist) if (Program.I().deckManager.currentBanlist != loaded_banlist)
{ {
ban_icon ico = GetComponentInChildren<ban_icon>(); var ico = GetComponentInChildren<ban_icon>();
loaded_banlist = Program.I().deckManager.currentBanlist; loaded_banlist = Program.I().deckManager.currentBanlist;
if (loaded_banlist != null) if (loaded_banlist != null)
{
ico.show(loaded_banlist.GetQuantity(cardData.Id)); ico.show(loaded_banlist.GetQuantity(cardData.Id));
}
else else
{
ico.show(3); ico.show(3);
}
}
if (isDraging)
{
gameObject.transform.position += (getGoodPosition(4) - gameObject.transform.position) * 0.3f;
}
if (Vector3.Distance(Vector3.zero, gameObject.transform.position) > 50 && bool_physicalON)
{
killIt();
} }
if (isDraging) gameObject.transform.position += (getGoodPosition(4) - gameObject.transform.position) * 0.3f;
if (Vector3.Distance(Vector3.zero, gameObject.transform.position) > 50 && bool_physicalON) killIt();
} }
public void killIt() public void killIt()
...@@ -50,15 +46,9 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -50,15 +46,9 @@ public class MonoCardInDeckManager : MonoBehaviour {
{ {
gameObject.transform.position = new Vector3(0, 5, 0); gameObject.transform.position = new Vector3(0, 5, 0);
endDrag(); endDrag();
if (Program.I().deckManager.cardInDragging==this) if (Program.I().deckManager.cardInDragging == this) Program.I().deckManager.cardInDragging = null;
{ var rigidbody = GetComponent<Rigidbody>();
Program.I().deckManager.cardInDragging = null; if (rigidbody == null) rigidbody = gameObject.AddComponent<Rigidbody>();
}
Rigidbody rigidbody = GetComponent<Rigidbody>();
if (rigidbody == null)
{
rigidbody = gameObject.AddComponent<Rigidbody>();
}
rigidbody.Sleep(); rigidbody.Sleep();
} }
else else
...@@ -71,22 +61,20 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -71,22 +61,20 @@ public class MonoCardInDeckManager : MonoBehaviour {
public Vector3 getGoodPosition(float height) public Vector3 getGoodPosition(float height)
{ {
float x = Input.mousePosition.x; var x = Input.mousePosition.x;
float y = Input.mousePosition.y; var y = Input.mousePosition.y;
Vector3 to_ltemp = Program.I().main_camera.ScreenToWorldPoint(new Vector3(x, y, 1)); var to_ltemp = Program.I().main_camera.ScreenToWorldPoint(new Vector3(x, y, 1));
Vector3 dv = to_ltemp - Program.I().main_camera.transform.position; var dv = to_ltemp - Program.I().main_camera.transform.position;
if (dv.y == 0) dv.y = 0.01f; if (dv.y == 0) dv.y = 0.01f;
to_ltemp.x = ((height - Program.I().main_camera.transform.position.y) to_ltemp.x = (height - Program.I().main_camera.transform.position.y)
* (dv.x) / dv.y + Program.I().main_camera.transform.position.x); * dv.x / dv.y + Program.I().main_camera.transform.position.x;
to_ltemp.y = ((height - Program.I().main_camera.transform.position.y) to_ltemp.y = (height - Program.I().main_camera.transform.position.y)
* (dv.y) / dv.y + Program.I().main_camera.transform.position.y); * dv.y / dv.y + Program.I().main_camera.transform.position.y;
to_ltemp.z = ((height - Program.I().main_camera.transform.position.y) to_ltemp.z = (height - Program.I().main_camera.transform.position.y)
* (dv.z) / dv.y + Program.I().main_camera.transform.position.z); * dv.z / dv.y + Program.I().main_camera.transform.position.z;
return to_ltemp; return to_ltemp;
} }
bool isDraging = false;
public void beginDrag() public void beginDrag()
{ {
physicalOFF(); physicalOFF();
...@@ -101,21 +89,18 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -101,21 +89,18 @@ public class MonoCardInDeckManager : MonoBehaviour {
isDraging = false; isDraging = false;
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) || getIfAlive() == false) if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) || getIfAlive() == false)
{ {
Vector3 form_position = getGoodPosition(4); var form_position = getGoodPosition(4);
Vector3 to_position = getGoodPosition(0); var to_position = getGoodPosition(0);
Vector3 delta_position = to_position - form_position; var delta_position = to_position - form_position;
GetComponent<Rigidbody>().AddForce(delta_position * 1000); GetComponent<Rigidbody>().AddForce(delta_position * 1000);
dying = true; dying = true;
} }
} }
public void tweenToVectorAndFall(Vector3 position,Vector3 rotation) public void tweenToVectorAndFall(Vector3 position, Vector3 rotation)
{ {
Rigidbody rigidbody = GetComponent<Rigidbody>(); var rigidbody = GetComponent<Rigidbody>();
if (rigidbody != null) if (rigidbody != null) rigidbody.Sleep();
{
rigidbody.Sleep();
}
transform.DOMove(position, 0.2f).OnComplete(physicalON); transform.DOMove(position, 0.2f).OnComplete(physicalON);
transform.DORotate(rotation, 0.15f); transform.DORotate(rotation, 0.15f);
...@@ -137,17 +122,12 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -137,17 +122,12 @@ public class MonoCardInDeckManager : MonoBehaviour {
physicalOFF(); physicalOFF();
} }
bool bool_physicalON = false;
private void physicalON() private void physicalON()
{ {
bool_physicalON = true; bool_physicalON = true;
GetComponent<BoxCollider>().enabled = true; GetComponent<BoxCollider>().enabled = true;
Rigidbody rigidbody = GetComponent<Rigidbody>(); var rigidbody = GetComponent<Rigidbody>();
if (rigidbody == null) if (rigidbody == null) rigidbody = gameObject.AddComponent<Rigidbody>();
{
rigidbody = gameObject.AddComponent<Rigidbody>();
}
rigidbody.Sleep(); rigidbody.Sleep();
rigidbody.useGravity = true; rigidbody.useGravity = true;
rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
...@@ -157,11 +137,8 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -157,11 +137,8 @@ public class MonoCardInDeckManager : MonoBehaviour {
{ {
bool_physicalON = false; bool_physicalON = false;
GetComponent<BoxCollider>().enabled = true; GetComponent<BoxCollider>().enabled = true;
Rigidbody rigidbody = GetComponent<Rigidbody>(); var rigidbody = GetComponent<Rigidbody>();
if (rigidbody == null) if (rigidbody == null) rigidbody = gameObject.AddComponent<Rigidbody>();
{
rigidbody = gameObject.AddComponent<Rigidbody>();
}
rigidbody.useGravity = false; rigidbody.useGravity = false;
rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
} }
...@@ -170,46 +147,34 @@ public class MonoCardInDeckManager : MonoBehaviour { ...@@ -170,46 +147,34 @@ public class MonoCardInDeckManager : MonoBehaviour {
{ {
bool_physicalON = false; bool_physicalON = false;
GetComponent<BoxCollider>().enabled = false; GetComponent<BoxCollider>().enabled = false;
Rigidbody rigidbody = GetComponent<Rigidbody>(); var rigidbody = GetComponent<Rigidbody>();
if (rigidbody != null) if (rigidbody != null) rigidbody.useGravity = false;
{
rigidbody.useGravity = false;
}
} }
public bool getIfAlive() public bool getIfAlive()
{ {
bool ret = true; var ret = true;
if (died == true) if (died) ret = false;
{ if (gameObject.transform.position.y < -0.5f) ret = false;
ret = false; var to_ltemp = refLectPosition(gameObject.transform.position);
}
if (gameObject.transform.position.y < -0.5f)
{
ret = false;
}
Vector3 to_ltemp = refLectPosition(gameObject.transform.position);
if (to_ltemp.x < -15.2f) ret = false; if (to_ltemp.x < -15.2f) ret = false;
if (to_ltemp.x > 15.2f) ret = false; if (to_ltemp.x > 15.2f) ret = false;
if (Program.I().deckManager.condition == DeckManager.Condition.changeSide) if (Program.I().deckManager.condition == DeckManager.Condition.changeSide) ret = true;
{
ret = true;
}
return ret; return ret;
} }
public static Vector3 refLectPosition(Vector3 pos) public static Vector3 refLectPosition(Vector3 pos)
{ {
Vector3 to_ltemp = pos; var to_ltemp = pos;
Vector3 dv = to_ltemp - Program.I().main_camera.transform.position; var dv = to_ltemp - Program.I().main_camera.transform.position;
if (dv.y == 0) dv.y = 0.01f; if (dv.y == 0) dv.y = 0.01f;
to_ltemp.x = ((0 - Program.I().main_camera.transform.position.y) to_ltemp.x = (0 - Program.I().main_camera.transform.position.y)
* (dv.x) / dv.y + Program.I().main_camera.transform.position.x); * dv.x / dv.y + Program.I().main_camera.transform.position.x;
to_ltemp.y = ((0 - Program.I().main_camera.transform.position.y) to_ltemp.y = (0 - Program.I().main_camera.transform.position.y)
* (dv.y) / dv.y + Program.I().main_camera.transform.position.y); * dv.y / dv.y + Program.I().main_camera.transform.position.y;
to_ltemp.z = ((0 - Program.I().main_camera.transform.position.y) to_ltemp.z = (0 - Program.I().main_camera.transform.position.y)
* (dv.z) / dv.y + Program.I().main_camera.transform.position.z); * dv.z / dv.y + Program.I().main_camera.transform.position.z;
return to_ltemp; return to_ltemp;
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections; using YGOSharp;
public class cardPicLoader : MonoBehaviour public class cardPicLoader : MonoBehaviour
{ {
public int loaded_code = -1; public int loaded_code = -1;
public int code = 0; public int code;
public YGOSharp.Banlist loaded_banlist = null;
public Texture2D defaults = null; public Texture2D defaults;
public ban_icon ico; public ban_icon ico;
public void clear() public Collider coli;
{
loaded_code = 0;
code = 0;
ico.show(3);
uiTexture.mainTexture = null;
}
public void reCode(int c) public UITexture uiTexture;
{
loaded_code = 0;
code = c;
}
public void relayer(int l) public Banlist loaded_banlist;
{
uiTexture.depth = 50 + l * 2;
UITexture t = ico.gameObject.GetComponent<UITexture>();
t.depth = 51 + l * 2;
}
public Collider coli = null; public Card data { get; set; }
void Update() private void Update()
{ {
if (coli != null) if (coli != null)
{
if (Program.InputGetMouseButtonDown_0) if (Program.InputGetMouseButtonDown_0)
{
if (Program.pointedCollider == coli) if (Program.pointedCollider == coli)
{ Program.I().cardDescription.setData(CardsManager.Get(code), GameTextureManager.myBack, "", true);
((CardDescription)(Program.I().cardDescription)).setData(YGOSharp.CardsManager.Get(code), GameTextureManager.myBack,"",true);
}
}
}
if (Program.I().deckManager != null) if (Program.I().deckManager != null)
{ {
if (loaded_code != code) if (loaded_code != code)
{ {
Texture2D t = GameTextureManager.get(code, GameTextureType.card_picture, defaults); var t = GameTextureManager.get(code, GameTextureType.card_picture, defaults);
if (t != null) if (t != null)
{ {
uiTexture.mainTexture = t; uiTexture.mainTexture = t;
uiTexture.aspectRatio = ((float)t.width) / ((float)t.height); uiTexture.aspectRatio = t.width / (float) t.height;
uiTexture.forceWidth((int)(uiTexture.height * uiTexture.aspectRatio)); uiTexture.forceWidth((int) (uiTexture.height * uiTexture.aspectRatio));
loaded_code = code; loaded_code = code;
loaded_banlist = null; loaded_banlist = null;
} }
} }
if (loaded_banlist != Program.I().deckManager.currentBanlist) if (loaded_banlist != Program.I().deckManager.currentBanlist)
{ {
loaded_banlist = Program.I().deckManager.currentBanlist; loaded_banlist = Program.I().deckManager.currentBanlist;
...@@ -73,13 +50,31 @@ public class cardPicLoader : MonoBehaviour ...@@ -73,13 +50,31 @@ public class cardPicLoader : MonoBehaviour
ico.show(3); ico.show(3);
return; return;
} }
ico.show(loaded_banlist.GetQuantity(code)); ico.show(loaded_banlist.GetQuantity(code));
} }
} }
} }
} }
public UITexture uiTexture; public void clear()
{
loaded_code = 0;
code = 0;
ico.show(3);
uiTexture.mainTexture = null;
}
public YGOSharp.Card data { get; set; } public void reCode(int c)
} {
loaded_code = 0;
code = c;
}
public void relayer(int l)
{
uiTexture.depth = 50 + l * 2;
var t = ico.gameObject.GetComponent<UITexture>();
t.depth = 51 + l * 2;
}
}
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class descKeeper : MonoBehaviour { public class descKeeper : MonoBehaviour
{
public UITexture card; public UITexture card;
public UITexture back; public UITexture back;
// Use this for initialization // Use this for initialization
void Start() private void Start()
{ {
} }
// Update is called once per frame // Update is called once per frame
void Update () { private void Update()
if (back.width < card.width) {
{ if (back.width < card.width) back.width = card.width + 2;
back.width = card.width + 2;
}
back.transform.localPosition = new Vector3(back.width / 2f, 0); back.transform.localPosition = new Vector3(back.width / 2f, 0);
Vector3 leftTop = new Vector3(-back.width / 2 + 2 + back.transform.localPosition.x, +back.height / 2 - 2 + back.transform.localPosition.y); var leftTop = new Vector3(-back.width / 2 + 2 + back.transform.localPosition.x,
+back.height / 2 - 2 + back.transform.localPosition.y);
card.transform.localPosition = new Vector3(leftTop.x + card.width / 2, leftTop.y - card.height / 2); card.transform.localPosition = new Vector3(leftTop.x + card.width / 2, leftTop.y - card.height / 2);
Program.I().cardDescription.width = back.width-2; Program.I().cardDescription.width = back.width - 2;
Program.I().cardDescription.cHeight = card.height; Program.I().cardDescription.cHeight = card.height;
} }
} }
\ No newline at end of file
using UnityEngine; using System;
using System.Collections; using UnityEngine;
public class forceColor : MonoBehaviour { public class forceColor : MonoBehaviour
{
// Use this for initialization // Use this for initialization
void Start () { private void Start()
{
var tweens = GetComponentsInChildren<TweenColor>(); var tweens = GetComponentsInChildren<TweenColor>();
foreach (var item in tweens) foreach (var item in tweens) DestroyImmediate(item);
{
DestroyImmediate(item);
}
Color c; Color c;
ColorUtility.TryParseHtmlString(Config.Getui("allUI.color"), out c); ColorUtility.TryParseHtmlString(Config.Getui("allUI.color"), out c);
var sprites = GetComponentsInChildren<UISprite>(); var sprites = GetComponentsInChildren<UISprite>();
foreach (var item in sprites) foreach (var item in sprites)
{
if (item.color.a > 0.1f) if (item.color.a > 0.1f)
{ {
item.color = c; item.color = c;
...@@ -22,11 +19,11 @@ public class forceColor : MonoBehaviour { ...@@ -22,11 +19,11 @@ public class forceColor : MonoBehaviour {
{ {
item.gameObject.GetComponentInParent<UIButton>().defaultColor = c; item.gameObject.GetComponentInParent<UIButton>().defaultColor = c;
} }
catch (System.Exception) catch (Exception)
{ {
} }
} }
}
ColorUtility.TryParseHtmlString(Config.Getui("List.color"), out c); ColorUtility.TryParseHtmlString(Config.Getui("List.color"), out c);
var lists = GetComponentsInChildren<UIPopupList>(); var lists = GetComponentsInChildren<UIPopupList>();
foreach (var item in lists) foreach (var item in lists)
...@@ -37,10 +34,11 @@ public class forceColor : MonoBehaviour { ...@@ -37,10 +34,11 @@ public class forceColor : MonoBehaviour {
item.gameObject.GetComponent<UISprite>().color = c; item.gameObject.GetComponent<UISprite>().color = c;
item.gameObject.GetComponent<UIButton>().defaultColor = c; item.gameObject.GetComponent<UIButton>().defaultColor = c;
} }
catch (System.Exception) catch (Exception)
{ {
} }
} }
ColorUtility.TryParseHtmlString(Config.Getui("lable.color"), out c); ColorUtility.TryParseHtmlString(Config.Getui("lable.color"), out c);
var ls = GetComponentsInChildren<UILabel>(); var ls = GetComponentsInChildren<UILabel>();
foreach (var item in ls) foreach (var item in ls)
...@@ -49,16 +47,14 @@ public class forceColor : MonoBehaviour { ...@@ -49,16 +47,14 @@ public class forceColor : MonoBehaviour {
item.gradientTop = c; item.gradientTop = c;
item.gradientBottom = Color.gray; item.gradientBottom = Color.gray;
} }
ColorUtility.TryParseHtmlString(Config.Getui("lable.color.fadecolor"), out c); ColorUtility.TryParseHtmlString(Config.Getui("lable.color.fadecolor"), out c);
ls = GetComponentsInChildren<UILabel>(); ls = GetComponentsInChildren<UILabel>();
foreach (var item in ls) foreach (var item in ls) item.gradientBottom = c;
{ }
item.gradientBottom = c;
} // Update is called once per frame
private void Update()
{
} }
}
// Update is called once per frame \ No newline at end of file
void Update () {
}
}
using UnityEngine; using System;
using System.Collections;
using System.IO; using System.IO;
using UnityEngine;
public class barPngLoader : MonoBehaviour { public class barPngLoader : MonoBehaviour
{
public UITexture under; public UITexture under;
public UIPanel healthBarCC; public UIPanel healthBarCC;
public UIPanel timeBarCC; public UIPanel timeBarCC;
public UIPanel faceCC; public UIPanel faceCC;
public UITexture api_healthBar; public UITexture api_healthBar;
public UITexture api_timeBar; public UITexture api_timeBar;
public UITexture api_face; public UITexture api_face;
public UILabel api_name; public UILabel api_name;
public UILabel api_timeHint; public UILabel api_timeHint;
public UILabel api_healthHint; public UILabel api_healthHint;
// Use this for initialization // Use this for initialization
void Start () { private void Start()
{
under.mainTexture = GameTextureManager.bar; under.mainTexture = GameTextureManager.bar;
api_healthBar.mainTexture = GameTextureManager.lp; api_healthBar.mainTexture = GameTextureManager.lp;
api_timeBar.mainTexture = GameTextureManager.time; api_timeBar.mainTexture = GameTextureManager.time;
try try
{ {
string[] allLines = (File.ReadAllText("texture/duel/healthBar/config.txt").Replace("\r", "").Replace(" ", "").Split("\n")); var allLines = File.ReadAllText("texture/duel/healthBar/config.txt").Replace("\r", "").Replace(" ", "")
.Split("\n");
foreach (var item in allLines) foreach (var item in allLines)
{ {
string[] mats = item.Split("="); var mats = item.Split("=");
if (mats.Length == 2) if (mats.Length == 2)
{ {
Color c; Color c;
...@@ -31,7 +36,8 @@ public class barPngLoader : MonoBehaviour { ...@@ -31,7 +36,8 @@ public class barPngLoader : MonoBehaviour {
{ {
case "totalSize.width": case "totalSize.width":
under.width = int.Parse(mats[1]); under.width = int.Parse(mats[1]);
under.transform.localPosition = new Vector3(-float.Parse(mats[1]) / 2f, under.transform.localPosition.y, 0); under.transform.localPosition = new Vector3(-float.Parse(mats[1]) / 2f,
under.transform.localPosition.y, 0);
break; break;
case "flatType": case "flatType":
if (int.Parse(mats[1]) == 1) if (int.Parse(mats[1]) == 1)
...@@ -44,16 +50,20 @@ public class barPngLoader : MonoBehaviour { ...@@ -44,16 +50,20 @@ public class barPngLoader : MonoBehaviour {
healthBarCC.clipSoftness = new Vector2(4, 4); healthBarCC.clipSoftness = new Vector2(4, 4);
timeBarCC.clipSoftness = new Vector2(4, 4); timeBarCC.clipSoftness = new Vector2(4, 4);
} }
break; break;
case "totalSize.height": case "totalSize.height":
under.height = int.Parse(mats[1]); under.height = int.Parse(mats[1]);
under.transform.localPosition = new Vector3(under.transform.localPosition.x, -float.Parse(mats[1]) / 2f, 0); under.transform.localPosition = new Vector3(under.transform.localPosition.x,
-float.Parse(mats[1]) / 2f, 0);
break; break;
case "playerNameLable.x": case "playerNameLable.x":
api_name.transform.localPosition = new Vector3(-float.Parse(mats[1]), api_name.transform.localPosition.y, 0); api_name.transform.localPosition = new Vector3(-float.Parse(mats[1]),
api_name.transform.localPosition.y, 0);
break; break;
case "playerNameLable.y": case "playerNameLable.y":
api_name.transform.localPosition = new Vector3(api_name.transform.localPosition.x, -float.Parse(mats[1]), 0); api_name.transform.localPosition = new Vector3(api_name.transform.localPosition.x,
-float.Parse(mats[1]), 0);
break; break;
case "playerNameLable.width": case "playerNameLable.width":
api_name.width = int.Parse(mats[1]); api_name.width = int.Parse(mats[1]);
...@@ -62,43 +72,27 @@ public class barPngLoader : MonoBehaviour { ...@@ -62,43 +72,27 @@ public class barPngLoader : MonoBehaviour {
api_name.height = int.Parse(mats[1]); api_name.height = int.Parse(mats[1]);
break; break;
case "playerNameLable.color": case "playerNameLable.color":
ColorUtility.TryParseHtmlString(mats[1],out c); ColorUtility.TryParseHtmlString(mats[1], out c);
api_name.color = c; api_name.color = c;
api_name.gradientTop = api_name.color; api_name.gradientTop = api_name.color;
break; break;
case "playerNameLable.alignment": case "playerNameLable.alignment":
if (mats[1] == "0") if (mats[1] == "0") api_name.alignment = NGUIText.Alignment.Center;
{ if (mats[1] == "1") api_name.alignment = NGUIText.Alignment.Left;
api_name.alignment = NGUIText.Alignment.Center; if (mats[1] == "2") api_name.alignment = NGUIText.Alignment.Right;
}
if (mats[1] == "1")
{
api_name.alignment = NGUIText.Alignment.Left;
}
if (mats[1] == "2")
{
api_name.alignment = NGUIText.Alignment.Right;
}
break; break;
case "playerNameLable.effect": case "playerNameLable.effect":
if (mats[1] == "0") if (mats[1] == "0") api_name.effectStyle = UILabel.Effect.None;
{ if (mats[1] == "1") api_name.effectStyle = UILabel.Effect.Shadow;
api_name.effectStyle = UILabel.Effect.None; if (mats[1] == "2") api_name.effectStyle = UILabel.Effect.Outline;
}
if (mats[1] == "1")
{
api_name.effectStyle = UILabel.Effect.Shadow;
}
if (mats[1] == "2")
{
api_name.effectStyle = UILabel.Effect.Outline;
}
break; break;
case "healthLable.x": case "healthLable.x":
api_healthHint.transform.localPosition = new Vector3(-float.Parse(mats[1]), api_healthHint.transform.localPosition.y, 0); api_healthHint.transform.localPosition = new Vector3(-float.Parse(mats[1]),
api_healthHint.transform.localPosition.y, 0);
break; break;
case "healthLable.y": case "healthLable.y":
api_healthHint.transform.localPosition = new Vector3(api_healthHint.transform.localPosition.x, -float.Parse(mats[1]), 0); api_healthHint.transform.localPosition =
new Vector3(api_healthHint.transform.localPosition.x, -float.Parse(mats[1]), 0);
break; break;
case "healthLable.width": case "healthLable.width":
api_healthHint.width = int.Parse(mats[1]); api_healthHint.width = int.Parse(mats[1]);
...@@ -112,38 +106,22 @@ public class barPngLoader : MonoBehaviour { ...@@ -112,38 +106,22 @@ public class barPngLoader : MonoBehaviour {
api_healthHint.gradientTop = api_name.color; api_healthHint.gradientTop = api_name.color;
break; break;
case "healthLable.alignment": case "healthLable.alignment":
if (mats[1] == "0") if (mats[1] == "0") api_healthHint.alignment = NGUIText.Alignment.Center;
{ if (mats[1] == "1") api_healthHint.alignment = NGUIText.Alignment.Left;
api_healthHint.alignment = NGUIText.Alignment.Center; if (mats[1] == "2") api_healthHint.alignment = NGUIText.Alignment.Right;
}
if (mats[1] == "1")
{
api_healthHint.alignment = NGUIText.Alignment.Left;
}
if (mats[1] == "2")
{
api_healthHint.alignment = NGUIText.Alignment.Right;
}
break; break;
case "healthLable.effect": case "healthLable.effect":
if (mats[1] == "0") if (mats[1] == "0") api_healthHint.effectStyle = UILabel.Effect.None;
{ if (mats[1] == "1") api_healthHint.effectStyle = UILabel.Effect.Shadow;
api_healthHint.effectStyle = UILabel.Effect.None; if (mats[1] == "2") api_healthHint.effectStyle = UILabel.Effect.Outline;
}
if (mats[1] == "1")
{
api_healthHint.effectStyle = UILabel.Effect.Shadow;
}
if (mats[1] == "2")
{
api_healthHint.effectStyle = UILabel.Effect.Outline;
}
break; break;
case "timeLable.x": case "timeLable.x":
api_timeHint.transform.localPosition = new Vector3(-float.Parse(mats[1]), api_timeHint.transform.localPosition.y, 0); api_timeHint.transform.localPosition = new Vector3(-float.Parse(mats[1]),
api_timeHint.transform.localPosition.y, 0);
break; break;
case "timeLable.y": case "timeLable.y":
api_timeHint.transform.localPosition = new Vector3(api_timeHint.transform.localPosition.x, -float.Parse(mats[1]), 0); api_timeHint.transform.localPosition = new Vector3(api_timeHint.transform.localPosition.x,
-float.Parse(mats[1]), 0);
break; break;
case "timeLable.width": case "timeLable.width":
api_timeHint.width = int.Parse(mats[1]); api_timeHint.width = int.Parse(mats[1]);
...@@ -157,100 +135,87 @@ public class barPngLoader : MonoBehaviour { ...@@ -157,100 +135,87 @@ public class barPngLoader : MonoBehaviour {
api_timeHint.gradientTop = api_name.color; api_timeHint.gradientTop = api_name.color;
break; break;
case "timeLable.alignment": case "timeLable.alignment":
if (mats[1] == "0") if (mats[1] == "0") api_timeHint.alignment = NGUIText.Alignment.Center;
{ if (mats[1] == "1") api_timeHint.alignment = NGUIText.Alignment.Left;
api_timeHint.alignment = NGUIText.Alignment.Center; if (mats[1] == "2") api_timeHint.alignment = NGUIText.Alignment.Right;
}
if (mats[1] == "1")
{
api_timeHint.alignment = NGUIText.Alignment.Left;
}
if (mats[1] == "2")
{
api_timeHint.alignment = NGUIText.Alignment.Right;
}
break; break;
case "timeLable.effect": case "timeLable.effect":
if (mats[1] == "0") if (mats[1] == "0") api_timeHint.effectStyle = UILabel.Effect.None;
{ if (mats[1] == "1") api_timeHint.effectStyle = UILabel.Effect.Shadow;
api_timeHint.effectStyle = UILabel.Effect.None; if (mats[1] == "2") api_timeHint.effectStyle = UILabel.Effect.Outline;
}
if (mats[1] == "1")
{
api_timeHint.effectStyle = UILabel.Effect.Shadow;
}
if (mats[1] == "2")
{
api_timeHint.effectStyle = UILabel.Effect.Outline;
}
break; break;
case "health.x": case "health.x":
healthBarCC.transform.localPosition = new Vector3(-float.Parse(mats[1]), healthBarCC.transform.localPosition.y, 0); healthBarCC.transform.localPosition = new Vector3(-float.Parse(mats[1]),
healthBarCC.transform.localPosition.y, 0);
api_healthBar.transform.localPosition = Vector3.zero; api_healthBar.transform.localPosition = Vector3.zero;
break; break;
case "health.y": case "health.y":
healthBarCC.transform.localPosition = new Vector3(healthBarCC.transform.localPosition.x, -float.Parse(mats[1]), 0); healthBarCC.transform.localPosition = new Vector3(healthBarCC.transform.localPosition.x,
-float.Parse(mats[1]), 0);
api_healthBar.transform.localPosition = Vector3.zero; api_healthBar.transform.localPosition = Vector3.zero;
break; break;
case "health.width": case "health.width":
healthBarCC.baseClipRegion = new Vector4(healthBarCC.baseClipRegion.x, healthBarCC.baseClipRegion.y, float.Parse(mats[1]), healthBarCC.baseClipRegion.w); healthBarCC.baseClipRegion = new Vector4(healthBarCC.baseClipRegion.x,
healthBarCC.baseClipRegion.y, float.Parse(mats[1]), healthBarCC.baseClipRegion.w);
api_healthBar.width = int.Parse(mats[1]); api_healthBar.width = int.Parse(mats[1]);
break; break;
case "health.height": case "health.height":
healthBarCC.baseClipRegion = new Vector4(healthBarCC.baseClipRegion.x, healthBarCC.baseClipRegion.y, healthBarCC.baseClipRegion.z, float.Parse(mats[1])); healthBarCC.baseClipRegion = new Vector4(healthBarCC.baseClipRegion.x,
healthBarCC.baseClipRegion.y, healthBarCC.baseClipRegion.z, float.Parse(mats[1]));
api_healthBar.height = int.Parse(mats[1]); api_healthBar.height = int.Parse(mats[1]);
break; break;
case "time.x": case "time.x":
timeBarCC.transform.localPosition = new Vector3(-float.Parse(mats[1]), timeBarCC.transform.localPosition.y, 0); timeBarCC.transform.localPosition = new Vector3(-float.Parse(mats[1]),
timeBarCC.transform.localPosition.y, 0);
api_timeBar.transform.localPosition = Vector3.zero; api_timeBar.transform.localPosition = Vector3.zero;
break; break;
case "time.y": case "time.y":
timeBarCC.transform.localPosition = new Vector3(timeBarCC.transform.localPosition.x, -float.Parse(mats[1]), 0); timeBarCC.transform.localPosition = new Vector3(timeBarCC.transform.localPosition.x,
-float.Parse(mats[1]), 0);
api_timeBar.transform.localPosition = Vector3.zero; api_timeBar.transform.localPosition = Vector3.zero;
break; break;
case "time.width": case "time.width":
timeBarCC.baseClipRegion = new Vector4(timeBarCC.baseClipRegion.x, timeBarCC.baseClipRegion.y, float.Parse(mats[1]), timeBarCC.baseClipRegion.w); timeBarCC.baseClipRegion = new Vector4(timeBarCC.baseClipRegion.x,
timeBarCC.baseClipRegion.y, float.Parse(mats[1]), timeBarCC.baseClipRegion.w);
api_timeBar.width = int.Parse(mats[1]); api_timeBar.width = int.Parse(mats[1]);
break; break;
case "time.height": case "time.height":
timeBarCC.baseClipRegion = new Vector4(timeBarCC.baseClipRegion.x, timeBarCC.baseClipRegion.y, timeBarCC.baseClipRegion.z, float.Parse(mats[1])); timeBarCC.baseClipRegion = new Vector4(timeBarCC.baseClipRegion.x,
timeBarCC.baseClipRegion.y, timeBarCC.baseClipRegion.z, float.Parse(mats[1]));
api_timeBar.height = int.Parse(mats[1]); api_timeBar.height = int.Parse(mats[1]);
break; break;
case "face.x": case "face.x":
faceCC.transform.localPosition = new Vector3(-float.Parse(mats[1]), faceCC.transform.localPosition.y, 0); faceCC.transform.localPosition = new Vector3(-float.Parse(mats[1]),
faceCC.transform.localPosition.y, 0);
api_timeBar.transform.localPosition = Vector3.zero; api_timeBar.transform.localPosition = Vector3.zero;
break; break;
case "face.y": case "face.y":
faceCC.transform.localPosition = new Vector3(faceCC.transform.localPosition.x, -float.Parse(mats[1]), 0); faceCC.transform.localPosition = new Vector3(faceCC.transform.localPosition.x,
-float.Parse(mats[1]), 0);
api_timeBar.transform.localPosition = Vector3.zero; api_timeBar.transform.localPosition = Vector3.zero;
break; break;
case "face.size": case "face.size":
faceCC.baseClipRegion = new Vector4(faceCC.baseClipRegion.x, faceCC.baseClipRegion.y, float.Parse(mats[1]), float.Parse(mats[1])); faceCC.baseClipRegion = new Vector4(faceCC.baseClipRegion.x, faceCC.baseClipRegion.y,
float.Parse(mats[1]), float.Parse(mats[1]));
api_face.width = int.Parse(mats[1]); api_face.width = int.Parse(mats[1]);
api_face.height = int.Parse(mats[1]); api_face.height = int.Parse(mats[1]);
break; break;
case "face.type": case "face.type":
if (mats[1] == "0") if (mats[1] == "0") faceCC.clipping = UIDrawCall.Clipping.TextureMask;
{ if (mats[1] == "1") faceCC.clipping = UIDrawCall.Clipping.SoftClip;
faceCC.clipping = UIDrawCall.Clipping.TextureMask;
}
if (mats[1] == "1")
{
faceCC.clipping = UIDrawCall.Clipping.SoftClip;
}
break; break;
} }
} }
} }
} }
catch (System.Exception e) catch (Exception e)
{ {
Debug.LogError(e); Debug.LogError(e);
} }
} }
// Update is called once per frame // Update is called once per frame
void Update () { private void Update()
{
} }
} }
\ No newline at end of file
using UnityEngine; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine;
public class gameUIbutton public class gameUIbutton
{ {
public string hashString; public bool dead;
public bool dying;
public GameObject gameObject; public GameObject gameObject;
public string hashString;
public int response; public int response;
public bool dying;
public bool dead;
} }
public class gameInfo : MonoBehaviour public class gameInfo : MonoBehaviour
{ {
public enum chainCondition
{
standard,
no,
all,
smart
}
public UITexture instance_btnPan; public UITexture instance_btnPan;
public UITextList instance_lab; public UITextList instance_lab;
public UIToggle toggle_ignore; public UIToggle toggle_ignore;
...@@ -20,143 +28,115 @@ public class gameInfo : MonoBehaviour ...@@ -20,143 +28,115 @@ public class gameInfo : MonoBehaviour
public UIToggle toggle_smart; public UIToggle toggle_smart;
public GameObject line; public GameObject line;
public void on_toggle_ignore() public GameObject mod_healthBar;
{
toggle_all.value = false;
toggle_smart.value = false;
}
public void on_toggle_all() public float width;
{
toggle_ignore.value = false;
toggle_smart.value = false;
}
public void on_toggle_smart() public bool swaped;
{
toggle_ignore.value = false;
toggle_all.value = false;
}
//public UITextList hinter; private readonly List<gameUIbutton> HashedButtons = new List<gameUIbutton>();
barPngLoader me; private readonly bool[] isTicking = new bool[2];
barPngLoader opponent; private int lastTickTime;
public GameObject mod_healthBar; //public UITextList hinter;
public float width = 0; private barPngLoader me;
int lastTickTime = 0; private barPngLoader opponent;
private readonly int[] time = new int[2];
// Use this for initialization // Use this for initialization
void Start() private void Start()
{ {
ini(); ini();
} }
public void ini() private void Update()
{
Update();
}
public bool swaped = false;
void Update()
{ {
if (me == null || opponent == null) if (me == null || opponent == null)
{ {
me = ((GameObject)MonoBehaviour.Instantiate(mod_healthBar, new Vector3(1000, 0, 0), Quaternion.identity)).GetComponent<barPngLoader>(); me = Instantiate(mod_healthBar, new Vector3(1000, 0, 0), Quaternion.identity).GetComponent<barPngLoader>();
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 = 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>(); var Transforms = me.GetComponentsInChildren<Transform>();
foreach (Transform child in Transforms) foreach (var child in Transforms) child.gameObject.layer = gameObject.layer;
{
child.gameObject.layer = gameObject.layer;
}
Transforms = opponent.GetComponentsInChildren<Transform>(); Transforms = opponent.GetComponentsInChildren<Transform>();
foreach (Transform child in Transforms) foreach (var child in Transforms) child.gameObject.layer = gameObject.layer;
{
child.gameObject.layer = gameObject.layer;
}
Color c; Color c;
ColorUtility.TryParseHtmlString(Config.Getui("gameChainCheckArea.color"), out c); ColorUtility.TryParseHtmlString(Config.Getui("gameChainCheckArea.color"), out c);
UIHelper.getByName<UISprite>(UIHelper.getByName<UIToggle>(gameObject, "ignore_").gameObject, "Background").color = c; UIHelper.getByName<UISprite>(UIHelper.getByName<UIToggle>(gameObject, "ignore_").gameObject, "Background")
UIHelper.getByName<UISprite>(UIHelper.getByName<UIToggle>(gameObject, "watch_").gameObject, "Background").color = c; .color = c;
UIHelper.getByName<UISprite>(UIHelper.getByName<UIToggle>(gameObject, "use_").gameObject, "Background").color = c; UIHelper.getByName<UISprite>(UIHelper.getByName<UIToggle>(gameObject, "watch_").gameObject, "Background")
} .color = c;
float k = ((float)(Screen.width - Program.I().cardDescription.width)) / 1200f; UIHelper.getByName<UISprite>(UIHelper.getByName<UIToggle>(gameObject, "use_").gameObject, "Background")
if (k > 1.2f) .color = c;
{ }
k = 1.2f;
} var k = (Screen.width - Program.I().cardDescription.width) / 1200f;
if (k <0.8f) if (k > 1.2f) k = 1.2f;
{ if (k < 0.8f) k = 0.8f;
k = 0.8f; var ks = new Vector3(k, k, k);
} var kb = (Screen.width - Program.I().cardDescription.width) / 1200f;
Vector3 ks = new Vector3(k, k, k); if (kb > 1.2f) kb = 1.2f;
float kb = ((float)(Screen.width - Program.I().cardDescription.width)) / 1200f; if (kb < 0.73f) kb = 0.73f;
if (kb > 1.2f) var ksb = new Vector3(kb, kb, kb);
{
kb = 1.2f;
}
if (kb < 0.73f)
{
kb = 0.73f;
}
Vector3 ksb = new Vector3(kb, kb, kb);
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 * opponent.under.height);
} }
else else
{ {
me.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);
opponent.transform.localPosition = new Vector3(Screen.width / 2-14, Screen.height / 2 - 14 - k * (float)(opponent.under.height)); opponent.transform.localPosition =
new Vector3(Screen.width / 2 - 14, Screen.height / 2 - 14 - k * opponent.under.height);
} }
width = (150 * kb) + 15f; width = 150 * kb + 15f;
float localPositionPanX = (((float)Screen.width - 150 * kb) / 2) - 15f; var localPositionPanX = (Screen.width - 150 * kb) / 2 - 15f;
instance_btnPan.transform.localPosition = new Vector3(localPositionPanX, 145, 0); instance_btnPan.transform.localPosition = new Vector3(localPositionPanX, 145, 0);
instance_lab.transform.localPosition = new Vector3(Screen.width/2-315, -Screen.height / 2+90, 0); instance_lab.transform.localPosition = new Vector3(Screen.width / 2 - 315, -Screen.height / 2 + 90, 0);
int j = 0; var j = 0;
for (int i = 0; i < HashedButtons.Count; i++) foreach (var t in HashedButtons)
{ if (t.gameObject != null)
if (HashedButtons[i].gameObject != null)
{ {
if (HashedButtons[i].dying) if (t.dying)
{ {
HashedButtons[i].gameObject.transform.localPosition += (new Vector3(0, -120, 0) - HashedButtons[i].gameObject.transform.localPosition) * Program.deltaTime * 20f; t.gameObject.transform.localPosition +=
if (Math.Abs(HashedButtons[i].gameObject.transform.localPosition.y - -120) < 1) (new Vector3(0, -120, 0) - t.gameObject.transform.localPosition) *
HashedButtons[i].dead = true; Program.deltaTime * 20f;
if (Math.Abs(t.gameObject.transform.localPosition.y - -120) < 1)
t.dead = true;
} }
else else
{ {
HashedButtons[i].gameObject.transform.localPosition += (new Vector3(0, -145 - j * 50, 0) - HashedButtons[i].gameObject.transform.localPosition) * Program.deltaTime * 10f; t.gameObject.transform.localPosition +=
(new Vector3(0, -145 - j * 50, 0) - t.gameObject.transform.localPosition) *
Program.deltaTime * 10f;
j++; j++;
} }
} }
else else
HashedButtons[i].dead = true; {
} t.dead = true;
for (int i = HashedButtons.Count - 1; i >= 0; i--) }
{
for (var i = HashedButtons.Count - 1; i >= 0; i--)
if (HashedButtons[i].dead) if (HashedButtons[i].dead)
HashedButtons.RemoveAt(i); HashedButtons.RemoveAt(i);
}
float height = 132 + 50 * j; float height = 132 + 50 * j;
if (j == 0) if (j == 0) height = 116;
{ instance_btnPan.height += (int) ((height - instance_btnPan.height) * 0.2f);
height = 116;
}
instance_btnPan.height += (int)(((float)height - (float)instance_btnPan.height) * 0.2f);
if (Program.TimePassed() - lastTickTime > 1000) if (Program.TimePassed() - lastTickTime > 1000)
{ {
lastTickTime = Program.TimePassed(); lastTickTime = Program.TimePassed();
...@@ -164,32 +144,47 @@ public class gameInfo : MonoBehaviour ...@@ -164,32 +144,47 @@ public class gameInfo : MonoBehaviour
} }
} }
List<gameUIbutton> HashedButtons = new List<gameUIbutton>(); public void on_toggle_ignore()
{
toggle_all.value = false;
toggle_smart.value = false;
}
public void on_toggle_all()
{
toggle_ignore.value = false;
toggle_smart.value = false;
}
public void on_toggle_smart()
{
toggle_ignore.value = false;
toggle_all.value = false;
}
public void ini()
{
Update();
}
public void addHashedButton(string hashString_, int hashInt, superButtonType type, string hint) public void addHashedButton(string hashString_, int hashInt, superButtonType type, string hint)
{ {
gameUIbutton hashedButton = new gameUIbutton(); var hashedButton = new gameUIbutton();
string hashString = hashString_; var hashString = hashString_;
if (hashString == "") if (hashString == "") hashString = hashInt.ToString();
{
hashString = hashInt.ToString();
}
hashedButton.hashString = hashString; hashedButton.hashString = hashString;
hashedButton.response = hashInt; hashedButton.response = hashInt;
hashedButton.gameObject = Program.I().create(Program.I().new_ui_superButtonTransparent); hashedButton.gameObject = Program.I().create(Program.I().new_ui_superButtonTransparent);
UIHelper.trySetLableText(hashedButton.gameObject, "hint_", hint); UIHelper.trySetLableText(hashedButton.gameObject, "hint_", hint);
UIHelper.getRealEventGameObject(hashedButton.gameObject).name = hashString + "----" + hashInt.ToString(); UIHelper.getRealEventGameObject(hashedButton.gameObject).name = hashString + "----" + hashInt;
UIHelper.registUIEventTriggerForClick(hashedButton.gameObject, listenerForClicked); UIHelper.registUIEventTriggerForClick(hashedButton.gameObject, listenerForClicked);
hashedButton.gameObject.GetComponent<iconSetForButton>().setTexture(type); hashedButton.gameObject.GetComponent<iconSetForButton>().setTexture(type);
hashedButton.gameObject.GetComponent<iconSetForButton>().setText(hint); hashedButton.gameObject.GetComponent<iconSetForButton>().setText(hint);
Transform[] Transforms = hashedButton.gameObject.GetComponentsInChildren<Transform>(); var Transforms = hashedButton.gameObject.GetComponentsInChildren<Transform>();
foreach (Transform child in Transforms) foreach (var child in Transforms) child.gameObject.layer = instance_btnPan.gameObject.layer;
{ hashedButton.gameObject.transform.SetParent(instance_btnPan.transform, false);
child.gameObject.layer = instance_btnPan.gameObject.layer;
}
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); iTween.ScaleTo(hashedButton.gameObject, new Vector3(0.9f, 0.9f, 0.9f), 0.3f);
hashedButton.dying = false; hashedButton.dying = false;
...@@ -197,94 +192,62 @@ public class gameInfo : MonoBehaviour ...@@ -197,94 +192,62 @@ public class gameInfo : MonoBehaviour
refreshLine(); refreshLine();
} }
void listenerForClicked(GameObject obj) private void listenerForClicked(GameObject obj)
{ {
string[] mats = obj.name.Split("----"); var mats = obj.name.Split("----");
if (mats.Length == 2) if (mats.Length == 2)
{ for (var i = 0; i < HashedButtons.Count; i++)
for (int i = 0; i < HashedButtons.Count; i++)
{
if (HashedButtons[i].hashString == mats[0]) if (HashedButtons[i].hashString == mats[0])
{
if (HashedButtons[i].response.ToString() == mats[1]) if (HashedButtons[i].response.ToString() == mats[1])
{
Program.I().ocgcore.ES_gameUIbuttonClicked(HashedButtons[i]); Program.I().ocgcore.ES_gameUIbuttonClicked(HashedButtons[i]);
}
}
}
}
} }
public bool queryHashedButton(string hashString) public bool queryHashedButton(string hashString)
{ {
for (int i = 0; i < HashedButtons.Count; i++) for (var i = 0; i < HashedButtons.Count; i++)
{
if (HashedButtons[i].hashString == hashString && !HashedButtons[i].dying) if (HashedButtons[i].hashString == hashString && !HashedButtons[i].dying)
{
return true; return true;
}
}
return false; return false;
} }
public void removeHashedButton(string hashString) public void removeHashedButton(string hashString)
{ {
gameUIbutton remove = null; gameUIbutton remove = null;
for (int i = 0; i < HashedButtons.Count; i++) for (var i = 0; i < HashedButtons.Count; i++)
{
if (HashedButtons[i].hashString == hashString) if (HashedButtons[i].hashString == hashString)
{
remove = HashedButtons[i]; remove = HashedButtons[i];
}
}
if (remove != null) if (remove != null)
{ {
if (remove.gameObject != null) if (remove.gameObject != null) Program.I().destroy(remove.gameObject, 0.3f, true);
{
Program.I().destroy(remove.gameObject, 0.3f, true);
}
remove.dying = true; remove.dying = true;
} }
refreshLine(); refreshLine();
} }
public void removeAll() public void removeAll()
{ {
if (HashedButtons.Count == 1) if (HashedButtons.Count == 1)
{
if (HashedButtons[0].hashString == "swap") if (HashedButtons[0].hashString == "swap")
{
return; return;
} for (var i = 0; i < HashedButtons.Count; i++)
}
for (int i = 0; i < HashedButtons.Count; i++)
{ {
if (HashedButtons[i].gameObject != null) if (HashedButtons[i].gameObject != null) Program.I().destroy(HashedButtons[i].gameObject, 0.3f, true);
{
Program.I().destroy(HashedButtons[i].gameObject, 0.3f, true);
}
HashedButtons[i].dying = true; HashedButtons[i].dying = true;
} }
refreshLine(); refreshLine();
} }
void refreshLine() private void refreshLine()
{ {
int j = 0; var j = 0;
for (int i = 0; i < HashedButtons.Count; i++) for (var i = 0; i < HashedButtons.Count; i++)
{
if (!HashedButtons[i].dying) if (!HashedButtons[i].dying)
{
j++; j++;
}
}
line.SetActive(j > 0); line.SetActive(j > 0);
} }
int[] time = new int[2];
bool[] isTicking = new bool[2];
public void setTime(int player, int t) public void setTime(int player, int t)
{ {
if (player < 2) if (player < 2)
...@@ -293,7 +256,6 @@ public class gameInfo : MonoBehaviour ...@@ -293,7 +256,6 @@ public class gameInfo : MonoBehaviour
setTimeAbsolutely(player, t); setTimeAbsolutely(player, t);
isTicking[player] = true; isTicking[player] = true;
isTicking[1 - player] = false; isTicking[1 - player] = false;
} }
} }
...@@ -312,7 +274,7 @@ public class gameInfo : MonoBehaviour ...@@ -312,7 +274,7 @@ public class gameInfo : MonoBehaviour
} }
public void setTimeStill(int player) public void setTimeStill(int player)
{ {
time[0] = Program.I().ocgcore.timeLimit; time[0] = Program.I().ocgcore.timeLimit;
time[1] = Program.I().ocgcore.timeLimit; time[1] = Program.I().ocgcore.timeLimit;
...@@ -330,6 +292,7 @@ public class gameInfo : MonoBehaviour ...@@ -330,6 +292,7 @@ public class gameInfo : MonoBehaviour
opponent.under.mainTexture = GameTextureManager.exBar; opponent.under.mainTexture = GameTextureManager.exBar;
me.under.mainTexture = GameTextureManager.bar; me.under.mainTexture = GameTextureManager.bar;
} }
if (Program.I().ocgcore.timeLimit == 0) if (Program.I().ocgcore.timeLimit == 0)
{ {
me.api_timeHint.text = "infinite"; me.api_timeHint.text = "infinite";
...@@ -347,103 +310,85 @@ public class gameInfo : MonoBehaviour ...@@ -347,103 +310,85 @@ 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 + "/" + Program.I().ocgcore.timeLimit;
opponent.api_timeHint.text = "waiting"; opponent.api_timeHint.text = "waiting";
UIHelper.clearITWeen(me.api_healthBar.gameObject); 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); iTween.MoveToLocal(me.api_timeBar.gameObject,
new Vector3(me.api_timeBar.width - t / (float) Program.I().ocgcore.timeLimit * me.api_timeBar.width,
me.api_healthBar.gameObject.transform.localPosition.y,
me.api_healthBar.gameObject.transform.localPosition.z), 1f);
} }
if (player == 1) if (player == 1)
{ {
opponent.api_timeHint.text = t.ToString() + "/" + Program.I().ocgcore.timeLimit.ToString(); opponent.api_timeHint.text = t + "/" + Program.I().ocgcore.timeLimit;
me.api_timeHint.text = "waiting"; me.api_timeHint.text = "waiting";
UIHelper.clearITWeen(opponent.api_healthBar.gameObject); 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); iTween.MoveToLocal(opponent.api_timeBar.gameObject,
new Vector3(
opponent.api_timeBar.width - t / (float) Program.I().ocgcore.timeLimit * opponent.api_timeBar.width,
opponent.api_healthBar.gameObject.transform.localPosition.y,
opponent.api_healthBar.gameObject.transform.localPosition.z), 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();
opponent.api_healthHint.text = ((float)Program.I().ocgcore.life_1 > 0 ? Program.I().ocgcore.life_1 : 0).ToString(); opponent.api_healthHint.text =
((float) Program.I().ocgcore.life_1 > 0 ? Program.I().ocgcore.life_1 : 0).ToString();
me.api_name.text = Program.I().ocgcore.name_0_c; me.api_name.text = Program.I().ocgcore.name_0_c;
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( 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.width - getRealLife(Program.I().ocgcore.life_0) / Program.I().ocgcore.lpLimit *
me.api_healthBar.width,
me.api_healthBar.gameObject.transform.localPosition.y, me.api_healthBar.gameObject.transform.localPosition.y,
me.api_healthBar.gameObject.transform.localPosition.z), 1f); me.api_healthBar.gameObject.transform.localPosition.z), 1f);
iTween.MoveToLocal(opponent.api_healthBar.gameObject, new Vector3( iTween.MoveToLocal(opponent.api_healthBar.gameObject, new Vector3(
(float)(opponent.api_healthBar.width) - getRealLife(Program.I().ocgcore.life_1) / ((float)Program.I().ocgcore.lpLimit) * (float)(opponent.api_healthBar.width), opponent.api_healthBar.width - getRealLife(Program.I().ocgcore.life_1) / Program.I().ocgcore.lpLimit *
opponent.api_healthBar.width,
opponent.api_healthBar.gameObject.transform.localPosition.y, opponent.api_healthBar.gameObject.transform.localPosition.y,
opponent.api_healthBar.gameObject.transform.localPosition.z), 1f); opponent.api_healthBar.gameObject.transform.localPosition.z), 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);
{ foreach (var item in Program.I().ocgcore.confirmedCards) instance_lab.Add(item);
instance_lab.Add(GameStringHelper.yijingqueren);
}
foreach (var item in Program.I().ocgcore.confirmedCards)
{
instance_lab.Add(item);
}
} }
static float getRealLife(float in_) private static float getRealLife(float in_)
{ {
if (in_ < 0) if (in_ < 0) return 0;
{ if (in_ > Program.I().ocgcore.lpLimit) return Program.I().ocgcore.lpLimit;
return 0;
}
if (in_ > Program.I().ocgcore.lpLimit)
{
return Program.I().ocgcore.lpLimit;
}
return in_; return in_;
} }
void tick() private void tick()
{ {
if (isTicking[0]) if (isTicking[0])
{ {
if (time[0] > 0) if (time[0] > 0) time[0]--;
{ if (amIdanger())
time[0]--;
}
if (amIdanger())
{
if (Program.I().ocgcore != null) if (Program.I().ocgcore != null)
{
Program.I().ocgcore.dangerTicking(); Program.I().ocgcore.dangerTicking();
}
}
setTimeAbsolutely(0, time[0]); setTimeAbsolutely(0, time[0]);
} }
if (isTicking[1]) if (isTicking[1])
{ {
if (time[1] > 0) if (time[1] > 0) time[1]--;
{
time[1]--;
}
setTimeAbsolutely(1, time[1]); setTimeAbsolutely(1, time[1]);
} }
} }
public enum chainCondition
{
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;
...@@ -470,19 +415,10 @@ public class gameInfo : MonoBehaviour ...@@ -470,19 +415,10 @@ public class gameInfo : MonoBehaviour
public chainCondition get_condition() public chainCondition get_condition()
{ {
chainCondition res = chainCondition.standard; var res = chainCondition.standard;
if (toggle_ignore.value) if (toggle_ignore.value) res = chainCondition.no;
{ if (toggle_smart.value) res = chainCondition.smart;
res = chainCondition.no; if (toggle_all.value) res = chainCondition.all;
}
if (toggle_smart.value)
{
res = chainCondition.smart;
}
if (toggle_all.value)
{
res = chainCondition.all;
}
return res; return res;
} }
} }
\ No newline at end of file
using UnityEngine; using System;
using System.Collections; using UnityEngine;
using System; using Random = UnityEngine.Random;
public class priority_floating : MonoBehaviour public class priority_floating : MonoBehaviour
{ {
int open = 0; private int open;
// Use this for initialization // Use this for initialization
void Start() private void Start()
{ {
open = Program.TimePassed() - UnityEngine.Random.Range(0, 500); open = Program.TimePassed() - Random.Range(0, 500);
} }
// Update is called once per frame // Update is called once per frame
void Update() private void Update()
{ {
gameObject.transform.localPosition = new Vector3(0, 10*(float)Math.Sin(3.1415936f * (float)(Program.TimePassed() - open) / 500f), 0); gameObject.transform.localPosition =
new Vector3(0, 10 * (float) Math.Sin(3.1415936f * (Program.TimePassed() - open) / 500f), 0);
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class spriteChanger : MonoBehaviour { public class spriteChanger : MonoBehaviour
{
public UITexture toBeChangedUITexture; public UITexture toBeChangedUITexture;
public Texture2D[] texts = new Texture2D[6]; public Texture2D[] texts = new Texture2D[6];
public void change(int i) public void change(int i)
{ {
if(i>0){ if (i > 0)
if (i < texts.Length) if (i < texts.Length)
{ toBeChangedUITexture.mainTexture = texts[i];
toBeChangedUITexture.mainTexture=texts[i];
}
}
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class mouseParticle : MonoBehaviour { public class mouseParticle : MonoBehaviour
{
public Camera camera; public Camera camera;
public ParticleSystem e1; public ParticleSystem e1;
public ParticleSystem e2; public ParticleSystem e2;
public Transform trans; public Transform trans;
private float time = 0;
// Use this for initialization // Use this for initialization
void Start () { private void Start()
{
camera.depth = 99999; camera.depth = 99999;
} }
float time = 0;
// Update is called once per frame // Update is called once per frame
void Update () { private void Update()
Vector3 screenPoint = Input.mousePosition; {
var screenPoint = Input.mousePosition;
screenPoint.z = 10; screenPoint.z = 10;
trans.position = camera.ScreenToWorldPoint(screenPoint); trans.position = camera.ScreenToWorldPoint(screenPoint);
...@@ -29,4 +34,4 @@ public class mouseParticle : MonoBehaviour { ...@@ -29,4 +34,4 @@ public class mouseParticle : MonoBehaviour {
e2.Stop(); e2.Stop();
} }
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class panelKIller : MonoBehaviour { public class panelKIller : MonoBehaviour
UIPanel pan; {
bool on = false; private bool on;
public void ini() private UIPanel pan;
{
pan = GetComponentInChildren<UIPanel>();
}
public void set(bool r)
{
on = r;
if (pan != null)
{
if (r)
{
pan.alpha = 0;
}
}
}
// Update is called once per frame // Update is called once per frame
void Update () { private void Update()
{
if (pan != null) if (pan != null)
{ {
float to =0; float to = 0;
if (on) if (on) to = 1;
{
to = 1;
}
if (Mathf.Abs(to - pan.alpha) > 0.1f) if (Mathf.Abs(to - pan.alpha) > 0.1f)
{ {
pan.alpha += (to - pan.alpha) * Program.deltaTime * 18; pan.alpha += (to - pan.alpha) * Program.deltaTime * 18;
} }
else else
{ {
if (pan.alpha != to) if (pan.alpha != to) pan.alpha = to;
{
pan.alpha = to;
}
} }
} }
} }
}
public void ini()
{
pan = GetComponentInChildren<UIPanel>();
}
public void set(bool r)
{
on = r;
if (pan != null)
if (r)
pan.alpha = 0;
}
}
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class faceShower : MonoBehaviour { public class faceShower : MonoBehaviour
{
void Start () { private void Start()
gameObject.transform.position = Program.I().camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width/2,Screen.height*1.5f,0)); {
iTween.MoveToAction(gameObject, Program.I().camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height/2, 0)),0.6f,()=>{ gameObject.transform.position = Program.I().camera_main_2d
iTween.ScaleToAction(gameObject,Vector3.zero, 0.6f, () => { .ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height * 1.5f, 0));
Destroy(gameObject); iTween.MoveToAction(gameObject,
}, 1f); Program.I().camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, 0)), 0.6f,
},0); () => { iTween.ScaleToAction(gameObject, Vector3.zero, 0.6f, () => { Destroy(gameObject); }, 1f); });
} }
}
} \ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class handShower : MonoBehaviour public class handShower : MonoBehaviour
{ {
public Texture2D[] pics = new Texture2D[3]; public Texture2D[] pics = new Texture2D[3];
public int op = 0; public int op;
public int me = 0; public int me;
public UITexture texture_0; public UITexture texture_0;
public UITexture texture_1; public UITexture texture_1;
public GameObject GameObject_0; public GameObject GameObject_0;
public GameObject GameObject_1; public GameObject GameObject_1;
void Start()
private void Start()
{ {
pics[0] = GameTextureManager.get("jiandao"); pics[0] = GameTextureManager.get("jiandao");
pics[1] = GameTextureManager.get("shitou"); pics[1] = GameTextureManager.get("shitou");
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.I().camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, -Screen.height * 1.5f, 0)); GameObject_0.transform.position = Program.I().camera_main_2d
iTween.MoveToAction(GameObject_0, Program.I().camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2 - 80, 0)), 1f, () => { .ScreenToWorldPoint(new Vector3(Screen.width / 2, -Screen.height * 1.5f, 0));
Destroy(GameObject_0,0.3f); iTween.MoveToAction(GameObject_0,
}, 0); Program.I().camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2 - 80, 0)), 1f,
GameObject_1.transform.position = Program.I().camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height * 1.5f, 0)); () => { Destroy(GameObject_0, 0.3f); });
iTween.MoveToAction(GameObject_1, Program.I().camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2 + 80, 0)), 1f, () => { GameObject_1.transform.position = Program.I().camera_main_2d
Destroy(GameObject_1, 0.3f); .ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height * 1.5f, 0));
}, 0); iTween.MoveToAction(GameObject_1,
Program.I().camera_main_2d.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2 + 80, 0)), 1f,
() => { Destroy(GameObject_1, 0.3f); });
} }
}
} \ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class lazyBookbtns : MonoBehaviour { public class lazyBookbtns : MonoBehaviour
{
public UILabel lable; public UILabel lable;
public UITextList textlist; public UITextList textlist;
public UISprite back; public UISprite back;
// Use this for initialization // Use this for initialization
void Start () { private void Start()
{
} }
// Update is called once per frame // Update is called once per frame
void Update () { private void Update()
{
} }
} }
\ No newline at end of file
using UnityEngine; using System;
using System.Collections; using UnityEngine;
using System;
public class lazyPlayer : MonoBehaviour {
public class lazyPlayer : MonoBehaviour
{
public UIToggle prep; public UIToggle prep;
public UIButton prepAsButton; public UIButton prepAsButton;
public UIButton prepAsCollider; public UIButton prepAsCollider;
public UIButton kickAsButton; public UIButton kickAsButton;
public UISprite prepAsTexture; public UISprite prepAsTexture;
public UILabel UILabel_name; public UILabel UILabel_name;
...@@ -22,63 +21,62 @@ public class lazyPlayer : MonoBehaviour { ...@@ -22,63 +21,62 @@ public class lazyPlayer : MonoBehaviour {
public Transform transformOfPrepFore; public Transform transformOfPrepFore;
int me = 0; private bool canKick;
public void ini() private int me;
{
me = int.Parse(gameObject.name); private bool mIfMe;
setIfprepared(false);
setIfMe(false); private string mName;
SetNotNull(false);
SetIFcanKick(false); private bool NotNull;
setName("");
} public Action<int> onKick = null;
public Action<int, bool> onPrepareChanged = null;
// Use this for initialization // Use this for initialization
void Start () private void Start()
{ {
UIHelper.registEvent(prepAsButton, OnPrepClicked); UIHelper.registEvent(prepAsButton, OnPrepClicked);
UIHelper.registEvent(kickAsButton, OnKickClicked); UIHelper.registEvent(kickAsButton, OnKickClicked);
// ini(); // ini();
} }
// Update is called once per frame // Update is called once per frame
void Update() private void Update()
{ {
}
public void ini()
{
me = int.Parse(gameObject.name);
setIfprepared(false);
setIfMe(false);
SetNotNull(false);
SetIFcanKick(false);
setName("");
} }
void OnPrepClicked() private void OnPrepClicked()
{ {
if (onPrepareChanged != null) if (onPrepareChanged != null) onPrepareChanged(me, prep.value);
{
onPrepareChanged(me, prep.value);
}
} }
void OnKickClicked() private void OnKickClicked()
{ {
Program.DEBUGLOG("OnKickClicked " + me.ToString()); Program.DEBUGLOG("OnKickClicked " + me);
if (onKick != null) if (onKick != null) onKick(me);
{
onKick(me);
}
//setIfMe(!getIfMe());//bb //setIfMe(!getIfMe());//bb
} }
bool canKick = false;
public void SetIFcanKick(bool canKick_) public void SetIFcanKick(bool canKick_)
{ {
canKick = canKick_; canKick = canKick_;
if (canKick) if (canKick)
{
kickAsButton.gameObject.SetActive(true); kickAsButton.gameObject.SetActive(true);
}
else else
{
kickAsButton.gameObject.SetActive(false); kickAsButton.gameObject.SetActive(false);
}
} }
public bool getIfcanKick() public bool getIfcanKick()
...@@ -86,8 +84,6 @@ public class lazyPlayer : MonoBehaviour { ...@@ -86,8 +84,6 @@ public class lazyPlayer : MonoBehaviour {
return canKick; return canKick;
} }
bool NotNull = false;
public void SetNotNull(bool notNull_) public void SetNotNull(bool notNull_)
{ {
NotNull = notNull_; NotNull = notNull_;
...@@ -108,8 +104,6 @@ public class lazyPlayer : MonoBehaviour { ...@@ -108,8 +104,6 @@ public class lazyPlayer : MonoBehaviour {
return NotNull; return NotNull;
} }
bool mIfMe = false;
public void setIfMe(bool isMe) public void setIfMe(bool isMe)
{ {
mIfMe = isMe; mIfMe = isMe;
...@@ -132,8 +126,6 @@ public class lazyPlayer : MonoBehaviour { ...@@ -132,8 +126,6 @@ public class lazyPlayer : MonoBehaviour {
return mIfMe; return mIfMe;
} }
string mName;
public void setName(string name_) public void setName(string name_)
{ {
mName = name_; mName = name_;
...@@ -153,10 +145,6 @@ public class lazyPlayer : MonoBehaviour { ...@@ -153,10 +145,6 @@ public class lazyPlayer : MonoBehaviour {
return mName; return mName;
} }
public Action<int, bool> onPrepareChanged = null;
public Action<int> onKick = null;
public void setIfprepared(bool preped) public void setIfprepared(bool preped)
{ {
prep.value = preped; prep.value = preped;
...@@ -166,4 +154,4 @@ public class lazyPlayer : MonoBehaviour { ...@@ -166,4 +154,4 @@ public class lazyPlayer : MonoBehaviour {
{ {
return prep.value; return prep.value;
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class spining : MonoBehaviour { public class spining : MonoBehaviour
void Update () { {
transform.localEulerAngles+=(Vector3.forward * Program.deltaTime * 160); private void Update()
{
transform.localEulerAngles += Vector3.forward * Program.deltaTime * 160;
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public enum superButtonType public enum superButtonType
{ {
act, attack, bp, act,
change, ep, mp, attack,
no, see, set, bp,
spsummon, summon, yes, change,
ep,
mp,
no,
see,
set,
spsummon,
summon,
yes
} }
public class iconSetForButton : MonoBehaviour public class iconSetForButton : MonoBehaviour
{ {
public UITexture UITextureInButton; public UITexture UITextureInButton;
public UILabel UILabelInButton; public UILabel UILabelInButton;
public Texture2D act; public Texture2D act;
...@@ -26,9 +32,10 @@ public class iconSetForButton : MonoBehaviour ...@@ -26,9 +32,10 @@ public class iconSetForButton : MonoBehaviour
public Texture2D spsummon; public Texture2D spsummon;
public Texture2D summon; public Texture2D summon;
public Texture2D yes; public Texture2D yes;
public void setTexture(superButtonType type) public void setTexture(superButtonType type)
{ {
switch (type) switch (type)
{ {
case superButtonType.act: case superButtonType.act:
UITextureInButton.mainTexture = act; UITextureInButton.mainTexture = act;
...@@ -67,12 +74,14 @@ public class iconSetForButton : MonoBehaviour ...@@ -67,12 +74,14 @@ public class iconSetForButton : MonoBehaviour
UITextureInButton.mainTexture = yes; UITextureInButton.mainTexture = yes;
break; break;
} }
Color c; Color c;
ColorUtility.TryParseHtmlString(Config.Getui("gameButtonSign.color"), out c); ColorUtility.TryParseHtmlString(Config.Getui("gameButtonSign.color"), out c);
UITextureInButton.color = c; UITextureInButton.color = c;
} }
public void setText(string hint) public void setText(string hint)
{ {
UILabelInButton.text = hint; UILabelInButton.text = hint;
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class hinter : MonoBehaviour { public class hinter : MonoBehaviour
{
public string str; public string str;
bool loaded = false; private bool loaded;
UIEventTrigger trigger = null;
// Use this for initialization private GameObject obj;
void Start () {
private UIEventTrigger trigger;
// Use this for initialization
private void Start()
{
trigger = GetComponent<UIEventTrigger>(); trigger = GetComponent<UIEventTrigger>();
if (trigger==null) if (trigger == null) trigger = gameObject.AddComponent<UIEventTrigger>();
{
trigger = gameObject.AddComponent<UIEventTrigger>();
}
trigger.onHoverOver.Add(new EventDelegate(this, "in_")); trigger.onHoverOver.Add(new EventDelegate(this, "in_"));
trigger.onHoverOut.Add(new EventDelegate(this, "out_")); trigger.onHoverOut.Add(new EventDelegate(this, "out_"));
trigger.onPress.Add(new EventDelegate(this, "out_")); trigger.onPress.Add(new EventDelegate(this, "out_"));
} }
GameObject obj; // Update is called once per frame
private void Update()
{
if (loaded == false)
if (InterString.loaded)
{
loaded = true;
str = InterString.Get(str);
}
}
void in_() private void in_()
{ {
Vector3 screenPosition = Program.I().camera_main_2d.WorldToScreenPoint(gameObject.GetComponentInChildren<UITexture>().gameObject.transform.position); var screenPosition = Program.I().camera_main_2d
.WorldToScreenPoint(gameObject.GetComponentInChildren<UITexture>().gameObject.transform.position);
screenPosition.y += 45; screenPosition.y += 45;
screenPosition.z = 0; screenPosition.z = 0;
Vector3 worldPositin = Program.I().camera_main_2d.ScreenToWorldPoint(screenPosition); var worldPositin = Program.I().camera_main_2d.ScreenToWorldPoint(screenPosition);
obj = Program.I().create(Program.I().mod_simple_ngui_text, worldPositin, Vector3.zero, true, Program.I().ui_main_2d, true); obj = Program.I().create(Program.I().mod_simple_ngui_text, worldPositin, Vector3.zero, true,
Program.I().ui_main_2d);
obj.GetComponent<UILabel>().text = str; obj.GetComponent<UILabel>().text = str;
obj.GetComponent<UILabel>().effectStyle = UILabel.Effect.Outline; obj.GetComponent<UILabel>().effectStyle = UILabel.Effect.Outline;
Program.I().destroy(obj, 5f, false, false); Program.I().destroy(obj, 5f);
} }
void out_() private void out_()
{
if (obj!=null)
{
Program.I().destroy(obj, 0.6f, true, true);
}
}
// Update is called once per frame
void Update()
{ {
if (loaded == false) if (obj != null) Program.I().destroy(obj, 0.6f, true, true);
{
if (InterString.loaded == true)
{
loaded = true;
str = InterString.Get(str);
}
}
} }
} }
\ No newline at end of file
using UnityEngine; using System;
using System.Collections; using UnityEngine;
public class setbar : MonoBehaviour { public class setbar : MonoBehaviour
public void show(){ {
public void show()
{
try try
{ {
if (Program.I().setting.isShowed) if (Program.I().setting.isShowed)
{
Program.I().setting.hide(); Program.I().setting.hide();
}
else else
{
Program.I().setting.show(); Program.I().setting.show();
}
} }
catch (System.Exception) catch (Exception)
{ {
} }
} }
public void book() public void book()
{ {
try try
{ {
if (Program.I().book.isShowed) if (Program.I().book.isShowed)
{
Program.I().book.hide(); Program.I().book.hide();
}
else else
{
Program.I().book.show(); Program.I().book.show();
}
} }
catch (System.Exception) catch (Exception)
{ {
} }
} }
} }
\ No newline at end of file
using UnityEngine; using UnityEngine;
using System.Collections;
public class toolShift : MonoBehaviour { public class toolShift : MonoBehaviour
public GameObject ObjectMust = null; {
public GameObject ObjectOption = null; public GameObject ObjectMust;
public GameObject ObjectOption;
void Update() private void Update()
{ {
if (Program.InputEnterDown) if (Program.InputEnterDown)
{
if (ObjectMust.name == "input_") if (ObjectMust.name == "input_")
{ {
UIInput input = UIHelper.getByName<UIInput>(ObjectMust, "input_"); var input = UIHelper.getByName<UIInput>(ObjectMust, "input_");
if (input != null) if (input != null)
{ {
if (ObjectMust.transform.localPosition.y < 0) if (ObjectMust.transform.localPosition.y < 0)
...@@ -36,26 +35,21 @@ public class toolShift : MonoBehaviour { ...@@ -36,26 +35,21 @@ public class toolShift : MonoBehaviour {
} }
} }
} }
}
} }
public void shift() public void shift()
{ {
Vector3 va = ObjectMust.transform.localPosition; var va = ObjectMust.transform.localPosition;
if (ObjectOption == null) if (ObjectOption == null)
{ {
if (va.y >= 0) if (va.y >= 0)
{
iTween.MoveToLocal(ObjectMust, new Vector3(va.x, -100, va.z), 0.6f); iTween.MoveToLocal(ObjectMust, new Vector3(va.x, -100, va.z), 0.6f);
}
else else
{
iTween.MoveToLocal(ObjectMust, new Vector3(va.x, 0, va.z), 0.6f); iTween.MoveToLocal(ObjectMust, new Vector3(va.x, 0, va.z), 0.6f);
}
} }
else else
{ {
Vector3 vb = ObjectOption.transform.localPosition; var vb = ObjectOption.transform.localPosition;
if (va.y > vb.y) if (va.y > vb.y)
{ {
iTween.MoveToLocal(ObjectMust, new Vector3(va.x, -100, va.z), 0.6f); iTween.MoveToLocal(ObjectMust, new Vector3(va.x, -100, va.z), 0.6f);
...@@ -68,4 +62,4 @@ public class toolShift : MonoBehaviour { ...@@ -68,4 +62,4 @@ public class toolShift : MonoBehaviour {
} }
} }
} }
} }
\ No newline at end of file
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