// Use this for initialization
    void Start()
    {
        _gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
        //Todo: check if gamemanager == null
        _presentManager = GameObject.Find("PresentManager").GetComponent <PresentManager>();

        GetComponentInChildren <SpriteRenderer>().sprite = Sprite;

        _stageDimensions = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));

        //spawn position
        float k = 1.0f;

        if (Playerid == PlayerId.P2)
        {
            k = -1.0f;
        }
        transform.position = new Vector3(k * _stageDimensions.x * 0.5f, -_stageDimensions.y + 1.0f, 0);

        //setup player actions
        Dictionary <KeyCallback, Action> playerActions = new Dictionary <KeyCallback, Action>();

        playerActions.Add(KeyCallback.KeyOnePressed, MoveLeft);
        playerActions.Add(KeyCallback.KeyTwoPressed, MoveRight);
        _gameManager.SetActionsForPlayer(Playerid, playerActions);

        //link to UI component.
        _text = TextNode.GetComponent <Text>();
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        _presentManager = GameObject.Find("PresentManager").GetComponent <PresentManager>();

        _stageDimensions = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));

        _cloudHolder = new GameObject("CloudsHolder").transform;
    }
Пример #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Get")
        {
            mouse.shootEnabled = true;
        }

        if (other.gameObject.tag == "Ladder")
        {
            onLadder = true;
        }

        if (other.gameObject.tag == "LadderTop")
        {
            onLadder = false;
        }

        if (other.gameObject.tag == "Shotgun")
        {
            mouse.wep.anim.SetTrigger("WeaponSwitch");
            mouse.shotGunBool = true;
            mouse.currWeapon  = 2;
            mouse.useShotgun  = true;
            pickups.clip      = weaponPickup;
            pickups.Play();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "Rifle")
        {
            mouse.wep.anim.SetTrigger("WeaponSwitch");
            mouse.machineGunBool = true;
            mouse.currWeapon     = 3;
            mouse.useMachineGun  = true;
            pickups.clip         = weaponPickup;
            pickups.Play();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "Knife")
        {
            mouse.wep.anim.SetTrigger("WeaponSwitch");
            mouse.knifeBool  = true;
            mouse.currWeapon = 4;
            mouse.useKnife   = true;
            pickups.clip     = weaponPickup;
            pickups.Play();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "Grenade")
        {
            mouse.wep.anim.SetTrigger("WeaponSwitch");
            mouse.grenadeBool = true;
            mouse.currWeapon  = 5;
            mouse.useGrenade  = true;
            pickups.clip      = weaponPickup;
            pickups.Play();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "FireWork")
        {
            mouse.wep.anim.SetTrigger("WeaponSwitch");
            mouse.fireWorkBool = true;
            mouse.currWeapon   = 6;
            mouse.useFirework  = true;
            pickups.clip       = weaponPickup;
            pickups.Play();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "Checkpoint" && other.gameObject.GetComponent <HitCheckPoint>().hit == false)
        {
            //checkpoint = other.gameObject;
            Physics.SyncTransforms();
            StartCoroutine(flashCheck());
            pickups.clip = checkNoise;
            pickups.Play();
            pointX = gameObject.transform.position.x;
            pointY = gameObject.transform.position.y;
            pointZ = gameObject.transform.position.z;
            float positionX = pointX;
            float positionY = pointY;
            float positionZ = pointZ;
            priorHealth         = health;
            priorPistolAmmo     = mouse.currAmmoP;
            priorShotGunAmmo    = mouse.currAmmoS;
            priorMachineGunAmmo = mouse.currAmmoM;
            priorGrenadeAmmo    = mouse.currAmmoG;
            priorFireWorkAmmo   = mouse.currAmmoF;
            priorPoints         = point.totalPoints;
            PlayerPrefs.SetFloat("CheckPointX", positionX);
            PlayerPrefs.SetFloat("CheckPointY", positionY);
            PlayerPrefs.SetFloat("CheckPointZ", positionZ);
            PlayerPrefs.SetInt("PriorH", priorHealth);
            PlayerPrefs.SetInt("PriorP", priorPistolAmmo);
            PlayerPrefs.SetInt("PriorS", priorShotGunAmmo);
            PlayerPrefs.SetInt("PriorM", priorMachineGunAmmo);
            PlayerPrefs.SetInt("PriorG", priorGrenadeAmmo);
            PlayerPrefs.SetInt("PriorF", priorFireWorkAmmo);
            PlayerPrefs.SetInt("PriorScore", priorPoints);
            other.gameObject.GetComponent <HitCheckPoint>().hit = true;

            /*CheckPoints check = other.transform.GetComponent<CheckPoints>();
             * check.Save();*/
        }

        if (other.gameObject.tag == "MiniCheck")
        {
            checkpoint = other.gameObject;
        }

        if (other.gameObject.tag == "Pit")
        {
            StartCoroutine(respawnTimer());
            Debug.Log("hi");
        }

        if (other.gameObject.tag == "Present")
        {
            Instantiate(confetti, other.transform.position, Quaternion.identity);
            PresentManager pres = other.transform.GetComponent <PresentManager>();
            if (pres != null && pres.tutorialFound == false && SceneManager.GetActiveScene() == SceneManager.GetSceneByName("Tutorial Level"))
            {
                presentsFound++;
                pickups.clip = presPickup;
                pickups.Play();
                pres.tutorialFound = true;
            }
            if (pres != null && pres.level1Found == false && SceneManager.GetActiveScene() == SceneManager.GetSceneByName("LevelOne"))
            {
                presentsFound++;
                pickups.clip = presPickup;
                pickups.Play();
                pres.level1Found = true;
            }
            if (pres != null && pres.level2Found == false && SceneManager.GetActiveScene() == SceneManager.GetSceneByName("LevelTwo"))
            {
                presentsFound++;
                pickups.clip = presPickup;
                pickups.Play();
                pres.level2Found = true;
            }
            if (pres != null && pres.level3Found == false && SceneManager.GetActiveScene() == SceneManager.GetSceneByName("LevelThree"))
            {
                presentsFound++;
                pickups.clip = presPickup;
                pickups.Play();
                pres.level3Found = true;
            }
            if (pres != null && pres.level4Found == false && SceneManager.GetActiveScene() == SceneManager.GetSceneByName("LevelFour"))
            {
                presentsFound++;
                pickups.clip = presPickup;
                pickups.Play();
                pres.level4Found = true;
            }
        }

        if (other.gameObject.tag == "ArenaStart")
        {
            StartArena start = other.transform.GetComponent <StartArena>();
            if (start != null)
            {
                start.hasPassed = true;
            }
        }

        if (other.gameObject.tag == "Consumable")
        {
            Consumables consume = other.transform.GetComponent <Consumables>();
            if (consume != null && consume.isHealth == true && health < 100)
            {
                health      += consume.amount;
                medic       += consume.amount;
                pickups.clip = healthPickup;
                pickups.Play();
                ShakeIt();
                StartCoroutine(flashGainHealth());
                Destroy(other.gameObject);
            }

            if (consume != null && consume.isAmmo == true)
            {
                mouse.currAmmoP += consume.amount;
                mouse.currAmmoS += consume.amount;
                mouse.currAmmoM += 25;
                munitions++;
                Destroy(other.gameObject);
                pickups.clip = ammoPickup;
                pickups.Play();
                mouse.ShakeIt();
                StartCoroutine(flashAmmo());
            }

            if (consume != null && consume.isKey == true)
            {
                KeyAmount   += consume.amount;
                pickups.clip = keyPickup;
                pickups.Play();
                Destroy(other.gameObject);
            }

            if (consume != null && consume.isRocket == true && mouse.currAmmoF < 8)
            {
                mouse.currAmmoF += consume.amount;
                pickups.clip     = ammoPickup;
                pickups.Play();
                StartCoroutine(flashAmmo());
                Destroy(other.gameObject);
            }

            if (consume != null && consume.isGrenade == true && mouse.currAmmoG < 6)
            {
                mouse.currAmmoG += consume.amount;
                pickups.clip     = ammoPickup;
                pickups.Play();
                StartCoroutine(flashAmmo());
                Destroy(other.gameObject);
            }

            if (consume != null && consume.isMax == true)
            {
                mouse.currAmmoP += 100;
                mouse.currAmmoS += 100;
                mouse.currAmmoM += 100;
                mouse.currAmmoF += 100;
                mouse.currAmmoG += 100;
                powerVoice.clip  = maxAmmo;
                powerVoice.Play();
                StartCoroutine(flashAmmo());
                Destroy(other.gameObject);
            }

            if (consume != null && consume.isSpeed == true)
            {
                StartCoroutine(GoFast());
                powerVoice.clip = superSpeed;
                powerVoice.Play();
                StartCoroutine(flashAmmo());
                //StartCoroutine(TimerSpeed(20));
                Destroy(other.gameObject);
            }

            if (consume != null && consume.isInstaKill == true)
            {
                StartCoroutine(KILL());
                //StartCoroutine(TimerInsta());
                powerVoice.clip = instaKill;
                powerVoice.Play();
                StartCoroutine(flashAmmo());
                Destroy(other.gameObject);
            }

            if (consume != null && consume.isInfinite == true)
            {
                StartCoroutine(MAX());
                //StartCoroutine(TimerInfinite());
                powerVoice.clip = infiniteAmmo;
                powerVoice.Play();
                StartCoroutine(flashAmmo());
                Destroy(other.gameObject);
            }
        }

        if (other.gameObject.tag == "PistolAmmo")
        {
            mouse.currAmmoP += 2;
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "ShotGunAmmo")
        {
            mouse.currAmmoS += 2;
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "MachineGunAmmo")
        {
            mouse.currAmmoM += 2;
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "Mus")
        {
            EnableMusic mus = other.transform.GetComponent <EnableMusic>();
            mus.mus.SetActive(true);
        }

        if (other.gameObject.tag == "End")
        {
            priorHealth         = health;
            priorPistolAmmo     = mouse.currAmmoP;
            priorShotGunAmmo    = mouse.currAmmoS;
            priorMachineGunAmmo = mouse.currAmmoM;
            priorGrenadeAmmo    = mouse.currAmmoG;
            priorFireWorkAmmo   = mouse.currAmmoF;
            priorPoints         = point.totalPoints;
            PlayerPrefs.SetInt("PriorH", priorHealth);
            PlayerPrefs.SetInt("PriorP", priorPistolAmmo);
            PlayerPrefs.SetInt("PriorS", priorShotGunAmmo);
            PlayerPrefs.SetInt("PriorM", priorMachineGunAmmo);
            PlayerPrefs.SetInt("PriorG", priorGrenadeAmmo);
            PlayerPrefs.SetInt("PriorF", priorFireWorkAmmo);
            PlayerPrefs.SetInt("PriorScore", priorPoints);
            if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("Tutorial Level"))
            {
                PlayerPrefs.SetInt("LevOne", 1);
                SceneManager.LoadScene("LevelOneLoadScreen");
            }
            if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("LevelOne"))
            {
                if (noHit == false)
                {
                    if (!SteamManager.Initialized)
                    {
                        return;
                    }
                    SteamUserStats.SetAchievement("Clean_Run");
                    SteamUserStats.StoreStats();
                    PlayerPrefs.SetInt("ACH_17", 1);
                }
                PlayerPrefs.SetInt("LevTwo", 1);
                SceneManager.LoadScene("LevelTwoLoadScreen");
                //Cursor.lockState = CursorLockMode.None;
                if (!SteamManager.Initialized)
                {
                    return;
                }
                SteamUserStats.SetAchievement("Tourist_One");
                SteamUserStats.StoreStats();
                PlayerPrefs.SetInt("ACH_8", 1);
            }
            if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("LevelTwo"))
            {
                if (noHit == false)
                {
                    if (!SteamManager.Initialized)
                    {
                        return;
                    }
                    SteamUserStats.SetAchievement("Clean_Run");
                    SteamUserStats.StoreStats();
                    PlayerPrefs.SetInt("ACH_17", 1);
                }
                PlayerPrefs.SetInt("LevThree", 1);
                SceneManager.LoadScene("LevelThreeLoadScreen");
                if (!SteamManager.Initialized)
                {
                    return;
                }
                SteamUserStats.SetAchievement("Tourist_Two");
                SteamUserStats.StoreStats();
                PlayerPrefs.SetInt("ACH_9", 1);
            }
            if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("LevelThree"))
            {
                if (noHit == false)
                {
                    if (!SteamManager.Initialized)
                    {
                        return;
                    }
                    SteamUserStats.SetAchievement("Clean_Run");
                    SteamUserStats.StoreStats();
                    PlayerPrefs.SetInt("ACH_17", 1);
                }
                PlayerPrefs.SetInt("LevFour", 1);
                SceneManager.LoadScene("LevelFourLoadScreen");
                if (!SteamManager.Initialized)
                {
                    return;
                }
                SteamUserStats.SetAchievement("Tourist_Three");
                SteamUserStats.StoreStats();
                PlayerPrefs.SetInt("ACH_10", 1);
            }
        }

        if (other.gameObject.tag == "Final")
        {
            GameObject spot = GameObject.FindGameObjectWithTag("MiniCheck");
            player.transform.position = spot.transform.position;
            Physics.SyncTransforms();
            BossSpawner bossy = other.transform.GetComponent <BossSpawner>();
            bossy.boss.SetActive(true);
            bossy.boss.GetComponent <Boss>().healthSlide.SetActive(true);
            for (int i = 0; i < bossy.spawners.Length; i++)
            {
                bossy.spawners[i].SetActive(true);
            }
            EnableMusic mus = other.transform.GetComponent <EnableMusic>();
            mus.mus.SetActive(true);
        }

        if (other.gameObject.tag == "finish")
        {
            if (noHit == false)
            {
                if (!SteamManager.Initialized)
                {
                    return;
                }
                SteamUserStats.SetAchievement("Clean_Run");
                SteamUserStats.StoreStats();
                PlayerPrefs.SetInt("ACH_17", 1);
            }

            if (!SteamManager.Initialized)
            {
                return;
            }
            SteamUserStats.SetAchievement("Tourist_Four");
            SteamUserStats.StoreStats();
            PlayerPrefs.SetInt("ACH_11", 1);


            if (noDeathCounter == 0)
            {
                if (!SteamManager.Initialized)
                {
                    return;
                }
                SteamUserStats.SetAchievement("Unstoppable");
                SteamUserStats.StoreStats();
                PlayerPrefs.SetInt("ACH_18", 1);
            }
            if (minutes < 15)
            {
                if (!SteamManager.Initialized)
                {
                    return;
                }
                SteamUserStats.SetAchievement("Speed_Runner");
                SteamUserStats.StoreStats();
                PlayerPrefs.SetInt("ACH_24", 1);
            }
            SceneManager.LoadScene("credits");
            Cursor.lockState = CursorLockMode.None;
        }

        if (other.gameObject.tag == "Door")
        {
            Lock door = other.transform.GetComponent <Lock>();
            if (KeyAmount < door.keysRequired)
            {
                keyText.SetActive(true);
                keysRequiredText.text = "Need " + (door.keysRequired -= KeyAmount) + " more to unlock";
            }
            if (KeyAmount >= door.keysRequired && door.unlocked == false)
            {
                door.unlocked = true;
                KeyAmount--;
                pickups.clip = keyPickup;
                pickups.Play();
            }
        }

        if (other.gameObject.tag == "ItemSpawn")
        {
            ItemSpawners item = other.transform.GetComponent <ItemSpawners>();
            //item.beginSpawn = true;
        }
    }
Пример #4
0
 void Start()
 {
     presentManager = GameObject.FindGameObjectWithTag("PresentManager").GetComponent <PresentManager> ();
 }