private Animation searchForAnim(Entity.Direction dir, Entity.Action act) { //remove 1 since dir starts with NONE, which is actually never used for the animation int tryPos = 4 * (int)act + (int)dir - 1; if (tryPos < states.Count) { Animation a = states[tryPos]; if (a.direction == dir && a.action == act) { //this is a standard list ! return(a); } } foreach (Animation a in states) { if (a.direction == dir && a.action == act) { return(a); } } throw new KeyNotFoundException("Unable to find an animation for this combination of states:(" + dir + ", " + act + ")"); }
public bool EditPathAction(Entity.Action action, out string errorMsg) { errorMsg = string.Empty; try { int delCount = actionRep.Update(action); return(true); } catch (Exception ex) { errorMsg = ex.Message; return(false); } }
public bool AddPathAction(Entity.Action action, out string errorMsg) { errorMsg = string.Empty; try { actionRep.Insert(action); return(true); } catch (Exception ex) { errorMsg = ex.Message; return(false); } }
public override void OnEntityAct(Entity.Action act) { bool doPlay = true; //don't play until player lands if (!(act == Entity.Action.hurt || act == Entity.Action.jump || act == Entity.Action.start)) { doPlay = player.planetAttach.isGround; } if (doPlay) { PlayAnim(act); } }
protected void PlayAnim(Entity.Action act) { if (mSpriteAnim != null) { if (mActionAnimIds == null) { mActionAnimIds = new int[(int)Entity.Action.NumActions]; for (int i = 0; i < mActionAnimIds.Length; i++) { mActionAnimIds[i] = mSpriteAnim.GetClipIdByName(((Entity.Action)i).ToString()); } } int id = mActionAnimIds[(int)act]; if (id != -1 && mSpriteAnim.clipId != id) { mSpriteAnim.Play(id); } } }
public void changeAnimState(Entity.Direction dir, Entity.Action act) { if (currentSate.direction == dir && currentSate.action == act) { //no need to update if we are already in the current state return; } try { currentSate = searchForAnim(dir, act); } catch (KeyNotFoundException e) { Debug.Log(e.StackTrace); currentSate = states[0]; } anim.Play(currentSate.animationName); }
public override void OnEntityAct(Entity.Action act) { base.OnEntityAct(act); switch (act) { case Entity.Action.spawning: case Entity.Action.idle: ResetCommonData(); break; case Entity.Action.stunned: if (flipOnStun) { Vector2 scale; scale = mSprite.scale; scale.y = -Mathf.Abs(scale.y); mSprite.scale = scale; } break; } }
//entity listener public void OnEntityAct(Entity.Action act) { if (player.prevAction == Entity.Action.start) { head.gameObject.active = true; headAttach.gameObject.SetActiveRecursively(true); } switch (act) { case Entity.Action.start: head.gameObject.active = false; headAttach.gameObject.SetActiveRecursively(false); break; case Entity.Action.die: neck.gameObject.SetActiveRecursively(false); head.gameObject.SetActiveRecursively(false); Expel(); break; } }
public ExhibitVisitedActionResult(Entity.Action action) : base(action) { }
public virtual void OnEntityAct(Entity.Action act) { PlayAnim(act); }
protected bool HasAnim(Entity.Action act) { return(mActionAnimIds[(int)act] != -1); }