예제 #1
0
    // 根据当前卡牌模板复制一张新的卡牌对象
    // this 是卡牌模板
    // NewMinionCard 是生成的新的卡牌实例
    public override Card GetCopy()
    {
        SpellCard NewSpellCard = new SpellCard();

        // 1.将新卡的释放效果链接到模板卡的释放效果
        NewSpellCard.SetSpellEffect(SpellEffect);

        // 2.创建法术实例并将引用进行设置
        //NewMinionCard.SetMinionPiece(GetWorldOperationController().CreatePieceForCard((string)GetParameter("HandCardID")));
        //NewMinionCard.GetMinionPiece().GetComponentInChildren<PieceStateController>().SetCard(NewMinionCard);
        //NewMinionCard.GetMinionPiece().GetComponentInChildren<PieceStateController>().DisplayPiece();


        // 3.创建卡面显示GameObject并设置引用
        // ---------------------------------------------
        // 获取卡面物体预制体
        GameObject MainHandCardBasePrefab = (GameObject)Resources.Load("Prefabs/HandCardBase");

        // 实例化卡面物体
        NewSpellCard.SetMainHandCardBase(GameObject.Instantiate(MainHandCardBasePrefab));
        // 将卡面物体的卡牌引用设置为当前卡牌
        NewSpellCard.GetMainHandCardBase().GetComponent <HandCardController>().SetCard(NewSpellCard);

        // 将卡面物体放置于Canvas下
        NewSpellCard.GetMainHandCardBase().transform.SetParent(GameObject.Find("Canvas").gameObject.transform);
        // 设置默认位置
        NewSpellCard.GetMainHandCardBase().GetComponent <RectTransform>().localPosition = new Vector3(0, 0, 0);
        // 将卡面物体隐藏
        //MainHandCardBase.SetActive(false);
        // ---------------------------------------------
        return(NewSpellCard);
    }