예제 #1
0
    public void AddHeroActionButton( HeroUnit.ActionSpell actionSpell )
    {
        //FIXME add buttons for each spells
        actionButtonCounter = 0;
        actionButtonArray[actionButtonCounter].SetActive( true );
        actionButtonArray[actionButtonCounter].GetComponent<Image>().sprite = uiViewPresenter.iceBoltIcon;
        if ( !actionSpell.spells[0].cd )
            actionButtonArray[actionButtonCounter].GetComponent<Image>().color = Color.white;
        actionButtonArray[actionButtonCounter].GetComponent<Button>().onClick.RemoveAllListeners();
        actionButtonArray[actionButtonCounter].GetComponent<Button>().onClick.AddListener( () => {
            int idx = 0;

            if (!actionSpell.spells[idx].cd ) {

                cursorAction( InputController.CursorsType.TargetSpell );

                Action<UnitViewPresenter> currentTargetSpell = x => {
                    actionSpell.targetSpell( actionSpell.spells[idx], x );
                    cursorAction( InputController.CursorsType.Simple );
                    actionButtonArray[idx].GetComponent<Image>().color = Color.gray;
                };

                this.currentTargetSpell( currentTargetSpell );
            }

        });

        ++actionButtonCounter;
        actionButtonArray[actionButtonCounter].SetActive( true );
        actionButtonArray[actionButtonCounter].GetComponent<Image>().sprite = uiViewPresenter.meteorShawerIcon;
        if ( !actionSpell.spells[1].cd )
            actionButtonArray[actionButtonCounter].GetComponent<Image>().color = Color.white;
        actionButtonArray[actionButtonCounter].GetComponent<Button>().onClick.RemoveAllListeners();
        actionButtonArray[actionButtonCounter].GetComponent<Button>().onClick.AddListener( () => {
            int idx = 1;
            if ( !actionSpell.spells[idx].cd ) {
                cursorAction( InputController.CursorsType.PositionSpell );

                Action<Vector3> currentPositionSpell = x => {
                    actionSpell.positionSpell( actionSpell.spells[idx], x );
                    cursorAction( InputController.CursorsType.Simple );
                    actionButtonArray[idx].GetComponent<Image>().color = Color.gray;
                };

                this.currentPositionSpell( currentPositionSpell );
            }
        } );
        ++actionButtonCounter;
        actionButtonArray[actionButtonCounter].SetActive( true );
        actionButtonArray[actionButtonCounter].GetComponent<Image>().sprite = uiViewPresenter.levelUpIcon;
        ++actionButtonCounter;
    }