昨天在网上找了一些资源图片,这回就不用担心 背景资源不多的问题了,现在我一边 制作,一边发布文章。
各种各样,500多个,这里还是特别感谢 ,万恶的资本主义,不设密码就给我分享。
在制作前,大家看下这里的图片,和我之前的图片规格,有点不一样,他们大了一号。
细心的朋友,可以拿这张 ,和我 之前的图比较下。
哎,为了这500多张的 图,我也只能稍微改改 切图了,但做法都是一样的。
里面有一些 动画图,需要切一下,我推荐
这个软件,360会认为木马,其实没什么事情的,看你自己了。
很方便吧,其实 不用切,改下程序也可以,不过我懒。。。。。。
u3d中也是按16*16格子切,当然最后就有48张图了。
好了,前期准备先说到这里,下面 开始 编写代码
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using LitJson;
using System; public class myDown : MonoBehaviour
{
public Transform trs;
public Transform go;
int _x, _y;
void Start()
{
_x = go.GetComponent<ResourcesSprite>().Widths - ;
_y = go.GetComponent<ResourcesSprite>().Heights - ;
} void Update()
{ } void OnFingerDown(FingerDownEvent e)
{ /* your code here */
RaycastHitGet(e.Position);
}
void OnDrag(DragGesture gesture)
{
DragGesture dragGesture = (gesture.State == GestureRecognitionState.Ended) ? null : gesture;
if (dragGesture)
{
RaycastHitGet(gesture.Position);
}
}
void RaycastHitGet(Vector3 e)
{
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(e), Vector2.zero);
if (hit)
{
if (hit.collider.tag == "sence")
{
int type = ; for (int i = ; i < trs.childCount; i++)
{
if (trs.GetChild(i).GetComponent<Toggle>().isOn)
{
type = i;
}
}
switch (type)
{
case : OnOneFourthFind(hit.collider.transform, "play0");
break;
case : OnOneFourthFind(hit.collider.transform, "play1");
break;
case : OnOneFourthFind(hit.collider.transform, "play2");
break;
case : OnOneFourthFind(hit.collider.transform, "play3");
break;
case : OnOneFourthFind(hit.collider.transform, "play4");
break;
case : OnOneFourthFind(hit.collider.transform, "play5");
break;
case : OnOneFourthFind(hit.collider.transform, "play6");
break;
case : OnOneFourthFind(hit.collider.transform, "play7");
break;
case : OnOneFourthFind(hit.collider.transform, "play8");
break;
case : OnOneFourthFind(hit.collider.transform, "play9");
break;
case : OnOneFourthFind(hit.collider.transform, "play10");
break;
case : OnOneFourthFind(hit.collider.transform, "play11");
break;
case : OnOneFourthFind(hit.collider.transform, "play12");
break;
case : OnOneFourthFind(hit.collider.transform, "play13");
break;
case : OnOneFourthFind(hit.collider.transform, "play14");
break;
case : OnOneFourthFind(hit.collider.transform, "play15");
break;
case : OnOneFourthFind(hit.collider.transform, "play16");
break;
case : OnOneFourthFind(hit.collider.transform, "play17");
break;
case : OnOneFourthFind(hit.collider.transform, "play18");
break;
case : OnOneFourthFind(hit.collider.transform, "play19");
break;
case : OnOneFourthFind(hit.collider.transform, "play20");
break;
case : OnOneFourthFind(hit.collider.transform, "play21");
break;
case : OnOneFourthFind(hit.collider.transform, "play22");
break;
case : OnOneFourthFind(hit.collider.transform, "play23");
break;
case : OnOneFourthFind(hit.collider.transform, "play24");
break;
case : OnOneFourthFind(hit.collider.transform, "play25");
break;
case : OnOneFourthFind(hit.collider.transform, "play26");
break;
case : OnOneFourthFind(hit.collider.transform, "play27");
break;
case : OnOneFourthFind(hit.collider.transform, "play28");
break;
case : OnOneFourthFind(hit.collider.transform, "play29");
break;
case : OnOneFourthFind(hit.collider.transform, "play30");
break;
case : OnOneFourthFind(hit.collider.transform, "play31");
break;
case : OnOneFourthFind(hit.collider.transform, "play32");
break; default: break;
}
}
}
} //一对四 查找坐标
void OnOneFourthFind(Transform tr, string keys)
{
int[] st = new int[];
st[] = ;
st[] = ;
st[] = ;
st[] = ;
for (int i = ; i < ; i++)
{
AutoTileShow autoTileShow1 = tr.GetChild(i).GetComponent<AutoTileShow>();
autoTileShow1.keys = keys;
autoTileShow1.Weight = st[i];
}
tr.GetComponent<keyRoot>().keys = keys;
string[] bit = OnWeightRange(tr);
ArrayList arr = OnWeightRangeTr(bit, tr);
arr.Add(tr);
for (int ii = ; ii < arr.Count; ii++)
{
Transform aa = arr[ii] as Transform;
OnWeightNumberFind(aa, aa.GetComponent<keyRoot>().keys);
}
}
//八方向对象获得
ArrayList OnWeightRangeTr(string[] bit, Transform tts)
{
uint[] bbt = new uint[];
ArrayList arr = new ArrayList();
for (int i = ; i < ; i++)
{
if (bit[i] != "")
{
arr.Add(tts.parent.Find(bit[i]));
}
}
return arr;
} //八方向范围获得
string[] OnWeightRange(Transform tts)
{
string[] tt = tts.name.Split(',');
int xx = int.Parse(tt[].ToString());
int yy = int.Parse(tt[].ToString());
string[] bit = new string[]; bit[] = (xx - ) + "," + (yy + );
bit[] = xx + "," + (yy + );
bit[] = (xx + ) + "," + (yy + );
bit[] = (xx + ) + "," + (yy);
bit[] = (xx + ) + "," + (yy - );
bit[] = xx + "," + (yy - );
bit[] = (xx - ) + "," + (yy - );
bit[] = (xx - ) + "," + yy; if (xx == )
{
bit[] = "";
bit[] = "";
bit[] = "";
}
if (xx == _x)
{
bit[] = "";
bit[] = "";
bit[] = "";
}
if (yy == )
{
bit[] = "";
bit[] = "";
bit[] = "";
}
if (yy == _y)
{
bit[] = "";
bit[] = "";
bit[] = "";
}
return bit;
}
//权值检索
void OnWeightNumberFind(Transform tts, string keys)
{
string[] bit = OnWeightRange(tts);
uint[] bbt = new uint[];
for (int i = ; i < ; i++)
{
if (bit[i] != "")
{
if (tts.parent.Find(bit[i]).GetComponent<keyRoot>().keys == keys)
{
bbt[i] = OnConvert(i);
}
else
{
bbt[i] = ;
}
}
else
{
bbt[i] = ;
}
} uint tb = ;
for (int i = ; i < ; i++)
{
tb |= bbt[i];
}
for (int k = ; k < ; k++)
{
tts.GetChild(k).GetComponent<AutoTileShow>().Weight = (int)(GameModel.getInstance().weightSprite[tb][k]);
tts.GetChild(k).GetComponent<AutoTileShow>().open = true;
}
}
//转换
uint OnConvert(int i)
{
uint ty = ;
switch (i)
{
case : ty = ;
break;
case : ty = ;
break;
case : ty = ;
break;
case : ty = ;
break;
case : ty = ;
break;
case : ty = ;
break;
case : ty = ;
break;
case : ty = ;
break;
}
return ty;
}
}
using UnityEngine;
using System.Collections; public class AutoTileShow : MonoBehaviour
{
int i = ;
private Sprite m_Image;
public bool open = true;
Sprite[] sp; void Start()
{
if (!gameObject.GetComponent<SpriteRenderer>())
{
m_Image = gameObject.AddComponent<SpriteRenderer>().sprite;
} sp = new Sprite[];//图片数据临时存放
} float timebattle;
public string keys;
public int Weight;
int maxTotal = ;
void Update()
{ timebattle -= Time.deltaTime;
if (timebattle <= )
{
timebattle = .2f;//闪烁频率 if (open)
{
switch (keys)
{
case "play0":
case "play2":
case "play3":
case "play4":
case "play5":
case "play6":
case "play7":
case "play8":
case "play9":
case "play10":
case "play11":
case "play12":
case "play13":
case "play14":
case "play15":
case "play16":
case "play17":
case "play18":
case "play19":
case "play20":
case "play21":
case "play22":
case "play23": maxTotal = ;
break;
case "play24":
case "play25": maxTotal = ;
break; case "play26":
case "play27":
case "play28":
case "play29":
case "play30":
case "play31":
case "play32": maxTotal = ;
break;
default: break;
}
sp = OnDirectionAutoTile(keys, Weight); open = false;
}
if (i > maxTotal - )
{
i = ;
}
m_Image = sp[i];
gameObject.GetComponent<SpriteRenderer>().sprite = m_Image;
i++;
}
} public Sprite[] OnDirectionAutoTile(string key, int number)
{
Sprite[] mapTile = new Sprite[];
mapTile = GameModel.getInstance()._TileSprite[number + "," + key];
return mapTile;
}
}
这么一贴,估计没几个朋友有兴趣继续看下去了。
好吧。上demo
链接:http://pan.baidu.com/s/1hrdKyHm 密码:h6wl
有什么不懂的,可以在 年后10天,提问