やまめも

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

2次元配列を使う

using UnityEngine;
using System.Collections;

public class SituationManager : MonoBehaviour {

	public Animator anim;
  //animationと名前が対応していないといけない。
	private string[,] myAnimList = {
		{"Hostage_0_0","Hostage_0_1","Hostage_0_2"},
		{"Bandit_0_0","Bandit_0_1","Bandit_0_2"},
		{"Empty_0_0","Empty_0_1","Idle"}
	};
	public static SituationManager instance = null;
	void Awake(){
		if( instance == null){
			instance = this;
		}
	}
	public void HostageIdle(){
		anim.Play(myAnimList[0,0]);
	}
	public void HostageCorrect(){
		anim.Play(myAnimList[0,1]);
	}
	public void HostageIncorrect(){
		anim.Play(myAnimList[0,2]);
	}
	public void BanditIdle(){
		anim.Play(myAnimList[1,0]);
	}
	public void BanditCorrect(){
		anim.Play(myAnimList[1,1]);
	}
	public void BanditIncorrect(){
		anim.Play(myAnimList[1,2]);
	}
	public void EmptyIdle(){
		anim.Play(myAnimList[2,0]);
	}
	public void Empty(){
		anim.Play(myAnimList[2,1]);
	}
	public void Idle(){
		anim.Play(myAnimList[2,2]);
	}
}

nextsystemkinectblog.seesaa.net