public void MakeOneEntityPlay() { //TODO Maybe having a function pulling an entity and another one making it play will be better as we will have to loop while no action is given //TODO Could also use a list of rdy players in the class. Is it more effective ? GeneralFightingEntity entity = m_FightingEntities.Find(CanPlay); if (entity == null) { Debug.Log("[WARN] Function to make an entity play was called but no entity was found able to play, reseting counter"); entitiesAbleToPlay = 0; //TODO should use this instead, above isn't clean //throw new Exception("Function to make an entity play was called but no entity was found able to play!!"); } else { if (entity.playerControlled) { if (!m_CombatMenuUI.isLoaded()) { m_CombatMenuUI.LoadActionsMenu(entity); } CombatAction action = m_CombatMenuUI.GetAction(); if (action != null) { Debug.Log("[INFO]: " + entity + " Playing action " + action); HandleAction(action); //TODO Make different action recover speed entity.ResetCptSpeed(); m_CombatMenuUI.UnloadMenu(); RemoveDeadEntities(); entitiesAbleToPlay--; CheckBattleOver(); } action = null; } else { Debug.Log("[To be implemented] NPC entity needs to play, skipping"); //TODO entity.ResetCptSpeed(); entitiesAbleToPlay--; } } }
void CreateEntities() { allyCount = ennemyCount = 0; int allyXOffset = 0, ennemyXOffset = 0; foreach (string entityName in GlobalContext.FightingEntitiesNamesToInstantiate) { GeneralFightingEntity entity = FightingEntitiesStore.instance.getEntityPrefab(entityName); if (entity.playerControlled) { allyCount++; m_FightingEntities.Add(Instantiate(entity, new Vector3(3f + ((allyXOffset % 2 == 0)?2:0), allyXOffset, 0), Quaternion.identity)); allyXOffset++; } else { ennemyCount++; m_FightingEntities.Add(Instantiate(entity, new Vector3(-3f + ((ennemyXOffset % 2 == 0) ? 2 : 0), ennemyXOffset, 0), Quaternion.identity)); ennemyXOffset++; } } }
static bool CanPlay(GeneralFightingEntity e) { return(e.CanPlay()); }