コード例 #1
0
    // Use this for initialization
    void Start()
    {
        _myAnimator = GetComponentInParent<Animator>();

        _enemyDetectionScript = gameObject.GetComponentInChildren<EnemyStateMachine>();
        _ghostHealth = GhostStartingHealth;

        //		_soundManager = GameObject.Find ("SoundManager").GetComponent<SoundManager> ();

        //		spookyMoan = GetComponents<AudioSource>()[0];
        spookyAttack = GetComponents<AudioSource>()[1];
        spookDeath = GetComponents<AudioSource>()[2];
    }
コード例 #2
0
    public void Start()
    {
        _myNavMeshAgent = GetComponent<NavMeshAgent>();

        AttackTarget = GameObject.Find("Player").transform;

        _enemyDetectionScript = gameObject.GetComponentInChildren<EnemyStateMachine>();

        if(Path == null) {
            Debug.LogError("Path cannot be null.", gameObject);
            return;
        }
        currentPoint = Path.GetPathEnumerator();
        currentPoint.MoveNext();
        if(currentPoint.Current == null)
            return;
        //transform.position = currentPoint.Current.position;
        _lastTransform = transform.position;
    }
コード例 #3
0
ファイル: AIController.cs プロジェクト: flaviold/PG2D
 void Start()
 {
     updatePlayersList();
     enemyStateMachine = new EnemyStateMachine(this);
 }
コード例 #4
0
 private void Start()
 {
     esm = EnemyPrefab.GetComponent <EnemyStateMachine>();
 }
コード例 #5
0
 public EnemyIdleState(Enemy enemy, EnemyStateMachine stateMachine, EnemyData enemyData, string animBoolName) : base(enemy, stateMachine, enemyData, animBoolName)
 {
 }
コード例 #6
0
ファイル: DamagedState.cs プロジェクト: kodalli/Ludum-Dare-48
 public DamagedState(Entity entity, EnemyStateMachine stateMachine, string animBoolName) : base(entity, stateMachine, animBoolName)
 {
 }
コード例 #7
0
 public override void EnterState(EnemyStateMachine enemy)
 {
     //Set attack timer
     attackTime = 30;
 }
コード例 #8
0
 public override void Initialize(GameObject actor)
 {
     enem = actor.GetComponent <EnemyStateMachine>();
 }
コード例 #9
0
    // 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 = PerformList[0].AttackersGameObject;
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (PerformList[0].AttackersTarget == HerosInBattle[i])
                    {
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        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):
            //idle
            break;

        case (PerformAction.CHECKALIVE):
            if (HerosInBattle.Count < 1)
            {
                battleStates = PerformAction.LOSE;
                //lose game
            }
            else if (gameManager.enemiesToBattle.Count < 1)
            {
                battleStates = PerformAction.WIN;     //win game
            }
            else
            {
                //call function
                clearAttackPanel();
                HeroInput = HeroGUI.ACTIVATE;
            }
            break;

        case (PerformAction.LOSE):
        {
            SceneManager.LoadScene(1);
        }
        break;

        case (PerformAction.WIN):
        {
            SceneManager.LoadScene(2);
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
            }
        }
        break;
        }

        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (HerosToManage.Count > 0)
            {
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                //create new handleturn instance
                HeroChoice = new HandleTurn();

                AttackPanel.SetActive(true);
                //populate action buttons
                CreateAttackButtons();

                HeroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):

            break;

        case (HeroGUI.DONE):
            HeroInputDone();
            break;
        }
    }
コード例 #10
0
    // 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].Attacker);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (PerformList[0].AttackersTarget == HerosInBattle[i])
                    {
                        ESM.heroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.Action;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        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):
            //idle
            break;

        case (PerformAction.CheckAlive):
            if (HerosInBattle.Count < 1)
            {
                battlestates = PerformAction.Lose;
                //lose the battle
            }
            else if (EnemiesInBattle.Count < 1)
            {
                battlestates = PerformAction.Win;
                //win the battle
                //gain experience
                //gain money
            }
            else
            {
                //call function
                ClearAttackPanel();
                HeroInput = HeroGui.Activate;
            }
            break;

        case (PerformAction.Win):
        {
            Debug.Log("You won the battle!");
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.Waiting;
            }
        }
        break;

        case (PerformAction.Lose):
        {
            Debug.Log("You lost the battle!");
        }
        break;
        }

        switch (HeroInput)
        {
        case (HeroGui.Activate):
            if (HeroesToManage.Count > 0)
            {
                HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoice = new HandleTurn();

                AttackPanel.SetActive(true);

                //populate action buttons
                CreateAttackButtons();

                HeroInput = HeroGui.Waiting;
            }

            break;

        case (HeroGui.Waiting):

            break;

        case (HeroGui.Input1):

            break;

        case (HeroGui.Input2):

            break;

        case (HeroGui.Done):
            HeroInputDone();
            break;
        }
    }
コード例 #11
0
 public override void Act(EnemyStateMachine state)
 {
     state.Enemy.Patrol();
 }
コード例 #12
0
 public E1_MoveState(Entity entity, EnemyStateMachine stateMachine, string animBoolName, SO_MoveState stateData, Enemy1 enemy) : base(entity, stateMachine, animBoolName, stateData)
 {
     this.enemy = enemy;
 }
コード例 #13
0
    void Update()
    {
        switch (battleState)
        {
        case PerformAction.WAIT:
            if (actionsInTurn.Count > 0)
            {
                battleState = PerformAction.TAKE_ACTION;
            }
            break;

        case PerformAction.TAKE_ACTION:
            GameObject performer = actionsInTurn[0].attackerGameObject;
            if (actionsInTurn[0].type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();

                if (actionsInTurn[0].attack.isAreaAttack)
                {
                    for (int i = 0; i < heroesInBattle.Count; i++)
                    {
                        if (actionsInTurn[0].targets[0] == heroesInBattle[i])
                        {
                            ESM.heroesToAttack[0] = actionsInTurn[0].targets[0];
                            break;
                        }
                        else
                        {
                            actionsInTurn[0].targets[0] = heroesInBattle[Random.Range(0, heroesInBattle.Count)];
                            ESM.heroesToAttack[0]       = actionsInTurn[0].targets[0];
                        }
                    }
                }

                ESM.actualState = EnemyStateMachine.TurnState.ACTION;
            }

            if (actionsInTurn[0].type == "Hero")
            {
                PlayerStateMachine PSM = performer.GetComponent <PlayerStateMachine>();
                PSM.actualState = PlayerStateMachine.TurnState.ACTION;
            }
            battleState = PerformAction.PERFORM_ACTION;

            break;

        case PerformAction.PERFORM_ACTION:

            break;

        case PerformAction.CHECK_ALIVE:
            if (heroesInBattle.Count < 1)
            {
                Debug.Log("Cambio a Lose");
                battleState = PerformAction.LOSE;
                //Lose the battle
            }
            else
            {
                if (enemiesInBattle.Count < 1)
                {
                    Debug.Log("Cambio a Win");
                    battleState = PerformAction.WIN;
                    //Win the battle
                }
                else
                {
                    Debug.Log("Sigo la partida");
                    ClearAttackPanel();
                    heroInput = HeroGUI.ACTIVATE;
                }
            }
            break;

        case PerformAction.LOSE:
            Debug.Log("Lose");
            break;

        case PerformAction.WIN:
            Debug.Log("Win");
            for (int i = 0; i < heroesInBattle.Count; i++)
            {
                heroesInBattle[i].GetComponent <PlayerStateMachine>().actualState = PlayerStateMachine.TurnState.WAITING;
            }
            break;
        }

        switch (heroInput)
        {
        case HeroGUI.ACTIVATE:
            if (heroesToManage.Count > 0)
            {
                heroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                heroChoice = new TurnHandler();

                ChangePanels(actionsPanel);
                CreateButtons();

                heroInput = HeroGUI.WAITING;
            }
            break;

        case HeroGUI.WAITING:
            break;

        case HeroGUI.SINGLE_ATTACK:
            break;

        case HeroGUI.MULTIPLE_ATTACK:
            break;

        case HeroGUI.DONE:
            HeroInputDone();
            break;
        }
    }
コード例 #14
0
    public override void Shoot(Vector2 targetPoint, State state)
    {
        _enemy = FindObjectOfType <EnemyStateMachine>();

        state.StartCoroutine(TripleShoot(targetPoint));
    }
コード例 #15
0
 public override void EnterState(EnemyStateMachine enemy)
 {
     enemy.attackTimer = 50;
 }
コード例 #16
0
 public EnemyState(EnemyStateMachine machine)
 {
     this.machine = machine;
     InitState();
 }
コード例 #17
0
    // Update is called once per frame
    public void Update()
    {
        switch (battleState)
        {
        case (performAction.Wait):
            if (PerformList.Count > 0)
            {
                battleState = 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 < PlayerInBattle.Count; i++)
                {
                    if (PerformList[0].AttackersTarget == PlayerInBattle[i])
                    {
                        ESM.PlayerToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState   = EnemyStateMachine.turnState.action;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = PlayerInBattle[Random.Range(0, PlayerInBattle.Count)];
                        ESM.PlayerToAttack             = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.turnState.action;
                    }
                }
            }

            battleState = performAction.PerformAction;
            break;

        case (performAction.PerformAction):
            break;

        case (performAction.CheckAlive):
            if (PlayerInBattle.Count < 1)
            {
                battleState = performAction.Lose;

                //lose game
                loseText.text = "Game Over";
                rematchButton.SetActive(true);
                returnButton.SetActive(true);
                resultPanel.SetActive(true);
                castButton.SetActive(false);
                resetButton.SetActive(false);
                actionDisplay.SetActive(false);
                actionBar.SetActive(false);
                Debug.Log("Game Over");
            }
            else if (EnemyInBattle.Count <= 0)
            {
                battleState      = performAction.Win;
                victoryText.text = "Victory!";
                rematchButton.SetActive(true);
                returnButton.SetActive(true);
                resultPanel.SetActive(true);
                castButton.SetActive(false);
                resetButton.SetActive(false);
                actionDisplay.SetActive(false);
                actionBar.SetActive(false);
            }

            break;

        case (performAction.Win):
        {
            Debug.Log("Victory!");
            for (int i = 0; i < PlayerInBattle.Count; i++)
            {
                PlayerInBattle[i].GetComponent <PlayerStateMachine>().currentState = PlayerStateMachine.turnState.alive;
            }
            victoryText.text = "Victory!";
            rematchButton.SetActive(true);
            returnButton.SetActive(true);
            resultPanel.SetActive(true);
            castButton.SetActive(false);
            resetButton.SetActive(false);
            actionDisplay.SetActive(false);
            actionBar.SetActive(false);
        }
        break;

        case (performAction.Lose):
        {
            for (int i = 0; i < PlayerInBattle.Count; i++)
            {
                EnemyInBattle[i].GetComponent <EnemyStateMachine>().currentState = EnemyStateMachine.turnState.waiting;
            }
            loseText.text = "Game Over";
            rematchButton.SetActive(true);
            returnButton.SetActive(true);
            resultPanel.SetActive(true);
            castButton.SetActive(false);
            resetButton.SetActive(false);
            actionDisplay.SetActive(false);
            actionBar.SetActive(false);
            Debug.Log("Game Over");
        }
        break;
        }
    }
コード例 #18
0
 public abstract void Act(EnemyStateMachine stateController);
コード例 #19
0
    // Update is called once per frame
    void Update()
    {
        switch (currentAction)
        {
        case (PreformAction.WAIT):
            if (PreformList.Count > 0)
            {
                currentAction = PreformAction.TAKEACTION;
            }
            break;

        case (PreformAction.TAKEACTION):
            GameObject preformer = GameObject.Find(PreformList[0].Attacker);
            if (PreformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = preformer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < ProtagsInBattle.Count; i++)
                {
                    if (PreformList[0].AttackersTarget == ProtagsInBattle[i])
                    {
                        ESM.ProtagToAttack = PreformList[0].AttackersTarget;
                        ESM.currentState   = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        PreformList[0].AttackersTarget = ProtagsInBattle[Random.Range(0, ProtagsInBattle.Count)];

                        ESM.ProtagToAttack = PreformList[0].AttackersTarget;
                        ESM.currentState   = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }

            if (PreformList[0].Type == "Protag")
            {
                ProtagStateMachine PSM = preformer.GetComponent <ProtagStateMachine>();
                PSM.EnemyToAttack = PreformList[0].AttackersTarget;
                PSM.currentState  = ProtagStateMachine.TurnState.ACTION;
            }
            currentAction = PreformAction.PREFORMACTION;

            break;

        case (PreformAction.PREFORMACTION):
            //idle
            break;

        case (PreformAction.CHECKALIVE):
            if (ProtagsInBattle.Count < 1)
            {
                currentAction = PreformAction.LOSE;
            }
            else if (EnemiesInBattle.Count < 1)
            {
                currentAction = PreformAction.WIN;
            }
            else
            {
                clearAttackPanel();
                ProtagInput = ProtagGUI.ACTIVATE;
            }

            break;

        case (PreformAction.LOSE):
        {
            Debug.Log("You lost the Battle!");
        }
        break;

        case (PreformAction.WIN):
        {
            Debug.Log("You won the Battle!");
            for (int i = 0; i < ProtagsInBattle.Count; i++)
            {
                ProtagsInBattle[i].GetComponent <ProtagStateMachine>().currentState = ProtagStateMachine.TurnState.WAITING;
            }
        }
        break;
        }

        switch (ProtagInput)
        {
        case (ProtagGUI.ACTIVATE):
            if (ProtagsToManage.Count > 0)
            {
                ProtagsToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                ProtagChoice = new HandleTurns();


                AttackPanel.SetActive(true);
                CreateAttackButtons();
                ProtagInput = ProtagGUI.WAITING;
            }
            break;

        case (ProtagGUI.WAITING):
            //idle
            break;

        case (ProtagGUI.DONE):
            ProtagInputDone();
            break;
        }
    }
コード例 #20
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Cancel"))
        {
            canvas.Back();
        }

        if (Enemies.Count <= 0)
        {
            battleStates = PerformAction.END;
        }

        //Main game logic state machine
        switch (battleStates)
        {
        //"Waiting State" Waiting until one of the entities wants to do an action
        case (PerformAction.WAIT):
            if (PerformList.Count > 0)
            {
                battleStates = PerformAction.TAKEACTION;
            }

            break;

        //Performing an action
        case (PerformAction.TAKEACTION):

            //Grabs first waiting entity
            GameObject currentActionObject = PerformList.Dequeue().gameObject;

            //Set the Entity State Machine to ACTION. TODO: Have EnemyStateMachine and PlayerStateMachine both derive from the same class.
            if (currentActionObject.tag == "Enemy")
            {
                EnemyStateMachine ESM = currentActionObject.GetComponent <EnemyStateMachine>();
                ESM.currentState = EnemyStateMachine.CurrentState.ACTION;
            }
            else if (currentActionObject.tag == "Hero")
            {
                PlayerStateMachine PSM = currentActionObject.GetComponent <PlayerStateMachine>();
                PSM.currentState = PlayerStateMachine.CurrentState.ACTION;
            }

            battleStates = PerformAction.PERFORMACTION;

            break;

        //Another waiting state, waiting until entity has finished action and set this state back to WAIT.
        case (PerformAction.PERFORMACTION):

            break;

        // Battle is over
        case (PerformAction.END):
            canvas.ShowWinText();
            break;
        }

        //Player UI handling state machine
        switch (playerUIStates)
        {
        //Waiting until a hero wants to use the UI
        case (PlayerUIAction.WAIT):
            if (HeroChoiceList.Count > 0)
            {
                playerUIStates = PlayerUIAction.PREPARING;
            }
            break;

        //Player wants to use UI, setting up UI with player data
        case (PlayerUIAction.PREPARING):     //setup boxes and selectors
            PlayerStateMachine currentActivePlayer = HeroChoiceList.Dequeue();
            canvas.EnablePlayerBox(currentActivePlayer);
            playerUIStates = PlayerUIAction.CHOOSING;
            break;

        //Player is currently awaiting input.
        case (PlayerUIAction.CHOOSING):
            break;
        }
    }
コード例 #21
0
ファイル: JellyMove.cs プロジェクト: leontres321/Subsuelo
 public JellyMove(Rigidbody2D rb, EnemyStateMachine sm, string name) : base(rb, sm, name)
 {
 }
コード例 #22
0
 public override bool Decide(EnemyStateMachine stateController)
 {
     return(stateController.Enemy.Look());
 }
コード例 #23
0
 public override void Act(EnemyStateMachine stateController)
 {
     stateController.Enemy.Attack();
 }
コード例 #24
0
 public abstract bool Decide(EnemyStateMachine stateController);
コード例 #25
0
    void Update()
    {
        switch (battleState)
        {
        case (PerformAction.WAIT):
            if (PerformList.Count > 0)
            {
                battleState = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            //Grabbing the performer that should currently be attacking
            GameObject performer = GameObject.Find(PerformList [0].Attacker);
            if (PerformList [0].Type == "Enemy")
            {
                //Getting the state machine from the enemy that is currently attacking
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine> ();

                //Checks if the hero they are attacking is still alive
                for (int i = 0; i < HeroesInBattle.Count; i++)
                {
                    if (PerformList [0].AttackersTarget == HeroesInBattle [i])
                    {
                        //Setting the hero to attack based on the handleturn object that was sent over to the performlist
                        ESM.heroToAttack = PerformList [0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        //Makes enemy attack a new targer if old target is dead
                        PerformList[0].AttackersTarget = HeroesInBattle[Random.Range(0, HeroesInBattle.Count)];

                        ESM.heroToAttack = PerformList [0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }
            if (PerformList [0].Type == "Hero")
            {
                //Getting the state machine from the hero that is currently attacking
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();    //WE'RE ALL IN THIS TOGETHER

                //Setting the enemy to attack based on the handleturn object that was sent over to the performlist
                HSM.enemyToAttack = PerformList[0].AttackersTarget;

                HSM.currentState = HeroStateMachine.TurnState.ACTION;
            }

            battleState = PerformAction.PERFORMACTION;

            break;

        case (PerformAction.PERFORMACTION):
            //idle
            break;

        //visual studio crapped out on me so monogames if f#$king with all the spacing when putting in new code....
        case (PerformAction.CHECKALIVE):        //This handles win and lose changes and dead hero cleanup

            if (HeroesInBattle.Count < 1)
            {
                //lose battle
                battleState = PerformAction.LOSE;
            }
            else if (EnemiesInBattle.Count < 1)
            {
                //win battle
                battleState = PerformAction.WIN;
            }
            else
            {
                //call function
                ClearActionPanel();
                heroInput = HeroGUI.ACTIVATE;
            }

            break;

        case (PerformAction.WIN):
            Debug.Log("You win");
            for (int i = 0; i < HeroesInBattle.Count; i++)
            {
                HeroesInBattle [i].GetComponent <HeroStateMachine> ().currentState = HeroStateMachine.TurnState.WAITING;
            }
            break;

        case (PerformAction.LOSE):
            Debug.Log("You lose");
            break;
        }

        switch (heroInput)
        {
        case (HeroGUI.ACTIVATE):

            //Checks to see if there are any heroes to manage
            if (heroesToManage.Count > 0)
            {
                heroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                //vreates new handleturn instance
                heroChoice = new HandleTurn();

                actionPanel.SetActive(true);

                //populates action buttons
                CreateAttackButtons();

                heroInput = HeroGUI.WAITING;
            }

            break;

        case (HeroGUI.WAITING):
            //idle state
            break;

        case (HeroGUI.DONE):

            HeroInputDone();

            break;
        }
    }
コード例 #26
0
ファイル: IdleState.cs プロジェクト: dracobk201/OpressiveFPS
 public IdleState(EnemyStateMachine stateMachine, float timeToChange)
 {
     _timeToChange = timeToChange;
     _stateMachine = stateMachine;
 }
コード例 #27
0
    // Update is called once per frame
    void Update()
    {
        switch (battleState)
        {
        case (performAction.WAIT):
            if (list.Count > 0)
            {
                battleState = performAction.TAKEACTION;
            }
            break;

        case (performAction.TAKEACTION):
            Debug.Log(list[0].Attacker);
            GameObject performer = GameObject.Find(list[0].Attacker);
            Debug.Log(performer);
            if (list[0].Type == "Enemy")
            {
                EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < heroes.Count; i++)
                {
                    if (list[0].attackersTarget == heroes[i])
                    {
                        esm.hero         = list[0].attackersTarget;
                        esm.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }     /*else
                           * {
                           * list[0].attackersTarget = heroes[Random.Range(0, heroes.Count)];
                           * }*/
                }
            }
            if (list[0].Type == "Hero")
            {
                HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>();
                hsm.enemyToAttack = list[0].attackersTarget;
                hsm.currentState  = HeroStateMachine.TurnState.ACTION;
            }

            battleState = performAction.PERFORMACTION;
            break;

        case (performAction.CHECKALIVE):
            if (heroes.Count == 0)
            {
                //lose game
                Debug.Log("Lost");
                battleState = performAction.LOSE;
            }
            else if (enemies.Count == 0)
            {
                //win battle
                Debug.Log("Win");
                for (int i = 0; i < heroes.Count; i++)
                {
                    heroes[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
                }
                battleState = performAction.WIN;
            }
            else
            {
                //call function
                //ActionList.SetActive(false);
                gameManager.GetComponent <GameStates>().List.SetActive(false);
                heroInput = heroGUI.ACTIVATE;
            }
            break;

        case (performAction.PERFORMACTION):

            break;

        case (performAction.LOSE):

            break;

        case (performAction.WIN):
            Destroy(GameObject.FindGameObjectWithTag("Dead enemy"));
            Destroy(GameObject.Find("BattleManager(Clone)"));
            gameManager.GetComponent <GameStates>().state = GameStates.GameState.WORLDSTATE;
            break;
        }

        switch (heroInput)
        {
        case (heroGUI.ACTIVATE):
            if (heroesToManage.Count > 0)
            {
                //heroesToManage[0]
                heroChoice = new HandleTurn();
                //ActionList.SetActive(true);
                gameManager.GetComponent <GameStates>().List.SetActive(true);
                heroInput = heroGUI.WAITING;
            }

            break;

        case (heroGUI.WAITING):
            break;

        case (heroGUI.DONE):
            heroInputDone();
            break;
        }
    }
コード例 #28
0
 public MeleeAttackState(Entity entity, EnemyStateMachine stateMachine, string animBoolName, Transform attackPosition, SO_MeleeAttackState stateData) : base(entity, stateMachine, animBoolName, attackPosition)
 {
     this.stateData = stateData;
 }
コード例 #29
0
 public EnemyDyingState(EnemyController enemyController, EnemyStateMachine stateMachine) : base(enemyController, stateMachine)
 {
 }
コード例 #30
0
    // 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].Attacker);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (PerformList[0].AttackersTarget == HerosInBattle[i])
                    {
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        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 (HerosInBattle.Count < 1)
            {
                battleStates = PerformAction.LOSE;
            }
            else if (EnemysInBattle.Count < 1)
            {
                battleStates = PerformAction.WIN;
            }
            else
            {
                clearAttackPanel();
                //call a function
                HeroInput = HeroGUI.ACTIVATE;
            }

            break;

        case (PerformAction.LOSE):
        {
            Debug.Log("YOU LOST!");
        }
        break;

        case (PerformAction.WIN):
        {
            Debug.Log("YOU WON!");
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
            }

            GameManager.instance.LoadSceneAfterBattle();
            GameManager.instance.gameState = GameManager.GameStates.WORLD_STATE;
            GameManager.instance.enemysToBattle.Clear();
        }
        break;
        }
        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (HerosToManage.Count > 0)
            {
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoice = new HandleTurn();

                AttackPanel.SetActive(true);

                CreateAttackbuttons();
                HeroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):

            break;

        case (HeroGUI.DONE):
            HeroInputDone();
            break;
        }
    }
コード例 #31
0
 public ChargeState(Entity entity, EnemyStateMachine stateMachine, string animBoolName, SO_ChargeState stateData) : base(entity, stateMachine, animBoolName)
 {
     this.stateData = stateData;
 }
コード例 #32
0
ファイル: State.cs プロジェクト: oultrox/Platform2D-Engine
 public void UpdateState(EnemyStateMachine controller)
 {
     DoAction(controller);
     CheckTransitions(controller);
 }
コード例 #33
0
 public override bool Decide(EnemyStateMachine stateController)
 {
     return(stateController.CheckIfCountDownElapsed(stateController.Enemy.ChaseOutDuration));
 }
コード例 #34
0
 public void SetMachine(EnemyStateMachine machine)
 {
     this.machine = machine;
 }
コード例 #35
0
    // 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].Attacker);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (PerformList[0].AttackersTarget == HerosInBattle[i])
                    {
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.Action;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        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):
            //idle
            break;

        case (PerformAction.CheckAlive):
            if (HerosInBattle.Count < 1)
            {
                BattleStates = PerformAction.Lose;
                //lose the battle
            }
            else if (EnemysInBattle.Count < 1)
            {
                BattleStates = PerformAction.Win;
                //win the battle
            }
            else
            {
                ClearAttackPanel();
                //call function
                HeroInput = HeroGUI.Activate;
            }
            break;

        case (PerformAction.Lose):
        {
            Debug.Log("KAYBETTİN");
        }
        break;

        case (PerformAction.Win):
        {
            Debug.Log("KAZANDIN");
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.Waiting;
            }
            GameManager.instance.LoadSceneAfterBattle();
            GameManager.instance.gameStates = GameManager.GameStates.World_State;
            GameManager.instance.enemysToBattle.Clear();
        }
        break;
        }
        switch (HeroInput)
        {
        case (HeroGUI.Activate):
            if (HerosToManage.Count > 0)
            {
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                //create new handleturn instance
                HeroChoise = new HandleTurn();

                AttackPanel.SetActive(true);
                //populate action buttons
                CreateAttackButtons();
                HeroInput = HeroGUI.Waiting;
            }
            break;

        case (HeroGUI.Waiting):

            break;

        case (HeroGUI.Done):
            HeroInputDone();
            break;
        }
    }