やまめも

【 ゲーム開発・日々のことについて 】

多次元配列(三次元配列)

三次元配列、大きい括弧順に要素になっていく。
以下の例だと、8組を持った大きな2括弧が第一要素になり、3組を持った大きな8括弧が第二要素になる。

using UnityEngine;
using System.Collections;

public class SituationManager : MonoBehaviour {

	//  SituationCreaterで選んだものを保持する変数。
	public string Tag;
	public Sprite SituationChara;
	public bool isDoorOpen;
	public Sprite TempSituation;

	public bool isCanTap;
	public bool isCorrect;

	public int CharaNumber;

	public Animator anim;
	private string[,,] myAnimList = {
		// level1
		{
			{"Hostage_0_0","Hostage_0_1","Hostage_0_2"},
			{"Hostage_1_0","Hostage_1_1","Hostage_1_2"},
			{"Hostage_2_0","Hostage_2_1","Hostage_2_2"},
			{"Hostage_3_0","Hostage_3_1","Hostage_3_2"},

			{"Bandit_0_0","Bandit_0_1","Bandit_0_2"},
			{"Bandit_1_0","Bandit_1_1","Bandit_1_2"},
			{"Bandit_2_0","Bandit_2_1","Bandit_2_2"},

			{"Empty_0_0","Empty_0_1","Idle"},
			{"Empty_1_0","Empty_1_1","Idle"}
		},

		// level2
		{
			{"Hostage_1_0_0","Hostage_1_0_1","Hostage_1_0_2"},
			{"Hostage_1_1_0","Hostage_1_1_1","Hostage_1_1_2"},
			{"Hostage_1_2_0","Hostage_1_2_1","Hostage_1_2_2"},
			{"Hostage_1_3_0","Hostage_1_3_1","Hostage_1_3_2"},

			{"Bandit_1_0_0","Bandit_1_0_1","Bandit_1_0_2"},
			{"Bandit_1_1_0","Bandit_1_1_1","Bandit_1_1_2"},
			{"Bandit_1_2_0","Bandit_1_2_1","Bandit_1_2_2"},

			{"Empty_1_0_0","Empty_1_0_1","Idle"},
			{"Empty_1_1_0","Empty_1_1_1","Idle"}
		}
	};
	public static SituationManager instance = null;
	void Awake(){
		if( instance == null){
			instance = this;
		}
	}
	void Start () {
	}
	void Update () {
	}

	public void HostageIdle(int level,int value){
		anim.Play(myAnimList[level,value,0]);
	}
	public void HostageCorrect(int level, int value){
		anim.Play(myAnimList[level,value,1]);
	}
	public void HostageIncorrect(int level, int value){
		anim.Play(myAnimList[level,value,2]);
	}
	public void BanditIdle(int level, int value){
		anim.Play(myAnimList[level,value,0]);
	}
	public void BanditCorrect(int level, int value){
		anim.Play(myAnimList[level,value,1]);
	}
	public void BanditIncorrect(int level, int value){
		anim.Play(myAnimList[level,value,2]);
	}
	public void EmptyIdle(int level, int value){
		anim.Play(myAnimList[level,value,0]);
	}
	public void Empty(int level, int value){
		anim.Play(myAnimList[level,value,1]);
	}
	public void Idle(int level, int value){
		anim.Play(myAnimList[level,value,2]);
	}
	public void EmptyBomPop(int level, int value){
		anim.Play(myAnimList[level, value,0]);
	}
	public void EmptyBomOut(int level, int value){
		anim.Play(myAnimList[level,value,1]);
	}
}

ufcpp.net
qiita.com
At The Intersection of Medical Science and Engineering Unity javascriptでの多次元配列