示例#1
0
    // Update is called once per frame
    void Update()
    {
        hpBar.fillAmount = Player1.cur_HP;
        switch (currentState)
        {
        case (Turnstate.processing):
            Timer10Sec();
            break;

        case (Turnstate.addToList):
            ChooseAction();
            currentState = Turnstate.action;
            break;

        case (Turnstate.waiting):
            break;

        case (Turnstate.selecting):
            break;

        case (Turnstate.action):
            StartCoroutine(TimeForAction());
            break;

        case (Turnstate.dead):
            break;
        }
    }
 // Use this for initialization
 void Start()
 {
     cur_cooldown  = Random.Range(0, 2f);
     startPosition = transform.position;
     BSM           = GameObject.Find("BattleManager").GetComponent <BattleStateMachine>();
     CurrentState  = Turnstate.Processing;
     Selector.SetActive(false);
 }
示例#3
0
    void UpgradeProgressBar()
    {
        cur_cooldown = cur_cooldown + Time.deltaTime;

        if (cur_cooldown >= max_cooldown)
        {
            CurrentState = Turnstate.ChooseAction;
        }
    }
示例#4
0
 // Use this for initialization
 void Start()
 {
     player1 = GameObject.FindGameObjectWithTag("Player").GetComponent <Player1Script>();
     StatesUp.gameObject.SetActive(false);
     StartPosition = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
     animPlayer1   = GameObject.FindGameObjectWithTag("Player2").gameObject.GetComponent <Animator>();
     targetEnemy   = GameObject.FindGameObjectWithTag("Player");
     bsm           = GameObject.FindGameObjectWithTag("BSM").GetComponent <BattleStateMachine>();
     currentState  = Turnstate.waiting;
 }
    void UpgradeProgressBar()
    {
        cur_cooldown = cur_cooldown + Time.deltaTime;
        float calc_cooldown = cur_cooldown / max_cooldown;

        ProgressBar.transform.localScale = new Vector3(Mathf.Clamp(calc_cooldown, 0, 1), ProgressBar.transform.localScale.y, ProgressBar.transform.localScale.z);
        if (cur_cooldown >= max_cooldown)
        {
            CurrentState = Turnstate.Addtolist;
        }
    }
示例#6
0
    public void takeDamage(float getDamageAmount)
    {
        animPlayer1.SetInteger("state", 3);
        Player1.cur_HP -= getDamageAmount;
        float health = Player1.cur_HP / Player1.HP;

        if (Player1.cur_HP <= 0)
        {
            animPlayer1.SetInteger("state", 5);
            currentState = Turnstate.dead;
        }
        hpBar.fillAmount = Player1.cur_HP;
    }
示例#7
0
    void Result()
    {
        state = Turnstate.RESULT;
        if (battleWin == true)
        {
            this.state_RESULT_WIN(this, EventArgs.Empty);
        }

        if (battleWin == false)
        {
            this.state_RESULT_LOSE(this, EventArgs.Empty);
        }
    }
示例#8
0
    void battleSelect()
    {
        if (CrossPlatformInputManager.GetButtonDown("Attack"))
        {
            currentState = Turnstate.ATTACK;
        }

        if (CrossPlatformInputManager.GetButtonDown("Special"))
        {
            currentState = Turnstate.SPECIAL;
        }

        if (CrossPlatformInputManager.GetButtonDown("Block"))
        {
            currentState = Turnstate.BLOCK;
        }
    }
示例#9
0
    //Melee Attack
    private IEnumerator TimeForAction()
    {
        if (actionStarted)
        {
            yield break;
        }

        actionStarted = true;

        //CheckWord Stringlength to base the damage
        Vector3 Player2Position = new Vector3(targetEnemy.transform.position.x - .5f, targetEnemy.transform.position.y, targetEnemy.transform.position.z);

        while (MoveTowardsEnemy(Player2Position))
        {
            yield return(null);
        }
        animPlayer1.SetInteger("state", 1);
        yield return(new WaitForSeconds(AttackSpeed));

        doDamage();
        animPlayer1.SetInteger("state", 0);

        Vector3 firstPosition = StartPosition;

        while (MoveTowardsStart(firstPosition))
        {
            yield return(null);
        }
        try
        {
            bsm.PerformList.RemoveAt(0);
        }
        catch
        {
            Debug.Log(bsm.PerformList.Count);
        }


        bsm.battleState = BattleStateMachine.PerformAction.wait;

        actionStarted = false;

        min_Timer    = 0;
        currentState = Turnstate.processing;
    }
示例#10
0
    // Update is called once per frame
    void Update()
    {
        Debug.Log(CurrentState);

        switch (CurrentState)
        {
        case (Turnstate.Processing):

            UpgradeProgressBar();


            break;

        case (Turnstate.ChooseAction):

            ChooseAction();
            CurrentState = Turnstate.Waiting;


            break;



        case (Turnstate.Waiting):


            break;



        case (Turnstate.Action):

            StartCoroutine(TimeForAction());


            break;

        case (Turnstate.Dead):


            break;
        }
    }
示例#11
0
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
        case (Turnstate.WAITING):

            if (player.playersTurn)
            {
                currentState = Turnstate.SELECTING;
            }
            else
            {
                gameManager.waiting();         //No UI so enemies can attack
            }
            break;

        case (Turnstate.SELECTING):
            battleSelect();         //Choosing Attack, Special or block
            break;

        case (Turnstate.ATTACK):
            gameManager.selectEnemyOn();
            break;

        case (Turnstate.BLOCK):

            break;

        case (Turnstate.SPECIAL):
            gameManager.selectEnemyOn();
            break;

        case (Turnstate.ULTIMATE):
            gameManager.selectEnemyOn();
            break;


        case (Turnstate.DEAD):

            break;
        }
    }
示例#12
0
    void Timer10Sec()
    {
        min_Timer = min_Timer + Time.deltaTime;
        float cacl_Timer = min_Timer / max_Timer;

        TimerP1.transform.localScale = new Vector3(Mathf.Clamp(cacl_Timer, 0, 1), TimerP1.transform.localScale.y, TimerP1.transform.localScale.z);
        if (min_Timer >= max_Timer)
        {
            if (textBox.text == "" || textBox.text == "Ilagay ang salitang makikita...")
            {
                player2.currentState = Player2Script.Turnstate.processing;
                currentState         = Turnstate.waiting;
                min_Timer            = 0;
            }
            else
            {
                Debug.Log("Pass p2");
                currentState = Turnstate.addToList;
            }
        }
    }
    private IEnumerator TimeForAction()
    {
        if (actionStarted)
        {
            yield break;
        }

        actionStarted = true;

        //animate the enemy near the hero to attacck
        Vector3 enemyPosition = new Vector3(EnemyToAttack.transform.position.x + 1.5f, EnemyToAttack.transform.position.y, EnemyToAttack.transform.position.z);

        while (MoveTowardsEnemy(enemyPosition))
        {
            yield return(null);
        }

        //Wait a bit
        yield return(new WaitForSeconds(0.5f));

        //do damage

        //animate back to start position
        Vector3 firstposition = startPosition;

        while (MoveTowardsStart(firstposition))
        {
            yield return(null);
        }
        //Remove performer from the list in BSM
        BSM.PerformList.RemoveAt(0);

        //Reset BSM= wait
        BSM.BattleStates = BattleStateMachine.PerformAction.Wait;
        actionStarted    = false;
        //reset this enemy state
        cur_cooldown = 0f;
        CurrentState = Turnstate.Processing;
    }
示例#14
0
    void Timer10Sec()
    {
        //this function timer must be remove after checking the word and trigger the action function
        min_Timer = min_Timer + Time.deltaTime;
        float cacl_Timer = min_Timer / max_Timer;

        TimerP2.transform.localScale = new Vector3(Mathf.Clamp(cacl_Timer, 0, 1), TimerP2.transform.localScale.y, TimerP2.transform.localScale.z);
        if (min_Timer >= max_Timer)
        {
            if (textBox.text == "" || textBox.text == "Ilagay ang salitang makikita...")
            {
                currentState = Turnstate.waiting;
                StopCoroutine(TimeForAction());
                player1.currentState = Player1Script.Turnstate.processing;
                min_Timer            = 0;
            }
            else
            {
                Debug.Log("Pass p1");
                currentState = Turnstate.addToList;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        Debug.Log(CurrentState);

        switch (CurrentState)
        {
        case (Turnstate.Processing):

            UpgradeProgressBar();


            break;

        case (Turnstate.Addtolist):
            BSM.HerosToManage.Add(this.gameObject);
            CurrentState = Turnstate.Waiting;

            break;

        case (Turnstate.Waiting):


            break;



        case (Turnstate.Action):
            StartCoroutine(TimeForAction());

            break;

        case (Turnstate.Dead):


            break;
        }
    }
示例#16
0
 // Use this for initialization
 void Start()
 {
     CurrentState   = Turnstate.Processing;
     BSM            = GameObject.Find("BattleManager").GetComponent <BattleStateMachine>();
     startpostition = transform.position;
 }
示例#17
0
 // Start is called before the first frame update
 void Start()
 {
     currentState  = Turnstate.WAITING;
     previousState = Turnstate.DEAD;
     player.CurrHP = player.MaxHP;
 }
示例#18
0
 void Battle_Start()
 {
     state = Turnstate.BATTLE_START;
     this.state_BATTLE_START(this, EventArgs.Empty);
     Invoke("Turn_Player", 2.0f);
 }
示例#19
0
 void Turn_Player()
 {
     state = Turnstate.TURN_PLAYER;
     this.state_TURN_PLAYER(this, EventArgs.Empty);
 }
示例#20
0
 void Turn_Enemy()
 {
     state = Turnstate.TURN_ENEMY;
     this.state_TURN_ENEMY(this, EventArgs.Empty);
 }