public void InitArmyInfo(ArmyInfo ai)
{
armyInfo = ai;
armyInfo.armyCtrl = GetComponent <ArmyController>();
SetArmyKingFlag();
if (armyInfo.cityTo != -1)
{
if (pathfinding == null)
{
pathfinding = GameObject.FindWithTag("Pathfinding").GetComponent <MyPathfinding>();
}
SetRoute(pathfinding.GetRoute(armyInfo.pos, armyInfo.cityTo));
}
state = (ArmyState)armyInfo.state;
timeTick = armyInfo.timeTick;
if (state == ArmyState.Garrison)
{
exSprite moveSprite = GetComponent <exSprite>();
exSpriteAnimation moveAnim = GetComponent <exSpriteAnimation>();
moveAnim.Stop();
int frame = armyInfo.direction;
if (frame == -1)
{
frame = 0;
}
moveAnim.SetFrame("ArmyGarrison", frame);
Vector3 pos = flagPos[3 + frame];
if (!armyInfo.isFlipped)
{
pos.x = -pos.x;
}
else
{
isHFlipped = true;
moveSprite.HFlip();
exSprite flagSprite = flagCtrl.GetComponent <exSprite>();
BoxCollider flagCol = flagCtrl.GetComponent <BoxCollider>();
flagSprite.HFlip();
flagCol.center = new Vector3(-flagCol.center.x, flagCol.center.y, flagCol.center.z);
}
flagCtrl.localPosition = pos;
}
else
{
CalcDirection();
}
}