Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        System.DateTime now = System.DateTime.Now;
        Random.InitState(PlayerPrefs.GetInt("Seed", now.Hour + now.Millisecond));

        sfx = GameObject.Find("SFX").GetComponent <SFX>();

        UI         = GameObject.Find("Canvas").GetComponent <UIManager>();
        bc         = GetComponent <BuildingCreator>();
        town       = Resources.Load("Town") as GameObject;
        village    = Resources.Load("Village") as GameObject;
        hexagonMap = new GameObject[sizeMapX][];
        GameObject LinePref = Resources.Load("Line") as GameObject;

        zombie = Resources.Load("Zombie") as GameObject;

        lifeBar = Resources.Load("LifeBars") as GameObject;

        smallRing = Resources.Load("Ring") as GameObject;
        bigRing   = Resources.Load("RingBig") as GameObject;

        for (int x = 0; x < sizeMapX; ++x)
        {
            hexagonMap[x] = new GameObject[sizeMapY /*+ sizeMapX / 2*/];

            for (int y = 0; y < sizeMapY; ++y)
            {
                float      r         = y % 2;
                GameObject hexagonGO = new GameObject();
                Hexagon    h         = hexagonGO.AddComponent <Hexagon>();
                h.ConstructHexagon(new Vector2((x * Mathf.Sqrt(3) * sizeHexagon) + ((Mathf.Sqrt(3) * sizeHexagon / 2) * y), (y * sizeHexagon * 2) * 0.75f), Material, LinePref);
                hexagonMap[x][y] = hexagonGO;
                h.x      = x;
                h.y      = y /* + x / 2*/;
                h.hm     = this;
                h.Zombie = GameObject.Instantiate(zombie);
                h.Zombie.transform.parent        = h.transform;
                h.Zombie.transform.localPosition = Vector3.zero + new Vector3(0, -0.5f, 0);
                h.Zombie.SetActive(false);
            }
        }
        //GetComponent<CharacterCreator>().PlaceCharacterOnHexagon(1, hexagonMap[0][0].GetComponent<Hexagon>(), CharacterCreator.ECharacterType.Medic);

        GenerateBuildings();
        CreateGroups();
        CreatePopulation();

        im = GameObject.Find("InfectionManager").GetComponent <InfectionManager>();
    }