示例#1
0
    public void clickCallBack(){

        if (!UIHOVERSTATUS.hovered && GameMaster.Instance.selectionMode){
            // If we are not interacting with the UI
            Vector2Int location = new Vector2Int(FInput.Instance.MouseOverTile.x, FInput.Instance.MouseOverTile.y);
            //print("Selected unit at : " + location);
        
            BaseUnit trg = BADBS.getPieceAtLoc(location);

            if (trg){
                if (selection){
                    selection.shouldHighlight = false;
                }
                selection = trg;
                trg.shouldHighlight = true;
                unitUIpanel.raise(0, this, new Dictionary<string, object>(){
                    {"BaseUnit", selection}
                });
            }
            else{
                if (selection){
                    if (!selection.moveMode){
                        selection.shouldHighlight = false;
                        selection = null;
                        unitUIpanel.raise(0, this, new Dictionary<string, object>(){
                            {"BaseUnit", selection}
                        });
                    }
                }
            }
        }
        
    }
示例#2
0
    public void addUnitAt(BaseUnit unit, int x, int y)
    {
        BoardSlot bs;

        if (x >= 0 && y >= 0 && x < boardWidth && y < boardHeight)
        {
            bs = _slots[x, y];
        }
        else
        {
            Debug.Log("Add unit at location failed, the index was out of range");
            return;
        }

        if (bs.unit)
        {
            Debug.Log("Unit currently in that location");
        }
        else
        {
            // We need to check that the selection is in board boundry
            //print("Adding unit to the board");
            bs.unit   = unit;
            unit.xPos = x;
            unit.yPos = y;

            EventDefinition displayEvent = new EventDefinition(SysTarget.UI, "addUnitDisplayObject", this);
            displayEvent.raise(unit.ID, this, new Dictionary <string, object> {
                { "BaseUnit", unit }
            });
        }

        unit.boardSpace = this;
    }
示例#3
0
    // Removes the card in the hand at the given index (from 0 to cards.Count - 1)
    public void removeCardFromHand(int index)
    {
        if (index >= cards.Count || index < 0)
        {
            throw new ApplicationException("\"index\" value passed to remove function not a valid index in the hand");
        }

        Destroy(cards[index].displayObject);
        cards.RemoveAt(index);

        // Signal Hand UI to redisplay Hand
        if (shouldDisplay)
        {
            EventDefinition handUI = new EventDefinition(SysTarget.UI, "displayHand");
            handUI.raise(0, this, new Dictionary <string, object>()
            {
                { "Hand", this }
            });
        }

        // If you were looking at the last card in the hand, make sure you're still doing that after the size decreases
        if (currentIndex == cards.Count)
        {
            currentIndex--;
        }
    }
示例#4
0
    public void attack()
    {
        GameMaster.Instance.selectionMode = false;
        if (!registeredAttack)
        {
            FInput.Instance.RegisterCallback("BDown:Fire1", false, () =>
            {
                if (attackMode)
                {
                    BaseUnit defender = this.boardSpace.getPieceAtLoc(FInput.Instance.MouseOverTile);
                    attack(defender);
                    attackMode = false;

                    EventDefinition unitUIpanel = new EventDefinition(SysTarget.UI, "setUnitPanelData");
                    unitUIpanel.raise(0, this, new Dictionary <string, object>()
                    {
                        { "BaseUnit", this }
                    });

                    GameMaster.Instance.selectionMode = true;
                }
            });

            registeredAttack = true;
        }

        attackMode = true;
    }
示例#5
0
    public void raiseEventSO()
    {
        EventDefinition tmp = new EventDefinition(def.sysTarget, def.target, this);

        tmp.raise(0, new Dictionary <string, object> {
            { "x", 5 },
            { "y", 3 }
        });
    }
示例#6
0
    // Adds a given card to the hand
    public void addCardToHand(BaseCard c)
    {
        cards.Add(c);

        // Signal Hand UI to redisplay Hand
        if (shouldDisplay)
        {
            EventDefinition handUI = new EventDefinition(SysTarget.UI, "displayHand");
            handUI.raise(0, this, new Dictionary <string, object>()
            {
                { "Hand", this }
            });
        }

        // If you no longer have an empty hand, show the first card in your hand
        if (cards.Count == 1)
        {
            currentIndex = 0;
        }
    }
示例#7
0
    /// <summary>
    /// Move function that will be given to the unit task for building
    /// the action list
    /// </summary>
    public void move()
    {
        if (!registeredMove)
        {
            FInput.Instance.RegisterCallback("BDown:Fire1", false, () => {
                if (moveMode)
                {
                    Vector2Int location = FInput.Instance.MouseOverTile;
                    move(location);
                    moveMode = false;

                    EventDefinition unitUIpanel = new EventDefinition(SysTarget.UI, "setUnitPanelData");
                    unitUIpanel.raise(0, this, new Dictionary <string, object>()
                    {
                        { "BaseUnit", this }
                    });
                }
            });
            registeredMove = true;
        }

        moveMode = true;
    }