Exemple #1
0
    private void SetupAttack()
    {
        var lowRowIndex  = 0;
        var highRowIndex = 0;

        if (attack is AttackAction)
        {
            var attackDetailModified = (AttackAction)attack.Clone();
            ApplyStagger(attackDetailModified, UnitProperties);

            SetTextOrHide(lowRowAnchor, attackDetailModified.ShiftBefore, ShiftBeforeContainer, ShiftBeforeTextMesh, ref lowRowIndex, false);
            SetTextOrHide(lowRowAnchor, attackDetailModified.BlackDices, BlackContainer, BlackDiceTextMesh, ref lowRowIndex);
            SetTextOrHide(lowRowAnchor, attackDetailModified.BlueDices, BlueContainer, BlueDiceTextMesh, ref lowRowIndex);
            SetTextOrHide(lowRowAnchor, attackDetailModified.OrangeAttackDices, OrangeContainer, OrangeDiceTextMesh, ref lowRowIndex);
            SetTextOrHide(lowRowAnchor, attackDetailModified.FlatModifier, FlatContainer, FlatBonusTextMesh, ref lowRowIndex);
            SetTextOrHide(lowRowAnchor, attackDetailModified.ShiftAfter, ShiftAfterContainer, ShiftAfterTextMesh, ref lowRowIndex, false);

            SetTextOrHide(highRowAnchor, attackDetailModified.Range, RangeContainer, RangeTextMesh, ref highRowIndex, !attackDetailModified.InfiniteRange);
            SetTextOrHide(highRowAnchor, attackDetailModified.InfiniteRange ? 1 : 0, InifiniteRangeContainer, null, ref highRowIndex);
            SetTextOrHide(highRowAnchor, attackDetailModified.MinimumRange, MinRange1Container, null, ref highRowIndex);
            SetTextOrHide(highRowAnchor, attackDetailModified.MagicAttack ? 1 : 0, MagicContainer, null, ref highRowIndex);
            SetTextOrHide(highRowAnchor, attackDetailModified.NodeSplash ? 1 : 0, SplashNodeContainer, null, ref highRowIndex);
            SetTextOrHide(highRowAnchor, attackDetailModified.Repeat == 1 ? 0 : attackDetailModified.Repeat, RepeatContainer, RepeatTextMesh, ref highRowIndex);
            SetTextOrHide(highRowAnchor, attackDetailModified.Push ? 1 : 0, PushTokenContainer, null, ref highRowIndex);

            var unitStaminaLeft = UnitProperties is PlayerProperties?UnitProperties.StaminaLeft() : 10;

            hoverLayerRenderer.material = attackDetailModified.HasEnoughStamina(unitStaminaLeft) ? fade_green_material : fade_red_material;
            hoverLayerRenderer.enabled  = IsSelected;

            StaminaTextMesh.text = $"[{attackDetailModified.StaminaCost}]";
            RangeTextMesh.text   = attackDetailModified.Range.ToString();

            MovementContainer.gameObject.SetActive(false);
        }
        else
        {
            TextMesh activeText = null;
            MovementLeftTextMesh.text     = "";
            MovementRightTextMesh.text    = "";
            MovementForwardTextMesh.text  = "";
            MovementBackwardTextMesh.text = "";

            if (movement.Direction == MovementDirection.Left)
            {
                activeText = MovementLeftTextMesh;
                MovementLeftTextMesh.gameObject.SetActive(true);
            }
            if (movement.Direction == MovementDirection.Right)
            {
                activeText = MovementRightTextMesh;
                MovementRightTextMesh.gameObject.SetActive(true);
            }
            if (movement.Direction == MovementDirection.Forward)
            {
                activeText = MovementForwardTextMesh;
                MovementForwardTextMesh.gameObject.SetActive(true);
            }
            if (movement.Direction == MovementDirection.Backward)
            {
                activeText = MovementBackwardTextMesh;
                MovementBackwardTextMesh.gameObject.SetActive(true);
            }

            SetTextOrHide(lowRowAnchor, movement.MoveDistance, MovementContainer, activeText, ref lowRowIndex);

            SetTextOrHide(lowRowAnchor, 0, ShiftBeforeContainer, ShiftBeforeTextMesh, ref lowRowIndex);
            SetTextOrHide(lowRowAnchor, 0, ShiftAfterContainer, ShiftAfterTextMesh, ref lowRowIndex);
            SetTextOrHide(lowRowAnchor, 0, BlackContainer, BlackDiceTextMesh, ref lowRowIndex);
            SetTextOrHide(lowRowAnchor, 0, BlueContainer, BlueDiceTextMesh, ref lowRowIndex);
            SetTextOrHide(lowRowAnchor, 0, OrangeContainer, OrangeDiceTextMesh, ref lowRowIndex);
            SetTextOrHide(lowRowAnchor, 0, FlatContainer, FlatBonusTextMesh, ref lowRowIndex);

            SetTextOrHide(highRowAnchor, 0, RangeContainer, RangeTextMesh, ref highRowIndex);
            SetTextOrHide(highRowAnchor, 0, InifiniteRangeContainer, null, ref highRowIndex);
            SetTextOrHide(highRowAnchor, 0, MinRange1Container, null, ref highRowIndex);
            SetTextOrHide(highRowAnchor, 0, SplashNodeContainer, null, ref highRowIndex);
            SetTextOrHide(highRowAnchor, 0, RepeatContainer, RepeatTextMesh, ref highRowIndex);

            SetTextOrHide(highRowAnchor, movement.MagicAttack ? 1 : 0, MagicContainer, null, ref highRowIndex);
            SetTextOrHide(highRowAnchor, movement.Push ? 1 : 0, PushTokenContainer, null, ref highRowIndex);

            StaminaTextMesh.text = "";
            RangeTextMesh.text   = "";

            hoverLayerRenderer.material = fade_green_material;
            hoverLayerRenderer.enabled  = IsSelected;
        }

        if (IsSelected)
        {
            EventManager.RaiseEvent(ObjectEventType.AttackSelected, GetCurrentAction());
        }
    }