public void Update() { m_NowTimer += Time.deltaTime; if (m_PlayerController != null) { if (m_PlayerController.playerType == IParkourPlayerController.PlayerType.Type_GuangTouQiang) { GuangtouqiangUpdate(); } else if (m_PlayerController.playerType == IParkourPlayerController.PlayerType.Type_Xiong2 || m_PlayerController.playerType == IParkourPlayerController.PlayerType.Type_XiongDa) { BrotherBearUpdate(); } } if (m_NowUseAnimationParamlist.Count != 0) { for (int i = 0; i < m_NowUseAnimationParamlist.Count; i++) { AnimationParam obj = m_NowUseAnimationParamlist[i]; obj.nowTimer += Time.deltaTime; if (obj.nowTimer > obj.delTimer) { if (obj.id == (int)PlayerAniType.G_PlayerArrestBear && delegateGuangtouqiangAniCollideArrestOver != null) { delegateGuangtouqiangAniCollideArrestOver(); } m_NowUseAnimationParamlist.RemoveAt(i); i++; } } } }
public static void StopAnimation(GameObject obj, string name, bool isCallBack = false) { AnimationParam param = Instance.GetAnimationParam(obj, name); if (obj == null || param == null) { return; } if (Instance.coroutines.ContainsKey(obj)) { Instance.StopCoroutine(Instance.coroutines[obj]); Instance.coroutines.Remove(obj); return; } if (Instance.animationItems.ContainsKey(obj)) { var item = Instance.animationItems[obj]; if (item.callback != null && isCallBack) { if (!Instance.actions.Contains(item.callback)) { Instance.actions.Add(item.callback); } } } Instance.removeList.Add(obj); }
internal void Initialization(IParkourPlayerController PlayerController) { m_PlayerController = PlayerController; m_RandomEventTimer_Bear = UnityEngine.Random.Range(m_RandomEventTimer_BearBegin, m_RandomEventTimer_BearEnd); /* * 重点问题: * 加密狗在安卓上几个小时后就会休眠,所有和加密狗的访问都会发生崩溃。 * 所以,在整个游戏运用过程中不应该在访问加密狗已经访问和加密狗相关联的任何功能了。 * 这里使用缓冲机制处理xml的读取 * * */ //XmlDocument doc = GameRoot.gameResource.LoadResource_XmlFile("HumanoidAnimation.xml"); XmlDocument doc = GameRoot.gameResource.BuffResource_XmlFile("HumanoidAnimation.xml"); XmlNodeList nodelist = doc.SelectNodes("item"); int i = 0; for (i = 0; i < nodelist.Count; i++) { AnimationParam obj = new AnimationParam(); obj.id = Convert.ToInt32(nodelist[i].Attribute("AniID")); obj.AnimationName = Convert.ToString(nodelist[i].Attribute("AnimationName")); obj.paramName = Convert.ToString(nodelist[i].Attribute("paramName")); obj.paramValue = (float)Convert.ToDouble(nodelist[i].Attribute("paramValue")); obj.nowTimer = 0.0f; obj.delValue = (float)Convert.ToDouble(nodelist[i].Attribute("delValue")); obj.delTimer = (float)Convert.ToDouble(nodelist[i].Attribute("delTimer")); m_AnimationParamlist.Add(obj.id, obj); } }
//光头强的刷新函数 private void GuangtouqiangUpdate() { if (!m_AnimationControl.isPlaying) { AnimationParam obj = GetAnimationParam((int)PlayerAniType.G_PlayerRun); m_AnimationControl.wrapMode = WrapMode.Loop; m_AnimationControl.CrossFade(obj.AnimationName); } }
internal AnimationParam GetAnimationParam(int id) { AnimationParam obj = null; if (m_AnimationParamlist.TryGetValue(id, out obj)) { return(obj); } else { return(null); } }
//光头强抓捕狗熊的动画 public void GuangtouqiangAniCollideArrest() { AnimationParam obj = GetAnimationParam((int)PlayerAniType.G_PlayerArrestBear); if (obj == null) { Debug.Log("没找对动画参数"); } m_AnimationControl.wrapMode = WrapMode.Once; m_AnimationControl.CrossFade(obj.AnimationName); obj.nowTimer = 0.0f; m_NowUseAnimationParamlist.Add(obj); }
//狗熊撞到障碍物动画 public void BrotherBearAniCollide() { //Debug.Log("狗熊碰墙"); AnimationParam obj = GetAnimationParam((int)PlayerAniType.X_PlayerCollide); if (obj == null) { Debug.Log("没找对动画参数"); } m_AnimationControl.wrapMode = WrapMode.Once; m_AnimationControl.CrossFade(obj.AnimationName); //obj.nowTimer = 0.0f; //m_NowUseAnimationParamlist.Add(obj); }
//狗熊的刷新函数 private void BrotherBearUpdate() { if (m_NowTimer > m_RandomEventTimer_Bear) { m_NowTimer = 0.0f; m_RandomEventTimer_Bear = UnityEngine.Random.Range(m_RandomEventTimer_BearBegin, m_RandomEventTimer_BearEnd); int EventParam = UnityEngine.Random.Range(0, m_RandomEventParam_Bear); AnimationParam obj = null; if (EventParam == 0) { obj = GetAnimationParam((int)PlayerAniType.X_PlayerLookLeft); } else if (EventParam == 1) { obj = GetAnimationParam((int)PlayerAniType.X_PlayerLookRight); } else { return; } if (obj == null) { Debug.Log("没找对动画参数"); } m_AnimationControl.wrapMode = WrapMode.Once; m_AnimationControl.CrossFade(obj.AnimationName); //obj.nowTimer = 0.0f; //m_NowUseAnimationParamlist.Add(obj); } if (!m_AnimationControl.isPlaying) { AnimationParam obj = GetAnimationParam((int)PlayerAniType.X_PlayerRun); m_AnimationControl.wrapMode = WrapMode.Loop; m_AnimationControl.CrossFade(obj.AnimationName); } if (m_IParkourPlayer_Xiong != null && m_IParkourPlayer_Xiong.IsInputController) { float accVal = InputDevice.Accelerate((int)m_IParkourPlayer_Xiong.playerIndex); if (accVal <= 0.3f) { m_AnimationControl[PlayerAniType.X_PlayerRun.ToString()].speed = 0f; } else { m_AnimationControl[PlayerAniType.X_PlayerRun.ToString()].speed = 1f + accVal; } } }
// 播放一个复杂动作 public AnimationEffect AddAnimation(int nID, AnimationParam param) { AnimationEffect newAnim = AnimationEffectFactory.Instance.CreateAnimation(nID); if (newAnim != null) { newAnim.param = param; newAnim.showLog = showLog; if (newAnim.Begin()) { mAnimationList.Add(newAnim); } } return(newAnim); }
//光头强的动画触发函数 public void GuangtouqiangAniRandomEvent() { int EventParam = UnityEngine.Random.Range(0, m_RandomEventParam_Guangtouqiang); if (EventParam <= 1) { //Debug.Log("光头强开火!!!!!!!!!!!!!!1"); AnimationParam obj = GetAnimationParam((int)PlayerAniType.G_PlayerFire); if (obj == null) { Debug.Log("没找对动画参数"); } m_AnimationControl.wrapMode = WrapMode.Once; m_AnimationControl.CrossFade(obj.AnimationName); //obj.nowTimer = 0.0f; //m_NowUseAnimationParamlist.Add(obj); } }
public static void PlayAnimation(GameObject obj, string name, float startTime = 0, UnityAction finishCallback = null, UnityAction frameCallback = null) { AnimationParam param = Instance.GetAnimationParam(obj, name); if (obj == null || param == null) { return; } AnimationItem item = new AnimationItem { obj = obj, time = startTime, parameter = param, callback = finishCallback, frameCallback = frameCallback }; if (param.delay != 0) { if (Instance.coroutines.ContainsKey(obj)) { Instance.StopCoroutine(Instance.coroutines[obj]); Instance.coroutines[obj] = Instance.StartCoroutine(Instance.AnimationDelay(item, param.delay)); } else { Instance.coroutines.Add(obj, Instance.StartCoroutine(Instance.AnimationDelay(item, param.delay))); } } else { if (Instance.animationItems.ContainsKey(obj)) { Instance.animationItems[obj] = item; } else { Instance.animationItems.Add(obj, item); } } }
void OnEnable() { param = (AnimationParam)target; }
public float fSpeed = 1.0f; //动画播放速率 public void ColoneTo(ref AnimationParam targetParam) { targetParam.pFSM = pFSM; targetParam.fSpeed = fSpeed; }