Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     sceneManagement = GameObject.FindGameObjectWithTag(GlobalVariables.MANAGERTAG).GetComponent <SceneManagement>();
     gameLogic       = GameObject.FindGameObjectWithTag(GlobalVariables.MANAGERTAG).GetComponent <GameLogic>();
     lives           = maxLives;
     livesText.text  = lives.ToString();
 }
Ejemplo n.º 2
0
    void Start()
    {
        damagecounter = 0;
        turnwhite     = false;
        r             = GetComponentsInChildren <Renderer>();
        gm            = FindObjectOfType <GameManager>();
        anim          = GetComponent <Animator>();
        rb            = GetComponent <Rigidbody2D>();
        sm            = FindObjectOfType <SceneManagement>();
        //NinjaController sling = FindObjectOfType<NinjaController>();

        enispunching       = false;
        enisidle           = true;
        eniswalking        = false;
        enishurt           = false;
        enisnut            = false;
        enpunchcol.enabled = true;
        time             = 0;
        punchistriggered = false;
        yomama           = false;
        player           = FindObjectOfType <PlayerMovement>();
        haswhistled      = false;

        //player = Transform.FindWithTag("Player").GetComponent<PlayerMovement>();
        //player = Transform.FindWithTag("Player").transform;
        //player = Transform.Find("Player").gameObject;
        //player = PlayerMovement.Transform.Find("Player").gameObject;


        playera = GameObject.FindWithTag("playerp");
        target  = playera.transform;
    }
Ejemplo n.º 3
0
    IEnumerator OnCollisionEnter2D(Collision2D c)
    {
        if (c.gameObject.CompareTag("Obstacle") && health != 0 && !EnemyDeath)                      //if player hit an obstacle
        {
            float sign = GetComponent <Transform>().position.x - c.gameObject.transform.position.x; // get position difference between player and obstacle to see in which direction he hit it
            float dir  = sign / Mathf.Abs(sign);                                                    // change the differencethe player to either 1 or -1
            rb.AddForce(new Vector2(300 * sign, 300));                                              // add force according to sign
            health          -= 0.125f;                                                              // decrease player health
            image.fillAmount = health;                                                              // change health amount (Image)
            audio.Play();                                                                           // play coins audio
            // removeCoins();
        }

        if (health == 0 && !isDead)   //if player is dead
        {
            gameSound.isOver = true;
            isDead           = true;                                          // set player as dead
            camera.Follow    = null;                                          // freeze camera
            animator.SetTrigger("Dead");                                      // trigger death animation
            rb.constraints = RigidbodyConstraints2D.FreezeRotation;           //freeze rotation of player
            rb.constraints = RigidbodyConstraints2D.FreezePositionX;          // freeze position of player
            rb.gameObject.GetComponent <BoxCollider2D>().isTrigger    = true; // so that the player
            rb.gameObject.GetComponent <CircleCollider2D>().isTrigger = true; // doesnt hit the floor
            yield return(new WaitForSeconds(1));                              // wait for 1 sec

            transition.SetTrigger("End");                                     // Trigger fade in animation
            yield return(new WaitForSeconds(2));

            gameOver.SetTrigger("gameOver");
            yield return(new WaitForSeconds(4));

            currentScene = SceneManager.GetActiveScene().buildIndex;
            SceneManagement.GameOver();
        }
    }
Ejemplo n.º 4
0
    private IEnumerator ThankYouMessage()
    {
        GetComponent <AudioSource>().Play();
        yield return(new WaitForSeconds(9.5f));

        SceneManagement.ReturnToMain();
    }
Ejemplo n.º 5
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Ejemplo n.º 6
0
 private void Start()
 {
     sceneManagementScript = GetComponent <SceneManagement>();
     currentLvlText.text   = "" + sceneManagementScript.currentScene;
     nextLvlText.text      = "" + sceneManagementScript.nextScene;
     StartCoroutine("SliderIncreaser");
 }
Ejemplo n.º 7
0
 //checks collision between the seeker's weapon and scene objects
 private void OnTriggerEnter(Collider other)
 {
     //if the object isn't a player
     if (other.gameObject.tag.Equals("Untagged") || other.gameObject.tag.Equals("HiderPlaceholder"))
     {
         source.PlayOneShot(emptySound, 5f);
         //destroys the game object
         Destroy(other.gameObject);
         //decreases amount of time left
         timer.DecreaseTime(secondsRemoved);
     }
     //if the object is a hider
     if (other.gameObject.tag.Equals("Hider0") || other.gameObject.tag.Equals("Hider1") || other.gameObject.tag.Equals("Hider2"))
     {
         source.PlayOneShot(hiderSound, 5f);
         Destroy(other.gameObject);
         //increases number of hiders found
         SceneManagement.hidersFound += 1;
         //checks to see if all hiders have been found
         if (SceneManagement.hidersFound >= 3)
         {
             SceneManagement.Win();
         }
     }
 }
Ejemplo n.º 8
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (!collision.gameObject.CompareTag("PlayerProjectile"))
     {
         SceneManagement.Tutorial2();
     }
 }
Ejemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        sm = GameObject.Find("Scenemangaer").GetComponent <SceneManagement>();
        Screen.autorotateToPortrait           = false;
        Screen.autorotateToPortraitUpsideDown = false;
        Screen.orientation = ScreenOrientation.LandscapeLeft;
        // DontDestroyOnLoad(this);
        uim = ControlUi.GetComponent <UiManager>();
        ControlUi.SetActive(false);
        for (int i = 0; i < compuestos.Length; i++)
        {
            int x = 0;
            int y = 0;
            int z = 0;

            x = compuestos[i].elementosNesesario[0];
            y = compuestos[i].elementosNesesario[1];
            z = compuestos[i].elementosNesesario[2];
            elements[x, y, z] = compuestos[i];
            elements[y, x, z] = compuestos[i];
            elements[z, x, y] = compuestos[i];
            elements[y, z, x] = compuestos[i];
            elements[z, y, x] = compuestos[i];
            elements[x, z, y] = compuestos[i];
        }
    }
Ejemplo n.º 10
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         SceneManagement.LevelComplete();
     }
 }
Ejemplo n.º 11
0
    // Update is called once per frame
    void Update()
    {
        // Add order within set amount of time
        StartCoroutine(TimeBeforeNextOrder());

#if DEBUG
        ordersInInspector = new List <string>();
        for (int i = 0; i < pancakeOrders.Count; i++)
        {
            ordersInInspector.Add(pancakeOrders[i].orderNumber.ToString());
        }
        currentOrderCounter = orderCounter;
#endif

        if (GlobalTimer.secondsRemaining < 0)
        {
            if (OrderTracker.CompleterdOrders1 > OrderTracker.CompleterdOrders2)
            {
                SceneManagement.PlayerOneWin();
            }
            else
            {
                SceneManagement.PlayerTwoWin();
            }
        }

        // check timer count of individual orders
        CheckTimers();
    }
Ejemplo n.º 12
0
    void Start()
    {
        int buttonIndex = transform.GetSiblingIndex() + 1;

        sceneManagement = SceneManagement.instance;
        button          = GetComponent <Button>();
        image           = GetComponent <Image>();
        timePlayedText  = GetComponentInChildren <TMP_Text>();
        string savePath = Application.persistentDataPath + buttonIndex + ".bin";

        if (File.Exists(savePath))
        {
            float  playingTime = SaveSystem.LoadGame(buttonIndex).playingTime;
            string hours       = Mathf.Floor((playingTime % 216000) / 3600).ToString("00");
            string minutes     = Mathf.Floor((playingTime % 3600) / 60).ToString("00");
            string seconds     = Mathf.Floor(playingTime % 60).ToString("00");
            timePlayedText.text = "Tempo de jogo: " + hours + ":" + minutes + ":" + seconds;
        }
        else
        {
            timePlayedText.text = "Novo jogo";
        }

        string screenshotPath = Application.persistentDataPath + buttonIndex + ".png";

        if (File.Exists(screenshotPath))
        {
            byte[]    picture = File.ReadAllBytes(screenshotPath);
            Texture2D texture = new Texture2D(1920, 1080, TextureFormat.RGB24, false);
            texture.LoadImage(picture);
            image.sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(0f, 0f));
        }

        button.onClick.AddListener(delegate { sceneManagement.LoadGameScene(); SceneManagement.index = buttonIndex; });
    }
Ejemplo n.º 13
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (!collision.gameObject.CompareTag("PlayerProjectile") && !collision.gameObject.CompareTag("PlayerUlt"))
     {
         SceneManagement.LevelSelect();
     }
 }
Ejemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     if (this.GetComponent <AudioSource>() != null)
     {
         audio = this.GetComponent <AudioSource>();
     }
     scene = this.GetComponent <SceneManagement>();
     fade  = GameObject.Find("FadePanel").GetComponent <FadeScript>();
     if (SceneManager.GetActiveScene().name == "SelectScene")
     {
         menu  = GameObject.Find("SelectSceneObj").GetComponent <MenuEvent>();
         enter = GameObject.Find("SelectSceneObj").GetComponent <CancelScript>();
         //select = GameObject.Find("P1Image").GetComponent<CharacterSelect>();
         //select2 = GameObject.Find("P2Image").GetComponent<CharacterSelect>();
     }
     if (SceneManager.GetActiveScene().name == "PlayMenuScene")
     {
         datare = GameObject.Find("GameSystem").GetComponent <DataRetention>();
     }
     if (SceneManager.GetActiveScene().name == "PlayScene" || SceneManager.GetActiveScene().name == "PlayMenuScene")
     {
         sys = GameObject.Find("GameSystem").GetComponent <PlayMenuSystem>();
     }
     if (SceneManager.GetActiveScene().name == "PlayMenuScene")
     {
         sys = GameObject.Find("PlayMenuSystemObj").GetComponent <PlayMenuSystem>();
     }
     //Debug.Log("sys:" + sys);
     //Debug.Log("datare:" + datare);
     sceneFlagMenu = false;
 }
 // Update is called once per frame
 void Update()
 {
     if (strawCountRemaining >= 3)
     {
         SceneManagement.KillWin();
     }
 }
Ejemplo n.º 16
0
 // Use this for initialization
 void Start()
 {
     DontDestroyOnLoad(gameObject);
     sceneManagInstance = FindObjectOfType <SceneManagement>();
     soundManagInstance = FindObjectOfType <SoundManager>();
     currentLevel       = -1;
 }
Ejemplo n.º 17
0
 public SceneManagement()
 {
     if (!instance)
     {
         instance = this;
     }
 }
Ejemplo n.º 18
0
 private void Awake()
 {
     Instance = this;
     Load("Player");
     Load("Scene01");
     Load("Scene02");
 }
Ejemplo n.º 19
0
    private void OnEnable()
    {
        sceneManagement = GetComponent <SceneManagement>();
        MinePlayer.ResetElement();
        OtherPlayer.ResetElement();
        roomDetails.ResetElement();

        socket          = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
        socket.Blocking = false;
        myEndPoint      = new IPEndPoint(IPAddress.Parse(MyAddres), MyPort);
        socket.Bind(myEndPoint);

        serverEndPoint = new IPEndPoint(IPAddress.Parse(ServerAddress), ServerPort);

        DontDestroyOnLoad(this.gameObject);
        commands = new command[20];

        commands[COMMAND_UPDATE]                    = Update;
        commands[COMMAND_WELCOME]                   = Welcome;
        commands[COMMAND_P_CONNECTED]               = OtherPlayerConnected;
        commands[COMMAND_SETUP_OP]                  = SetUpOtherPlayer;
        commands[COMMAND_COUNTDOWN]                 = Countdown;
        commands[COMMAND_SPAWN_OBSTACLE]            = SpawnObstacle;
        commands[COMMAND_COLLIDE]                   = Collided;
        commands[COMMAND_DESTROY]                   = DestroyObstacle;
        commands[COMMAND_INTANGIBLEOP]              = IntangibleOP;
        commands[COMMAND_CHANGEOTHERPLAYERPOSITION] = ChangePosOP;
        commands[COMMAND_CHECKPING]                 = CheckLatency;
        commands[COMMAND_CHECKRESPONSE]             = CheckResponse;


        sceneManagement.LoadGameScene();
        SceneManager.activeSceneChanged += LoadGameSceneElements;
    }
Ejemplo n.º 20
0
 // Use this for initialization
 void Start()
 {
     sceneManagement = GameObject.FindGameObjectWithTag("Manager").GetComponent <SceneManagement>();
     gameLogic       = GameObject.FindGameObjectWithTag("Manager").GetComponent <GameLogic>();
     lives           = maxLives;
     livesText.text  = lives.ToString();
 }
Ejemplo n.º 21
0
 void Start()
 {
     player       = FindObjectOfType <PlayerMovement>();
     sm           = GetComponent <SceneManagement>();
     chill.volume = PlayerPrefsController.GetMusicVolume();
     fight.volume = 0;
 }
Ejemplo n.º 22
0
    protected override IEnumerator DeathAnimation()
    {
        if (theManager.GetComponent <GhostManager>().LastGhost())
        {
            GetComponent <Collider2D>().enabled = false;
            GameManager.instance.Win();

            dead = true;

            GameObject.Find("Main Camera").GetComponent <ScreenShake>().Shake();
            StartCoroutine(SpawnDeathParticles());
            yield return(new WaitForSeconds(2.5f));

            yield return(FadeToBlack());

            Destroy(gameObject);
            SceneManagement.Win();
        }
        else
        {
            animator.SetBool(clipBool, true);
            GetComponent <Collider2D>().enabled = false;

            AnimationClip[] clips = animator.runtimeAnimatorController.animationClips;
            foreach (AnimationClip clip in clips)
            {
                if (clip.name.Equals(deathClip))
                {
                    yield return(new WaitForSeconds(clip.length));
                }
            }
            nextGhosts();
        }
    }
Ejemplo n.º 23
0
    private IEnumerator DisclaimerMessage()
    {
        GetComponent <AudioSource>().Play();
        yield return(new WaitForSeconds(11f));

        SceneManagement.LevelComplete();
    }
Ejemplo n.º 24
0
    public void Save()
    {
        PlayerData playerData = player.data;
        LevelData  levelData  = null;

        if (SceneManagement.CurrentLevelNumber() > 0)
        {
            Enemy[] enemies = enemyManager.GetActiveEnemies();
            Tower[] towers  = towerManager.GetActiveTowers().ToArray();
            Dictionary <string, int> towerPositions = new Dictionary <string, int>();
            Dictionary <string, int> enemyPositions = new Dictionary <string, int>();

            foreach (Enemy enemy in enemies)
            {
                enemyPositions.Add(enemy.transform.position.ToString(), (int)enemy.type);
            }

            foreach (Tower tower in towers)
            {
                towerPositions.Add(tower.transform.position.ToString(), (int)tower.type);
            }

            levelData = new LevelData(SceneManagement.CurrentLevelNumber(), towerPositions, enemyPositions, Round, enemyManager.SpawnRate.ToString(), player.Coins, player.Health);
        }
        saveData.playerData = playerData;
        saveData.levelData  = levelData;

        saveAndLoad.SaveGameData(saveData);
    }
Ejemplo n.º 25
0
 // Update is called once per frame
 void Update()
 {
     //CameraRotation();
     //currentPos = whitePiecesSide.transform.position;
     turnText.text = $"Player Turn: {currentTurn}";
     if (numberOfBlackPiecesOnBoard <= 0)
     {
         SceneManagement.GameOver();
     }
     else if (numberOfWhitePiecesOnBoard <= 0)
     {
         SceneManagement.Win();
     }
     //if(currentTurn==colorTurn.white)
     //{
     //    //whitePiecesSide.enabled = true;
     //    //blackPiecesSide.enabled = false;
     //    //whitePiecesSide.transform.RotateAround(Vector3.zero, Vector3.up, degrees);
     //}
     //else if (currentTurn == colorTurn.black)
     //{
     //    //whitePiecesSide.enabled = false;
     //    //blackPiecesSide.enabled = true;
     //}
 }
Ejemplo n.º 26
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Ejemplo n.º 27
0
    public void EndGame()
    {
        //On game ending, saves the last score into player prefs and loads the end scene
        ScoreObject s = new ScoreObject(CoinManager.instance.GetCoins(), (int)playTime);

        SaveLoad.SaveLastScore(s.ToString());
        SceneManagement.LoadScene(2);
    }
Ejemplo n.º 28
0
    void Start()
    {
        sceneManager = FindObjectOfType <SceneManagement> ();
        text         = textObject.GetComponent <TextMeshProUGUI> ();

        sprite = this.gameObject.GetComponent <SpriteRenderer> ();
        light  = this.gameObject.GetComponentInChildren <Light> ();
    }
Ejemplo n.º 29
0
 public void Damage(int damage)
 {
     PlayerStats.playerHealth -= damage;
     if (PlayerStats.playerHealth <= 0)
     {
         SceneManagement.loadSceneByIndex(0);
     }
 }
Ejemplo n.º 30
0
 void Update()
 {
     if (Input.anyKeyDown)
     {
         PlayerStats.reset();
         SceneManagement.nextScene();
     }
 }