Beispiel #1
0
    public void OnMouseEnter()
    {
        Unit       unit       = Unit.current;
        UnitAction unitAction = unit.Actions()[actionIndex].GetComponent <UnitAction>();

        StanceInformation.Show(unitAction.Name(), unitAction.MpCost().ToString(), unitAction.actionType().ToString() + " -- " + unitAction.Description());
    }
Beispiel #2
0
    public void DoAction(int x, int z, int actionIndex)
    {
        MainCamera.Lock();
        MainCamera.CenterOnWorldPoint(Unit.current.transform.position);
        ActionInformation.Hide();
        GameObject actionObject = Actions()[actionIndex];
        UnitAction action       = actionObject.GetComponent <UnitAction>();

        Cursor cursor = CursorController.cursorMatrix[x][z];

        GameObject actionDialogueObject = Instantiate(actionDialoguePrefab, transform.position, Quaternion.identity);

        actionDialogueObject.GetComponent <ActionDialogue>().message = action.Name();
        actionDialogueObject.GetComponent <ActionDialogue>().unit    = this;
        actionObject.GetComponent <UnitAction>().currentMp           = currentMp;
        System.Action beginAction = () => { actionObject.GetComponent <UnitAction>().BeginAction(cursor.gameObject); };
        currentMp -= action.MpCost();
        actionDialogueObject.GetComponent <ActionDialogue>().whenDone = beginAction;

        LookToward(x, z);
    }
Beispiel #3
0
    public static void ShowActionCursors(Unit unit, int actionIndex)
    {
        showingActionCursors = true;
        UnitAction action = unit.Actions()[actionIndex].GetComponent <UnitAction>();

        ActionInformation.Show(action.Name(), action.MpCost().ToString(), action.actionType().ToString() + " -- " + action.Description());

        Unit.Coordinate projectedCoordinate = unit.ProjectedCoordinate();

        int xPos = projectedCoordinate.xPos;
        int zPos = projectedCoordinate.zPos;

        List <Cursor> tiles = Helpers.GetRadialTiles(xPos, zPos, action.MaxDistance(), action.MaxHeightDifference(), action.CanTargetOthers(), action.MinDistance(), action.HeightAssisted());

        foreach (Cursor tile in tiles)
        {
            if (IsValidTarget(Unit.Subject(), action, tile, xPos, zPos))
            {
                tile.SetAttack();
            }
        }
    }
Beispiel #4
0
    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++;
            }
        }
    }