public static Character CreateCharacter(eFactions fraction, Tile spawnTile, Character prefab, ScriptableObject uniqueSpell) { Character e = Instantiate(prefab, new Vector3( spawnTile.transform.position.x, spawnTile.transform.position.y, spawnTile.transform.position.z) , prefab.transform.rotation); e.pFaction = fraction; e.pUniqueSpell = uniqueSpell as IUniqueSpell; e.pTile = spawnTile; return(e); }
private void Start() { pUiManager.CloseAllWindows(); EntityManager.pInstance.SpawnCharacters(); EntityManager.pInstance.GetCharacterForId(0).Select(); if (Random.Range(0, 2) == 0) { pCurrentFaction = eFactions.AI1; } else { pCurrentFaction = eFactions.AI2; } mFirstFaction = pCurrentFaction; Debug.Log("Starting with " + pCurrentFaction.ToString()); pUiManager.CloseAllWindows(); pUiManager.UpdatePlayerSelection(); ChangeState(eGameState.IdleLoop); }
public List <Character> pGetCurrentFactionEntities(eFactions faction) { return(mAllEntities.Values.ToList().FindAll(T => T.pFaction == faction && T.pHpCurrent > 0 && T.pApCurrent > 9)); }
public List <Character> pGetFactionEntities(eFactions faction) { return(mAllEntities.Values.ToList().FindAll(T => T.pFaction == faction)); }
public void ChangeState(eGameState state) //TODO: Replace with setter { Debug.Log("Changing Gamestate " + pGameState + " -> " + state + " faction: " + pCurrentFaction.ToString()); if (pGameState == eGameState.EndOfMatch) { return; } pGameState = state; switch (pGameState) { case eGameState.Select: pUiManager.CloseAllWindows(); pUiManager.UpdatePlayerSelection(); pUiManager.pTurnButton.gameObject.SetActive(true); pGridGameObject.SetActive(false); if (pActiveCharacter != null) { pActiveCharacter.Deselect(); } break; case eGameState.Selected: pGridGameObject.SetActive(false); pActiveCharacter.HideRange(); pActiveCharacter.HideView(); pUiManager.ShowStatScreen(); break; case eGameState.Move: pActiveCharacter.HideView(); pActiveCharacter.HideRange(); pActiveCharacter.ShowRange(); pGridGameObject.SetActive(true); pUiManager.ShowStatScreen(); break; case eGameState.Moving: break; case eGameState.WaitForInput: GridManager.pInstance.HidePath(); pActiveCharacter.HideView(); pActiveCharacter.HideRange(); break; case eGameState.FireSkill: pActiveCharacter.HideRange(); pActiveCharacter.HideView(); pActiveCharacter.ShowView(); pGridGameObject.SetActive(true); break; case eGameState.FireUnique: pActiveCharacter.HideRange(); pActiveCharacter.HideView(); pActiveCharacter.ShowView(); pGridGameObject.SetActive(true); break; case eGameState.EndTurn: if (pActiveCharacter != null) { pActiveCharacter.pApCurrent = 0; pActiveCharacter.HideRange(); pActiveCharacter.HideView(); pActiveCharacter.pAura.gameObject.SetActive(false); EntityManager.pInstance.EndRound(pActiveCharacter); pActiveCharacter.Deselect(); } pCurrentFaction = pCurrentFaction == eFactions.Player1 ? eFactions.AI2 : eFactions.AI1; //spawning of new npcs if next faction is beginner faction if (pCurrentFaction == mFirstFaction) { EntityManager.pInstance.SpawnAI(); } ChangeState(eGameState.AIturn); break; case eGameState.AIturn: pUiManager.CloseAllWindows(); pUiManager.UpdatePlayerSelection(); if (EntityManager.pInstance.pGetCurrentFactionEntities(pCurrentFaction).Count > 0) // skip AI turn if no AI present for faction { for (int i = 0; i < 1; ++i) //HACK three ai moves per turn, debug only one { Character ai; if (pCurrentFaction == eFactions.AI1) { if (EntityManager.pInstance.pGetCurrentFactionEntities(pCurrentFaction).Count >= EntityManager.pInstance.mAI1EntityPointer) { EntityManager.pInstance.mAI1EntityPointer = 0; // loop to first entity } ai = EntityManager.pInstance.pGetCurrentFactionEntities(pCurrentFaction)[EntityManager.pInstance.mAI1EntityPointer++]; } else // faction AI2 { if (EntityManager.pInstance.pGetCurrentFactionEntities(pCurrentFaction).Count >= EntityManager.pInstance.mAI2EntityPointer) { EntityManager.pInstance.mAI2EntityPointer = 0; // loop to first entity } ai = EntityManager.pInstance.pGetCurrentFactionEntities(pCurrentFaction)[EntityManager.pInstance.mAI2EntityPointer++]; } CameraMovement.SetTarget(ai.transform); StartCoroutine(AIevaluator.EvaluateAI(ai)); } } break; case eGameState.IdleLoop: StartCoroutine(IdleWait(eGameState.AIturn)); break; case eGameState.InMenu: pUiManager.CloseAllWindows(); pUiManager.pPauseMenu.SetActive(true); break; } //pUiManager.Refresh(); }