Beispiel #1
0
    private void CreateBuilddingAtPos(Vector3 pos, UserHouse userHouse, Vector2 posInMap)
    {
        GameObject go = GameObject.Instantiate(BuidingFinishedPrefab) as GameObject;

        go.transform.SetParent(BuidingFinishedRoot.transform);
        go.transform.localPosition = pos;
        go.transform.localScale    = new Vector3(1, 1, 1);

        float depth = Mathf.Abs(Vector3.Distance(go.transform.position, Camera.main.transform.position));

        go.name = string.Format("Building_{0:D4}", (int)(depth));

        UIEmpireBuildingFinished bdf = go.GetComponent <UIEmpireBuildingFinished>();

        go.SetActive(true);



        bdf.Init(userHouse);

        listBuidingFinished.Add(bdf);

        SortDepthListBuilding();


        if (userHouse.HouseId == 1)
        {
            uiContaint.silverOfBank.transform.position = go.transform.position + Vector3.up * 50;
        }
    }
    public void OnRemoveBuilding(UIEmpireBuildingFinished building)
    {
        Vector2 startpos = Vector2.zero;
        Vector2 endPos   = Vector2.zero;

        // GetRectOfBuiding(cells[building.posInMap], building._empireBuilding, out startpos, out endPos);

        for (int x = (int)startpos.x; x <= endPos.x; x++)
        {
            for (int y = (int)startpos.y; y <= endPos.y; y++)
            {
                Vector2 curCellPos = new Vector2(x, y);
                if (cells.ContainsKey(curCellPos))
                {
                    UIEmpireCell curCell = cells[curCellPos];
                    curCell.ChangeState(UIEmpireCell.State.Free);
                }
            }
        }
    }
Beispiel #3
0
    public void OnResponseDestroyHouse()
    {
        UIEmpireCursor.Instance.Hide(false);
        buildingFinishedDrag.OnDestroyBuilding();
        buildingFinishedDrag = null;
        houseDataSelected    = null;
        empireMap.CanNotBuilding();

        UIEmpireCursor.Instance.Hide(false);
        houseDataSelected = null;
        empireMap.CanNotBuilding();

        //foreach (UIEmpireBuildingFinished building in listBuidingFinished)
        //{
        //    GameObject.Destroy(building.gameObject);
        //}
        //listBuidingFinished.Clear();
        //StartCoroutine(InitOldBuiding());
        OnResponseOpenCell();
        DroptoTrash = false;
    }
Beispiel #4
0
 public void RemoveBuilding(UIEmpireBuildingFinished building)
 {
     empireMap.OnRemoveBuilding(building);
     listBuidingFinished.Remove(building);
 }
Beispiel #5
0
 public void OnDragBuildingFinished(UIEmpireBuildingFinished building)
 {
     buildingFinishedDrag = building;
     UIEmpireCursor.Instance.Show(Helper.LoadSpriteForBuilding(building.userHouse.HouseId));
     // OnDragBuilding(LandConfig.HOUSE_DATA[building.userHouse.HouseId]);
 }