Esempio n. 1
0
 // Start is called before the first frame update
 void Awake()
 {
     room   = GameObject.Find("Room");
     mG     = room.GetComponent <mapGenerator>();
     length = Random.Range(minLength, maxLength);
     width  = Random.Range(minWidth, maxWidth);
 }
 void Start()
 {
     mapMother = FindObjectOfType <mapGenerator>();
     rigidBody = GetComponent <Rigidbody>();
     rigidBody.freezeRotation = true;
     die();
 }
    public void initiate()
    {
        poolmanager.instance.initiate();
        elementaryAffection.instance.initiate();

        if (_map == null)
        {
            _map = new GameObject("(" + mapSize + "x" + mapSize + ") map");
            mapData      data      = _map.AddComponent <mapData>();
            mapGfx       gfx       = _map.AddComponent <mapGfx>();
            mapGenerator generator = _map.AddComponent <mapGenerator>();

            List <string> layerNames = new List <string>()
            {
                "ground", "path", "decoration", "tower"
            };

            data.mapSize = mapSize;
            data.layers  = layerNames;
            data.initiate();

            layerNames.Add("waypoint");

            gfx.prefixIdentifier = new List <string>()
            {
                "basis",
                "ground",
                "spawn",
                "bottomLeftPath",
                "bottomRightPath",
                "horizontalPath",
                "upperLeftPath",
                "upperRightPath",
                "verticalPath"
            };

            gfx.initiate(layerNames);

            generator.buildBoardFoundation(data, gfx);
            generator.buildRandomBoard(data, gfx);

            gfx.instantiateBoard(data.getBoard(), data.mapSize);

            createWavesystem(generator.startWaypoint);
        }
        else
        {
            Destroy(_map);
            _map = null;

            Destroy(_wavesystem);
            _wavesystem = null;

            elementaryAffection.instance.reset();

            initiate();
        }
    }
Esempio n. 4
0
    private void Start()
    {
        mapGen                 = FindObjectOfType <mapGenerator>();
        maxViewDst             = detailLevels[detailLevels.Length - 1].visibleDstThreshold;
        chunkSize              = mapGenerator.mapChunkSize - 1;
        chunksVisibleInViewDst = Mathf.RoundToInt(maxViewDst / chunkSize);

        UpdateVisibleChunks();
    }
 void Awake()
 {
     dataFromTiles = new Dictionary <TileBase, TileData>();
     clintConnects = FindObjectOfType <Clintconnects>();
     tileUpdater   = FindObjectOfType <TileUpdater>();
     mapGenerator  = FindObjectOfType <mapGenerator>();
     mapManager    = FindObjectOfType <MapManager>();
     map           = FindObjectOfType <Tilemap>();
 }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < transform.childCount; i++)
        {
            lifeSprites.Add(transform.GetChild(i).gameObject);
        }

        scoreText     = GameObject.FindGameObjectWithTag("scoreText").GetComponent <Text>();
        highScoreText = GameObject.FindGameObjectWithTag("scoreText2").GetComponent <Text>();

        mapGen = FindObjectOfType <mapGenerator>();
    }
Esempio n. 7
0
    public override void OnInspectorGUI()
    {
        mapGenerator mapGen = (mapGenerator)target;

        if (DrawDefaultInspector())
        {
            if (mapGen.autoUpdate)
            {
                mapGen.GenerateMap();
            }
        }
        if (GUILayout.Button("Generator"))
        {
            mapGen.GenerateMap();
        }
    }
Esempio n. 8
0
    public void newMap()
    {
        Transform rT   = room.GetComponent <Transform>();
        float     posx = rT.position.x;
        float     posy = rT.position.y;

        mG     = room.GetComponent <mapGenerator>();
        length = Random.Range(minLength, maxLength);
        width  = Random.Range(minWidth, maxWidth);
        side   = mG.secSide;
        oSide  = Random.Range(0, 3);
        if ((side == 1 && oSide == 0) || (side == 3 && oSide == 2) || (side == 2 && oSide == 3) || (side == 0 && oSide == 1))
        {
            int tempSide = oSide;
            while (tempSide == oSide)
            {
                oSide = Random.Range(0, 3);
            }
        }
        if (side == 0)
        {
            posy = rT.position.y + (((mG.width / 2) * testy) + ((width / 2) * testy));
        }
        else if (side == 1)
        {
            posy = rT.position.y - (((mG.width / 2) * testy) + ((width / 2) * testy));
        }
        else if (side == 2)
        {
            posx = rT.position.x - (((mG.length / 2) * testx) + ((length / 2) * testx));
        }
        else
        {
            posx = rT.position.x + ((mG.length / 2) * testx) + ((length / 2) * testx);
        }
        GameObject clone = Instantiate(roomPrefab, new Vector2(posx, posy), Quaternion.identity);

        rooms[arrayIndex] = clone;
        room = clone;
        arrayIndex++;
        if (arrayIndex > 3)
        {
            arrayIndex = 0;
        }
    }
Esempio n. 9
0
 void Awake()
 {
     mapGenerator   = FindObjectOfType <mapGenerator>();
     windGenerator  = FindObjectOfType <WindGenerator>();
     mapManager     = FindObjectOfType <MapManager>();
     clintConnects  = FindObjectOfType <Clintconnects>();
     solarZellen    = FindObjectOfType <SolarZellen>();
     kohleGenerator = FindObjectOfType <KohleGenerator>();
     steinSeller    = FindObjectOfType <SteinSeller>();
     seller         = FindObjectOfType <Seller>();
     miner          = FindObjectOfType <Miner>();
     goldSeller     = FindObjectOfType <GoldSeller>();
     goldMiner      = FindObjectOfType <GoldMiner>();
     eisenMiner     = FindObjectOfType <EisenMiner>();
     doubleSeller   = FindObjectOfType <DoubleSeller>();
     diamondMiner   = FindObjectOfType <DiamondMiner>();
     map            = FindObjectOfType <Tilemap>();
     Alive          = true;
     if (isLocalPlayer)
     {
         test();
     }
     StartCoroutine(Waitforplayer());
 }
 void Start()
 {
     mapMother  = FindObjectOfType <mapGenerator>();
     controller = FindObjectOfType <Controller>();
 }
Esempio n. 11
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this);
        }

        tiles = new List <List <Hex> >();
        //tilesToGameObjects = new Dictionary<Hex, GameObject>();

        #region debug
        if (debug)
        {
            if (generateHeigthMap)
            {
                perlinNoiseScale = 25f;
                heigthMapTexture = GenerateHeigthMap();
            }
            for (int x = 0; x < width; x++)
            {
                temp = new List <Hex>();

                for (int y = 0; y < height; y++)
                {
                    generatePrefab(x, y, colorMappings[0]);
                    tilesSpawned++;
                }

                tiles.Add(temp);
            }
            if (calcNeigboursOnStartUp)
            {
                foreach (List <Hex> hexList in tiles)
                {
                    foreach (Hex hex in hexList)
                    {
                        Hex[] gos = hex.GetNeighbours();
                        //Debug.Log("Tile at pos " + hex.x + "," + hex.y + " has " + gos.Length + " neighbours");
                    }
                }
            }
            if (generateDebugPlayer)
            {
                GameObject go = Instantiate(debugUnit, GameObject.Find("Hex_0_0").transform.position, Quaternion.identity);
                go.name = "TestUnit";
            }
        }
        #endregion
        else
        {
            width  = map.width;
            height = map.height;

            if (generateHeigthMap)
            {
                heigthMapTexture = GenerateHeigthMap();
            }

            for (int x = 0; x < width; x++)
            {
                temp = new List <Hex>();

                for (int y = 0; y < height; y++)
                {
                    generateTile(x, y);
                }

                tiles.Add(temp);
            }
        }

        Debug.Log("nr of tiles spawned = " + tilesSpawned);
    }
Esempio n. 12
0
 // Use this for initialization
 void Awake()
 {
     map        = FindObjectOfType <mapGenerator>();
     ui         = FindObjectOfType <UIDisplay>();
     pathFinder = GameObject.FindGameObjectWithTag("pathfinding").GetComponent <PathFinding>();
 }
Esempio n. 13
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Pellet")
        {
            ui.IncrementScore(1);

            if (collision.gameObject.name.Contains("Power"))
            {
                GhostHivemindMovement hivemind = FindObjectOfType <GhostHivemindMovement>();
                if (hivemind)
                {
                    hivemind.BecomeFrightened();
                }
                else
                {
                    foreach (GameObject g in GameObject.FindGameObjectsWithTag("ghost"))
                    {
                        g.GetComponent <UpdatedGhostMovement>().BecomeFrightened();
                    }
                }

                isInvincible     = true;
                invincibleTimer += invDurationPerPellet;   // power pellets stack
            }

            Destroy(collision.gameObject);
        }
        if (collision.gameObject.tag == "ghost")
        {
            GhostHivemindMovement hivemind = FindObjectOfType <GhostHivemindMovement>();
            UpdatedGhostMovement  singular = collision.gameObject.GetComponent <UpdatedGhostMovement>();

            if (singular && singular.respawn)
            {
                return;
            }

            if (isInvincible)
            {
                // do invincible behavior
                ui.IncrementScore(ghostScore);
                ghostScore *= 2;

                if (hivemind)
                {
                    string ghostName = collision.gameObject.name;
                    if (ghostName.Contains("Blinky"))
                    {
                        hivemind.Eaten("blinky");
                    }
                    else if (ghostName.Contains("Pinky"))
                    {
                        hivemind.Eaten("pinky");
                    }
                    else if (ghostName.Contains("Inky"))
                    {
                        hivemind.Eaten("inky");
                    }
                    else if (ghostName.Contains("Clyde"))
                    {
                        hivemind.Eaten("clyde");
                    }
                }
                else if (singular)
                {
                    singular.Eaten();
                }
            }
            else
            {
                mapGenerator mapGen = FindObjectOfType <mapGenerator>();
                mapGen.DecLives();

                GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;


                dead = true;
                GetComponent <Animator>().SetBool("Dead", true);
                GetComponent <CircleCollider2D>().enabled = false;

                StartCoroutine(Respawn());
            }
        }
    }
Esempio n. 14
0
 private void Start()
 {
     MG = GameObject.Find("Pipe").GetComponent <mapGenerator>();
 }