private IEnumerator TESTResetTurn(float resetTime) { yield return(new WaitForSeconds(resetTime)); Entities.EntityContainer playerEntityContainer = Entities.Player.access.GetComponent <Entities.EntityContainer>(); if (playerEntityContainer.statusState == Entities.StatusState.Stunned) { playerEntityContainer.statusState = Entities.StatusState.None; } #region Testing Enemy Ability Functionality //find and assign the enemies foreach (GameObject go in GameObject.FindGameObjectsWithTag("Enemy")) { if (go.name == "Medusa") { medusa = go.GetComponent <Entities.SpawnedContainer>().entityParent; } else if (go.name == "Forsaken Thrall") { thralls.Add(go.GetComponent <Entities.SpawnedContainer>().entityParent); } } //queue up damage every turn Ability medusaABTest2Damage = Systems.PlayerAbilities.abilities.AbilityDatabase()[4]; Systems.ActionManagement.management.QueueAction(medusaABTest2Damage, GameObject.FindWithTag("Ally"), medusa); foreach (GameObject thrall in thralls) { yield return(new WaitForSeconds(1f)); Systems.ActionManagement.management.QueueAction(medusaABTest2Damage, GameObject.FindWithTag("Ally"), thrall); } yield return(new WaitForSeconds(1f)); //check turn counter if (TurnManager.management.TurnCount == 2) { //grab medusa's ability Ability medusaABTestStun = Systems.PlayerAbilities.abilities.AbilityDatabase()[3]; //queue it up to be used on the player Systems.ActionManagement.management.QueueAction(medusaABTestStun, GameObject.FindWithTag("Ally"), medusa); yield return(new WaitForSeconds(1f)); } #endregion endTurnButton.GetComponent <Button>().interactable = true; playerEntityContainer.ChangeStat("Mana", playerEntityContainer.RetreiveEntity().MaxMana, true); TurnManager.management.SetTurn(CombatTurns.Player); }
public override void OnEndDrag(PointerEventData eventData) { try { Entities.EntityContainer entityContainerPlayer = Entities.Player.access.GetComponent <Entities.EntityContainer>(); if (TurnManager.management.GetTurn() == CombatTurns.Player && entityContainerPlayer.statusState != Entities.StatusState.Stunned) { GameObject target = entityContainerPlayer.Target; if (ability.AbilityType == AbilityType.Damage || ability.AbilityType == AbilityType.Debuff || ability.AbilityType == AbilityType.Hybrid) { if (eventData.pointerCurrentRaycast.gameObject.tag == "Enemy") { target = eventData.pointerCurrentRaycast.gameObject.transform.parent.gameObject; //Debug.Log("<color=blue><b>Target: </b></color>" + target.name); } } if (ability.AbilityType == AbilityType.Buff || ability.AbilityType == AbilityType.Heal) { if (eventData.pointerCurrentRaycast.gameObject.tag == "Ally") { target = eventData.pointerCurrentRaycast.gameObject.transform.parent.gameObject; //Debug.Log("<color=blue><b>Target: </b></color>" + target.name); } } if (target != null) { //queue up the ability and bind it to QueuedAction, //then clear it from the ability's target so it won't //use the old Target and assign invalid Actions. if (Entities.Player.access.GetComponent <Entities.EntityContainer>().Mana >= ability.Cost) { Systems.ActionManagement.management.QueueAction(ability, target, Entities.Player.access.gameObject); } else { //Debug.Log("<color=red><b>Alert: </b></color>Not enough Mana to use Selected Ability."); } } UIInteractionManager.management.EnableButtons(UIInteractionManager.management.actionsMenuButtonsParent); target = null; } } catch (Exception e) { Debug.Log("<color=red><b>Error: </b></color>" + e); } }
/// <summary> /// Generate the Entity Containers in the Entity Parent(s). /// </summary> /// <param name="entity"></param> public GameObject GenerateUIElements(Entities.EntityContainer container, Entities.Entity entity) { switch (entity.EntityType) { case Entities.EntityType.Ally: try { go = Instantiate(entityContainer, allyEntityParent.transform); go.transform.tag = "Ally"; go.transform.GetChild(2).tag = "Ally"; //transform for the icon Transform allyPortraitPos = go.transform.GetChild(2).transform; //increasing the scale just to emphasize the player (temporary) go.transform.localScale += new Vector3(0.2f, 0.2f); //moving the icon to be appropriate for the UI (maybe temporary) allyPortraitPos.localPosition = new Vector3( (-151), allyPortraitPos.localPosition.y, allyPortraitPos.localPosition.z); } catch (Exception e) { Debug.Log("<color=red><b>Error: </b></color>" + e); return(null); } try { PopulateEntityInformation(container, entity, go); } catch (Exception e) { Debug.Log("<color=red><b>Error: </b></color>" + e); return(null); } return(go); case Entities.EntityType.Enemy: try { go = Instantiate(entityContainer, enemyEntityParent.transform); go.transform.tag = "Enemy"; go.transform.GetChild(2).tag = "Enemy"; } catch (Exception e) { Debug.Log("<color=red><b>Error: </b></color>" + e); return(null); } try { PopulateEntityInformation(container, entity, go); } catch (Exception e) { Debug.Log("<color=red><b>Error: </b></color>" + e); return(null); } return(go); default: return(null); } }
/// <summary> /// Populates the Entity Container with the Data parsed from Entity. /// </summary> /// <param name="entity"></param> /// <param name="go"></param> private void PopulateEntityInformation(Entities.EntityContainer container, Entities.Entity entity, GameObject go) { #region Entity #Generate Configuration //assign all of the core, basic information to the created Entity go.name = entity.EntityName; container.gameObject.name = entity.EntityName; Entities.SpawnedContainer spawnedContainer = go.GetComponent <Entities.SpawnedContainer>(); spawnedContainer.GeneratedID = container.GenerateUniqueID(); spawnedContainer.entityParent = container.gameObject; //log out all the information of the created Entity //if enabled to show the debug if (showEntityDebug) { Debug.Log(string.Format("<color=blue><b>Entity Generated: </b></color> \n<b>Name:</b> {0}\n<b>ID:</b> {1}\n<b>Parent:</b> {2}", entity.EntityName, spawnedContainer.GeneratedID, spawnedContainer.entityParent)); } #endregion #region Icon //This is dependant on the heirarchy of the Entity Container Object. //Any changes to the heirarchy will break this code. //Please be aware of this fact before changing the saved Prefab. try { go.transform.GetChild(2).GetComponent <Image>().sprite = entity.Icon; } catch (Exception e) { Debug.Log("<color=red><b>Error: </b></color>" + e); } #endregion #region Health Bar //This is dependant on the heirarchy of the //Entity Container Object. //Any changes to the heirarchy will break this code. //Please be aware of this fact before changing the saved Prefab. try { Slider healthSlider = go.transform.GetChild(0).GetComponent <Slider>(); healthSlider.maxValue = entity.MaxHealth; healthSlider.value = entity.Health; Text healthText = go.transform.GetChild(0).GetChild(2).GetComponent <Text>(); healthText.text = healthSlider.value + "/" + healthSlider.maxValue; container.HealthSlider = healthSlider; container.HealthText = healthText; } catch (Exception e) { Debug.Log("<color=red><b>Error: </b></color>" + e); } #endregion #region Mana Bar //This is dependant on the heirarchy of the //Entity Container Object. //Any changes to the heirarchy will break this code. //Please be aware of this fact before changing the saved Prefab. try { Slider manaSlider = go.transform.GetChild(1).GetComponent <Slider>(); manaSlider.maxValue = entity.MaxMana; manaSlider.value = entity.Mana; Text manaText = go.transform.GetChild(1).GetChild(2).GetComponent <Text>(); manaText.text = manaSlider.value + "/" + manaSlider.maxValue; container.ManaSlider = manaSlider; container.ManaText = manaText; } catch (Exception e) { Debug.Log("<color=red><b>Error: </b></color>" + e); } #endregion }