예제 #1
0
    void Update()
    {
        string         json = File.ReadAllText(Application.dataPath + "/GameInProgress.json");
        gameInProgress GIP  = JsonUtility.FromJson <gameInProgress>(json);

        if (!GIP.IsPlaying)
        {
            Effect1(0);
            Effect2(0);
            Effect3(0);
            Effect4(false);
        }
    }
예제 #2
0
    void mapToArcade()
    {
        SoundManager.instance.StopSound();

        /*INITIALIZE EFFECTS*/
        effect ef = new effect();

        ef.turn = 0;
        ef.bombermanDamageTurn1 = ef.bombermanDamageTurn2 = -1;
        ef.noInvincibleTurn1    = ef.noInvincibleTurn2 = -1;
        ef.whoReflectDamage     = 0;
        ef.turnToReflect1       = ef.turnToReflect2 = -1;
        ef.turnToStopPoison1    = ef.turnToStopPoison2 = -1;

        string json = JsonUtility.ToJson(ef);

        File.WriteAllText(Application.dataPath + "/Effects.json", json);

        /*THE ARCADE SCENE WILL RESTART */
        gameInProgress GIP = new gameInProgress();

        GIP.IsPlaying = false;
        string playing = JsonUtility.ToJson(GIP);

        File.WriteAllText(Application.dataPath + "/GameInProgress.json", playing);


        data Data = new data();

        Data.position = player.position;

        Data.position.y -= 2;
        string json1 = JsonUtility.ToJson(Data);

        File.WriteAllText(Application.dataPath + "/savefile.json", json1);
        StartCoroutine(mapToArcadeCor());
    }
예제 #3
0
    void Update()
    {
        string        checkEnd = File.ReadAllText(Application.dataPath + "/enemyToBattle.json");
        enemyToBattle enemy    = JsonUtility.FromJson <enemyToBattle>(checkEnd);

        if (enemy.nextEnemyNr == 10)
        {
            endScript.EndScreen();
        }

        string json = File.ReadAllText(Application.dataPath + "/GameInProgress.json");

        gameInProgress GIP = JsonUtility.FromJson <gameInProgress>(json);

        IsPlayingVar = GIP.IsPlaying;

        if (IsPlayingVar)
        {
            animator.SetBool("IsPlaying", true);
            moveScript.animator.SetFloat("LastVertical", 1);
            moveScript.movement    = new Vector2(0, 0);
            moveScript.canMove     = false;
            player.position        = waypoint2.position;
            transform.position     = waypoint1.position;
            cam.transform.position = player.position + new Vector3(-0.5f, 0.5f, -10);
            cam.orthographicSize   = 2;
            if (PauseMenu.GameIsPaused)
            {
                Cardridge1.SetActive(false);
                Cardridge2.SetActive(false);
                Cardridge3.SetActive(false);
            }
            else
            {
                Cardridge1.SetActive(true);
                Cardridge2.SetActive(true);
                Cardridge3.SetActive(true);
            }
        }
        else if (moveToConsole)
        {
            moveScript.movement = new Vector2(0, 0);
            moveScript.canMove  = false;
            T += Time.deltaTime;
            if (T >= moveTimer)
            {
                MovePlayers();
                if (player.position == waypoint2.position && transform.position == waypoint1.position && combatScript.playerHP > 0 && combatScript.enemyHP > 0)
                {
                    IsPlayingVar = true;
                    gameInProgress GIP2 = new gameInProgress();
                    GIP2.IsPlaying = true;

                    string json2 = JsonUtility.ToJson(GIP2);

                    File.WriteAllText(Application.dataPath + "/GameInProgress.json", json2);
                }
            }
        }
        else
        {
            animator.SetBool("IsPlaying", false);
            moveScript.canMove     = true;
            transform.position     = new Vector3(0, 0, 0);
            cam.transform.position = new Vector3(0, 0, -10f);
            cam.orthographicSize   = 5;
            Cardridge1.SetActive(false);
            Cardridge2.SetActive(false);
            Cardridge3.SetActive(false);
        }
    }
예제 #4
0
    void GameOver()
    {
        gameInProgress GIP = new gameInProgress();

        GIP.IsPlaying = false;

        string json = JsonUtility.ToJson(GIP);

        File.WriteAllText(Application.dataPath + "/GameInProgress.json", json);

        for (int i = 1; i <= 3; i++)
        {
            Card card = new Card();
            card.name      = "";
            card.wasPlayed = false;
            json           = JsonUtility.ToJson(card);
            File.WriteAllText(Application.dataPath + "/card" + i.ToString() + ".json", json);
        }

        string        json1 = File.ReadAllText(Application.dataPath + "/enemyToBattle.json");
        enemyToBattle enemy = JsonUtility.FromJson <enemyToBattle>(json1);


        if (enemyHP <= 0)
        {
            enemy.nextEnemyNr++;
            spawnPoint.ifToSpawn(false);
            if (enemy.nextEnemyNr == 9)
            {
                enemyHP = 200;
            }
            else
            if (enemy.nextEnemyNr == 2 || enemy.nextEnemyNr == 5 || enemy.nextEnemyNr == 8)
            {
                enemyHP = 150;
            }
            else
            {
                enemyHP = 100;
            }

            if (playerHP < 1)
            {
                playerHP = 1;
            }
        }
        else if (playerHP <= 0)
        {
            if (enemy.nextEnemyNr == 9)
            {
                enemyHP = 200;
            }
            else
            if (enemy.nextEnemyNr == 2 || enemy.nextEnemyNr == 5 || enemy.nextEnemyNr == 8)
            {
                enemyHP = 150;
            }
            else
            {
                enemyHP = 100;
            }
            spawnPoint.ifToSpawn(true); respawn();
            playerHP = 100;
        }
        else
        {
            spawnPoint.ifToSpawn(false);
        }

        HP x = new HP();

        x.playerHP = playerHP;
        x.enemyHP  = enemyHP;



        string json2 = JsonUtility.ToJson(enemy);

        File.WriteAllText(Application.dataPath + "/enemyToBattle.json", json2);
        string json3 = JsonUtility.ToJson(x);

        File.WriteAllText(Application.dataPath + "/HPs.json", json3);
    }
예제 #5
0
    void Update()
    {
        string         check = File.ReadAllText(Application.dataPath + "/GameInProgress.json");
        gameInProgress GIP   = JsonUtility.FromJson <gameInProgress>(check);

        if (GIP.IsPlaying)
        {
            string        json4 = File.ReadAllText(Application.dataPath + "/enemyToBattle.json");
            enemyToBattle enemy = JsonUtility.FromJson <enemyToBattle>(json4);
            if (playerHP <= 0 || enemyHP <= 0 || ("Enemy" + (enemy.nextEnemyNr).ToString()) != enemy.currentEnemyNr)
            {
                GameOver();
            }
            else
            {
                Cursor.visible = true;
                string Hp  = File.ReadAllText(Application.dataPath + "/HPs.json");
                HP     hps = JsonUtility.FromJson <HP>(Hp);

                playerHP = hps.playerHP;
                enemyHP  = hps.enemyHP;

                if (Input.GetMouseButtonDown(0))
                {
                    Vector3 mousePos   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);

                    RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
                    if (hit.collider != null)
                    {
                        nameGot = hit.collider.gameObject.name;
                    }

                    string json = "";

                    if (nameGot == "Cardridge1")
                    {
                        json = File.ReadAllText(Application.dataPath + "/card1.json");
                    }

                    if (nameGot == "Cardridge2")
                    {
                        json = File.ReadAllText(Application.dataPath + "/card2.json");
                    }

                    if (nameGot == "Cardridge3")
                    {
                        json = File.ReadAllText(Application.dataPath + "/card3.json");
                    }


                    Card card = JsonUtility.FromJson <Card>(json);

                    Card card2 = new Card();
                    card2.wasPlayed = true;


                    if (nameGot == "Cardridge1")
                    {
                        card2.name = card.name;
                        json       = JsonUtility.ToJson(card2);
                        File.WriteAllText(Application.dataPath + "/card1.json", json);

                        scChange.arcadeToGame(card.name);
                    }
                    if (nameGot == "Cardridge2")
                    {
                        card2.name = card.name;
                        json       = JsonUtility.ToJson(card2);
                        File.WriteAllText(Application.dataPath + "/card2.json", json);

                        scChange.arcadeToGame(card.name);
                    }
                    if (nameGot == "Cardridge3")
                    {
                        card2.name = card.name;
                        json       = JsonUtility.ToJson(card2);
                        File.WriteAllText(Application.dataPath + "/card3.json", json);

                        scChange.arcadeToGame(card.name);
                    }
                }
            }
        }
    }