public void SetArmyAssault() { head.Stop(); body.Stop(); horse.Stop(); head.SetFrame("Misc", 1); body.SetFrame("Misc", 1); horse.SetFrame("Idle", 0); armyAssaultFlag = true; }
public override void OnEnter() { // Get the target of the animation TargetGameObject = Fsm.GetOwnerDefaultTarget(gameObject); // If there is no target if (TargetGameObject == null && AnimationName != null) { Finish(); return; } exanimation = TargetGameObject.GetComponent<exSpriteAnimation>(); exsprite = TargetGameObject.GetComponent<exSprite>(); exsprite.trimTexture = trimTexture.Value; exsprite.useTextureOffset = useTextureOffset.Value; if (color.Value != Color.white) { exsprite.color = color.Value; }else { exsprite.color = exsprite.color; } exsprite.enabled = true; exanimation.Stop(); exanimation.Play(AnimationName.Value); }
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(); } }
public void SetArmyGarrison() { state = ArmyState.Garrison; if (animName != "") { exSpriteAnimation moveAnim = GetComponent <exSpriteAnimation>(); moveAnim.Stop(); int frame = -1; if (animName == animNames[0] || animName == animNames[3] || animName == animNames[6]) { frame = 0; } else if (animName == animNames[1] || animName == animNames[4] || animName == animNames[7]) { frame = 1; } else if (animName == animNames[2] || animName == animNames[5] || animName == animNames[8]) { frame = 2; } moveAnim.SetFrame("ArmyGarrison", frame); Vector3 pos = flagPos[3 + frame]; if (!isHFlipped) { pos.x = -pos.x; } flagCtrl.localPosition = pos; animName = ""; } }
public bool OnDamage(int t, WarSceneController.Direction dir) { if (state == State.Dead) { return(false); } bool flag = true; int block = 50; switch (t) { case -1: block = 0; break; case 1000: block = 50; break; case 0: if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 20; } else if (soliderType == 1 || soliderType == 2 || soliderType == 8) { block = 70; } break; case 1: if (soliderType == 0 || soliderType == 6 || soliderType == 10) { block = 30; } else if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 70; } break; case 2: if (soliderType == 0 || soliderType == 7 || soliderType == 10) { block = 30; } else if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 70; } break; case 3: case 4: case 5: if (soliderType == 1 || soliderType == 2 || soliderType == 6 || soliderType == 8 || soliderType == 10) { block = 30; } else if (soliderType == 0 || soliderType == 7 || soliderType == 9) { block = 80; } break; case 6: if (soliderType == 2 || soliderType == 8 || soliderType == 10) { block = 30; } else if (soliderType == 1 || soliderType == 3 || soliderType == 9) { block = 70; } break; case 7: if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 25; } else if (soliderType == 1 || soliderType == 2 || soliderType == 8) { block = 65; } break; case 8: if (soliderType == 0 || soliderType == 7 || soliderType == 10) { block = 25; } else if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 65; } break; case 9: if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 25; } else if (soliderType == 1 || soliderType == 2 || soliderType == 8) { block = 65; } break; case 10: block = 60; break; } int rand = Random.Range(0, 100); if (block > rand) { flag = false; } if (!flag) { if (!isFighting) { isParrying = true; timeTick = 0; anim.Stop(); anim.SetFrame("Parry", 0); } return(false); } if (isKnight) { if (t != -1 && life > 1) { life--; return(false); } } SoundController.Instance.PlaySound3D("00036", transform.position); state = State.Dead; timeTick = 0; anim.Stop(); anim.SetFrame("Dead", 0); if ((dir == WarSceneController.Direction.Left && transform.localScale.x > 0) || (dir == WarSceneController.Direction.Right && transform.localScale.x < 0)) { transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); } if (isKnight && soliderType != 6) { Transform horse = transform.GetChild(0); horse.gameObject.SetActive(true); horse.parent = transform.parent; horse.GetComponent <SolidersHorse>().SetHorseRun(); warCtrl.AddSoliderHorse(horse.GetComponent <SolidersHorse>()); } Vector3 pos = transform.localPosition; pos += deadBodyOffset; transform.localPosition = pos; warCtrl.RemoveSolider(index); Destroy(mapPoint.gameObject); return(true); }