Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dictionary <int,int> animDict
- public void AddAnimation(int[] numbers, int anim)
- {
- if (numbers.Length != 9) return;
- animDict[Index(numbers)] = anim;
- }
- public void Awake()
- {
- AddAnimation({ 0,0,1, 1,0,0, 0,0,0 },43);
- AddAnimation({ 0,1,1, 1,0,0, 0,0,0 },42);
- }
- private int Index(int[] numbers)
- {
- int result = 0;
- foreach(int number in numbers)
- {
- result *= 2;
- result += number;
- }
- return result;
- }
- void SpawnBorder( int[] firstCheck, Vector3[] firstCheckPostion )
- {
- int index = Index(firstCheck);
- int anim = 0;
- if (animDict.TryGetValue(index, out anim)
- {
- GameObject spawnBorder = Instantiate(SoilBorders,LevelCreator.gridPositionArray[tempPlayerX, tempPlayerY],Quaternion.identity) as GameObject;
- spawnBorder.transform.position = new Vector3(spawnBorder.transform.position.x,spawnBorder.transform.position.y,0.07f);
- PackedSprite borderType = spawnBorder.GetComponent<PackedSprite>();
- borderType.PlayAnim(anim);
- }
- else
- {
- // Not found error
- }
- }
Add Comment
Please, Sign In to add comment