//创建一张卡片 public static CardEnemy create() { CardEnemy card = new CardEnemy(); card.init(); return(card); }
public static CardEnemy create(CardData cards) { CardEnemy card = new CardEnemy(); card.init(cards); return(card); }
private void addScript() { EnemyCollider cardCollision = this.cardObj.gameObject.AddComponent <EnemyCollider>(); CardEnemy card = this.cardObj.gameObject.AddComponent <CardEnemy>(); card.cardData = this.cardData; card.cardObj = this.cardObj; card.cardState = this.cardState; }
public void createCardObject(int pos) { CardData cardData = EnemyFightController.getInstance().substitute(pos); CardEnemy card = CardEnemy.create(cardData); card.setParent(parentGame); card.setPosition(new Vector3(Screen.width, 0, 0)); card.setScale(doSize * enemyCardScale); card.moveTo(viewPosList[pos], () => { _enemyCardNumsObj.text = (EnemyFightData.getInstance().cardsNumber() + EnemyFightData.getInstance().usingCardsNumber()).ToString(); }); viewCardDic.Add(pos, card); }
public void DestroyCardsObject(CardEnemy card) { int pos = card.cardData.Pos; int id = viewCardDic[pos].getCardData().getId(); //清理数据 EnemyFightController.getInstance().destroy(id); card.DestoryCard(); //清理对象 viewCardDic.Remove(pos); createCardObject(pos); }
void OnTriggerEnter(Collider coll) { if (coll.gameObject.name == "myPanel") { CardEnemy enemyCard = this.gameObject.GetComponent <CardEnemy>(); //爆炸效果 GameObject par = Instantiate(Resources.Load("Prefab/ColliderParticle") as GameObject); par.transform.parent = this.transform.parent; par.transform.localPosition = FightUIData.getInstance().MineVec3; //掉血效果 GameObject HpObj = Instantiate(Resources.Load("Prefab/Fight/dropBlood") as GameObject); Text Hp = HpObj.transform.GetComponent <Text>(); Debug.Log(Hp); Hp.transform.parent = this.transform.parent; Hp.transform.localPosition = FightUIData.getInstance().MineVec3; // - new Vector3(0,100,0); Hp.text = "-" + enemyCard.cardData.getNumber(); Sequence sq = DOTween.Sequence(); sq.SetRelative(); Tweener tw = HpObj.transform.DOLocalMoveY(Screen.height * 0.1f, 0.5f).SetEase(Ease.OutExpo).SetRelative(); tw.OnComplete(delegate() { DestroyObject(HpObj); }); sq.Join(tw); sq.Join(HpObj.transform.DOScale(new Vector3(1.5f, 1.5f, 1.5f), 0.5f)); touchEve(enemyCard); atk(); } else { CardEnemy enemyCard = this.gameObject.GetComponent <CardEnemy>(); enemyCard.correctRotate(); } }
void Start() { clearnDictionary(); _enemyCardNumsObj = enemyCardNumsObj; _hpObj = hpObj; EnemyFightController.getInstance().initEnemyFightData(); _enemyCardNumsObj.text = EnemyFightData.getInstance().cardsNumber().ToString(); _hpObj.text = EnemyFightData.getInstance().getHp().ToString(); parentGame = this.gameObject; //初始化摆位 //卡牌父节点尺寸 Vector2 vec2 = this.gameObject.transform.GetComponent <RectTransform>().sizeDelta; //卡牌节点尺寸 float itemWidth = 0.0f; float itemHeight = 0.0f; //卡牌间的距离间距 float space = 20.0f; //卡牌加间隙占的总宽度 float allCardWidth = 0.0f; //第一张卡牌的坐标位置 float fristX = 0.0f; doSize = 1.0f; float middPanelHeight = FightUIData.getInstance().getMiddHeight(); //初始化首发卡牌对象 Dictionary <int, CardData> cardDataDic = EnemyFightController.getInstance().getFristCards(); for (int i = 1; i <= cardDataDic.Count; i++) { CardEnemy card = CardEnemy.create(cardDataDic[i]); card.setParent(this.gameObject); if (1 == i) { itemWidth = card.getSize().x; itemHeight = card.getSize().y; if (AdaptationResolutionMG.getInstance().getDeviceSizeType() == DEVICE_SIZE_TYPE.Leng) { doSize = AdaptationResolutionMG.getInstance().getRawWidth() / (float)Screen.width; } else if (AdaptationResolutionMG.getInstance().getDeviceSizeType() == DEVICE_SIZE_TYPE.Compare) { doSize = AdaptationResolutionMG.getInstance().getDoSizeWidth(); } else { doSize = Screen.width / (float)(itemWidth * Const.FRIST_CARD_NUM + space * (Const.FRIST_CARD_NUM - 1)); } allCardWidth = (itemWidth * Const.FRIST_CARD_NUM) + (Const.FRIST_CARD_NUM - 1) * space; allCardWidth = allCardWidth * doSize; //表示已经超出屏幕 在现有的基础上再一次缩放 if (Screen.width < allCardWidth) { doSize = doSize * Screen.width / allCardWidth; } itemWidth = itemWidth * doSize; itemHeight = itemHeight * doSize; space = space * doSize; allCardWidth = (itemWidth * Const.FRIST_CARD_NUM) + (Const.FRIST_CARD_NUM - 1) * space; fristX = (Screen.width - allCardWidth) * 0.5f - Screen.width * 0.5f + itemWidth * 0.5f; } card.setScale(doSize * enemyCardScale); int key = cardDataDic[i].Pos; viewPosList.Add(key, new Vector2(fristX + (i - 1) * (itemWidth + space), -middPanelHeight * 0.5f + itemHeight * 1.3f)); viewCardDic.Add(key, card); card.setPosition(viewPosList[i]); } }
public static CardEnemy create(CardData cards) { CardEnemy card = new CardEnemy(); card.init(cards); return card; }
//创建一张卡片 public static CardEnemy create() { CardEnemy card = new CardEnemy(); card.init(); return card; }