public void OnMouseEnter() { Unit unit = Unit.current; Stance stance = unit.Stances()[stanceIndex].GetComponent <Stance>(); StanceInformation.Show(stance.Name(), "0", stance.Description()); }
public override void ReceiveVisualFeedback(Cursor cursor) { if (cursor.standingUnit) { Stance stance = cursor.standingUnit.Stance(); int damage = stance.used && stance.Name() != "Neutral" ? highDamage : lowDamage; SendDamage(damage, cursor.standingUnit); } Unit().FinishAction(); }
//Only use this publiclly if you know what you're doing, //Normally stick to change state public void ChangeStance(Stance newStance, bool fromStance = false) { //ChangeStance is only required to provide transitions if moving from stance to stance //If moving from Action to Stance then the action is responsible for providing the transition if (fromStance) { //String concatenation and comparisons aren't phenomally fast I know, but it beats a mess of nested ifs //And this code will not be called very often (at max about twice a second I imagine) string transition = "trans_" + this.stance.Name() + "->" + newStance.Name(); //Check for transition if (this.nodeAnimateSprite.Frames.HasAnimation(transition)) { this.Transition(transition); } else { //Check for oppsite transition transition = "trans_" + newStance.Name() + "->" + this.stance.Name(); if (this.nodeAnimateSprite.Frames.HasAnimation(transition)) { this.Transition(transition, true); //Plays opposite backwards } else { this.nodeAnimateSprite.Play(newStance.sprite); } } this.stance = newStance; } else { //Not coming from stance, therefore transition will be handled by the current action this.stance = newStance; this.nodeAnimateSprite.Reset(); } }
public static void Refresh() { Hide(); if (GameController.inputsFrozen) { return; } Unit unit = Unit.Subject(); display.transform.Find("Panel").Find("End Turn").gameObject.SetActive(!ModelController.inModelMode); display.enabled = ModelController.inModelMode || Player.player && Unit.current && Unit.current.playerIndex == Player.player.playerIndex && !Unit.current.dead && (!Unit.current.hasActed || !Unit.current.hasMoved); float yStart = 25; int i = 0; if (unit && (ModelController.inModelMode || !unit.hasActed && !unit.dead)) { foreach (GameObject actionObject in unit.Actions()) { int localIndex = i; GameObject buttonObject = Instantiate(menu.actionButtonPrefab, Vector3.zero, Quaternion.identity); buttonObject.transform.parent = menu.transform.Find("Panel").Find("Actions"); //buttonObject.transform.position = Vector3.zero; UnitAction action = unit.Actions()[i].GetComponent <UnitAction>(); buttonObject.transform.Find("Text").GetComponent <Text>().text = action.Name(); buttonObject.transform.position = menu.transform.Find("Panel").transform.position; buttonObject.transform.localScale = new Vector3(1, 1, 1); buttonObject.GetComponent <RectTransform>().anchoredPosition = new Vector2(-88, yStart - (i * 50)); buttonObject.GetComponent <Button>().onClick.AddListener(() => Menu.menu.PickAction(unit, localIndex)); buttonObject.GetComponent <ActionButton>().actionIndex = localIndex; buttonObject.SetActive(unit.Actions()[i].GetComponent <UnitAction>().used || unit.playerIndex == Player.player.playerIndex); if (unit.currentMp < action.MpCost()) { buttonObject.SetActive(false); } i++; } } int x = 0; if (unit && (ModelController.inModelMode || !unit.hasActed && !unit.hasMoved)) { foreach (GameObject actionObject in unit.Stances()) { int localIndex = x; GameObject buttonObject = Instantiate(menu.stanceButtonPrefab, Vector3.zero, Quaternion.identity); buttonObject.transform.parent = menu.transform.Find("Panel").Find("Stances"); Stance stance = unit.Stances()[x].GetComponent <Stance>(); string newName = stance.Name(); Stance unitStance = ModelController.inModelMode ? unit.GetComponent <ModelBehavior>().Stance() : unit.Stance(); if (stance == unitStance) { newName = newName + " *"; } buttonObject.transform.position = menu.transform.Find("Panel").transform.position; buttonObject.transform.localScale = new Vector3(1, 1, 1); buttonObject.transform.Find("Text").GetComponent <Text>().text = newName; buttonObject.GetComponent <RectTransform>().anchoredPosition = new Vector2(80, yStart - (x * 50)); buttonObject.GetComponent <Button>().onClick.AddListener(() => Menu.menu.PickStance(unit, localIndex)); buttonObject.GetComponent <StanceButton>().stanceIndex = localIndex; buttonObject.SetActive(unit.Stances()[x].GetComponent <Stance>().used || unit.playerIndex == Player.player.playerIndex); x++; } } }