// Start is called before the first frame update void Start() { editAsk = GameObject.Find("EventSystem").GetComponent <AskPanel>(); editenemiesCardList = GameObject.Find("enemytchoose").GetComponent <EnemiesCard>(); editManager = GameObject.Find("EventSystem").GetComponent <GameManager>(); editMyCard = GameObject.Find("myCard").GetComponent <MyCard>(); }
public void InitUserInfo(long uuid, string nickName, int characterIndex, int level, int index) { _index = index; _uuid = uuid; _nickName = nickName; _characterIndex = characterIndex; _level = level; _isEmpty = false; _currentCardCnt = 0; for (int n = 0; n < (int)eCardField.max; n++) { _completeCountDic.Add((eCardField)n, 0); _skillCubeTrack.Add((eCardField)n, new List <SkillCube>()); } for (int n = 0; n < _myPickCard.Length; n++) { if (_myPickCard[n] == null) { _myPickCard[n] = new MyCard(); } } }
public void OnToolTip(MyCard card, bool state) { for (int i = 0; i < _cards.Length; ++i) { if (card == _cards[i]) { cardInfo.SetCardInfo(_cards[i]); break; } } }
/// <summary> /// Sets the PicutreBox image using the underlying card and the orientation. /// </summary> public void UpdateCardImage() { // Set image. pbMyPictureBox.Image = MyCard.GetCardImage(); // If orientation is horizontal. if (myOrientation == Orientation.Horizontal) { // rotate the image. pbMyPictureBox.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); } }
public static async Task <List <MyPlaceableView> > CreatePlacable(MyCard data1, Transform parent, Vector3 Pos, Placeable.Faction faction) { List <MyPlaceableView> views = new List <MyPlaceableView>(); for (int i = 0; i < data1.placeablesIndices.Length; i++) { //取小兵ID var cardID = data1.placeablesIndices[i]; MyPlaceable placeable = null; for (int j = 0; j < MyPlaceableModel.instance.list.Count; j++) { //根据小兵ID找小兵 if (MyPlaceableModel.instance.list[j].id == cardID) { placeable = MyPlaceableModel.instance.list[j]; break; } } //取偏移 Vector3 offset = data1.relativeOffsets[i]; //实列小兵 //GameObject unitPrefad= Resources.Load<GameObject>((faction == Placeable.Faction.Player)? placeable.associatedPrefab: placeable.alternatePrefab); //var placeableInst = Instantiate(unitPrefad, parent, false); var ps = (faction == Placeable.Faction.Player) ? placeable.associatedPrefab : placeable.alternatePrefab; //异步实列小兵 GameObject placeableInst = await Addressables.InstantiateAsync(ps, parent, false).Task; //设置小兵偏移 placeableInst.transform.localPosition = offset; placeableInst.transform.position = Pos + offset; //赋值小兵数据 var p2 = placeable.Clone(); p2.faction = faction; placeableInst.GetComponent <MyPlaceableView>().data = p2; views.Add(placeableInst.GetComponent <MyPlaceableView>()); } return(views); }
public async Task <ActionResult <bool> > RemoveItemFromCard([FromBody] MyCard myCard) { bool result = true; using (var trans = _context.Database.BeginTransaction()) { try { _context.Remove(myCard); await _context.SaveChangesAsync(); trans.Commit(); } catch (Exception err) { trans.Rollback(); result = false; } } return(result); }
IEnumerator 卡牌创建到预览区(float delay) { // 延时创建卡牌 yield return(new WaitForSeconds(delay)); print($"AddToDeck"); // 随机创建一张牌 int iCard = Random.Range(0, MyCardModel.instance.list.Count); MyCard card = MyCardModel.instance.list[iCard]; GameObject cardPrefab = Resources.Load <GameObject>(card.cardPrefab); previewCard = Instantiate(cardPrefab, canvas).transform; // 为这张牌设置卡牌数据 previewCard.GetComponent <MyCardComponent>().data = card; previewCard.position = startPos.position; previewCard.localScale = Vector3.one * 0.5f; previewCard.DOMove(endPos.position, .2f); }
//用(async)声明为异步方法, 使用(await new)返回值必须为 Task(任务) public async Task 创建卡牌到预览区(float 延迟值) { await new WaitForSeconds(延迟值);//这里会创建一个Task,在await时C#会返回Task对象(任务) int iCard = Random.Range(0, MyCardModel.instance.list.Count); MyCard card = MyCardModel.instance.list[iCard]; //GameObject cardPrefab = Resources.Load<GameObject>(card.cardPrefab); ////GameObject cardPrefab = cardPrefabs[Random.Range(0, cardPrefabs.Length)]; //previewCard = Instantiate(cardPrefab).transform; //异步等待 GameObject cardPrefab = await Addressables.InstantiateAsync(card.cardPrefab).Task;//异步等待实例化完成 previewCard = cardPrefab.transform; previewCard.SetParent(canvas, false); // 位于父节点下的(0,0,0)偏移处 previewCard.localScale = Vector3.one * 0.7f; previewCard.position = startPos.position; previewCard.DOMove(endPos.position, 0.1f); previewCard.GetComponent <MyCardView>().data = card; }
/// <summary> /// Call card ToString. /// </summary> /// <returns></returns> public override string ToString() { return(MyCard.ToString()); }