Ejemplo n.º 1
0
    //given an index and the type of summon, summons that entity with the next available name
    public void BuildBuilding(int cellindex, string buildingname, string playerid)
    {
        Vector3 buildindex = hexGrid.GetCellPos(cellindex);

        buildindex.y = 0.2f;

        //Instantiate the prefab from the resources folder
        GameObject building   = (GameObject)Instantiate(Resources.Load(buildingname), buildindex, Quaternion.identity);
        Guid       buildingID = Guid.NewGuid();

        building.name = buildingID.ToString();
        char playerChar = playerid[0];

        buildingStorage.PlayerBuildingList(playerChar).Add(building);
        hexGrid.SetBuildingObject(cellindex, building);

        //sets stats for building
        buildingStats.SetPlayerID(building, playerid);
        buildingStats.SetType(building, buildingname);
        buildingStats.SetUniqueID(building, buildingID);
        buildingStats.SetCellIndex(building, cellindex);

        int health = buildingStats.GetMaxHealth(buildingname);

        buildingStats.SetMaxHealth(building, health);
        buildingStats.SetCurrHealth(building, health);
        int range = buildingStats.GetRange(buildingname);

        buildingStats.SetRange(building, range);
        int rangedattdmg = buildingStats.GetRangedAttackDmg(buildingname);

        buildingStats.SetRangedAttackDmg(building, rangedattdmg);
        int defense = buildingStats.GetDefense(buildingname);

        buildingStats.SetDefense(building, defense);
        int vision = buildingStats.GetVision(buildingname);

        buildingStats.SetVision(building, vision);

        loadMap.CreateHealthLabel(cellindex, health, building.name);
    }