public void PlayRunAnimation(UnitAnimatorType type) { act = (int)type; var dataUnit = GetComponent <UnitInfo>().dataUnit; anList = new [] { dataUnit.Sprite(act - 1), dataUnit.Sprite(act), dataUnit.Sprite(act - 1), dataUnit.Sprite(act + 1) }; act = 0; ShowRen(); running = true; }
public void PlayIdleAnimation(UnitAnimatorType type, int repeat = 3) { var dataUnit = GetComponent <UnitInfo>().dataUnit; //has animation? if (!dataUnit.ExistAnimationSprite(type)) { return; } //build it anList = new [] { dataUnit.AnimationSprite(type), dataUnit.AnimationSprite(type, -1), dataUnit.AnimationSprite(type), dataUnit.AnimationSprite(type, 1) }; act = 0; maxRepeat = 4 * repeat; ShowRen(); running = true; }
public bool ExistAnimationSprite(UnitAnimatorType typ) { if (typ == UnitAnimatorType.Face) { return(SpriteHelper.Exist(folder + "face")); } if (typ.ToString().StartsWith("Attack") || typ.ToString().StartsWith("Defend")) { return(SpriteHelper.Exist(folder + "fight")); } if (typ == UnitAnimatorType.Yes || typ == UnitAnimatorType.No || typ == UnitAnimatorType.Laugh || typ == UnitAnimatorType.Cast) { return(SpriteHelper.Exist(folder + "emo")); } return(false); }
public void MoveAnimationCalc(int x, int y) { var dataUnit = GetComponent <UnitInfo>().dataUnit; UnitAnimatorType type = UnitAnimatorType.MoveSouth; //rotate if (x > 0) { type = UnitAnimatorType.MoveEast; } else if (x < 0) { type = UnitAnimatorType.MoveWest; } else if (y < 0) { type = UnitAnimatorType.MoveNorth; } PlayRunAnimation(type); }
public Sprite AnimationSprite(UnitAnimatorType typ, int offset = 0) { //has a face? if (typ == UnitAnimatorType.Face) { return(ExistAnimationSprite(typ) ? SpriteHelper.Load(folder + "face:face") : Sprite()); } //show attack if (typ.ToString().StartsWith("Attack") || typ.ToString().StartsWith("Defend")) { return(SpriteHelper.Load(folder + "fight:fight_" + ((int)typ + offset))); } //has default animations? if (typ == UnitAnimatorType.Yes || typ == UnitAnimatorType.No || typ == UnitAnimatorType.Laugh || typ == UnitAnimatorType.Cast) { return(SpriteHelper.Load(folder + "emo:emo_" + ((int)typ + offset))); } return(null); }
public void PlayFightAnimation(UnitAnimatorType type) { var dataUnit = GetComponent <UnitInfo>().dataUnit; //has animation? if (!dataUnit.ExistAnimationSprite(type)) { if (type == UnitAnimatorType.AttackEast || type == UnitAnimatorType.DefendEast) { type = UnitAnimatorType.MoveEast; } else if (type == UnitAnimatorType.AttackWest || type == UnitAnimatorType.DefendWest) { type = UnitAnimatorType.MoveWest; } else if (type == UnitAnimatorType.AttackSouth || type == UnitAnimatorType.DefendSouth) { type = UnitAnimatorType.MoveSouth; } else { type = UnitAnimatorType.MoveNorth; } PlayRunAnimation(type); maxRepeat = 4; return; } //build it anList = new [] { dataUnit.AnimationSprite(type), dataUnit.AnimationSprite(type, -1), dataUnit.AnimationSprite(type), dataUnit.AnimationSprite(type, 1) }; act = 0; maxRepeat = 4; ShowRen(); running = true; GetComponent <SpriteRenderer>().flipX = type == UnitAnimatorType.DefendEast || type == UnitAnimatorType.AttackWest; }