コード例 #1
0
	public bool runAnimation (string anim)
	{
		CAnimationData data = null;
		if (m_animations == null || 
		    !m_animations.TryGetValue(anim, out data))
			return false;
			
		m_currentAnimationName = anim;	
			
		m_currentAnimation = data;
		m_currentAnimation.m_currentCellIndex = 0;
		m_timeForNextFrame = 0;
			
		int cell = m_currentAnimation.m_cells[m_currentAnimation.m_currentCellIndex];
		//print(name + " anim " + anim + " cell " + cell);
		setCell(cell);

		return true;
	}
コード例 #2
0
	protected void Update ()
	{
#endif
		// Don't animate if there's no animation, or if renderer is not visible
		if (m_currentAnimation == null || (!m_renderer.isVisible && !m_invis))
			return;
		
		float now = Time.time;
		if (now >= m_timeForNextFrame)
		{
			if (++m_currentAnimation.m_currentCellIndex >= m_currentAnimation.m_cells.Count)
			{
				if (m_currentAnimation.m_loop)
					m_currentAnimation.m_currentCellIndex = 0;
				else
				{
					m_currentAnimation = null;
					return;
				}
			}				
			m_timeForNextFrame = now + m_currentAnimation.m_currentFreq;			
			
			int cell = m_currentAnimation.m_cells[m_currentAnimation.m_currentCellIndex];
			if (cell != m_currentCell)
				setCell(cell);
		}	
	}
コード例 #3
0
	/*public void makeVisible (bool onoff)
	{
		m_mesh.triangles = onoff ? m_triangles : null;
		m_invis = !onoff;
	}*/
	
	protected void loadAnimations (string json)
	{
		object json_obj = MiniJSON.jsonDecode(json);
		if (json_obj is Hashtable)
		{
			foreach (DictionaryEntry de in (json_obj as Hashtable))
			{
				CAnimationData data = new CAnimationData (de.Value);
				if (m_animations == null)
					m_animations = new Dictionary<string, CAnimationData> ();
				m_animations.Add(de.Key.ToString(), data);
			}
		}
	}