private Vector4[] _uvs;// = new Vector4[MAX]; void Start() { //モーションを10個くらいつくっとく // //motion int numMotion = 7; _motions = new SolitaireMotion[numMotion]; for (int i = 0; i < numMotion; i++) { _motions[i] = new SolitaireMotion(); _motions[i]._limit = _bottomDistance; _motions[i].Init(_startPosSpace); } _propertyBlock = new MaterialPropertyBlock(); _matrices = new Matrix4x4[_count]; _data = new SolitaireData[_count]; _colors = new Vector4[_count]; _randoms = new Vector4[_count]; _uvs = new Vector4[_count]; for (int i = 0; i < _count; i++) { _matrices[i] = Matrix4x4.identity; _data[i] = new SolitaireData();// _data[i].rot = Quaternion.Euler( 0, 0, 0 ); _randoms[i] = _data[i].random; _colors[i] = new Vector4( 1f, 1f, 1f, 1f ); _matrices[i].SetTRS( _data[i].pos, _data[i].rot, _data[i].scale ); _uvs[i] = SolitaireUV.GetUV(0, 0, 4, 13); //_uvs[i] = SolitaireUV.GetUV2(0,0); } _mat.SetVectorArray("_Random", _randoms); _propertyBlock.SetVectorArray("_Uv", _uvs); _propertyBlock.SetVectorArray("_Color", _colors); //_Loop(); }
//motion kara dispatch suru //計算 public void Reset() { //三箇所 ランダムに /* * Vector3[] startPos = new Vector3[]{ * new Vector3(-0.111f,0,0), * new Vector3(-0.038f,0,0), * new Vector3( 0.036f,0,0), * new Vector3( 0.111f,0,0) * };*/ Vector3[] startPos = new Vector3[] { new Vector3(-_space * 1.5f, 0, 0), new Vector3(-_space * 0.5f, 0, 0), new Vector3(_space * 0.5f, 0, 0), new Vector3(_space * 1.5f, 0, 0) }; //0,1,2,3 int kindOfCard = Mathf.FloorToInt(startPos.Length * Random.value); position = startPos[kindOfCard]; _v = new Vector3(); _v.x = Mathf.Sign(Random.value - 0.5f) * (0.005f + 0.01f * Random.value); //デフォルトでどっちかに降る _v.y = Random.value * 0.03f; _v.z = -(Random.value + 0.2f) * 0.02f; _uv = SolitaireUV.GetUV( kindOfCard, Mathf.FloorToInt(Random.value * 13f), 4, 13 ); rotation = Quaternion.Euler(0, Mathf.Atan2(_v.z, _v.x) / Mathf.PI * 180f * 0.5f, 0); _counter = 0; _counterLimit = 300; // + Mathf.FloorToInt( 100 * Random.value ); _positions = new List <Vector3>(); for (int i = 0; i < _counterLimit; i++) { UpdatePos(); } }