예제 #1
0
    /// <summary>
    /// 建造兵营
    /// </summary>
    public void CreatBuding(string name)
    {
        if (campNow != null)
        {
            return;
        }
        IAssetFactory factory = PBDGFactory.GetAssetFactory();

        campNow = factory.CreatBuding(name);
        // m_PBDGame.Add(campNow, "建筑物");
    }
예제 #2
0
    public override void LoadAsset()
    {
        IAssetFactory Factory           = PBDGFactory.GetAssetFactory();
        GameObject    soliderGameObject = Factory.CreatSolider("prefab", m_buildParam.AssetName);

        soliderGameObject.transform.position = m_buildParam.Position;
        soliderGameObject.gameObject.name    = "Soldier";
        m_buildParam.NewBuding.SetGameObject(soliderGameObject);



        if (m_pBDG != null)
        {
            m_pBDG.AddSolider(m_buildParam.NewBuding as ISolider);
            m_pBDG.Add(soliderGameObject, "工兵");
        }
    }
예제 #3
0
    public CampSystem(PBDG_GameMain pBDG_Game) : base(pBDG_Game)
    {
        //数据可以是在配置表中取

        //兵营
        Camp camp1 = new Camp("Camp", 5, 2000, "Camp", "RookieCamp", false, "工兵");
        Camp camp2 = new Camp("Camp", 5, 2000, "Camp", "RookieCamp", false, "坦克");

        //所有数据先初始化
        campsList.Add(camp1);
        campsList.Add(camp2);

        for (int i = 0; i < 10; i++)
        {
            IAssetFactory factory = PBDGFactory.GetAssetFactory();
            GameObject    temp    = factory.CreatBuding("CaptiveCamp");
            temp.transform.position = new Vector3(Random.Range(-50, 50), 3.7f, Random.Range(-50, 50));
            pBDG_Game.Add(temp, "建筑物");
        }
    }
예제 #4
0
    //刷新显示
    public void RefreshShow()
    {
        //先获取所有兵营的信息
        List <ICamp> camps = pBDG_Game.GetCampList();

        for (int i = 0; i < camps.Count;)
        {
            GameObject temp = null;
            if (content.childCount > 0 && content.childCount - 1 >= i)
            {
                temp = content.GetChild(i).gameObject;
            }
            else
            {
                IAssetFactory Factory = PBDGFactory.GetAssetFactory();
                temp = Factory.Creat("prefab", "image_camp");
                temp.transform.SetParent(content, false);

                Button tempBtn = temp.GetComponent <Button>();
                tempBtn.onClick.AddListener(() =>
                {
                    pBDG_Game.CreatBuding(tempBtn.name);
                });
            }
            if (temp != null)
            {
                temp.name = camps[i].GetName();
                temp.GetComponent <Image>().sprite = ResourcesManager.Instance.Load <Sprite>("Sprites", camps[i].GetImage(), false);
            }

            if (camps[i].GetIsShow())
            {
                i++;
            }
            else
            {
                break;
            }
        }
    }