示例#1
0
    public void EnemyDrawHand2()
    {
        //defaults the draw to enemy's EnemyActionFormat draw stat
        for (int i = 0; enemyUnit.draw > i; i++)
        {
            EnemyActionFormat tempAction = actionDeck[Random.Range(0, actionDeck.Count)];
            //for assigning sprites and enabling action slot gameObject
            //iterates through the action panel to enable action slots and assign sprites
            foreach (Transform actionSlot in actionPanel.transform)
            {
                //cache for the child transform's gameObject
                GameObject actionObject = actionSlot.gameObject;
                //iterates till it finds a disabled slot, enables it then breaks
                if (actionObject.activeSelf == false)
                {
                    //removed from deck so that an action is not repeated during draw
                    actionDeck.Remove(tempAction);

                    //Each action has the EnemyActionIcon script that contains the sprite holder and EnemyActionFormat of the action itself
                    EnemyActionIcon enemyActionIcon = actionSlot.GetComponent <EnemyActionIcon>();
                    //assigns which sprite to use from the sprite dictionary
                    enemyActionIcon.actionIcon.sprite = actionIconsDict[tempAction.actionType];
                    //assigns the EnemyActionFormat from the deck to the EnemyActionIcon holder
                    enemyActionIcon.enemyAction = tempAction;
                    actionObject.SetActive(true);
                    break;
                }
            }
        }
    }
示例#2
0
    public void EnemyCastIntent2()
    {
        //this bool is for determining whether we move on from finding links
        bool isNoMoreLinks = false;

        //do is for assuring that we find an initial intent
        do
        {
            //for finding initial intent
            if (intentPanel.transform.childCount <= 0)
            {
                //only finds from actions that are enabled
                List <GameObject> tempList = new List <GameObject>();
                foreach (Transform actionTransform in actionPanel.transform)
                {
                    if (actionTransform.gameObject.activeSelf)
                    {
                        tempList.Add(actionTransform.gameObject);
                    }
                }
                tempList[Random.Range(0, tempList.Count - 1)].transform.SetParent(intentPanel.transform);
            }
            //for finding available links for the initial intent
            else
            {
                //checks each remaining card in in actionHand if there are linkables
                foreach (Transform actionTransform in actionPanel.transform)
                {
                    if (actionTransform.gameObject.activeSelf == true)
                    {
                        EnemyActionIcon inputIntent  = actionTransform.gameObject.GetComponent <EnemyActionIcon>();
                        EnemyActionIcon outputIntent = intentPanel.transform.GetChild(intentPanel.transform.childCount - 1).gameObject.GetComponent <EnemyActionIcon>();

                        //checks the last element of the link if its output link matches the elements iterated through
                        if (inputIntent.enemyAction.inputLink == outputIntent.enemyAction.outputLink)
                        {
                            //transfers the gameObject itself to be under the intent panel
                            actionTransform.SetParent(intentPanel.transform);
                            isNoMoreLinks = false;
                            break;
                        }
                    }
                    //if we get here, no more available enemyActions
                    isNoMoreLinks = true;
                }
            }
            //will keep iterating and finding links until there are none
        } while (isNoMoreLinks == false);
    }