Esempio n. 1
0
 void LessIntense()
 {
     AudioFW.AdjustLoopVolume("GameLoopNormal", .4f, 2.5f);
     AudioFW.AdjustLoopVolume("GameLoopIntense", .0f, 2.5f);
     intense = false;
     print("Not so intence anymore");
 }
Esempio n. 2
0
 void Intense()
 {
     intenseTime = Time.time + intenseCooldown;
     AudioFW.AdjustLoopVolume("GameLoopNormal", .0f, .5f);
     AudioFW.AdjustLoopVolume("GameLoopIntense", .4f, .5f);
     intense = true;
     print("Its getting intense!");
 }
Esempio n. 3
0
 public void RPC_startFight()
 {
     Debug.Log("Fight started");
     UIManager.Instance.BossHealthCanvas.SetActive(true);
     transform.GetChild(1).gameObject.SetActive(false);
     GameManager.Instance.bossFightStarted = true;
     immune       = false;
     fightStarted = true;
     AudioFW.StopAllSounds();
     AudioFW.PlayLoop("BossLoop");
     AudioFW.AdjustLoopVolume("BossLoop", 0.2f, 2f);
 }
Esempio n. 4
0
 private void Start()
 {
     watchedIntro += WatchIntro;
     watchedIntro += NameEntry;
     loadMenu     += LoadMenu;
     menuMusic    += PlayMenuMusic;
     input.text    = PlayerPrefs.GetString("Name");
     //PlayerPrefs.SetInt("IntroSeen", 0);
     if (PlayerPrefs.GetInt("IntroSeen") == 1)
     {
         skipIntro.interactable = true;
         skipIntro.Select();
     }
     LeanTween.move(introText, Vector2.up * 1900, 50f).setOnComplete(watchedIntro);
     AudioFW.PlayLoop("IntroLoop");
     AudioFW.AdjustLoopVolume("IntroLoop", .25f, 1f);
 }
Esempio n. 5
0
 void PlayMenuMusic()
 {
     AudioFW.PlayLoop("MenuLoop");
     AudioFW.AdjustLoopVolume("MenuLoop", .25f, 2.5f);
 }
Esempio n. 6
0
    void Update()
    {
        if (photonView.isMine)
        {
            if (!switchingScene)               // Normal gameloop
            // Player Direction Indicator
            {
                if (allPlayersFound == true)
                {
                    IndicatePlayers();
                }

                if (Time.time >= stunDeactTime && stunned)
                {
                    stunned   = false;
                    rb2D.drag = 0;
                }

                camPos = MainCamera.GetComponent <Camera>().WorldToScreenPoint(transform.position);

                // Respawn
                if (respawnTimer <= 0)
                {
                    respawnTimer = respawnTime;
                    uim.SetInfoText("", 1);
                    respawn();
                    AudioFW.StopAllSounds();
                    AudioFW.PlayLoop("GameLoopNormal");
                    AudioFW.PlayLoop("GameLoopIntense");
                    AudioFW.AdjustLoopVolume("GameLoopNormal", .4f, 0);
                    AudioFW.AdjustLoopVolume("GameLoopIntense", 0f, 0);
                    myCharacterEffect.SetActive(true);
                    photonView.RPC("respawn", PhotonTargets.Others);
                }

                // When the player is alive
                if (alive)
                {
                    if (!inPortal)
                    {
                        // Health potion input
                        if (Input.GetKeyDown(KeyCode.H) || Input.GetAxis("Fire3") > 0.5f)
                        {
                            UsePotion();
                        }
                        // Attack input
                        if (Input.GetAxis("Fire1") > 0.5f)
                        {
                            if (Time.time > attackTime + attackInterval)
                            {
                                attackTime = Time.time;
                                Attack();
                            }
                            // Camera recoil when shooting. Kinda shit tbh
                            if (ranged)
                            {
                                shooting = true;
                            }
                        }
                        else
                        {
                            if (ranged)
                            {
                                shooting = false;
                            }
                        }
                        // Movement input
                        movement.x = Input.GetAxisRaw("Horizontal");
                        movement.y = Input.GetAxisRaw("Vertical");

                        // Cheats

                        // For testing weaponupgrades
                        //if (Input.GetKeyDown(KeyCode.N))
                        //{
                        //	SpeedDowngrade();
                        //}

                        //if (Input.GetKeyDown(KeyCode.M))
                        //{
                        //	GetSpeedBoost();
                        //}

                        // For debugging use only (might break something)
                        //if (Input.GetKeyDown(KeyCode.B))
                        //{
                        //	potion = true;
                        //	UsePotion();
                        //}

                        // Teleport to boss
                        //if(Input.GetKeyDown(KeyCode.T)) {
                        //	transform.position = new Vector3(211f, 92f, 0f);
                        //}


                        if (speedLevel > 0)
                        {
                            if ((speedDowngradeTimer - Time.deltaTime) > 0)
                            {
                                speedDowngradeTimer -= Time.deltaTime;
                            }
                            else
                            {
                                speedDowngradeTimer = 0;
                            }
                            if (speedDowngradeTimer <= 0)
                            {
                                SpeedDowngrade();
                            }
                        }

                        if (weaponLevel > 0)
                        {
                            if ((weaponDowngradeTimer - Time.deltaTime) > 0)
                            {
                                weaponDowngradeTimer -= Time.deltaTime;
                            }
                            else
                            {
                                weaponDowngradeTimer = 0;
                            }
                            if (weaponDowngradeTimer <= 0)
                            {
                                weaponDowngrade();
                            }
                        }

                        if (movement.x != 0 || movement.y != 0)
                        {
                            lastDir = new Vector2(movement.x, movement.y);
                        }

                        // Camera movement
                        if (!stunned)
                        {
                            Vector3 newCamPos;
                            if (pfa.usingController)
                            {
                                newCamPos = new Vector3(Input.GetAxis("Horizontal2") * maxCamOffset,
                                                        Input.GetAxis("Vertical2") * maxCamOffset,
                                                        playerCam.transform.position.z) + transform.position;
                                LeanTween.cancel(playerCam);
                                LeanTween.move(playerCam, newCamPos, .5f);
                            }
                            else
                            {
                                newCamPos = new Vector3(Mathf.Clamp((Input.mousePosition.x - camPos.x) * playerCamOffset, -maxCamOffset, maxCamOffset),
                                                        Mathf.Clamp((Input.mousePosition.y - camPos.y) * playerCamOffset, -maxCamOffset, maxCamOffset),
                                                        playerCam.transform.position.z) + transform.position;
                                LeanTween.cancel(playerCam);
                                LeanTween.move(playerCam, newCamPos, .25f);
                            }
                        }

                        animator.SetFloat("Horizontal", projHead.transform.right.x);
                        animator.SetFloat("Vertical", projHead.transform.right.y);
                        animator.SetFloat("Magnitude", movement.magnitude);


                        if ((Input.GetKeyDown(KeyCode.Space) || (Input.GetAxis("Fire2") > 0.5f)) && specialTime + specialCooldown <= Time.time)
                        {
                            specialTime = Time.time;
                            Debug.Log("Special");
                            if (characterType == EntityType.Hero0)
                            {
                                // Light MaGi - Dash
                                Dash();
                            }
                            else if (characterType == EntityType.Hero1)
                            {
                                // Light Oni - Area Heal
                                AreaHeal();
                            }
                            else if (characterType == EntityType.Hero2)
                            {
                                // Dark MaGi - Push
                                Push();
                            }
                            else if (characterType == EntityType.Hero3)
                            {
                                // Dark Oni - Area Damage
                                AreaDamage();
                            }
                            uim.setSpecialCooldownTimer(specialTime + specialCooldown, specialCooldown);
                        }

                        if (intense && Time.time > intenseTime)
                        {
                            if (!Physics2D.OverlapCircle(transform.position, 10f, layerMaskEnemy))
                            {
                                LessIntense();
                            }
                            else
                            {
                                intenseTime = Time.time + intenseCooldown;
                            }
                        }


                        if (dashing)
                        {
                            if (specialTime + dashLength <= Time.time)
                            {
                                dashing = false;
                                Invoke("StopDashEffect", .3f);
                            }
                        }
                    }
                }
                else                     // Camera switching when the player is dead

                // Respawn when boss is defeated
                {
                    if (GameManager.Instance.bossDefeated)
                    {
                        respawnTimer = respawnTime;
                        uim.SetInfoText("", 1);
                        respawn();
                        AudioFW.StopAllSounds();
                        AudioFW.PlayLoop("GameLoopNormal");
                        AudioFW.PlayLoop("GameLoopIntense");
                        AudioFW.AdjustLoopVolume("GameLoopNormal", .4f, 0);
                        AudioFW.AdjustLoopVolume("GameLoopIntense", 0f, 0);
                        photonView.RPC("respawn", PhotonTargets.Others);
                    }

                    respawnTimer -= Time.deltaTime;
                    uim.SetInfoText("You Died\n" + "Respawn in " + respawnTimer.ToString("f0"), 1);
                    if (Input.GetMouseButtonDown(0))
                    {
                        if (players.Length > 1)
                        {
                            findCamera();
                        }
                        else
                        {
                            Debug.Log("Cant search for a remote camera, only 1 player in the game");
                        }
                    }
                    // If remote camera is found follow a camera/player with current camNum.
                    if (camFound)
                    {
                        MainCamera.transform.position = Vector3.Lerp(MainCamera.transform.position, players[camNum].transform.Find("Main Camera").transform.position, 0.1f);
                    }
                }
            }
            else                 // About to change scene
            {
                sceneTimer -= Time.deltaTime;
                if (!gameWon)
                {
                    UIManager.Instance.SetInfoText("You All Died\n" + "Restarting level " + sceneTimer.ToString("f0"), 1);
                }
                else
                {
                    UIManager.Instance.SetInfoText("Hope this is the way home", 1);
                }
                //transform.position = charPos;
                //charPos = transform.position;
                if (sceneTimer < 0)
                {
                    if (!gameWon)
                    {
                        if (PhotonNetwork.isMasterClient)
                        {
                            // Should load game scene
                            print("Should load game scene");
                            PhotonNetwork.LoadLevel(3);
                            sceneTimer = 10;
                        }
                    }
                    else
                    {
                        // Should load credits scene
                        print("Should load credits scene");
                        PhotonNetwork.LoadLevel(4);
                    }
                }
            }
        }
        else
        {
            transform.position = Vector3.Lerp(transform.position, TargetPosition, 0.1f);
            rb2D.isKinematic   = true;
        }
    }
Esempio n. 7
0
    void Start()
    {
        PowerupEffect.GetComponent <ParticleSystem>().Stop();
        PushEffect     = Resources.Load("PushEffect", typeof(ParticleSystem)) as ParticleSystem;
        respawnTimer   = respawnTime;
        rotator        = transform.Find("ProjectileHeading").gameObject;
        pfa            = rotator.GetComponent <PlayerFacingAt>();
        meleeIndicator = rotator.transform.Find("MeleeIndicator").gameObject;
        meleeIndicator.SetActive(false);
        alive                = true;
        stunned              = false;
        rb2D                 = GetComponent <Rigidbody2D>();
        col                  = GetComponent <CircleCollider2D>();
        spriteRenderer       = GetComponent <SpriteRenderer>();
        layerMaskEnemy       = LayerMask.GetMask("Enemy");
        layerMaskPlayer      = LayerMask.GetMask("Player");
        layerMaskIndicator   = LayerMask.GetMask("DirectionIndicator");
        projHead             = transform.Find("ProjectileHeading").gameObject;
        MainCamera           = transform.Find("Main Camera").gameObject;
        DirectionIndicator1  = transform.Find("DirectionIndicator1").gameObject;
        DirectionIndicator2  = transform.Find("DirectionIndicator2").gameObject;
        DirectionIndicator3  = transform.Find("DirectionIndicator3").gameObject;
        IndicatorColliderObj = MainCamera.transform.Find("IndicatorCollider").gameObject;
        lightmagiLeft        = Resources.Load <Sprite>("Sprites/32magi_run_left 2");
        lightOnileft         = Resources.Load <Sprite>("Sprites/32oni_run_left");
        darkMagiLeft         = Resources.Load <Sprite>("Sprites/dark_magi_run_left");
        darkOniLeft          = Resources.Load <Sprite>("Sprites/Dark_Oni_run_left");
        players              = GameObject.FindGameObjectsWithTag("Player");
        SetCharacterAttributes();
        meleeIndicator.transform.localScale    = new Vector3(attackRange, .1f, 1);
        meleeIndicator.transform.localPosition = new Vector3(attackRange / 2, 0, 0);
        meleeIndicator.SetActive(false);
        camPos = MainCamera.GetComponent <Camera>().WorldToScreenPoint(transform.position);
        uim    = GameObject.Find("UIManager").GetComponent <UIManager>();
        var photonView = GetComponent <PhotonView>();        // Jos bugeja ni tässä.

        Invoke("FindPlayers", 1f);

        /*
         * if (!PhotonNetwork.isMasterClient)
         *      return;
         * var photonView = GetComponent<PhotonView>();
         */
        if (photonView != null)
        {
            PlayerManager.Instance.ModifyHealth(photonView.owner, health);
            UIManager.Instance.UpdatePlayerUI();
        }
        if (photonView.isMine)
        {
            GameManager.Instance.pc = this;
            myCharacterEffect.SetActive(true);
            AudioFW.StopAllSounds();
            AudioFW.PlayLoop("GameLoopNormal");
            AudioFW.PlayLoop("GameLoopIntense");
            AudioFW.AdjustLoopVolume("GameLoopNormal", .4f, 0);
            AudioFW.AdjustLoopVolume("GameLoopIntense", 0f, 0);
        }

        players = GameObject.FindGameObjectsWithTag("Player");
    }