Example #1
0
    private void SelectMoveTarget(USquareGridSquare us)
    {
        if (us == null)
        {
            return;
        }

        this.UISquareSelected(us);

        if (this.select_context.move_area == null)
        {
            Debug.Log("arrrrrgh");
            return;
        }

        if (!this.select_context.move_area.Squares.Contains(us))
        {
            return;
        }

        if (this.select_context.prev_square == us)
        {
            /* disable input while waiting for move animation and cleanup */
            this.select_context.input_enabled = false;
            this.StartCoroutine(this.MoveUnit(this.game.UActiveUnit, us));
        }
        else
        {
            this.select_context.SelectMoveTarget(us);
        }
    }
Example #2
0
    private IEnumerator MoveUnit(USquareGridUnit unit, USquareGridSquare us)
    {
        /* FIXME: since our distances are so small, doesn't matter but we can cache this result earlier */
        var moveable = unit.GetMoveableArea(this.game.Grid);

        moveable.ResetForSearch();
        foreach (var tmp in moveable.GetPath(us))
        {
            //Debug.Log (tmp);
            this.game.MoveUnit(unit, tmp);
            yield return(new WaitForSeconds(0.5f));
        }
        Debug.Log("---move animation done---");

        this.ui_mgr.unit_action_move.button.interactable = false;
        this.ui_mgr.unit_action_move.text.text           = "Move";

        this.select_context.Transition(SelectContext.States.ACTIVE_UNIT, this.SelectActiveUnit);

        /**
         * move cursor to unit's new position
         * TODO: since we're wiping the moveable in transition,
         * we have to do the select after. need to do something more elegant
         */
        this.SelectActiveUnit(us);

        this.select_context.input_enabled = true;
    }
Example #3
0
 public void SelectedSquare(USquareGridSquare us)
 {
     if (us != null)
     {
         this.selected_square_panel.Activate(
             "Row: " + us.Row +
             "\nCol: " + us.Col +
             "\nHeight: " + us.Height);
     }
 }
 public void SelectActiveUnit(USquareGridSquare us)
 {
     if (this.active_unit_selected != null)
     {
         this.active_unit_selected.SelectableM.Cleanup();
         this.active_unit_selected = null;
     }
     this.active_unit_cache.Select(us);
     this.active_unit_selected = us;
 }
Example #5
0
    public SelectContext(PrefabCache prefab_cache,
                         SelectContext.States state,
                         SelectContext.SelectAction action)
    {
        this.selector      = new USquareGridSelector(prefab_cache);
        this.move_area     = null;
        this.prev_square   = null;
        this.input_enabled = true;


        this.state  = state;
        this.action = action;
    }
    public override void Moved(SquareGridSquare s)
    {
        Vector3           new_pos;
        USquareGridSquare us = (USquareGridSquare)s;

        this.square = us;

        /* need to put the piece on the top of the background (TODO: gravity?) */
        new_pos   = us.WorldCenterCoords;
        new_pos.y = new_pos.y + this.half_height;
        this.g.transform.position = new_pos;

        /* not sure how expensive setactive is */
        this.g.SetActive(true);
    }
Example #7
0
    private void SelectActiveUnit(USquareGridSquare us)
    {
        USquareGridUnit unit;

        if (us == null)
        {
            return;
        }

        this.UISquareSelected(us);

        unit = (USquareGridUnit)us.GetUnit();
        if ((unit != null) && (this.game.UActiveUnit == unit))
        {
            this.ui_mgr.unit_action_panel.SetActive(true);
            this.ui_mgr.SelectedActiveUnit(unit);
        }

        this.select_context.SelectActiveUnit(us);
    }
    public void SelectMoveTarget(USquareGridSquare us)
    {
        var old_move_target = this.move_target_selected;

        if (old_move_target != null)
        {
            old_move_target.SelectableM.Cleanup();
            /* assume old_move_target was always a legit moveable */
            this.moveable_cache.Select(old_move_target);
        }

        /**
         * FIXME: should be responsibility of caller to check that square is moveable,
         * but check it here for now
         */
        if (this.moveable.Contains(us))
        {
            this.move_target_cache.Select(us);
            this.move_target_selected = us;
        }
    }
Example #9
0
 public void SelectMoveTarget(USquareGridSquare us)
 {
     this.selector.SelectMoveTarget(us);
     this.prev_square = us;
 }
Example #10
0
 public void SelectActiveUnit(USquareGridSquare us)
 {
     this.selector.SelectActiveUnit(us);
 }
Example #11
0
 public void RightSelectedSquare(USquareGridSquare us)
 {
 }
Example #12
0
 private void UISquareSelected(USquareGridSquare us)
 {
     this.ui_mgr.SelectedSquare(us);
     this.ui_mgr.SelectedUnit((USquareGridUnit)us.GetUnit());
 }