Beispiel #1
0
    public override void OnInspectorGUI()
    {
        RockSpawner      myScript       = (RockSpawner)target;
        SerializedObject serializedObj  = new SerializedObject(myScript);
        GUIStyle         customGUIStyle = new GUIStyle();

        customGUIStyle.fontSize = 16;

        DrawPropertiesExcluding(serializedObj, new string[] { "minThrowAngle", "maxThrowAngle", "minStrength", "maxStrength", "minTimeBetweenSpawns", "maxTimeBetweenSpawns" });
        GUILayout.Label("");
        EditorGUILayout.LabelField("Angle", style: customGUIStyle);

        EditorGUILayout.LabelField("Min:", myScript.minThrowAngle[(int)myScript.difficultySetting].ToString("#.#") + "°");
        EditorGUILayout.LabelField("Max:", myScript.maxThrowAngle[(int)myScript.difficultySetting].ToString("#.#") + "°");
        EditorGUILayout.MinMaxSlider(ref myScript.minThrowAngle[(int)myScript.difficultySetting], ref myScript.maxThrowAngle[(int)myScript.difficultySetting], 15.0f, 85.0f);

        EditorGUILayout.LabelField("Strength", style: customGUIStyle);
        EditorGUILayout.LabelField("Min:", myScript.minStrength[(int)myScript.difficultySetting].ToString("#.#"));
        EditorGUILayout.LabelField("Max:", myScript.maxStrength[(int)myScript.difficultySetting].ToString("#.#"));
        EditorGUILayout.MinMaxSlider(ref myScript.minStrength[(int)myScript.difficultySetting], ref myScript.maxStrength[(int)myScript.difficultySetting], 1, 20);

        EditorGUILayout.LabelField("Time between spawns", style: customGUIStyle);
        EditorGUILayout.LabelField("Min:", myScript.minTimeBetweenSpawns[(int)myScript.difficultySetting].ToString("#.#") + " s");
        EditorGUILayout.LabelField("Max:", myScript.maxTimeBetweenSpawns[(int)myScript.difficultySetting].ToString("#.#") + " s");
        EditorGUILayout.MinMaxSlider(ref myScript.minTimeBetweenSpawns[(int)myScript.difficultySetting], ref myScript.maxTimeBetweenSpawns[(int)myScript.difficultySetting], 1, 10);

        serializedObj.ApplyModifiedProperties();
    }
Beispiel #2
0
 // Start is called before the first frame update
 protected virtual void Awake()
 {
     rockFactory = GameObject.Find("RockFactory").GetComponent <RockSpawner>();
     gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
     spr         = gameObject.GetComponentInChildren <SpriteRenderer>();
     rigid       = gameObject.GetComponent <Rigidbody2D>();
 }
Beispiel #3
0
 // Use this for initialization
 void Start()
 {
     //initialize variables
     instance       = this;
     timer          = 0;
     numActiveRocks = 0;
     pool           = new Stack <GameObject>();
     numBins        = binWeights.Length;
     binWidth       = 1.0f / numBins;
     lowestSpawn    = -12.5f;
     highestSpawn   = 17.5f;
     // populate pool with new rocks
     for (int i = 0; i < maxRockCount; ++i)
     {
         GameObject rock = Instantiate(rockPrefab, new Vector3(-100, -100, 0), Quaternion.identity); // spawn the rock initially offscreen
         ReturnRock(rock);
     }
     // draw some lines to show bins for debugging purposes (only shows up in scene view)
     for (int i = 1; i < numBins; ++i)
     {
         Vector3 start = Camera.main.ViewportToWorldPoint(new Vector3(i * binWidth, 1, 0));
         start.z = 0;
         Vector3 end = Camera.main.ViewportToWorldPoint(new Vector3(i * binWidth, 0, 0));
         end.z = 0;
         Debug.DrawLine(start, end, Color.red, Mathf.Infinity);
     }
     if (PlayerPrefs.GetString("GameMode") == "King of the Hill")
     {
         SpawnKingRock();
         spawnFrequency    = kingSpawnFrequency;
         lavaRockSpawnRate = 0;
         spawnDecrease     = 0;
     }
 }
    void DeactivateRockForGeyser()
    {
        //GameObject rock = GameObject.Find("RockForGeyser");
        //rock.SetActive(false);
        GameObject.FindObjectOfType <Geyser>().enabled = true;
        RockSpawner spwnr = GameObject.FindGameObjectWithTag("SpawnerForGeyser").GetComponent <RockSpawner>();

        spwnr.spawned_objects = 0;
        spwnr.DeactivateRockForGeyser();
    }
Beispiel #5
0
 // Start is called before the first frame update
 void Start()
 {
     for (int i = dwarfAvailable; i < dwarfInstances.Count; i++)
     {
         dwarfInstances[i].SetActive(false);
     }
     dwarfInstances[0].GetComponent <Worker>().enabled = false;
     rockSpawner             = FindObjectOfType <RockSpawner>();
     minecartSpawner         = FindObjectOfType <MinecartSpawner>();
     rockSpawner.enabled     = false;
     minecartSpawner.enabled = false;
 }
    // Start is called before the first frame update
    void Start()
    {
        if (!isSpawned)
        {
            spawner     = GameObject.Find("RockSpawner");
            rockSpawner = spawner.GetComponent <RockSpawner>();
            targetPos   = rockSpawner.randomPos;
            isSpawned   = true;
        }

        newShadow = Instantiate(shadow, targetPos, Quaternion.identity);
        newShadow.transform.parent = gameObject.transform;
    }
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
        move = false;
        // set the desired aspect ratio (the values in this example are
        // hard-coded for 16:9, but you could make them into public
        // variables instead so you can set them at design time)
        float targetaspect = 5f / 6.0f;

        // determine the game window's current aspect ratio
        float windowaspect = (float)Screen.width / (float)Screen.height;

        // current viewport height should be scaled by this amount
        float scaleheight = windowaspect / targetaspect;

        // obtain camera component so we can modify its viewport
        Camera camera = Camera.main;

        // if scaled height is less than current height, add letterbox
        if (scaleheight < 1.0f)
        {
            Rect rect = camera.rect;

            rect.width  = 1.0f;
            rect.height = scaleheight;
            rect.x      = 0;
            rect.y      = (1.0f - scaleheight) / 2.0f;

            camera.rect = rect;
        }
        else         // add pillarbox
        {
            float scalewidth = 1.0f / scaleheight;

            Rect rect = camera.rect;

            rect.width  = scalewidth;
            rect.height = 1.0f;
            rect.x      = (1.0f - scalewidth) / 2.0f;
            rect.y      = 0;

            camera.rect = rect;
        }

//		Camera.main.orthographicSize = 80.22f / Screen.width * Screen.height;
//		transform.position = new Vector3(0, Camera.main.orthographicSize / 2, -10);
//		wallOfDeath.transform.localPosition = new Vector3(0,-Camera.main.orthographicSize + 3, 10);
//		rockSpawner.transform.localPosition = new Vector3(0,Camera.main.orthographicSize + 10, 10);

        spawner = GetComponentInChildren <RockSpawner>();
    }
    // Use this for initialization
    void Start()
    {
        animator = this.GetComponent <Animator>();

        if (!rockSpawner)
        {
            rockSpawner = FindObjectOfType <RockSpawner>();
        }
        if (!qte)
        {
            qte = FindObjectOfType <QTEHandler_Test>();
        }
        rb           = GetComponent <Rigidbody2D>();
        rb.simulated = false;
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Cart_Destructor") && !gameManager.hasCaveInHappened)
        {
            Debug.Log("calling?");
            hit_cart = true;

            rocks.transform.parent = null;
            RockSpawner rockSpawner = rocks.GetComponent <RockSpawner>();

            StartCoroutine(rockSpawner.SpawnRocks());
            cart.GetComponent <CartMovement>().Crash();
            gameManager.hasCaveInHappened = true;
            gameManager.EndGame();
        }
    }
Beispiel #10
0
    public GameLogic(Lights lights, Player player1, Player player2, RockSpawner rRockSpawner)
    {
        this.rRockSpawner  = rRockSpawner;
        this.rocks         = new Rocks();
        this.player2       = player2;
        this.player1       = player1;
        this.lights        = lights;
        player1OutputEvent = new PlayerOutputEventHandler();
        player2OutputEvent = new PlayerOutputEventHandler();

        player1OutputEvent.moveLeft  = () => MoveLeft(player1, otherPlayer: player2, lights: lights);
        player2OutputEvent.moveLeft  = () => MoveLeft(player2, otherPlayer: player1, lights: lights);
        player1OutputEvent.moveRight = () => MoveRight(player1, otherPlayer: player2, lights: lights);
        player2OutputEvent.moveRight = () => MoveRight(player2, otherPlayer: player1, lights: lights);
        player1OutputEvent.shoot     = () => Shoot(player1, rocks, onShootSuccess: ScoreUpAction(player1.color), playerInput: player1Input);
        player2OutputEvent.shoot     = () => Shoot(player2, rocks, onShootSuccess: ScoreUpAction(player2.color), playerInput: player2Input);
    }
Beispiel #11
0
    internal void Setup(Game game)
    {
        var pPrefabContainer = game.pPrefabContainer;

        var cContainer    = ComponentContainer.Create();
        var roRockSpawner = new RockSpawner(pPrefabContainer.rock1, pPrefabContainer.rock2, cContainer.sSpawnPoints);
        var gameLogic     = new GameLogic(cContainer.lights, cContainer.player1, cContainer.player2, roRockSpawner);

        game.cContainer    = cContainer;
        game.roRockSpawner = roRockSpawner;

        roRockSpawner.output = gameLogic;

        cContainer.player1.input = new Player1InputHandler();
        cContainer.player2.input = new Player2InputHandler();

        cContainer.player1.output = gameLogic.player1OutputEvent;
        cContainer.player2.output = gameLogic.player2OutputEvent;

        cContainer.player1.currentLight = cContainer.lights.list.Where(l => l.positionIndex == 0).First();
        cContainer.player2.currentLight = cContainer.lights.list.Where(l => l.positionIndex == 1).First();

        gameLogic.player1ScoreInput = cContainer.player1Score;
        gameLogic.player2ScoreInput = cContainer.player2Score;

        gameLogic.player1Input = cContainer.player1;
        gameLogic.player2Input = cContainer.player2;

        gameLogic.rocks.rockLifeCycleOutput    = cContainer.lights;
        gameLogic.rocks.gGroundCollisionOutput = gameLogic;

        gameLogic.gGameOverOutput = new GameOverHandler(new List <GameOverOutput> {
            gameLogic.rocks,
            game.roRockSpawner,
            cContainer.player1Ending,
            cContainer.player2Ending,
            cContainer.player1,
            cContainer.player2
        });
    }
Beispiel #12
0
    public void GenerateMap()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(mapChunkSize, mapChunkSize, seed, noiseScale, octaves, persistance, lacunarity, offset);

        Color[] colourMap = new Color [mapChunkSize * mapChunkSize];
        for (int y = 0; y < mapChunkSize; y++)
        {
            for (int x = 0; x < mapChunkSize; x++)
            {
                float currentHeight = noiseMap [x, y];
                for (int i = 0; i < regions.Length; i++)
                {
                    if (currentHeight <= regions[i].height)
                    {
                        colourMap [y * mapChunkSize + x] = regions [i].colour;
                        break;
                    }
                }
            }
        }

        MapDisplay display = FindObjectOfType <MapDisplay> ();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
        }
        else if (drawMode == DrawMode.ColourMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColourMap(colourMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(noiseMap, meshHeightMultiplier, meshHeightCurve, levelOfDetail), TextureGenerator.TextureFromColourMap(colourMap, mapChunkSize, mapChunkSize));
            display.ClearObjects();
            display.SpawnTree(TreeSpawner.SpawnTrees(noiseMap, regions, meshHeightMultiplier, meshHeightCurve, woodiness));
            display.SpawnRock(RockSpawner.SpawnRocks(noiseMap, regions, meshHeightMultiplier, meshHeightCurve, stoniness));
        }
    }
Beispiel #13
0
 private void Awake()
 {
     Instance = this;
 }
Beispiel #14
0
 public static bool loadData(string name)
 {
     try{
         string[] players = null, machines = null, stumps = null, rocks = null, animals = null, crates = null, structures = null;
         string   time    = "";
         using (StreamReader sR = new StreamReader(path + "/" + name + ".txt")){
             WorldData.sType = decrypt(sR.ReadLine());
             players         = decrypt(sR.ReadLine()).Split('!');
             machines        = decrypt(sR.ReadLine()).Split('!');
             stumps          = decrypt(sR.ReadLine()).Split('!');
             rocks           = decrypt(sR.ReadLine()).Split('!');
             animals         = decrypt(sR.ReadLine()).Split('!');
             crates          = decrypt(sR.ReadLine()).Split('!');
             structures      = decrypt(sR.ReadLine()).Split('!');
             time            = decrypt(sR.ReadLine());
         }
         string[]   data;
         GameObject player  = GameObject.Find("Player");
         Player     playerS = player.GetComponent <Player>();
         foreach (string p in players)
         {
             if (p.Split('@')[0] == "player")
             {
                 data = p.Split('@')[1].Split('#');
                 player.transform.position = new Vector3((float)Convert.ToDouble(data[0]), (float)Convert.ToDouble(data[1]), (float)Convert.ToDouble(data[2]));
                 data              = p.Split('@');
                 playerS.health    = Convert.ToInt16(data[2]);
                 playerS.nutrition = Convert.ToInt16(data[3]);
                 data              = p.Split('@')[4].Split('#');
                 for (int i = 0; i < data.Length; i++)
                 {
                     playerS.inv[i] = new Vector2((float)Convert.ToDouble(data[i].Split('$')[0]), (float)Convert.ToDouble(data[i].Split('$')[1]));
                 }
                 data = p.Split('@')[5].Split('#');
                 for (int i = 0; i < data.Length; i++)
                 {
                     playerS.toolbar[i] = new Vector2((float)Convert.ToDouble(data[i].Split('$')[0]), (float)Convert.ToDouble(data[i].Split('$')[1]));
                 }
                 data = p.Split('@')[6].Split('#');
                 for (int i = 0; i < data.Length; i++)
                 {
                     playerS.armor[i] = new Vector2((float)Convert.ToDouble(data[i].Split('$')[0]), (float)Convert.ToDouble(data[i].Split('$')[1]));
                 }
                 data = p.Split('@')[7].Split('#');
                 playerS.spawnPoint = new Vector3((float)Convert.ToDouble(data[0]), (float)Convert.ToDouble(data[1]), (float)Convert.ToDouble(data[2]));
             }
         }
         foreach (string m in machines)
         {
             foreach (GameObject g in playerS.machines)
             {
                 if (g.name == m.Split('@')[0])
                 {
                     Vector3 pos, rot;
                     data = m.Split('@')[1].Split('#');
                     pos  = new Vector3((float)Convert.ToDouble(data[0]), (float)Convert.ToDouble(data[1]), (float)Convert.ToDouble(data[2]));
                     rot  = new Vector3(0f, (float)Convert.ToDouble(m.Split('@')[2]), 0f);
                     GameObject newM = Instantiate(g, pos, player.transform.rotation) as GameObject;
                     newM.name = newM.name.Split('(')[0];
                     newM.transform.eulerAngles = rot;
                     if (m.Split('@').Length == 4)
                     {
                         MonoBehaviour mScript = null;
                         if (g.name == "Iron Furnace" || g.name == "Stone Furnace")
                         {
                             mScript = newM.GetComponent <Furnace>();
                         }
                         else if (g.name == "Oven" || g.name == "Campfire")
                         {
                             mScript = newM.GetComponent <Oven>();
                         }
                         else if (g.name == "Chest")
                         {
                             mScript = newM.GetComponent <Chest>();
                         }
                         data = m.Split('@')[3].Split('#');
                         Vector2[] mInv = new Vector2[data.Length];
                         for (int i = 0; i < data.Length; i++)
                         {
                             mInv[i] = new Vector2((float)Convert.ToDouble(data[i].Split('$')[0]), (float)Convert.ToDouble(data[i].Split('$')[1]));
                         }
                         mScript.SendMessage("loadInv", mInv);
                     }
                 }
             }
         }
         foreach (string s in stumps)
         {
             if (s != "")
             {
                 foreach (GameObject t in GameObject.FindGameObjectsWithTag("tree"))
                 {
                     if (Vector3.Distance(t.transform.position, new Vector3((float)Convert.ToDouble(s.Split('@')[0]), (float)Convert.ToDouble(s.Split('@')[1]), (float)Convert.ToDouble(s.Split('@')[2]))) < 1f)
                     {
                         t.GetComponent <Tree>().loadStump();
                     }
                 }
             }
         }
         RockSpawner rockSpawner = GameObject.Find("RockSpawner").GetComponent <RockSpawner>();
         foreach (string r in rocks)
         {
             if (r != "")
             {
                 rockSpawner.loadRock(Convert.ToInt16(r.Split('@')[0]), Convert.ToInt16(r.Split('@')[1]));
             }
         }
         rockSpawner.loadComplete = true;
         AnimalSpawner animalSpawner = GameObject.Find("AnimalSpawner").GetComponent <AnimalSpawner>();
         foreach (string a in animals)
         {
             if (a != "")
             {
                 GameObject animal = null;
                 if (a.Split('@')[0] == "Ra")
                 {
                     animal = animalSpawner.rabbit;
                 }
                 else if (a.Split('@')[0] == "De")
                 {
                     animal = animalSpawner.deer;
                 }
                 else if (a.Split('@')[0] == "Bo")
                 {
                     animal = animalSpawner.boar;
                 }
                 else if (a.Split('@')[0] == "Be")
                 {
                     animal = animalSpawner.bear;
                 }
                 else if (a.Split('@')[0] == "Ch")
                 {
                     animal = animalSpawner.chicken;
                 }
                 Vector3 pos, rot;
                 data = a.Split('@')[1].Split('#');
                 pos  = new Vector3((float)Convert.ToDouble(data[0]), (float)Convert.ToDouble(data[1]), (float)Convert.ToDouble(data[2]));
                 rot  = new Vector3(0f, (float)Convert.ToDouble(a.Split('@')[2]), 0f);
                 GameObject newA = Instantiate(animal, pos, player.transform.rotation) as GameObject;
                 newA.transform.eulerAngles = rot;
                 newA.SendMessage("loadHealth", Convert.ToInt16(a.Split('@')[3]));
                 AnimalSpawner.animals++;
             }
         }
         animalSpawner.loadComplete = true;
         GameObject crate = GameObject.Find("Player").GetComponent <Player>().crateGO;
         foreach (string c in crates)
         {
             if (c != "")
             {
                 data = c.Split('@')[0].Split('#');
                 Vector3 pos = new Vector3((float)Convert.ToDouble(data[0]), (float)Convert.ToDouble(data[1]), (float)Convert.ToDouble(data[2]));
                 data = c.Split('@')[1].Split('#');
                 GameObject newC = Instantiate(crate, pos, new Quaternion(0, 0, 0, 0)) as GameObject;
                 newC.GetComponent <Crate>().spawn(new Vector2((float)Convert.ToDouble(data[0]), (float)Convert.ToDouble(data[1])));
             }
         }
         foreach (string s in structures)
         {
             if (s != "")
             {
                 data = s.Split('@')[1].Split('#');
                 Vector3    pos  = new Vector3((float)Convert.ToDouble(data[0]), (float)Convert.ToDouble(data[1]), (float)Convert.ToDouble(data[2]));
                 GameObject newS = Instantiate(playerS.structures[Convert.ToInt16(s.Split('@')[0])], pos, new Quaternion(0, 0, 0, 0)) as GameObject;
                 newS.transform.eulerAngles = new Vector3(0f, (float)Convert.ToDouble(s.Split('@')[2]), 0f);
                 data = s.Split('@');
                 newS.GetComponent <Structure>().load(Convert.ToInt16(data[0]), data[3], Convert.ToInt16(data[4]));
                 if (Convert.ToInt16(data[0]) % 8 == 7)
                 {
                     newS.GetComponent <Door>().creator = data[3];
                 }
                 else if (Convert.ToInt16(data[0]) % 8 == 5 && data[5] == "1")
                 {
                     foreach (Transform t in newS.GetComponentsInChildren <Transform>())
                     {
                         t.localPosition = new Vector3(t.localPosition.x, t.localPosition.y, 0f);
                     }
                     newS.transform.position = pos;
                 }
             }
         }
         Clock clock = GameObject.Find("Clock").GetComponent <Clock>();
         clock.hour   = Convert.ToInt16(time.Split('!')[0]);
         clock.second = (float)Convert.ToInt16(time.Split('!')[1]);
         return(true);
     }catch { return(false); }
 }
Beispiel #15
0
 private void Awake()
 {
     currentOre  = maxOre;
     rockSpawner = FindObjectOfType <RockSpawner>();
 }