void Start () { battleState = PerformAction.WAIT; playerGUI = PlayerInput.ACTIVATE; survivorList.AddRange (GameObject.FindGameObjectsWithTag("survivor")); zombieList.AddRange (GameObject.FindGameObjectsWithTag("zombie")); AdjustForLessThan5Zombies (); UpdateUINumbers(); }
void Start() { //バトル待機 battleStates = PerformAction.WAIT; //heroとEnemyの数を追加 HerosInBattle.AddRange(GameObject.FindGameObjectsWithTag("Hero")); EnemyInBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); //GUIActive設定 HeroInput = HeroGuI.ACTIVATE; AttackPanel.SetActive(false); EnemySelectPanel.SetActive(false); MagicPanel.SetActive(false); EnemyButtons(); }
// Use this for initialization void Start() { battlestate = PerformAction.WAIT; //add players to list at start of battle PlayerCharacters.AddRange(GameObject.FindGameObjectsWithTag("Player")); //add enemies to list at start of battle // EnemyCharacters.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); playerInput = PlayerGUI.ACTIVATE; //set panels to inactive attackPanel.SetActive(false); targetPanel.SetActive(false); skillPanel.SetActive(false); TargetButtons(); Debug.Log("buttonscreated"); }
void Start() { UpdateHeroStats(); audioManager = AudioControllerScript.instance; if (audioManager == null) { Debug.LogError("someting went horribly wrong (audioController is not found)"); } audioManager.Ambient(); magicFire = GameObject.Find("Flash"); magicFire.SetActive(false); magicPoison = GameObject.Find("Poison"); magicPoison.SetActive(false); Vector3 enemyPos = new Vector3(-4.5f, 1f, -1.25f); Enemy = Instantiate(GameManager.instance.selectedEnemies[0], enemyPos, Quaternion.identity) as GameObject; Enemy.transform.name = "Enemy"; Vector3 hero1Pos = new Vector3(3, 1, -3); Hero1 = Instantiate(GameManager.instance.selectedHeroes[0], hero1Pos, Quaternion.identity) as GameObject; string name = GameManager.instance.selectedHeroes [0].GetComponent <HeroStateMachine> ().playerStats.theName; Hero1.transform.name = name; Vector3 hero2Pos = new Vector3(3, 1, 0); Hero2 = Instantiate(GameManager.instance.selectedHeroes[1], hero2Pos, Quaternion.identity) as GameObject; Hero1.transform.Rotate(0, -90, 0); Hero2.transform.Rotate(0, -90, 0); name = GameManager.instance.selectedHeroes [1].GetComponent <HeroStateMachine> ().playerStats.theName; Hero2.transform.name = name; Enemy.transform.Rotate(0, 90, 0); //_anim.Play("Run"); battleStates = PerformAction.WAIT; EnemysInBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); HerosInBattle.AddRange(GameObject.FindGameObjectsWithTag("Hero")); HeroInput = HeroGUI.ACTIVATE; ActionPanel.SetActive(false); EnemySelectPanel.SetActive(false); MagicPanel.SetActive(false); EnemyButtons(); }
// Update is called once per frame void Update() { switch (battleStates) { case (PerformAction.WAIT): if (PerformList.Count > 0) { battleStates = PerformAction.TAKEACTION; } break; case (PerformAction.TAKEACTION): break; case (PerformAction.PERFORMACTION): break; } }
// Start is called before the first frame update void Start() { battleState = PerformAction.WAIT; heroesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Hero")); heroInput = HeroGUI.ACTIVATE; GameObject goBackButton = Instantiate(backButton) as GameObject; goBackButton.GetComponent <Button>().onClick.AddListener(() => GoBack()); goBackButton.transform.SetParent(backSpacer, false); actionPanel.SetActive(false); targetSelectPanel.SetActive(false); magicPanel.SetActive(false); backPanel.SetActive(false); EnemyButtons(); }
private void butGridMarker_Click(object sender, RoutedEventArgs e) { PerformAction?.Invoke(this, new CircleEventArgs() { ActionType = eActionTypes.ToggleGridMarkers }); if (grdGridMarkers.Visibility == Visibility.Visible) { grdGridMarkers.Visibility = Visibility.Collapsed; } else { grdGridMarkers.Visibility = Visibility.Visible; } grdGridRotationMarkers.Visibility = grdGridMarkers.Visibility; }
// Start is called before the first frame update void Start() { m_battleStates = PerformAction.WAIT; m_heroes.AddRange(GameObject.FindGameObjectsWithTag("Hero")); m_enemies.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); m_heroInput = HeroGUI.ACTIVATE; m_actionPanel.SetActive(false); m_magicPanel.SetActive(false); for (int i = 0; i < m_heroes.Count; i++) { m_heroHPs.Add(m_heroes[i].GetComponent <HeroStateMachine>().m_hero.m_currentHP); } m_attackQueue = m_heroToManage; }
void Start() { // Sets the Battle State to waiting battleState = PerformAction.WAIT; // Grabs all Heros and Enemies in Battle and adds to list EnemiesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); HerosInBattle.AddRange(GameObject.FindGameObjectsWithTag("Hero")); actionPanel.SetActive(false); targetPanel.SetActive(false); // Spawns Buttons EnemyButtons(); battleAudioSource.GetComponent <AudioSource>(); battleAudioSource.clip = battleBackgroundMusic; battleAudioSource.loop = true; battleAudioSource.Play(); }
void Start() { //Starting state battleState = PerformAction.WAIT; //Populates the lists with all enemies or heroes in battle scene EnemiesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); HeroesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Hero")); //Starting state heroInput = HeroGUI.ACTIVATE; //Deactivating panels on start actionPanel.SetActive(false); enemySelectPanel.SetActive(false); magicPanel.SetActive(false); EnemyButtons(); }
private void edges_PerformAction(object sender, EventArgs e) { var ea = e as ResizeMoveEdgesEventArgs; if (ea.ActionType == eActionTypes.ToolbarTopRight) { if (spToolbar.Visibility == Visibility.Visible) { spToolbar.Visibility = Visibility.Collapsed; } else { spToolbar.Visibility = Visibility.Visible; } } else if (ea.ActionType == eActionTypes.CenterLeft) { if (leftCenterToolBar.Visibility == Visibility.Visible) { leftCenterToolBar.Visibility = Visibility.Collapsed; } else { leftCenterToolBar.Visibility = Visibility.Visible; } } else if (ea.ActionType == eActionTypes.MoveTopLeft) { if (_foundSelectedPageContent != null) { determineBoundElements(); } } else if (ea.ActionType == eActionTypes.ResizeBottomRight) { if (_foundSelectedPageContent != null) { determineBoundElements(); } } PerformAction?.Invoke(this, e); }
void Update() { //The stats that the battle system will run to determine the flow of battle. switch (BattleState) { case (PerformAction.WAIT): //If there is a value with the list created by the 'PreformList' variable, take an action ('TAKEACTION'). if (PerformList.Count > 0) { //Will switch the state to 'TAKEACTION'. BattleState = PerformAction.TAKEACTION; } break; case (PerformAction.TAKEACTION): //Take the information from the preform list (from the first of the list) and prepare thouse actions to be preformed. //Take the information stored in the variable 'preformer' (which is now a gameObject) and set it equal to the vaule found at the top of the list from our 'PreformList' with referance to the name of the 'Attacker'. GameObject performer = GameObject.Find(PerformList[0].Attacker); //Anything with the type of Enemy will call the script and methods found in the 'EnemyStateMachine'. if (PerformList[0].Type == "Enemy") { //Creates the referance for the 'EnemyStateMachine". EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>(); //Pushes the information back to the 'EnemyStateMachine'. ESM.heroToAttack = PerformList[0].Attackers_Target; ESM.currentState = EnemyStateMachine.TurnState.ACTION; } if (PerformList[0].Type == "Hero") { } //Once we are done with getting the info about the actions we preform it. BattleState = PerformAction.PERFORMACTION; break; case (PerformAction.PERFORMACTION): break; } }
void Start() { gameManager = GameManager.instance; PlayBattleMusic(); Game.isFading = true; fadeAnim = GameObject.FindWithTag("FadeImage").GetComponent <Animator>(); LoadCharacters(); LoadEnemies(); battleStates = PerformAction.WAIT; HeroInput = HeroGUI.ACTIVATE; // Debug.Log(SceneManager.GetActiveScene().name); actionPanel.SetActive(false); magicPanel.SetActive(false); enemySelectPanel.SetActive(false); FloatingTextController.Initialize(floatingTextPrefab); if (m_LanguageManagerInstance == null) { m_LanguageManagerInstance = LanguageManager.Instance; } battleMessage = battleMessagePanel.GetComponentInChildren <Text>(); }
// Update is called once per frame void Update() { switch (actionState) { case (PerformAction.WAIT): // Waits until the action list has at least one action to perfom (sent from heroes or enemies) if (performList.Count > 0) { actionState = PerformAction.TAKEACTION; } break; case (PerformAction.TAKEACTION): // Get GameObject which is performing the action GameObject actionPerformer = GameObject.Find(performList[0].attacker); // Choose action based on type of attacker if (performList[0].attackerType == "Enemy") { ESM = actionPerformer.GetComponent <EnemyStateMachine>(); ESM.targetToAttack = performList[0].attackerTarget; ESM.currentState = EnemyStateMachine.TurnState.ACTION; } if (performList[0].attackerType == "Hero") { } // Go to next Battle State actionState = PerformAction.PERFORMACTION; break; case (PerformAction.PERFORMACTION): break; } }
// Use this for initialization void Start() { battleState = PerformAction.Wait; heroesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Hero")); enemiesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); _heroNameText = heroName.transform.Find("Text").GetComponent <Text>(); heroInput = HeroGui.Activate; turnActionPanel.SetActive(false); _turnActionText = turnActionPanel.transform.Find("TurnText").GetComponent <Text>(); actionPanel.SetActive(false); attackPanel.SetActive(false); enemySelectPanel.SetActive(false); _enemiesSpacer = enemySelectPanel.transform; _actionSpacer = actionPanel.transform; _attackSpacer = attackPanel.transform; CreateActionButtons(); }
void Start() { AddMonstersToBattlefield(); //Populate Lists of Monsters AllMonstersOnBattlefield.AddRange(GameObject.FindGameObjectsWithTag("Monster")); foreach (GameObject obj in AllMonstersOnBattlefield) { if (obj.GetComponent <BaseMonster>().wild) { EnemyMonstersOnBattlefield.Add(obj); } else { FriendlyMonstersOnBattlefield.Add(obj); } } //Update lists if someone dies //search for all monsters on the battlefield //add them in a list, then use this list - Remove from list if Dead(?) battleState = PerformAction.INCREMENT; }
// Start is called before the first frame update void Start() { foreach (GameObject spell in spells) { spell.SetActive(false); } battleStates = PerformAction.WAIT; HeroesInGame.AddRange(GameObject.FindGameObjectsWithTag("Hero")); heroname = HeroesInGame[0].name; youwin = "YouWin" + heroname; youlose = "YouLose" + heroname; EnemiesInGame.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); HeroInput = HeroGUI.ACTIVATE; ActionPanel.SetActive(false); EnemySelectPanel.SetActive(false); SpellPanel.SetActive(false); EnemyButtons(); }
// Start is called before the first frame update void Start() { combatStates = PerformAction.WAIT; EnemiesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); HeroesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Player")); int currentHealth = HeroesInBattle[0].GetComponent <PlayerStateMachine>().Ashus.getCurrentHealth(); int currentMana = HeroesInBattle[0].GetComponent <PlayerStateMachine>().Ashus.getCurrentMP(); int currentAether = HeroesInBattle[0].GetComponent <PlayerStateMachine>().Ashus.getCurrentAether(); int maxHealth = HeroesInBattle[0].GetComponent <PlayerStateMachine>().Ashus.getMaxHealth(); int maxMana = HeroesInBattle[0].GetComponent <PlayerStateMachine>().Ashus.getMaxMP(); int maxAether = HeroesInBattle[0].GetComponent <PlayerStateMachine>().Ashus.getMaxAether(); HealthText.text = "Health: " + currentHealth + "/" + maxHealth; ManaText.text = "Mana: " + currentMana + "/" + maxMana; FlowText.text = "Aether: " + currentAether + "/" + maxAether; HeroInput = HeroGUI.ACTIVATE; AttackPanel.SetActive(false); EnemySelectPanel.SetActive(false); SkillPanel.SetActive(false); EnemyButtons(); SetUpSkills(); }
// Start is called before the first frame update void Start() { playerState = GameObject.Find("PlayerState").GetComponent <PlayerState>(); enemyState = GameObject.Find("EnemyState").GetComponent <EnemyState>(); battleStates = PerformAction.WAIT; HeroesInBattle.Add(GameObject.Find("Hero0")); HeroesInBattle.Add(GameObject.Find("Hero1")); HeroesInBattle.Add(GameObject.Find("Hero2")); HeroesInBattle.Add(GameObject.Find("Hero3")); EnemiesInBattle.Add(GameObject.Find("Enemy0")); EnemiesInBattle.Add(GameObject.Find("Enemy1")); EnemiesInBattle.Add(GameObject.Find("Enemy2")); EnemiesInBattle.Add(GameObject.Find("Enemy3")); SpawnUnits(); HeroInput = HeroGUI.ACTIVATE; ActionPanel.SetActive(false); TargetSelectPanel.SetActive(false); //find spacer HeroPanelSpacer = GameObject.Find("HeroPanelSpacer").transform; EnemyPanelSpacer = GameObject.Find("EnemyPanelSpacer").transform; CreateCharacterBars(); battleStarted = true; advantageState = GameObject.Find("WorldState").GetComponent <WorldState>().advantageState; foreach (GameObject unit in HeroesInBattle) { unit.GetComponent <HeroStateMachine>().advantageState = advantageState; } foreach (GameObject unit in EnemiesInBattle) { unit.GetComponent <EnemyStateMachine>().advantageState = advantageState; } }
// Update is called once per frame void Update() { switch (battleStates) { case (PerformAction.WAIT): if (PerformList.Count > 0) { if (PerformList[0].Type == "Monster") { battleStates = PerformAction.TAKEACTION; } else { battleStates = PerformAction.STOP; } } break; case (PerformAction.TAKEACTION): GameObject performer = GameObject.Find(PerformList[0].Attacker); if (PerformList[0].Type == "Character") { CharacterState CS = performer.GetComponent <CharacterState>(); CS.MonsterToAttack = PerformList[0].AttackersTarget; CS.currentState = CharacterState.TurnState.ACTION; notPerformer = GameObject.Find(ForcesInBattle[1].name); PetState PS = notPerformer.GetComponent <PetState>(); PS.currentState = PetState.TurnState.WAITING; for (int i = 0; i < MonstersInBattle.Count; i++) { notPerformers = GameObject.Find(MonstersInBattle[i].name); MonsterState MS = notPerformers.GetComponent <MonsterState>(); MS.currentState = MonsterState.TurnState.WAITING; } } else if (PerformList[0].Type == "Pet") { notPerformer = GameObject.Find(ForcesInBattle[0].name); CharacterState CS = notPerformer.GetComponent <CharacterState>(); CS.currentState = CharacterState.TurnState.WAITING; PetState PS = performer.GetComponent <PetState>(); PS.MonsterToAttack = PerformList[0].AttackersTarget; PS.currentState = PetState.TurnState.ACTION; for (int i = 0; i < MonstersInBattle.Count; i++) { notPerformers = GameObject.Find(MonstersInBattle[i].name); MonsterState MS = notPerformers.GetComponent <MonsterState>(); MS.currentState = MonsterState.TurnState.WAITING; } } else { notPerformer1 = GameObject.Find(ForcesInBattle[0].name); CharacterState CS = notPerformer1.GetComponent <CharacterState>(); CS.currentState = CharacterState.TurnState.WAITING; notPerformer2 = GameObject.Find(ForcesInBattle[1].name); PetState PS = notPerformer2.GetComponent <PetState>(); PS.currentState = PetState.TurnState.WAITING; for (int i = 0; i < MonstersInBattle.Count; i++) { notPerformers = GameObject.Find(MonstersInBattle[i].name); MonsterState nMS = notPerformers.GetComponent <MonsterState>(); nMS.currentState = MonsterState.TurnState.WAITING; } MonsterState MS = performer.GetComponent <MonsterState>(); for (int i = 0; i < ForcesInBattle.Count; i++) { if (PerformList[0].AttackersTarget == ForcesInBattle[i]) { MS.ForceToAttack = PerformList[0].AttackersTarget; MS.currentState = MonsterState.TurnState.ACTION; break; } } } for (int i = 1; i < PerformList.Count; i++) { if (PerformList[0].Attacker == PerformList[i].Attacker) { PerformList.RemoveAt(i); } } break; case (PerformAction.STOP): notPerformer1 = GameObject.Find(ForcesInBattle[0].name); CharacterState nCS = notPerformer1.GetComponent <CharacterState>(); nCS.currentState = CharacterState.TurnState.WAITING; notPerformer2 = GameObject.Find(ForcesInBattle[1].name); PetState nPS = notPerformer2.GetComponent <PetState>(); nPS.currentState = PetState.TurnState.WAITING; for (int i = 0; i < MonstersInBattle.Count; i++) { notPerformers = GameObject.Find(MonstersInBattle[i].name); MonsterState nMS = notPerformers.GetComponent <MonsterState>(); nMS.currentState = MonsterState.TurnState.WAITING; } if (nCS.SelectedTarget) { PerformList[0].AttackersTarget = nCS.MonsterToAttack = nCS.SelectedTarget; if (nCS.attack_or_skill == 1) { nCS.which_skill = 0; PerformList[0].choosenAttack = nCS.character.attacks[nCS.which_skill]; nCS.currentState = CharacterState.TurnState.ACTION; battleStates = PerformAction.TAKEACTION; } else if (nCS.attack_or_skill == 2) { nCS.character.curMP -= nCS.character.skills[nCS.which_skill].skillCost; if (nCS.character.curMP < 0) { Debug.Log("기술을 사용하기 위한 기력이 충분하지 않습니다."); nCS.character.curMP += nCS.character.skills[nCS.which_skill].skillCost; nCS.attack_or_skill = 3; nCS.SelectedTarget = null; } else { PerformList[0].choosenSkill = nCS.character.skills[nCS.which_skill]; nCS.currentState = CharacterState.TurnState.ACTION; battleStates = PerformAction.TAKEACTION; } } } else if (nPS.SelectedTarget) { PerformList[0].AttackersTarget = nPS.MonsterToAttack = nPS.SelectedTarget; if (nPS.attack_or_skill == 1) { nPS.which_skill = 0; PerformList[0].choosenAttack = nPS.pet.attacks[nPS.which_skill]; nPS.currentState = PetState.TurnState.ACTION; battleStates = PerformAction.TAKEACTION; } else if (nPS.attack_or_skill == 2) { nPS.pet.curMP -= nPS.pet.skills[nPS.which_skill].skillCost; if (nPS.pet.curMP < 0) { Debug.Log("기술을 사용하기 위한 기력이 충분하지 않습니다."); nPS.pet.curMP += nPS.pet.skills[nPS.which_skill].skillCost; nPS.attack_or_skill = 3; nPS.SelectedTarget = null; } else { PerformList[0].choosenSkill = nPS.pet.skills[nPS.which_skill]; nPS.currentState = PetState.TurnState.ACTION; battleStates = PerformAction.TAKEACTION; } } } break; case (PerformAction.PERFORMATION): ReturnToWorld(); break; } }
public UseDoorPAbility(Prop attached) { AttachedProp = attached; PropAction = new PerformAction(Invoke); }
// Start is called before the first frame update void Start() { battleStates = PerformAction.WAIT; }
// Update is called once per frame void Update() { switch (m_battleStates) { case (PerformAction.WAIT): // if (m_performList.Count > 0) { m_battleStates = PerformAction.TAKEACTION; } break; case (PerformAction.TAKEACTION): GameObject performer = GameObject.Find(m_performList[0].Attacker); // if (m_performList[0].Type == "Enemy") { EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine>(); for (int i = 0; i < m_heroes.Count; i++) { if (m_performList[0].Target == m_heroes[i]) { esm.m_heroTarget = m_performList[0].Target; esm.m_currentState = EnemyStateMachine.TurnState.ACTION; break; } else { int j = Random.Range(0, m_heroes.Count); m_performList[0].Target = m_heroes[j]; esm.m_heroTarget = m_performList[0].Target; esm.m_currentState = EnemyStateMachine.TurnState.ACTION; } } } // if (m_performList[0].Type == "Hero") { HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>(); hsm.m_enemyTarget = m_performList[0].Target; hsm.m_currentState = HeroStateMachine.TurnState.ACTION; } m_battleStates = PerformAction.PERFORMACTION; break; case (PerformAction.PERFORMACTION): // Idle break; case (PerformAction.CHECKALIVE): // Lose battle if (m_heroToManage.Count < 1) { m_battleStates = PerformAction.LOSE; } // Win battle else if (m_enemies.Count < 1) { m_battleStates = PerformAction.WIN; } else { clearAttackPanel(); m_heroInput = HeroGUI.ACTIVATE; } break; case (PerformAction.WIN): Debug.Log("You Win!"); break; case (PerformAction.LOSE): Debug.Log("You Lose!"); break; } switch (m_heroInput) { case (HeroGUI.ACTIVATE): if (m_heroToManage.Count > 0) { m_herosChoice = new HandleTurn(); m_actionPanel.SetActive(true); createAttackButtons(); m_heroInput = HeroGUI.WAITING; } break; case (HeroGUI.WAITING): break; case (HeroGUI.DONE): heroInputDone(); for (int i = 0; i < m_heroes.Count; i++) { m_heroes[i].GetComponent <HeroStateMachine>().m_currentState = HeroStateMachine.TurnState.WAITING; } break; } m_heroHPs[0] = m_heroes[0].GetComponent <HeroStateMachine>().m_hero.m_currentHP; m_heroHPs[1] = m_heroes[1].GetComponent <HeroStateMachine>().m_hero.m_currentHP; m_heroHPs[2] = m_heroes[2].GetComponent <HeroStateMachine>().m_hero.m_currentHP; }
public void PlayerChoosePurchaseSurvivorSave () { int survIDtoRestore = survivorWithBite.survivor.survivor_id; //disable the bite panel survivorBitPanel.SetActive(false); //turn zombies and survivors back on foreach (GameObject surv in survivorList) { surv.SetActive(true); if (surv.GetComponent<SurvivorStateMachine>().survivor.survivor_id == survIDtoRestore) { //send full stam to server, and set in UI SurvivorStateMachine mySSM = surv.GetComponent<SurvivorStateMachine>(); mySSM.survivor.curStamina = mySSM.survivor.baseStamina; mySSM.UpdateStaminaBar(); StartCoroutine(SendRestoreSurvivorToServer(survIDtoRestore)); } } foreach (GameObject zombie in zombieList) { zombie.GetComponent<SpriteRenderer>().enabled = true; } foreach (GameObject surv in survivorList) { surv.GetComponent<SpriteRenderer>().enabled = true; } //resume combat battleState = PerformAction.WAIT; }
public void PlayerChooseKillSurvivor () { //disable the survivor panel survivorBitPanel.SetActive(false); //send survivor ID to the server to destoy the record on the server. int survivorIDtoDestroy = survivorWithBite.survivor.survivor_id; StartCoroutine(SendDeadSurvivorToServer(survivorIDtoDestroy)); //turn on all disabled survivors + zombies. foreach (GameObject survivor in survivorList) { survivor.GetComponent<SpriteRenderer>().enabled = true; //destroy the gameobject of the survivor that has died in the scene if (survivor.GetComponent<SurvivorStateMachine>().survivor.survivor_id == survivorIDtoDestroy) { Destroy(survivor.gameObject); } } foreach (GameObject zombie in zombieList) { zombie.GetComponent<SpriteRenderer>().enabled = true; } //destroy the survivor record on the GameManager. foreach (GameObject surv in GameManager.instance.survivorCardList) { surv.GetComponent<SpriteRenderer>().enabled = true; if (surv.GetComponent<BaseSurvivor>().survivor_id == survivorIDtoDestroy) { Destroy(surv.gameObject); } } //resume combat battleState = PerformAction.WAIT; }
// Update is called once per frame void Update() { timer += Time.deltaTime; ItemPanel.transform.GetChild(0).transform.GetChild(1).gameObject.GetComponent <Text>().text = "x" + hpPotions; ItemPanel.transform.GetChild(1).transform.GetChild(1).gameObject.GetComponent <Text>().text = "x" + spPotions; switch (battleStates) { case PerformAction.WAIT: if (PerformList.Count > 0) { battleStates = PerformAction.ACTION; } break; case PerformAction.ACTION: GameObject performer = GameObject.Find(PerformList[0].attacker); if (PerformList[0].type == "Enemy") { EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>(); ESM.PlayerToAttack = PerformList[0].TargetGO; ESM.currenState = EnemyStateMachine.TurnState.ACTION; } if (PerformList[0].type == "Player") { PlayerStateMachine PSM = performer.GetComponent <PlayerStateMachine>(); PSM.EnemyToAttack = PerformList[0].TargetGO; PSM.currentState = PlayerStateMachine.TurnState.ACTION; } break; case PerformAction.PERFORM: break; } switch (playerInput) { case PlayerUI.ACTIVATE: if (CharsToManage.Count > 0) { PlayerStateMachine PSM = CharsToManage[0].GetComponent <PlayerStateMachine>(); CharsToManage[0].transform.Find("pointer").gameObject.SetActive(true); PlayerChoice = new HandleTurn(); attributeTime = false; hpTurn += 1; defTurn += 1; spdTurn += 1; lukTurn += 1; PSM.defending += 1; AttackPanel.SetActive(true); playerInput = PlayerUI.WAITING; eventSystem.SetSelectedGameObject(atkButton); if (spdTurn >= CharsInBattle.Count * CharsInBattle.Count) { if (PSM.player.currSPD > PSM.player.maxSPD) { PSM.player.currSPD = PSM.player.maxSPD; } } if (defTurn >= CharsInBattle.Count * CharsInBattle.Count) { if (PSM.player.currDEF > PSM.player.maxDEF) { PSM.player.currDEF = PSM.player.maxDEF; } } if (lukTurn >= CharsInBattle.Count * CharsInBattle.Count) { if (PSM.player.currLUK > PSM.player.maxLUK) { PSM.player.currLUK = PSM.player.maxLUK; } } } if (!stopLeveling) { if (EnemiesInBattle.Count <= 0) { stopLeveling = false; PlayerUpdateProgressBar = false; WinPanel.SetActive(true); PlayWinMusic(); levelCharacter = 0; ExpEarn(); stopLeveling = true; } } if (CharsInBattle.Count <= 0) { stopLeveling = false; LosePanel.SetActive(true); PlayerUpdateProgressBar = false; Lost(); stopLeveling = true; } break; case PlayerUI.WAITING: if (EnemiesInBattle.Count <= 0) { playerInput = PlayerUI.DONE; } break; case PlayerUI.DONE: PlayerInputDone(); break; default: break; } if (EnemySelectPanel.activeSelf) { if (Input.GetButtonDown("Cancel")) { EnemySelectPanel.SetActive(false); AttackPanel.SetActive(true); foreach (GameObject enemyButton in enemyButtons) { Destroy(enemyButton); } foreach (GameObject specialButton in spButtons) { Destroy(specialButton); } foreach (GameObject CostText in costTexts) { Destroy(CostText); } foreach (GameObject attButton in spButtons) { Destroy(attButton); } switch (EnemiesInBattle.Count) { case 1: EnemiesInBattle[0].transform.Find("pointer").gameObject.SetActive(false); eventSystem.SetSelectedGameObject(atkButton); break; case 2: EnemiesInBattle[0].transform.Find("pointer").gameObject.SetActive(false); EnemiesInBattle[1].transform.Find("pointer").gameObject.SetActive(false); eventSystem.SetSelectedGameObject(atkButton); break; case 3: EnemiesInBattle[0].transform.Find("pointer").gameObject.SetActive(false); EnemiesInBattle[1].transform.Find("pointer").gameObject.SetActive(false); EnemiesInBattle[2].transform.Find("pointer").gameObject.SetActive(false); eventSystem.SetSelectedGameObject(atkButton); break; } } } if (ItemPanel.activeSelf) { if (Input.GetButtonDown("Cancel")) { ItemPanel.SetActive(false); AttackPanel.SetActive(true); eventSystem.SetSelectedGameObject(atkButton); } } if (levelUp) { if (timer >= 3) { ExpEarn(); LevelUp(); } } else { if (returning) { if (timer >= 1) { if (!stopShowing) { GameObject clone2 = Instantiate(popUp, popUp.transform.position, popUp.transform.rotation, GameObject.FindGameObjectWithTag("Canvas").transform); clone2.GetComponent <Text>().text = "+" + spPup + " SP Potions"; Destroy(clone2, 1f); stopShowing = true; } } if (timer >= 3) { SceneManager.LoadScene("Test"); } } } if (lost) { if (timer >= 8) { SceneManager.LoadScene("GameOver"); } } if (SpecialPanel.activeSelf) { if (Input.GetButtonDown("Cancel")) { SpecialPanel.SetActive(false); DescriptionPanel.SetActive(false); CostPanel.SetActive(false); AttackPanel.SetActive(true); foreach (GameObject specialButton in spButtons) { Destroy(specialButton); } foreach (GameObject CostText in costTexts) { Destroy(CostText); } foreach (GameObject attButton in spButtons) { Destroy(attButton); } eventSystem.SetSelectedGameObject(atkButton); } } }
void Update() { switch(battleStates) { case (PerformAction.Wait): if(PerformList.Count > 0) { battleStates = PerformAction.TakeAction; } break; case (PerformAction.TakeAction): GameObject performer = GameObject.Find(PerformList[0].Attacker); if(PerformList[0].Type == "Enemy") { StartCoroutine(AiWait()); /* EnemyStateMachine ESM = performer.GetComponent<EnemyStateMachine>(); ESM.HeroToAttack = PerformList[0].AttackersTarget; ESM.currentState = EnemyStateMachine.TurnState.Action;*/ } if (PerformList[0].Type == "Hero") { HeroStateMachine HSM = performer.GetComponent<HeroStateMachine>(); HSM.EnemyToAttack = PerformList[0].AttackersTarget; HSM.currentState = HeroStateMachine.TurnState.Action; } battleStates = PerformAction.PerformAction; break; case (PerformAction.PerformAction): break; case (PerformAction.Checkalive): if(HeroesInBattle.Count < 1) { battleStates = PerformAction.Lose; } else if(EnemiesInBattle.Count < 1) { battleStates = PerformAction.Win; } else { clearActionPanel(); HeroInput = HeroGui.Activate; } break; case (PerformAction.Win): { if(!victoryBool) { Instantiate(VictoryTextPrefab); victoryBool = true; } Debug.Log("You win"); for(int i = 0; i< HeroesInBattle.Count; i++) { HeroesInBattle[i].GetComponent<HeroStateMachine>().currentState = HeroStateMachine.TurnState.Waiting; } } break; case (PerformAction.Lose): { if(!loseBool) { Instantiate(LoseTextPrefab); loseBool = true; } Debug.Log("You lose"); } break; } switch(HeroInput) { case (HeroGui.Activate): if(HeroesToManage.Count > 0) { HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(true); HeroChoise = new HandleTurn(); ActionPanel.SetActive(true); //populate buttons CreateAttackButtons(); HeroInput = HeroGui.Waiting; } break; case (HeroGui.Waiting): break; case (HeroGui.Done): HeroInputDone(); break; } }
public EquipItemAbility() { ItemAction = new PerformAction(Invoke); }
private void HandleMainStateMachine() { switch (battleStates) { case (PerformAction.WAIT): if (performList.Count > 0) { battleStates = PerformAction.TAKEACTION; } break; case (PerformAction.TAKEACTION): GameObject performer = GameObject.Find(performList[0].Attacker); if (performList[0].Type == "Enemy") { EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>(); for (int i = 0; i < HeroesInBattle.Count; ++i) { if (performList [0].AttackersTarget == HeroesInBattle [i]) { ESM.characterToAttack = performList [0].AttackersTarget; ESM.currentState = EnemyStateMachine.TurnState.ACTION; break; } else { performList [0].AttackersTarget = HeroesInBattle [Random.Range(0, HeroesInBattle.Count)]; ESM.characterToAttack = performList [0].AttackersTarget; ESM.currentState = EnemyStateMachine.TurnState.ACTION; } } } if (performList[0].Type == "Hero") { CharacterStateMachine HSM = performer.GetComponent <CharacterStateMachine>(); HSM.characterToAttack = performList[0].AttackersTarget; HSM.currentState = CharacterStateMachine.TurnState.ACTION; } battleStates = PerformAction.PERFORMACTION; break; case (PerformAction.PERFORMACTION): break; case (PerformAction.CHECKALIVE): if (HeroesInBattle.Count < 1) { ClearAttackPanel(); battleStates = PerformAction.LOSE; } else if (EnemiesInBattle.Count < 1) { battleStates = PerformAction.WIN; } else { ClearAttackPanel(); HeroInput = HeroGUI.ACTIVATE; battleStates = PerformAction.WAIT; } break; case (PerformAction.LOSE): #if UNITY_EDITOR Debug.Log("You've lost"); #endif currentAudioSourceMusic.Stop(); battleBgMusic[3].Play(); fadeAnim.SetTrigger("fadeGameOver"); break; case (PerformAction.WIN): #if UNITY_EDITOR Debug.Log("You won"); #endif if (!afterCombat) { afterCombat = true; for (int i = 0; i < HeroesInBattle.Count; ++i) { HeroesInBattle[i].GetComponent <CharacterStateMachine>().currentState = CharacterStateMachine.TurnState.WAITING; } StartCoroutine("FinishBattle"); } break; } }
public Sweeper RegisterJob(PerformAction job) { lock (lockJobs) { jobs.Add(job); } return this; }
// Use this for initialization void Start() { battleState = PerformAction.WAIT; enemiesinGame.AddRange(GameObject.FindGameObjectsWithTag("enemy")); heroesinGame.AddRange(GameObject.FindGameObjectsWithTag("hero")); }
// Update is called once per frame private void Update() { if (PerformList.Count == charactersCount) { ExecutePerformList = new List <HandleTurn>(PerformList); SortTurnOrder(ExecutePerformList); PerformList.Clear(); }//*/ switch (BattleStates) { case (PerformAction.WAIT): { // if at least one character has // pushed action data to turn list if (ExecutePerformList.Count > 0) { BattleStates = PerformAction.TAKEACTION; Debug.Log("TAKEACTION started"); } break; } case (PerformAction.TAKEACTION): { GameObject performer = GameObject.Find(ExecutePerformList[0].Attacker); if (ExecutePerformList[0].Type == "Enemy") { EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine>(); esm.HeroToAttack = ExecutePerformList[0].AttackersTarget; esm.CurrentState = EnemyStateMachine.TurnState.ACTION; } if (ExecutePerformList[0].Type == "Hero") { HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>(); hsm.EnemyToAttack = ExecutePerformList[0].AttackersTarget; hsm.CurrentState = HeroStateMachine.TurnState.ACTION; } BattleStates = PerformAction.PERFORMACTION; break; } case (PerformAction.PERFORMACTION): { // placeholder state while // characters perform action // Resets to WAIT // when action is completed break; } } // switch (BattleStates) switch (HeroInput) { case (HeroGUI.ACTIVATE): { if (HerosToManage.Count > 0 && ExecutePerformList.Count == 0) { HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true); heroChoice = new HandleTurn(); AttackPanel.SetActive(true); HeroInput = HeroGUI.WAITING; } break; } case (HeroGUI.WAITING): { // idle state break; } case (HeroGUI.INPUT1): { // not used yet break; } case (HeroGUI.INPUT2): { // not used yet break; } case (HeroGUI.DONE): { HeroInputDone(); break; } } // switch (HeroInput) } // void Update()
// Update is called once per frame void Update() { switch (battleStates) { case (PerformAction.WAIT): if (PerformList.Count > 0) { battleStates = PerformAction.TAKEACTION; } break; case (PerformAction.TAKEACTION): GameObject performer = GameObject.Find(PerformList[0].AttackersGameObject.name); //Debug.Log(GameObject.Find(PerformList[0].AttackersGameObject.name)); if (PerformList[0].Type == "Enemy") { //Debug.Log(performer); EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>(); //Check hero is dead for (int i = 0; i < HeroesInGame.Count; i++) // we don't need a for loop because we have just 1 hero. { //if attackers target is hero and not dead go on. if (PerformList[0].AttackersTarget == HeroesInGame[i]) { ESM.heroToAttack = PerformList[0].AttackersTarget; ESM.currentState = EnemyStateMachine.TurnState.ACTION; break; } //if the attackers target is hero and dead select another hero and go on //this is not necessary too. else { PerformList[0].AttackersTarget = HeroesInGame[Random.Range(0, HeroesInGame.Count)]; ESM.heroToAttack = PerformList[0].AttackersTarget; ESM.currentState = EnemyStateMachine.TurnState.ACTION; } } ESM.heroToAttack = PerformList[0].AttackersTarget; ESM.currentState = EnemyStateMachine.TurnState.ACTION; } randomEnemyAttack = Random.Range(0, 2); //Debug.Log(randomEnemyAttack); if (PerformList[0].Type == "Hero") { // Debug.Log("Hero is ready"); HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>(); HSM.EnemyToAttack = PerformList[0].AttackersTarget; HSM.EnemyToAttackCube = PerformList[0].AttackersTargetCube; HSM.currentState = HeroStateMachine.TurnState.ACTION; } if (PerformList[0].Type == "Enemy") { if (randomEnemyAttack == 0) { enemyisSpell = true; } else { enemyisSpell = false; } } battleStates = PerformAction.PERFORMACTION; break; case (PerformAction.PERFORMACTION): break; case (PerformAction.CHECKALIVE): if (HeroesInGame.Count < 1) { battleStates = PerformAction.LOSE; //Lose the battle } else if (EnemiesInGame.Count < 1) { battleStates = PerformAction.WIN; //Win the battle } else { clearAttackPanel(); HeroInput = HeroGUI.ACTIVATE; } break; case (PerformAction.LOSE): Debug.Log("You LOSE the battle"); SceneManager.LoadScene(youlose); break; case (PerformAction.WIN): Debug.Log("You win the battle"); for (int i = 0; i < HeroesInGame.Count; i++) { HeroesInGame[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING; } SceneManager.LoadScene(youwin); break; } switch (HeroInput) { case (HeroGUI.ACTIVATE): if (HeroesToManage.Count > 0) { HeroChoice = new HandleTurns(); ActionPanel.SetActive(true); CreateAttackButtons(); HeroInput = HeroGUI.WAITING; } break; case (HeroGUI.WAITING): //idle break; case (HeroGUI.DONE): HeroInputDone(); break; } }
// Update is called once per frame void Update() { // controlle se isActive è uguale a true if (isactive) { // sommo il tempo al timer timer += Time.deltaTime; // controllo se il timer è maggiore di start timer if (timer >= startTimer) { //uso la funzione set active Per impostare testo a false testo.SetActive(false); //imposto il timer a 0 timer = 0; //imposto isActive a false isactive = false; } } // creo uno switch fra battle state switch (BattleState) { //creo il primo caso case (PerformAction.Wait): //controllo se la performlist.conunt è maggiore di 0 if (performList.Count > 0) { //cambio lo stato il take action BattleState = PerformAction.TakeAction; } break; //caso 2 case (PerformAction.TakeAction): //assegno il performer all al primo numero degli attakers della performList GameObject performer = GameObject.Find(performList[0].Attacker); //controllo se il tipo della perform list è uguale a Enemy if (performList[0].Type == "Enemy") { //assegno a ESM il lo script EnemyStateMachine del performer EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>(); //per ogni eroe in gioco for (int i = 0; i < HerosInGame.Count; i++) { //controllo quando l'eroe in gioco e attacksTarget combaciano if (performList[0].AttacksTarget == HerosInGame[i]) { // assegno a ESM.heroToAttack l'eroe giusto tramite il controllo di prima ESM.heroToAttack = performList[0].AttacksTarget; // cambio il currentState di ESM in action ESM.CurrentState = EnemyStateMachine.TurnState.Action; break; } else { //randomizzo il player da attaccare performList[0].AttacksTarget = HerosInGame[Random.Range(0, HerosInGame.Count)]; // assegno a ESM.heroToAttack l'eroe randomizzato ESM.heroToAttack = performList[0].AttacksTarget; // cambio il currentState di ESM in action ESM.CurrentState = EnemyStateMachine.TurnState.Action; } } } // controllo se il tipo della perform list è uguale a Player if (performList[0].Type == "Player") { //assegno a HSM lo script HeroStateM del performer HeroStateM HSM = performer.GetComponent <HeroStateM>(); // assegno a HSM.enemyToAttack il nemico scelto HSM.enemyToAttack = performList[0].AttacksTarget; // cambio il currentState di HSM in action HSM.CurrentState = HeroStateM.TurnState.Action; } //cambio il BattleState a PerformAction BattleState = PerformAction.PerformAction; break; //caso3 case (PerformAction.PerformAction): //idle break; //caso4 case (PerformAction.CheckAlive): //se gli eroi in game sono minori di 1 if (HerosInGame.Count < 1) { // cambio il battle state a lose BattleState = PerformAction.Lose; //lose the battle } // se i nemici in gioco sono minori di 1 else if (EnemyInGame.Count < 1) { // cambio il battle state a 1 BattleState = PerformAction.Win; //win the battle } else { //chiamo la funzione clearAttackPanel clearAttackPanel(); //cambio l'HeroInput in activate HeroInput = HeroGUI.Activate; } break; //caso5 case (PerformAction.Lose): { //vado nella scena di gameOver SceneManager.LoadScene("GameOver"); } break; //caso6 case (PerformAction.Win): { //per ogni eroe in game for (int i = 0; i < HerosInGame.Count; i++) { //cambio lo stato in wating HerosInGame[i].GetComponent <HeroStateM>().CurrentState = HeroStateM.TurnState.Waiting; } //attivo il testo cura testoCura.SetActive(true); //sommo il timer al tempo timer += Time.deltaTime; //controllo se il timer è maggiore dello start timer e se isBoss e uguale a false if (timer >= startTimer && isBoss == false) { //disattivo il testo cura testoCura.SetActive(false); // imposto timer a 0 timer = 0; //chiamo la funzione LoadSceneAfterBattle GameManager.instace.LoadSceneAfterBattle(); //cambio il game state a WorldState GameManager.instace.gameState = GameManager.GameState.WorldState; //pulisco gli enemyToBattle GameManager.instace.EnemysToBattle.Clear(); } //se isBoss e uguale a true else if (isBoss == true) { //cambio scena in vittoria SceneManager.LoadScene("Win"); } } break; } // creo uno switch per l'hero imput switch (HeroInput) { //caso1 case (HeroGUI.Activate): //se hero to manage è maggiore di 0 if (HeroToManage.Count > 0) { //cerco il selecter del heroToManage e lo attivo HeroToManage[0].transform.Find("Selecter").gameObject.SetActive(true); //assengo a HeroChoice un nuovo HandleTurn HeroChoice = new HandleTurn(); //attivo l'AttackPanel AttackPanel.SetActive(true); //chiamo la funzione cretataAttackButtons createAttackButtons(); //Cambio l'HeroInput a wating HeroInput = HeroGUI.Waiting; } break; //caso3 case (HeroGUI.Waiting): //idle break; //caso4 case (HeroGUI.Done): //chaimo la funzione HeroInputDone HeroInputDone(); break; } }
// Update is called once per frame void Update () { switch (battleState) { case (PerformAction.WAIT): if (TurnList.Count > 0) { battleState = PerformAction.SELECTACTION; } else if (zombieList.Count < 1) { // end of the building Debug.Log ("End building called"); GameManager.instance.BuildingIsCleared(CalculateSupplyEarned(), CalculateWaterFound(), CalculateFoodFound(), CalculateSurvivorFound()); SceneManager.LoadScene ("03a Win"); }else if (autoAttackIsOn && survivorTurnList.Count > 0) { //continue auto attack AttackButtonPressed(); } else if (survivorTurnList.Count < 1 && TurnList.Count < 1) { //give NPC turns after Player has expended all their turns. ResetAllTurns(); } break; case (PerformAction.SELECTACTION): GameObject performer = GameObject.Find(TurnList[0].attacker); if (TurnList [0].type == "zombie") { ZombieStateMachine ZSM = performer.GetComponent<ZombieStateMachine>(); ZSM.target = TurnList[0].TargetsGameObject; ZSM.currentState = ZombieStateMachine.TurnState.TAKEACTION; } if (TurnList [0].type == "survivor") { SurvivorStateMachine SSM = performer.GetComponent<SurvivorStateMachine>(); SSM.plyrTarget = TurnList[0].TargetsGameObject; SSM.currentState = SurvivorStateMachine.TurnState.ACTION; } battleState = PerformAction.COMPLETED; break; case (PerformAction.BITECASE): break; case (PerformAction.COMPLETED): break; } switch (playerGUI) { case (PlayerInput.ACTIVATE): if (survivorTurnList.Count > 0) { survivorTurnList [0].transform.FindChild("arrow").gameObject.SetActive(true); survivorTurnList [0].GetComponent<SurvivorStateMachine>().isSelected = true; playerGUI = PlayerInput.WAITING; } break; case (PlayerInput.WAITING): //idle break; case (PlayerInput.WEAPONCHANGE): break; // case (PlayerInput.EXECUTETURN): // GameObject performer = GameObject.Find(survivorTurnList[0].name); // SurvivorStateMachine SSM = performer.GetComponent<SurvivorStateMachine>(); // if (playerTarget != null) { // SSM.plyrTarget = playerTarget.gameObject; // } else { // SSM.currentState = SurvivorStateMachine.TurnState.AUTOCHOOSING; // } // // break; } }
// Use this for initialization void Start() { battleState = PerformAction.WAITING; Enemies.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); Party.AddRange(GameObject.FindGameObjectsWithTag("Player")); }
private void but1200600_Click(object sender, RoutedEventArgs e) { PerformAction?.Invoke("AddPage1200600", EventArgs.Empty); }