Exemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     currentState = GAMESTATES.IDLE;
     walkSpeed    = 3.0f;
     rb           = GetComponent <Rigidbody2D>();
     anim         = GetComponent <Animator>();
 }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     player           = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerBehaviour>();
     currentGameState = GAMESTATES.GAME;
     score            = 0;
     SoundManager.Instance.PlaySfx("Fx1");
 }
Exemplo n.º 3
0
 public void MoveEvent(InputAction.CallbackContext context)
 {
     velocity = context.ReadValue <Vector2>() * 1.5f;
     if (velocity.y != 0)
     {
         currentState = GAMESTATES.JUMP;
     }
 }
Exemplo n.º 4
0
 IEnumerator KeepState(GAMESTATES _state)
 {
     // send event that state has entered
     EventManager.Instance.InvokeEvent(_state.ToString() + "_ENTERED");
     while (m_gameState == _state)
     {
         yield return(null);
     }
     // send event that state has exited
     m_prevState = _state;
     EventManager.Instance.InvokeEvent(m_prevState.ToString() + "_EXITED");
 }
Exemplo n.º 5
0
 //---------------------------------------------------------------------
 private bool changeState(GAMESTATES _state)
 {
     // validate if state change is possible, if not exit and return false
     if (m_gameState == _state)
     {
         return(false);
     }
     Debug.Log("Entering " + _state);
     // set the new state, start coroutine to keep the state and return true
     m_gameState = _state;
     StartCoroutine(KeepState(m_gameState));
     EventManager.Instance.InvokeEvent("GAMESTATE_CHANGED");
     return(true);
 }
Exemplo n.º 6
0
 void AntiAir()
 {
     currentState = GAMESTATES.AIRINVUL;
     rb.AddForce(new Vector2(0, 250), ForceMode2D.Force);
     anim.SetBool("Grounded", false);
     Collider2D[] cols = Physics2D.OverlapBoxAll(attackHitboxes[1].bounds.center, attackHitboxes[1].bounds.extents, 1.0f, LayerMask.GetMask("Hitbox"));
     foreach (Collider2D c in cols)
     {
         if (c.gameObject != gameObject)
         {
             c.gameObject.GetComponent <BaseCharacter>().Kill();
         }
     }
 }
Exemplo n.º 7
0
    // fixed update for physics only
    private void FixedUpdate()
    {
        if (specialPressed && !isJumping && !projectileInst && velocity.y == 0 && currentState == GAMESTATES.IDLE)
        {
            currentState = GAMESTATES.FIREBALL;
            anim.SetTrigger("Fireball");
            rb.velocity    = new Vector2(0, 0);
            canWalk        = false;
            specialPressed = false;
        }

        if (specialPressed && velocity.y < 0 && !isJumping && currentState == GAMESTATES.IDLE)
        {
            currentState = GAMESTATES.DP;
            anim.SetTrigger("AntiAir");
            canWalk        = false;
            specialPressed = false;
        }

        if (specialPressed && isJumping)
        {
            currentState = GAMESTATES.AERIAL;
            anim.SetTrigger("Aerial");
            specialPressed = false;
        }
        //CheckDirection();

        // walk
        if (!isJumping && canWalk)
        {
            rb.velocity = new Vector2(velocity.x * walkSpeed, rb.velocity.y);
        }

        // jump
        if (velocity.y > 0 && !isJumping && canWalk)
        {
            if (rb.velocity.x == 0)
            {
                anim.SetTrigger("Jump");
            }
            else
            {
                anim.SetTrigger("JumpFwd");
            }
            anim.SetBool("Grounded", false);
            rb.AddForce(new Vector2(0, 400), ForceMode2D.Force);
            isJumping = true;
        }
    }
Exemplo n.º 8
0
    public static void SetGameState(GAMESTATES state)
    {
        gameState = state; // set the gamestate
        switch (state)
        {
        case GAMESTATES.MENU:                                  // if the game state is menu
            instance.TitlePageCanvas.SetActive(true);          // show the title page
            instance.PlayingCanvas.SetActive(false);           // hide the playing canvas
            CursorController.instance.SetToNavigationCursor(); // use the navigation cursor
            break;

        case GAMESTATES.PLAYING:                                           // if the game state is playing
            instance.TitlePageCanvas.SetActive(false);                     // hide the title page
            instance.PlayingCanvas.SetActive(true);                        // show the playing canvas
            instance.txtWeaponLevel.text = "Weapon Level: " + weaponLevel; // set the weapon level text
            CursorController.instance.SetToCrossHairCursor();              // ensure the cursor being used is the crosshair
            break;
        }
    }
Exemplo n.º 9
0
        /// <summary>
        /// Used once all players have joined lobby
        /// </summary>
        public static void GameStart() {
            int playercount = PlayerCount();
            if (playercount < 5)
                return; // Too few players
            else if (playercount < 7) {
                gameSize = SIZE.SML;
                HitlerKnows = true;
            } else if (playercount < 9) {
                gameSize = SIZE.MED;
                HitlerKnows = false;
            } else if (playercount < 11) {
                gameSize = SIZE.LGE;
                HitlerKnows = false;
            } else
                return; // Too many players

                int[] randomPlayers = new int[playercount];
                for (int i = 0; i < playercount; i++) {
                    randomPlayers[i] = i;
                }
                randomPlayers.Shuffle();

                int pIndex = 0;
                //Set Hitler
                players[randomPlayers[pIndex]].Role = ROLES.Hitler;
                pIndex++;
                //Set fascists
                int numFascists = (playercount - 3) / 2;
                while (pIndex < numFascists) {
                    players[randomPlayers[pIndex]].Role = ROLES.Fascist;
                    pIndex++;
                }
                //Set remaining as Liberal
                while (pIndex < playercount) {
                    players[randomPlayers[pIndex]].Role = ROLES.Liberal;
                    pIndex++;
                }
                //Reset deck of cards
                policies = new PoliciesDeck();
                //Clear boards
                Boards.ClearAll();
                //Randomly select president
                System.Random rand = new System.Random();
                CurrentPrez = rand.Next(0, playercount - 1);
                SetNewNextPres(CurrentPrez + 1);
                //No need to make users communicate roles, as info will be available on devices

                gameState = GAMESTATES.READING_ROLES;
            }
Exemplo n.º 10
0
 public static void EndVeto(bool Vote) {
     if (Vote == Utility.JA) {
         policies.discard(players[CurrentChan].Hand[0]);
         policies.discard(players[CurrentChan].Hand[1]);
         players[CurrentChan].Hand.Clear();
         ElectionTracker++;
         SetPres();
     } else {
         gameState = GAMESTATES.CHAN_POLICY;
     }
 }
Exemplo n.º 11
0
 public void ChangeGameState(int state)  //for button click event (just in case)
 {
     gameState = (GAMESTATES)state;
     callOnce  = true;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Metodo para verificar o estado atual do jogo
 /// </summary>
 /// <param name="state"></param>
 /// <returns></returns>
 public bool IsCurrentGameState(GAMESTATES state)
 {
     return(currentGameState == state);
 }
Exemplo n.º 13
0
 private static void ResolvePowers (POWERS p) {
     switch (p) {
         case POWERS.LoyaltyCheck:
             gameState = GAMESTATES.LOYALTY_CHECK;
             break;
         case POWERS.SpecialElection:
             gameState = GAMESTATES.SPECIAL_ELECTION;
             break;
         case POWERS.PolicyCheck:
             gameState = GAMESTATES.POLICY_PEEK;
             players[CurrentPrez].Hand = policies.showTopThree();
             break;
         case POWERS.Assassination:
             gameState = GAMESTATES.ASSASSINATE;
             break;
         default:
             SetPres();
             break;
     }
 }
Exemplo n.º 14
0
 private static void SetPres() {
     CurrentPrez = NextPrez;
     SetNewNextPres(CurrentPrez + 1);
     gameState = GAMESTATES.SELECTING_CHAN;
 }
Exemplo n.º 15
0
        //----------------------------------GAME LOOP---------------------------------

        public static void Update() {
            switch (gameState) {
                case GAMESTATES.READING_ROLES:
                    bool done = true;
                    for (int i = 0; i < PlayerCount(); i++) {
                        if (!players[i].HasVoted)
                            done = false;
                    }
                    if (done) {
                        gameState = GAMESTATES.SELECTING_CHAN;
                    }
                    break;
                case GAMESTATES.VOTING:
                    int voteTotal = 0;
                    for (int i = 0; i < PlayerCount(); i++) {
                        if (!players[i].HasVoted)
                            return;
                        if (players[i].Vote == Utility.JA)
                            voteTotal++;
                        else
                            voteTotal--;
                    }
                    if(voteTotal > 0) {
                        if (players[CurrentChan].Role == ROLES.Hitler && Boards.FascistBoards[(int)gameSize].CardsPlayed >= 3) {
                            EndGame(Utility.FASCIST);
                        } else {
                            StartPres_Policy();
                        }
                    } else {
                        ElectionTracker++;
                        if (ElectionTracker > 3) {
                            AutoPlayCard(policies.drawCards(1)[0]);
                        } else {
                            SetPres();
                        }
                    }
                    break;
                case GAMESTATES.PRES_POLICY:
                    if (players[CurrentPrez].Hand.Count < 3) {
                        StartChan_Policy();
                    }
                    break;
                case GAMESTATES.CHAN_POLICY:
                    if (players[CurrentPrez].Hand.Count < 2) {
                        bool CardPlayed = players[CurrentChan].Hand[0];
                        players[CurrentChan].Hand.Clear();
                        PlayCard(CardPlayed);
                    }
                    break;
            }
        }
Exemplo n.º 16
0
 private static void EndGame(bool whoWon) {
     gameState = GAMESTATES.ENDED;
 }
Exemplo n.º 17
0
 public static void ChooseChancellor(int PlayerID) {
     CurrentChan = PlayerID;
     gameState = GAMESTATES.VOTING;
     foreach (PlayerLogic p in players)
         p.HasVoted = false;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Metodo para setar o estado atual de jogo
 /// </summary>
 /// <param name="state"></param>
 public void SetCurrentGameState(GAMESTATES state)
 {
     currentGameState = state;
 }
Exemplo n.º 19
0
 public static void ChoosePresident(int PlayerID) {
     CurrentPrez = PlayerID;
     gameState = GAMESTATES.SELECTING_CHAN;
 }
Exemplo n.º 20
0
 public void ChangeGameState(GAMESTATES state)
 {
     gameState = state;
     callOnce  = true;       // Set to true so every time the state change, there's a place to call some code once in the loop
 }
Exemplo n.º 21
0
 public static void StartVeto() {
     gameState = GAMESTATES.VETOING;
 }
Exemplo n.º 22
0
 static public void ChangeStateTo(GAMESTATES a_state)
 {
     currentState = a_state;
 }
Exemplo n.º 23
0
 void CanWalk()
 {
     canWalk      = true;
     currentState = GAMESTATES.IDLE;
 }