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; } } } }
public void EnemyAct() { //base.RemoveBlock(); //foreach (EnemyActionFormat intendedAction in intendedActions) //{ // for (int i = 0; intendedActions.IndexOf(intendedAction) >= i; i++) // { // EnemyActionFactory.GetEnemyActionEffect(intendedActions[i].enumEnemyAction).InitializeEnemyAction(enemyUnit, gameObject); // //EnemyActionFactory.GetEnemyActionEffect(intendedAction.enumEnemyAction).InitializeEnemyAction(enemyUnit, gameObject); // } // //intendedActionHolder.SetActive(false); // //intendedActionHolder.transform.SetAsLastSibling(); // intendedActionHolders[intendedActions.IndexOf(intendedAction)].SetActive(false); // //intendedActionHolders[intendedActions.IndexOf(intendedAction)].transform.SetAsLastSibling(); // //actionHand.Remove(intendedAction); // //actionDeck.Add(intendedAction); // Debug.Log($"index is {intendedActions.IndexOf(intendedAction)}"); //} //actionDeck.AddRange(intendedActions); //intendedActions.Clear(); //removes block first before acting base.RemoveBlock(); //iterates through the intent panel and activate their effects foreach (Transform intentTransforms in intentPanel.transform) { //activates the first EnemyActionIcon first then carries over to the next before activating the second effect just like in creative mode for (int i = 0; intentTransforms.GetSiblingIndex() >= i; i++) { EnemyActionFormat actionFormat = intentPanel.transform.GetChild(i).GetComponent <EnemyActionIcon>().enemyAction; EnemyActionFactory.GetEnemyActionEffect(actionFormat.enumEnemyAction).InitializeEnemyAction(enemyUnit, gameObject); } intentTransforms.gameObject.SetActive(false); } //for transferring enemy actions back to the actionPanel //only checks index 0 because we're returning the prefabs to actionHand one by one while (intentPanel.transform.childCount > 0) { Transform returningAction = intentPanel.transform.GetChild(0); EnemyActionFormat returningActionFormat = returningAction.gameObject.GetComponent <EnemyActionIcon>().enemyAction; //returns the EnemyActionFormat to deckHolder actionDeck.Add(returningAction.gameObject.GetComponent <EnemyActionIcon>().enemyAction); returningAction.SetParent(actionPanel.transform); returningAction.SetAsLastSibling(); } }
public void EnemyDrawHand() { for (int i = 0; enemyUnit.draw > i; i++) { EnemyActionFormat tempAction = actionDeck[Random.Range(0, actionDeck.Count)]; //actionHand.Add(tempAction); //actionDeck.Remove(tempAction); //for assigning sprites and enabling action slot gameObject //foreach (GameObject action in actionSlotObjects) //{ // if (action.activeSelf == false) // { // Image tempActionImage = action.GetComponent<Image>(); // tempActionImage.sprite = actionIconsDict[tempAction.actionType]; // action.SetActive(true); // break; // } //} //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) { //at draw, moves actions from pool to hand by draw times actionHand.Add(tempAction); actionDeck.Remove(tempAction); Image tempActionImage = actionObject.GetComponent <Image>(); tempActionImage.sprite = actionIconsDict[tempAction.actionType]; actionObject.SetActive(true); actionSlotObjects.Add(actionObject); break; } } } }