Inheritance: MonoBehaviour
Exemplo n.º 1
0
 public ItemList(int count)
 {
     redCrossList = new Icon[count];
     itemList = new Item[count];
     itemCollected = new bool[count];
     itemSpawner = new ItemSpawner();
 }
Exemplo n.º 2
0
 void Awake()
 {
     night = 0;
     dayNight = FindObjectOfType<DayNight>();
     enemySpawner = GetComponent<EnemySpawner>();
     itemSpawner = GetComponent<ItemSpawner>();
     audioManager = GetComponent<AudioManager>();
 }
 void Awake()
 {
     if(instance == null)
     {
         instance = this;
     } else
     {
         Destroy(gameObject);
     }
 }
 public FloorGenerator(Floor floor)
 {
     this.floor = floor;
     spawner    = GameObject.FindWithTag("ItemSpawner").GetComponent <ItemSpawner>();
 }
Exemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     itemSpawner = FindObjectOfType <ItemSpawner>();
     player      = FindObjectOfType <PlayerControl>();
 }
Exemplo n.º 6
0
 void Start()
 {
     instance         = this;
     map              = FindObjectOfType <Map>();
     map.OnMapLoaded += () => InitialSpawn();
 }
        public IEnumerator LoadObjectsTask()
        {
            yield return(new WaitForSeconds(0.15f));

            Main.missionManager = GameObject.FindObjectOfType <MissionManager>();
            yield return(new WaitForSeconds(0.15f));;
            Main.gameController = GameObject.FindObjectOfType <GameController>();
            yield return(new WaitForSeconds(0.15f));

            Main.levelController = GameObject.FindObjectOfType <LevelController>();
            yield return(new WaitForSeconds(0.15f));;
            Main.levelSelectionManager = GameObject.FindObjectOfType <LevelSelectionManager>();
            yield return(new WaitForSeconds(0.15f));

            Main.walkieTalkie = GameObject.FindObjectOfType <WalkieTalkie>();
            yield return(new WaitForSeconds(0.15f));

            Main.handCamera = GameObject.FindObjectOfType <HandCamera>();
            yield return(new WaitForSeconds(0.15f));

            Main.inventoryManager = GameObject.FindObjectOfType <InventoryManager>();
            yield return(new WaitForSeconds(0.15f));

            Main.liftButton = GameObject.FindObjectOfType <LiftButton>();
            yield return(new WaitForSeconds(0.15f));

            Main.contract = GameObject.FindObjectOfType <Contract>();
            yield return(new WaitForSeconds(0.15f));

            Main.pCMenu = GameObject.FindObjectOfType <PCMenu>();
            yield return(new WaitForSeconds(0.15f));

            Main.exitLevel = GameObject.FindObjectOfType <ExitLevel>();
            yield return(new WaitForSeconds(0.15f));

            Main.ghostAI = UnityEngine.Object.FindObjectOfType <GhostAI>();
            yield return(new WaitForSeconds(0.15f));

            Main.lightSwitch = GameObject.FindObjectOfType <LightSwitch>();
            yield return(new WaitForSeconds(0.15f));

            Main.light = GameObject.FindObjectOfType <Light>();
            yield return(new WaitForSeconds(0.15f));

            Main.dNAEvidences = Enumerable.ToList <DNAEvidence>(GameObject.FindObjectsOfType <DNAEvidence>());
            yield return(new WaitForSeconds(0.15f));

            Main.contracts = Enumerable.ToList <Contract>(GameObject.FindObjectsOfType <Contract>());
            yield return(new WaitForSeconds(0.15f));

            Main.items = Enumerable.ToList <InventoryItem>(GameObject.FindObjectsOfType <InventoryItem>());
            yield return(new WaitForSeconds(0.15f));

            Main.players = Enumerable.ToList <Player>(GameObject.FindObjectsOfType <Player>());
            yield return(new WaitForSeconds(0.15f));

            if (Main.levelController != null)
            {
                Main.photonView = (Main.ghostAI.field_Public_PhotonView_0 ?? null);
                yield return(new WaitForSeconds(0.15f));
            }
            Main.ghostInfo = GameObject.FindObjectOfType <GhostInfo>();
            yield return(new WaitForSeconds(0.15f));

            Main.deadPlayer = GameObject.FindObjectOfType <DeadPlayer>();
            yield return(new WaitForSeconds(0.15f));

            Main.player = GameObject.FindObjectOfType <Player>();
            yield return(new WaitForSeconds(0.15f));

            Main.rigidbody = GameObject.FindObjectOfType <Rigidbody>();
            yield return(new WaitForSeconds(0.15f));

            Main.itemSpawner = GameObject.FindObjectOfType <ItemSpawner>();
            yield return(new WaitForSeconds(0.15f));

            Main.ghostInteraction = GameObject.FindObjectOfType <GhostInteraction>();
            yield return(new WaitForSeconds(0.15f));

            //Main.baseController = GameObject.FindObjectOfType<BaseController>();
            yield return(new WaitForSeconds(0.15f));

            Main.ouijaBoard = GameObject.FindObjectOfType <OuijaBoard>();
            yield return(new WaitForSeconds(0.15f));

            Main.ouijaBoards = Enumerable.ToList <OuijaBoard>(GameObject.FindObjectsOfType <OuijaBoard>());
            yield return(new WaitForSeconds(0.15f));

            Main.keys = Enumerable.ToList <Key>(GameObject.FindObjectsOfType <Key>());
            yield return(new WaitForSeconds(0.15f));

            Main.ghosts = Enumerable.ToList <GhostAI>(GameObject.FindObjectsOfType <GhostAI>());
            yield return(new WaitForSeconds(0.15f));

            Main.serverManager = GameObject.FindObjectOfType <ServerManager>();
            yield return(new WaitForSeconds(0.15f));

            Main.torches = Enumerable.ToList <Torch>(GameObject.FindObjectsOfType <Torch>());
            yield return(new WaitForSeconds(0.15f));

            Main.ghostAudio = GameObject.FindObjectOfType <GhostAudio>();
            yield return(new WaitForSeconds(0.15f));

            Main.fuseBox = GameObject.FindObjectOfType <FuseBox>();
            yield return(new WaitForSeconds(0.15f));

            Main.doors = Enumerable.ToList <Door>(GameObject.FindObjectsOfType <Door>());
            yield return(new WaitForSeconds(0.15f));

            Main.lightSwitches = Enumerable.ToList <LightSwitch>(GameObject.FindObjectsOfType <LightSwitch>());

            if (UnityEngine.Object.FindObjectOfType <Player>() != null)
            {
                Main.player = (UnityEngine.Object.FindObjectOfType <Player>() ?? null);
                yield return(new WaitForSeconds(0.15f));

                Main.playerAnim = (Main.player.field_Public_Animator_0 ?? null);
                yield return(new WaitForSeconds(0.15f));

                if (Main.playerAnim != null)
                {
                    Main.boneTransform = (Main.playerAnim.GetBoneTransform((HumanBodyBones)10) ?? null);
                    yield return(new WaitForSeconds(0.15f));

                    if (Main.boneTransform != null)
                    {
                        Main.light = (Main.boneTransform.GetComponent <Light>() ?? null);
                        yield return(new WaitForSeconds(0.15f));
                    }
                }
            }
            yield return(null);

            yield break;
        }
Exemplo n.º 8
0
    protected override void Start()
    {
        base.Start();

        itemSpawner = FindObjectOfType<ItemSpawner>();
    }
Exemplo n.º 9
0
    // Change Roll values to change odds of Items spawning
    // Currently Regular = 10, Sale = 30, Rare = 100
    public Item Get_Normal_Item(ItemSpawner spawner)
    {
        Roll = Random.Range(0, 11);

        switch (Roll)
        {
        case 0:
        {
            return(SpawnNewItem(spawner.transform, "banana", 100, false, 0));
        }

        case 1:
        {
            return(SpawnNewItem(spawner.transform, "BarFridge", 100, false, 0));
        }

        case 2:
        {
            return(SpawnNewItem(spawner.transform, "beachBall", 100, false, 0));
        }

        case 3:
        {
            return(SpawnNewItem(spawner.transform, "bread", 100, false, 0));
        }

        case 4:
        {
            return(SpawnNewItem(spawner.transform, "FancyMicrowave", 100, false, 0));
        }

        case 5:
        {
            return(SpawnNewItem(spawner.transform, "FancyToaster", 100, false, 0));
        }

        case 6:
        {
            return(SpawnNewItem(spawner.transform, "Flamingo", 100, false, 90));
        }

        case 7:
        {
            return(SpawnNewItem(spawner.transform, "Flatscreen_TV", 100, false, 0));
        }

        case 8:
        {
            return(SpawnNewItem(spawner.transform, "hotdog", 100, false, 0));
        }

        case 9:
        {
            return(SpawnNewItem(spawner.transform, "pizza", 100, false, 0));
        }

        case 10:
        {
            return(SpawnNewItem(spawner.transform, "shoes", 100, false, 90));
        }

        default:
        {
            return(SpawnNewItem(spawner.transform, "banana", 100, false, 0));
        }
        }
    }
Exemplo n.º 10
0
 private void Start()
 {
     mySpawner = transform.root.GetComponent <ItemSpawner>();
 }
Exemplo n.º 11
0
 private void Awake()
 {
     Instance = this;
 }
Exemplo n.º 12
0
    // private PhotonView playerPV;

    private void Start()
    {
        // myItemStatus = FindObjectOfType<MyItemStatus>();
        itemSpawner = GameObject.FindWithTag("ItemSpawner").gameObject.GetComponent <ItemSpawner>();
    }
Exemplo n.º 13
0
 public void TestWeaponDescription()
 {
     Assert.AreEqual("A sword, you can stab monsters with it.", ItemSpawner.GenerateWeaponDesc(5, new MeleeWeapon()));
     Assert.AreEqual("A ranged weapon, you can hit things at a distance with it.", ItemSpawner.GenerateWeaponDesc(5, new RangedWeapon()));
 }
Exemplo n.º 14
0
    public void TestArmorDescription(EquipmentManager.EquipSlot slot, string description)
    {
        ArmorItem armor = new ArmorItem(slot);

        Assert.AreEqual(description, ItemSpawner.GenerateArmorDesc(5, armor));
    }
Exemplo n.º 15
0
    public void ItemValue(GameItem.ItemRarity rarity, double value)
    {
        GameItem valueTestItem = new GameItem(null, null, "Generic Item", "I am an Item.", 10, rarity, 5, 10, 2);

        Assert.AreEqual(value, ItemSpawner.GenerateItemValue(valueTestItem));
    }
 // Start is called before the first frame update
 void Start()
 {
     itemSpawner = GameObject.FindGameObjectWithTag("GameController").GetComponent <ItemSpawner>();
     winText     = GameObject.FindGameObjectWithTag("HUD").GetComponentInChildren <Text>();
     movement    = GetComponent <PlayerMovement>();
 }
Exemplo n.º 17
0
    private void OnTriggerEnter(Collider other)
    {
        Controller c = other.GetComponent <Controller>();

        if (c != null && !c.isBad && c.HasWeapon)
        {
            switch (type)
            {
            case BonusType.Max_HP:
                c.max_healthPoint += value + (5 * c.max_healthPoint / 100);
                // We heal a bit more than we augment the player hp
                c.regen(value + (10 * c.max_healthPoint / 100));
                break;

            case BonusType.HP_Regen:
                // The + 10 is a little hidden bonus from me because stay strong will ya ?
                c.regen((value * c.max_healthPoint / 100) + 10);
                break;

            case BonusType.Dmg:
                c.damageDone += value;
                break;

            case BonusType.Speed:
                c.movementSpeed += value;
                if (c.movementSpeed > Controller.maxSpeed)
                {
                    c.movementSpeed = Controller.maxSpeed;
                }
                break;

            case BonusType.FireRate:
                c.reloadDelay *= (value / 100.0f);
                break;

            case BonusType.Respawn:
                c.soulCounter += value;
                break;

            case BonusType.ItemTimer:
                // 20 sec is the minimum interval between 2 spawn
                if (spawner != null)
                {
                    this.spawner.cd_spawn = Mathf.Max(this.spawner.cd_spawn - value, 20);
                }
                break;

            case BonusType.ScorePoints:
                Controller.killCount += this.value;
                break;

            case BonusType.Nothing:
            default:
                break;
            }
            if (spawner != null)
            {
                spawner.IsItemPresent = false;
                spawner = null;
            }
            Destroy(gameObject);
        }
    }
Exemplo n.º 18
0
    // runs the host
    public void RunHost()
    {
        // setting ip address
        if (ipAddressInput != null)
        {
            string str = ipAddressInput.text;
            onlineManager.SetIPAddress(str, true);
        }

        // setting port
        if (ipAddressInput != null)
        {
            int val = int.Parse(portInput.text);
            onlineManager.SetPort(val);
        }

        // if the online manager isn't the master, disable the item spawner.
        if (!onlineManager.isMaster) // this is a client, not a server.
        {
            // finds the item spanwer
            ItemSpawner spawner = FindObjectOfType <ItemSpawner>();

            // if the item spawner exists.
            if (spawner != null)
            {
                // disable spawning operations.
                // this makes it so that new items are given by the server onyl.
                spawner.spawnerEnabled = false;
            }
        }

        // if the timer has not been set.
        if (onlineManager.timer == null)
        {
            // finds timer text
            TimerText timerText = FindObjectOfType <TimerText>();

            // timer text found.
            if (timerText != null)
            {
                TimerObject timerObject = timerText.GetActiveTimer();

                // checks to see if the timer object is set.
                if (timerObject != null)
                {
                    // sets timer for online manager.
                    onlineManager.timer = timerObject;
                }

                // if this isn't the master, disable the timer.
                if (!onlineManager.isMaster)
                {
                    // pauses the active timer
                    timerText.PauseActiveTimer();
                }
            }
        }

        // onlineManager.isMaster = ;
        bool success = onlineManager.RunHost();

        // display messages
        if (onlineManager.isMaster && success) // server running
        {
            Debug.Log("Server Running");
        }
        else if (!onlineManager.isMaster && success) // client running
        {
            Debug.Log("Client Running");
        }
        else if (!success) // nothing running.
        {
            Debug.LogError("Host Run Failed.");
        }
    }
Exemplo n.º 19
0
 void Start()
 {
     ItemSpawner.main = this;
 }
Exemplo n.º 20
0
 public void Init(ItemSpawner spawner)
 {
     this.spawner = spawner;
 }
Exemplo n.º 21
0
 private void Awake()
 {
     manager = GameObject.FindGameObjectWithTag("MinigameManager").GetComponent <MissileMadness>();
     spawner = GameObject.FindGameObjectWithTag("MinigameManager").GetComponent <ItemSpawner>();
 }
Exemplo n.º 22
0
 // Start is called before the first frame update
 void Start()
 {
     itemSpawner = GetComponent <ItemSpawner>();
     ship        = Game.Instance.ship;
 }
Exemplo n.º 23
0
    // Start is called before the first frame update
    void Start()
    {
        // finds the game manager if it hasn't been set.
        if (gameManager == null)
        {
            gameManager = FindObjectOfType <GameplayManager>();
        }

        // sets the skybox
        if (skybox != null)
        {
            RenderSettings.skybox = skybox;
        }

        // flag not set
        if (flag == null)
        {
            flag = GameObject.Find("Flag");

            if (flag == null) // if the flag doesn't exist, make one.
            {
                // loads up the flag prefab
                object prefab = Resources.Load(flagPrefab);

                // loads default flag
                if (prefab == null)
                {
                    prefab = Resources.Load("Prefabs/Flag");
                }

                // instantiates the prefab.
                flag = Instantiate((GameObject)prefab);
            }
        }

        // if the flag exists, change its position
        if (flag != null)
        {
            if (useFlagPosAsSpawn)
            {
                flagSpawn = flag.transform.position;
            }
            else
            {
                flag.transform.position = flagSpawn;
            }
        }


        // searches for the item spawner if it hasn't been set
        if (itemSpawner == null)
        {
            itemSpawner = FindObjectOfType <ItemSpawner>();
        }

        // if an item spawner exists, set its min and max spawn areas.
        if (itemSpawner != null)
        {
            itemSpawner.spawnAreaMin = itemSpawnAreaMin;
            itemSpawner.spawnAreaMax = itemSpawnAreaMax;
        }


        // if 'true', the spawn points are adde from the objects are added.
        if (findSpawns) // find spawns
        {
            AddSpawnPoints(includeInactiveSpawns);
        }

        // no spawns added
        if (playerSpawns.Count == 0)
        {
            playerSpawns.Add(new Vector3(0, 0, 5));
        }
    }
Exemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     ai_state = AI_STATE.STOPPED;
     vxe = VoxelExtractionPointCloud.Instance;
     itemspawn = ItemSpawner.Instance;
     lastposition = new Vector3 ();
     stepdownThreshold = vxe.voxel_size * 2;
     stepdownThreshold = stepdownThreshold * stepdownThreshold;
     playerFaceThreshold = vxe.voxel_size * 7;
     //init ();
 }
Exemplo n.º 25
0
 public async Task LoadObjectsTask()
 {
     string curSceneName = SceneManager.GetActiveScene().name.ToLower();
     while (!curSceneName.Contains("menu") && !curSceneName.Contains("new"))
     {
         await Task.Delay(4000);
         if (SceneManager.sceneLoaded != null)
         {
             Main.missionManager = GameObject.FindObjectOfType<MissionManager>();
             await Task.Delay(150);
             Main.gameController = GameObject.FindObjectOfType<GameController>();
             await Task.Delay(150);
             Main.levelController = GameObject.FindObjectOfType<LevelController>();
             await Task.Delay(150);
             Main.levelSelectionManager = GameObject.FindObjectOfType<LevelSelectionManager>();
             await Task.Delay(150);
             Main.walkieTalkie = GameObject.FindObjectOfType<WalkieTalkie>();
             await Task.Delay(150);
             Main.handCamera = GameObject.FindObjectOfType<HandCamera>();
             await Task.Delay(150);
             Main.inventoryManager = GameObject.FindObjectOfType<InventoryManager>();
             await Task.Delay(150);
             Main.liftButton = GameObject.FindObjectOfType<LiftButton>();
             await Task.Delay(150);
             Main.contract = GameObject.FindObjectOfType<Contract>();
             await Task.Delay(150);
             Main.pCMenu = GameObject.FindObjectOfType<PCMenu>();
             await Task.Delay(150);
             Main.exitLevel = GameObject.FindObjectOfType<ExitLevel>();
             await Task.Delay(150);
             Main.ghostAI = GameObject.FindObjectOfType<GhostAI>();
             await Task.Delay(150);
             Main.lightSwitch = GameObject.FindObjectOfType<LightSwitch>();
             await Task.Delay(150);
             Main.light = GameObject.FindObjectOfType<Light>();
             await Task.Delay(150);
             Main.dNAEvidences = Enumerable.ToList<DNAEvidence>(GameObject.FindObjectsOfType<DNAEvidence>());
             await Task.Delay(150);
             Main.contracts = Enumerable.ToList<Contract>(GameObject.FindObjectsOfType<Contract>());
             await Task.Delay(150);
             Main.items = Enumerable.ToList<InventoryItem>(GameObject.FindObjectsOfType<InventoryItem>());
             await Task.Delay(150);
             Main.players = Enumerable.ToList<Player>(GameObject.FindObjectsOfType<Player>());
             await Task.Delay(150);
             Main.photonView = GameObject.FindObjectOfType<PhotonView>();
             await Task.Delay(150);
             Main.ghostInfo = GameObject.FindObjectOfType<GhostInfo>();
             await Task.Delay(150);
             Main.deadPlayer = GameObject.FindObjectOfType<DeadPlayer>();
             await Task.Delay(150);
             Main.player = GameObject.FindObjectOfType<Player>();
             await Task.Delay(150);
             Main.rigidbody = GameObject.FindObjectOfType<Rigidbody>();
             await Task.Delay(150);
             Main.itemSpawner = GameObject.FindObjectOfType<ItemSpawner>();
             await Task.Delay(150);
             Main.ghostInteraction = GameObject.FindObjectOfType<GhostInteraction>();
             await Task.Delay(150);
             //Main.baseController = GameObject.FindObjectOfType<BaseController>();
             await Task.Delay(150);
             Main.ouijaBoard = GameObject.FindObjectOfType<OuijaBoard>();
             await Task.Delay(150);
             Main.ouijaBoards = Enumerable.ToList<OuijaBoard>(GameObject.FindObjectsOfType<OuijaBoard>());
             await Task.Delay(150);
             Main.keys = Enumerable.ToList<Key>(GameObject.FindObjectsOfType<Key>());
             await Task.Delay(150);
             Main.ghosts = Enumerable.ToList<GhostAI>(GameObject.FindObjectsOfType<GhostAI>());
             await Task.Delay(150);
             Main.serverManager = GameObject.FindObjectOfType<ServerManager>();
             await Task.Delay(150);
             Main.torches = Enumerable.ToList<Torch>(GameObject.FindObjectsOfType<Torch>());
             await Task.Delay(150);
             Main.ghostAudio = GameObject.FindObjectOfType<GhostAudio>();
             await Task.Delay(150);
             Main.fuseBox = GameObject.FindObjectOfType<FuseBox>();
             await Task.Delay(150);
             Main.doors = Enumerable.ToList<Door>(GameObject.FindObjectsOfType<Door>());
             await Task.Delay(150);
             Main.lightSwitches = Enumerable.ToList<LightSwitch>(GameObject.FindObjectsOfType<LightSwitch>());
         }
     }
 }
Exemplo n.º 26
0
 public void SetSpawner(ItemSpawner spawner)
 {
     _spawner = spawner;
 }
Exemplo n.º 27
0
 public TrapInfo(int _f, ItemSpawner _trap)
 {
     floor = _f;
     trap  = _trap;
 }
Exemplo n.º 28
0
    // Update is called once per frame
    void Update()
    {
        switch (m_GameState)
        {
        //case GameState.Opening:
        //break;
        case GameState.Waiting:
            break;

        case GameState.Opening:
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
            UpdatePauseState = true;
            m_PauseState     = PauseState.StartMenu;
            m_GameState      = GameState.Paused;
            break;

        case GameState.Start:
            ChangeVolume();
            ChangeFOV();
            m_PlayerParts[0].gameObject.transform.position = new Vector3(0, -0.5f, 0);
            m_PlayerParts[0].gameObject.transform.rotation = new Quaternion(0, 0, 0, 0);
            ItemSpawner itemSpawner = UnityEngine.Object.FindObjectOfType <ItemSpawner>();
            int         i           = 0;
            foreach (bool bools in itemSpawner.m_SpawnPointFull)
            {
                itemSpawner.m_SpawnPointFull[i] = false;
                i++;
            }
            itemSpawner.m_GarbageCount   = 0;
            itemSpawner.m_garbageSpawned = false;
            m_DisplayTime    = m_LevelTime;
            UpdatePauseState = true;
            m_PauseState     = PauseState.Off;
            m_GameState      = GameState.Playing;
            break;

        case GameState.Playing:
            //MOVE    AudioListener.volume = m_VolumeSlider.value;
            //m_VolumeSliderText.text = "Volume: " + Mathf.RoundToInt(m_VolumeSlider.value * 100).ToString() + "%";
            //m_FOVSliderText.text = "FOV: " + Mathf.RoundToInt((m_FOVSlider.value * 100) + 30).ToString();
            //m_MessageText.text = "Ready...";
            //Time.timeScale = 0;
            //waitFor = 3;
            //StartCoroutine(WaitCommand(waitFor));
            //WaitUntil waitUntil = wait == true;
            //m_MessageText.text = "Go!";
            //StartCoroutine(Timer(m_DisplayTime, m_TimerDisplay));
            //waitFor = 0.5f;
            //StartCoroutine(WaitCommand(waitFor));
            //Time.timeScale = 1;
            if (Input.GetKeyUp(KeyCode.Escape) && m_isGamePaused == false)
            {
                PauseGame();
            }
            m_DisplayTime -= Time.deltaTime;
            int seconds = Mathf.RoundToInt(m_DisplayTime);
            m_TimerDisplay.text = string.Format("{0:D2}:{1:D2}", (seconds / 60), (seconds % 60));
            if (m_DisplayTime <= 0)
            {
                //vacGun = UnityEngine.Object.FindObjectOfType<VacGun>();
                //vacGun.m_LoadedGarbage = 0;
                //m_GarbageLoadedDisplay.text = "Ammo:\n" + vacGun.m_LoadedGarbage.ToString();
                GameStateStartUp = true;
                m_GameState      = GameState.GameOver;
            }
            m_ScoreDisplay.text = "Score:\n" + m_Score.ToString();
            VacGun vacGun = UnityEngine.Object.FindObjectOfType <VacGun>();
            m_GarbageLoadedDisplay.text = "Ammo:\n" + vacGun.m_LoadedGarbage.ToString();
            break;

        case GameState.Paused:
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
            foreach (GameObject gameObject in m_InGameHUD)
            {
                gameObject.gameObject.SetActive(false);
            }
            Time.timeScale = 0;
            m_isGamePaused = true;
            foreach (Component part in m_PlayerParts)
            {
                part.gameObject.SetActive(false);
            }
            break;

        case GameState.GameOver:
            m_Score = 0;
            vacGun  = UnityEngine.Object.FindObjectOfType <VacGun>();
            vacGun.m_LoadedGarbage      = 0;
            m_ScoreDisplay.text         = "Score:\n" + m_Score.ToString();
            m_GarbageLoadedDisplay.text = "Ammo:\n" + vacGun.m_LoadedGarbage.ToString();
            itemSpawner = UnityEngine.Object.FindObjectOfType <ItemSpawner>();
            foreach (GameObject garbageball in itemSpawner.m_AllGarbage)
            {
                garbageball.SetActive(false);
            }
            itemSpawner.m_AllGarbage.RemoveRange(0, itemSpawner.m_AllGarbage.Count);
            Debug.Log("Game Over");
            //waitFor = 2;
            //StartCoroutine(WaitCommand(waitFor));
            m_HighScoreEditor.AddScore(m_Score, m_PlayerName);
            highscoreEditor highscoreEditor = UnityEngine.Object.FindObjectOfType <highscoreEditor>();
            if (highscoreEditor.m_AddedToHighscores == true)
            {
                m_MessageText.text = "Your final score was " + m_Score + "!\nWell done!";
            }
            else
            {
                m_MessageText.text = "Your final score was " + m_Score + ".";
            }
            m_HighScoreEditor.SaveScores();
            m_GameState      = GameState.Paused;
            UpdatePauseState = true;
            m_PauseState     = PauseState.GameOverMenu;
            break;

        case GameState.Quiting:
            m_HighScoreEditor.SaveScores();
            m_SettingEditor.SaveSettings(m_VolumeSlider, m_FOVSlider);
            Debug.Log("Quiting... Loser!");
            Application.Quit();
            break;
        }
        switch (m_PauseState)
        {
        case PauseState.Off:
            while (UpdatePauseState == true)
            {
                foreach (GameObject gameObject in m_PauseMenu)
                {
                    gameObject.gameObject.SetActive(false);
                }
                Cursor.lockState = CursorLockMode.Locked;
                Cursor.visible   = false;
                foreach (GameObject gameObject in m_InGameHUD)
                {
                    gameObject.gameObject.SetActive(true);
                }
                Time.timeScale = 1;
                m_isGamePaused = false;
                foreach (Component part in m_PlayerParts)
                {
                    part.gameObject.SetActive(true);
                }
                UpdatePauseState = false;
            }
            break;

        case PauseState.StartMenu:
            while (UpdatePauseState == true)
            {
                foreach (GameObject gameObject in m_PauseMenu)
                {
                    gameObject.gameObject.SetActive(false);
                }
                m_PauseMenu[0].SetActive(true);
                m_PauseMenu[2].SetActive(true);
                UpdatePauseState = false;
            }
            break;

        case PauseState.PauseMenu:
            while (UpdatePauseState == true)
            {
                foreach (GameObject gameObject in m_PauseMenu)
                {
                    gameObject.gameObject.SetActive(false);
                }
                m_PauseMenu[0].SetActive(true);
                m_PauseMenu[1].SetActive(true);
                UpdatePauseState = false;
            }
            break;

        case PauseState.GameOverMenu:
            while (UpdatePauseState == true)
            {
                foreach (GameObject gameObject in m_PauseMenu)
                {
                    gameObject.gameObject.SetActive(false);
                }
                m_PauseMenu[0].SetActive(true);
                m_PauseMenu[3].SetActive(true);
                UpdatePauseState = false;
            }
            break;

        case PauseState.HighscoreMenu:
            while (UpdatePauseState == true)
            {
                foreach (GameObject gameObject in m_PauseMenu)
                {
                    gameObject.gameObject.SetActive(false);
                }
                m_PauseMenu[0].SetActive(true);
                m_PauseMenu[4].SetActive(true);
                highscoreEditor highscoreEditor = UnityEngine.Object.FindObjectOfType <highscoreEditor>();
                int             i            = 0;
                string          HSNamesList  = "";
                string          HSScoresList = "";
                foreach (int score in highscoreEditor.m_Scores)
                {
                    HSNamesList  += highscoreEditor.m_ScoreNames[i] + "\n";
                    HSScoresList += highscoreEditor.m_Scores[i].ToString() + "\n";
                    i++;
                }
                m_HighscoresNames.text  = HSNamesList;
                m_HighscoresScores.text = HSScoresList;
                UpdatePauseState        = false;
            }
            break;
        }
    }
Exemplo n.º 29
0
 public bool Compare(ItemSpawner _trap)
 {
     return(_trap == trap);
 }
Exemplo n.º 30
0
 private void Start()
 {
     _itemSpawner = GetComponentInParent <ItemSpawner>();
 }
Exemplo n.º 31
0
    /// <summary>플레이어가 먹은 아이템 할당</summary>
    /// <param name="_spawnerId">아이템ID</param>
    /// <param name="_playerId">플레이어ID</param>
    public void SaveItemToPlayer(ItemSpawner _spawner, PlayerManager _player)
    {
        switch (_player.playerType)
        {
        case PlayerType.HUMAN:
            if (_spawner.itemType == ItemType.GUN)
            {
                _player.playerItem.item_number1 = _spawner;
                if (_player.id == Client.instance.myId)
                {
                    UIManager.instance.itemImageUI[0].sprite  = UIManager.instance.itemImage[(int)_player.playerType * UIManager.instance.itemImageUI.Length];
                    UIManager.instance.itemCountText[0].text  = "1";
                    UIManager.instance.itemCountText[0].color = UIManager.instance.textColor[(int)UIManager.TextColor.MINT];
                }
            }
            else if (_spawner.itemType == ItemType.EMP)
            {
                _player.playerItem.item_number2.Add(_spawner);
                if (_player.id == Client.instance.myId)
                {
                    UIManager.instance.itemImageUI[1].sprite = UIManager.instance.itemImage[(int)_player.playerType * UIManager.instance.itemImageUI.Length + 1];
                    UIManager.instance.itemCountText[1].text = _player.playerItem.item_number2.Count.ToString();
                    if (_player.playerItem.item_number2[0].itemType == ItemType.BATTERY)
                    {
                        UIManager.instance.itemCountText[1].text = (_player.playerItem.item_number1.GetComponent <Gun>().batteryAmount / 30).ToString();
                    }
                    UIManager.instance.itemCountText[1].color = UIManager.instance.textColor[(int)UIManager.TextColor.MINT];
                }
            }
            else if (_spawner.itemType == ItemType.BATTERY)
            {
                _player.playerItem.batteryCount        += 30;
                UIManager.instance.bulletAmoutText.text = _player.playerItem.batteryCount.ToString();
                if (_player.id == Client.instance.myId)
                {
                    UIManager.instance.itemImageUI[2].sprite  = UIManager.instance.itemImage[(int)_player.playerType * UIManager.instance.itemImageUI.Length + 2];
                    UIManager.instance.itemCountText[2].text  = (_player.playerItem.batteryCount / 30).ToString();
                    UIManager.instance.itemCountText[2].color = UIManager.instance.textColor[(int)UIManager.TextColor.MINT];
                }
            }
            else
            {
                //Debug.Log($"Error - 서버에서 이미 동작하였습니다. 아이템을 먹을 수 없습니다");
            }
            break;

        case PlayerType.CREATURE:
            if (_spawner.itemType == ItemType.DRONE)
            {
                _player.playerItem.item_number1 = _spawner;
                if (_player.id == Client.instance.myId)
                {
                    UIManager.instance.itemImageUI[0].sprite  = UIManager.instance.itemImage[(int)_player.playerType * UIManager.instance.itemImageUI.Length];
                    UIManager.instance.itemCountText[0].text  = "1";
                    UIManager.instance.itemCountText[0].color = UIManager.instance.textColor[(int)UIManager.TextColor.MINT];
                }
            }
            else if (_spawner.itemType == ItemType.LIGHTTRAP)
            {
                _player.playerItem.item_number2.Add(_spawner);
                if (_player.id == Client.instance.myId)
                {
                    UIManager.instance.itemImageUI[1].sprite  = UIManager.instance.itemImage[(int)_player.playerType * UIManager.instance.itemImageUI.Length + 1];
                    UIManager.instance.itemCountText[1].text  = _player.playerItem.item_number2.Count.ToString();
                    UIManager.instance.itemCountText[1].color = UIManager.instance.textColor[(int)UIManager.TextColor.MINT];
                }
            }
            else
            {
                //Debug.Log($"Error - 서버에서 이미 동작하였습니다. 아이템을 먹을 수 없습니다");
            }
            break;
        }
        _spawner.ItemPickedUp();
    }
    void Update()
    {
        int.TryParse(settingsText, out difficultyOverride);
        int.TryParse(controllerText, out controllerOverride);
        int.TryParse(bananaText, out bannanasGoal);
        int.TryParse(feathersText, out feathersGoal);
        int.TryParse(timeText, out timeGoal);

        if(difficultyOverride == 1)
        {
            settingsDifficulty = 0;
        }
        else if(difficultyOverride == 2)
        {
            settingsDifficulty = 1;
        }
        else if(difficultyOverride == 3)
        {
            settingsDifficulty = 2;
        }

        if (controllerOverride == 1)
        {
            controllerChoice = 0;
        }
        else if (controllerOverride == 2)
        {
            controllerChoice = 1;
        }

        //settingsDifficulty = int.Parse("" + settingsText) - 1;
        //controllerChoice = int.Parse("" + controllerText) - 1;

        settingsDifficulty = Mathf.Clamp(settingsDifficulty, 0, 2);
        difficultyOverride = Mathf.Clamp(difficultyOverride, 1, 3);
        controllerOverride = Mathf.Clamp(controllerOverride, 1, 2);
        controllerChoice = Mathf.Clamp(controllerChoice, 0, 1);
        timeGoal = Mathf.Clamp(timeGoal, 0, 300);
        feathersGoal = Mathf.Clamp(feathersGoal, 0, 50);
        bannanasGoal = Mathf.Clamp(bannanasGoal, 0, 50);

        if (sendEmail)
        {
            mail = "Ja";
        }
        else
        {
            mail = "Nee";
        }

        if (onDepth)
        {
            //Get Position of the Object
            screenPos1 = camera.WorldToScreenPoint(goals[0].position);
            screenPos2 = camera.WorldToScreenPoint(goals[1].position);
            screenPos3 = camera.WorldToScreenPoint(goals[2].position);

            screenPos1.y = Screen.height - (screenPos1.y + 1);
            screenPos2.y = Screen.height - (screenPos2.y + 1);
            screenPos3.y = Screen.height - (screenPos3.y + 1);
        }

        if (onSettingsDepth)
        {
            //Get Position of the Object
            settingsPos1 = camera.WorldToScreenPoint(settings[0].position);
            settingsPos2 = camera.WorldToScreenPoint(settings[1].position);
            settingsPos3 = camera.WorldToScreenPoint(settings[2].position);
            settingsPos4 = camera.WorldToScreenPoint(settings[3].position);
            //Get inverse of y-position
            settingsPos1.y = Screen.height - (settingsPos1.y + 1);
            settingsPos2.y = Screen.height - (settingsPos2.y + 1);
            settingsPos3.y = Screen.height - (settingsPos3.y + 1);
            settingsPos4.y = Screen.height - (settingsPos4.y + 1);
        }

        if (Application.loadedLevel == 0)
        {
            return;
        }
        else if (Application.loadedLevel == 1)
        {
            itemSpawner = GameObject.Find("World").GetComponent<ItemSpawner>();
            itemSpawner.dificulty = settingsDifficulty;
        }
    }
Exemplo n.º 33
0
 /// <summary>EMPTrap 리스트 추가</summary>
 /// <param name="_floor">설치한 층</param>
 /// <param name="_EMPTrap">설치한 EMPTrap</param>
 public void AddEMPTrap(int _floor, ItemSpawner _EMPTrap)
 {
     ItemSpawner.empTrapList.Add(new ItemSpawner.TrapInfo(_floor, _EMPTrap));
 }
Exemplo n.º 34
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        script = (ItemSpawner)target;


        EditorGUILayout.Space();

        GUI.color = Color.green;
        EditorGUILayout.Space();

        EditorGUILayout.HelpBox("Automatic Item Spawner", MessageType.None);

        EditorGUILayout.Space();
        GUI.color = Color.white;


        //---------------------------------------------------------------------------
        EditorGUILayout.PropertyField(serializedObject.FindProperty("itemName"),
                                      new GUIContent("Item Name", "Enter item your name"), true);
        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("Items"),
                                      new GUIContent("Items", "Drag youre items"), true);
        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("mover"),
                                      new GUIContent("Mover", "Drag mover gameobject"), true);
        EditorGUILayout.Space();

        EditorGUILayout.PropertyField(serializedObject.FindProperty("distance"),
                                      new GUIContent("Totall Distance", "Distance between each item set"), true);
        EditorGUILayout.Space();

        EditorGUILayout.PropertyField(serializedObject.FindProperty("betweenItems"),
                                      new GUIContent("Between Items", "How much distance between two items?"), true);
        EditorGUILayout.Space();

        EditorGUILayout.PropertyField(serializedObject.FindProperty("itemsDurationOnEachSet"),
                                      new GUIContent("Sets Length", ""), true);

        EditorGUILayout.Space();

        EditorGUILayout.PropertyField(serializedObject.FindProperty("betweenEachItemSet"),
                                      new GUIContent("Between Sets Distance", ""), true);

        EditorGUILayout.Space();

        if (GUILayout.Button("Start", GUILayout.Height(40)))
        {
            GameObject Items = new GameObject(script.itemName + "s");
            Items.transform.parent = script.transform;
            //Items = (GameObject)Instantiate (new GameObject ("Coins"), new Vector3 (0, 0, 0), Quaternion.identity);


            for (int a = 0; a < script.distance; a++)
            {
                rand1++;
                rand2 = (int)(Mathf.Floor(script.itemsDurationOnEachSet));
                if (rand1 >= rand2 + 1)
                {
                    rand1 = 0;
                }
                if (rand1 >= rand2)
                {
                    script.mover.transform.Translate(Vector3.right * script.betweenEachItemSet);
                }
                else
                {
                    script.mover.transform.Translate(Vector3.right * script.betweenItems);
                }
                RaycastHit2D hit = Physics2D.Raycast(script.mover.transform.position, -Vector2.up, 430);
                if (hit.collider != null)
                {
                    GameObject tem;
                    if (script.Items.Length > 1)
                    {
                        tem = (GameObject)Instantiate(script.Items [(int)(Mathf.Floor(Random.Range(0f, 2.1f)))], new Vector2(hit.point.x, hit.point.y + 1), Quaternion.identity);
                    }
                    else
                    {
                        tem = (GameObject)Instantiate(script.Items [0], new Vector2(hit.point.x, hit.point.y + 1), Quaternion.identity);
                    }

                    id++;
                    tem.transform.parent = Items.transform;
                    tem.name             = script.itemName + " " + id.ToString();
                }
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
Exemplo n.º 35
0
 void Awake()
 {
     itemSpawner = GetComponentInParent <ItemSpawner>();
 }
Exemplo n.º 36
0
    // Start is called before the first frame update
    void Start()
    {
        // finds gameplay manager if not set.
        if (gameManager == null)
        {
            gameManager = FindObjectOfType <GameplayManager>();
        }

        // if the item spawenr has not been set, search for it.
        if (itemSpawner == null)
        {
            itemSpawner = FindObjectOfType <ItemSpawner>();
        }


        // if server hasn't been set.
        if (server == null)
        {
            server = FindObjectOfType <UdpServerX>();

            // no server object exists, so make one (if applicable)
            if (server == null && generateServer)
            {
                server = new UdpServerX();
            }
        }

        // server is set, so add endpoints.
        if (server != null)
        {
            // set blocking sockets value
            server.SetBlockingSockets(blocking);

            // adds remote clients
            for (int i = 0; i < startupEndpoints; i++)
            {
                server.AddEndPoint(serverBufferSize);
            }
        }

        // if the client hasn't been set.
        if (client == null)
        {
            client = FindObjectOfType <UdpClient>();

            // makes client if one does not exist (if applicable)
            if (client == null && generateClient)
            {
                client = new UdpClient();
            }
        }

        // set blocking sockets value
        if (client != null)
        {
            client.SetBlockingSockets(blocking);
        }

        // if the server or client should be run on start.
        // note that if either one is set to 'true' by default, they will override this.
        if (runHostOnStart)
        {
            if (isMaster)
            {
                server.RunServer();
            }
            else
            {
                client.RunClient();
            }
        }


        // interval setter
        {
            // if the interval timer is not set, look for it on the object.
            if (intervalTimer == null)
            {
                intervalTimer = GetComponent <IntervalTimer>();
            }

            // interval timer found
            if (intervalTimer != null)
            {
                intervalTimer.startOnInterval = false;
                intervalTimer.intervalLength  = intervalLength;
                intervalTimer.countdown       = 0; // send immediately
            }
        }


        // timer not set.
        if (timer == null)
        {
            timer = FindObjectOfType <TimerObject>();
        }

        // TODO: when the game is starting, this is getting ahold of the players that are about to be deleted.
        // this needs to either change how it operates, or have a delay for getting remote players.

        // if the list hasn't had anything put into it.
        if (findPlayers)
        {
            if (players.Count == 0)
            {
                // only pulls from players with the remote player component active.
                RemotePlayer[] arr = FindObjectsOfType <RemotePlayer>(false);

                // adds players to list.
                foreach (RemotePlayer rp in arr)
                {
                    players.Add(rp);
                }
            }
        }


        // finds controlled player
        foreach (RemotePlayer rp in players)
        {
            if (rp.player.controllablePlayer)
            {
                localPlayer = rp;
                break;
            }
        }
    }
Exemplo n.º 37
0
        /// <summary>
        /// Initializes the Map, Items, the Player, the PlayerInterface and the Minimap
        /// </summary>
        public virtual void initialize()
        {
            mapCreator = new MapCreator();
            mapCreator.initialize();
            map = mapCreator.generateMap();

            itemMap = new ItemMap();
            itemSpawner = new ItemSpawner();
            itemSpawner.initialSpawn(itemMap, map, playerList);

            initializePlayer();

            minimap = new Minimap(new Vector2(0, 0), map);
            if (playerList.Count == 1)
                minimap.setPosition(new Vector2(Settings.getResolutionX() - minimap.getWidth(), 0));
            else
                minimap.setPosition(new Vector2(Settings.getResolutionX() / 2 - minimap.getWidth() / 2, Settings.getResolutionY() / 2 - minimap.getHeight() / 2));

            Game1.sounds.menuSound.Stop();
            Game1.sounds.inGameSound.Play();
        }