protected override void PlaceCardInZone(CardController cardController, bool animated = true) { //cardController.IsFlipped = true; cardController.transform.SetParent(this.transform); SortCardInZone(true); }
protected override void HandleOnCardDragged(CardController card, Vector3 mousePosition) { base.HandleOnCardDragged(card, mousePosition); LineRenderer lineRenderer = card.gameObject.GetComponent<LineRenderer>(); lineRenderer.SetPosition(1, mousePosition); }
public override void Apply(CardController controller) { _controller = controller; _controllerSetter = new ControllerSetter(_newController); _controllerSetter.Initialize(ChangeTracker); _controller.AddModifier(_controllerSetter); }
protected override void HandleOnCardStartDraging(CardController card, Vector3 mousePosition) { base.HandleOnCardStartDraging (card, mousePosition); LineRenderer lineRenderer = card.gameObject.AddComponent<LineRenderer>(); lineRenderer.SetPosition(0, card.transform.position); lineRenderer.SetWidth(0.5f, 0.5f); }
public bool CanPutCardInResource(CardController card) { if (OnCanPutInResource != null) { return OnCanPutInResource(this, card); } return false; }
void Start() { cardTexture = GetComponent<SpriteRenderer>(); cardSlotScript = slotHolder.GetComponent<CardSlotManager> (); pairController = pair.GetComponent<CardController> (); Deselect (); }
public virtual void RemoveCardFromZone(CardController card) { if (_cardsInZone.Contains(card)) { _cardsInZone.Remove(card); } UnregisterFromCardEvents(card); SortCardInZone(true); }
void BuildCard(CardController card) { card.deckController = this.transform.GetComponent<Deck>(); card.CardSpeed = cardsInHand.Count; card.CardDirectionValue = cardsInHand.Count - 1; card.CardDirectionIsRight = cardsInHand.Count % 2 == 0 ? true : false; card.CardDescriptionText = "Description Text \n Goes Here"; card.targetPosition = transform.position; card.cardFront = ReturnCardFront(card.CardDirectionValue, card.CardDirectionIsRight, card); card.SetHandController(transform.GetComponent<AiHandController>()); }
public bool IsCardInZone(CardController card) { foreach (CardController cardInZone in _cardsInZone) { if (card == cardInZone) { return true; } } return false; }
public void PlayAtkCard(GameObject g) { Debug.Log ("entrou no playcard"); if (parent.selected == true) { if (cardcontroller == null) { cardcontroller = (CardController)parent.GetComponent("CardController"); } Debug.Log("Aguarde um round para poder atacar com essa carta"); if (parent.player2 !=null && parent.podeAtacar == true) { Debug.Log("Entro no if do ataque"); parent.podeAtacar = false; parent.PlayAtkCard(); parent.Deselect(); target = g; Debug.Log(target); Player1Status status = (Player1Status)target.GetComponent("Player1Status"); status.DealDamage((int)ataque); EventManager.Instance.OnTargetSelect -= PlayAtkCard; } if (parent.player1 !=null && parent.podeAtacar == true) { parent.podeAtacar = false; Debug.Log("Entro no if do ataque"); parent.PlayAtkCard(); parent.Deselect(); target = g; Debug.Log(target); Player2Status status = (Player2Status)target.GetComponent("Player2Status"); status.DealDamage((int)ataque); EventManager.Instance.OnTargetSelect -= PlayAtkCard; } } // GameObject fb_prefab = Resources.Load<GameObject>("Prefabs/SpellEffects/Fireball"); // fireball = (GameObject)GameObject.Instantiate(fb_prefab); // fireball.transform.position = new Vector3(0, -6.0f, 0); // ProjectileBehavior pb = (ProjectileBehavior)fireball.GetComponent("ProjectileBehavior"); // pb.SetDestination(g.transform.position); //EventManager.Instance.OnCardAnimationEnd += AnimationEnd; // Vector3 pos = target.transform.position; // Destroy(fireball); // GameObject fb_prefab = Resources.Load<GameObject>("Prefabs/SpellEffects/Explosion"); // fireball = (GameObject)GameObject.Instantiate(fb_prefab); // fireball.transform.position = pos; }
public virtual void AddCardToZone(CardController card, bool animated = true) { if (card != null && !_cardsInZone.Contains(card)) { _cardsInZone.Add(card); this.PlaceCardInZone(card, animated); RegisterToCardEvents(card); SortCardInZone(animated); } }
public void AddCard(CardController card, eZoneType zone = eZoneType.Library) { _playerCardsDictionary.Add(card.UniqueId, card); if (zone == eZoneType.Library) { _libraryContainer.AddCardToZone(card); } else { Debug.LogError("Unsupported zone to add card!"); } //card.transform.SetParent(this.gameObject.transform); }
// Use this for initialization void Start() { if (fort1 == null || fort2 == null) { fort1 = GetComponentsInChildren<Fort>()[0]; fort2 = GetComponentsInChildren<Fort>()[1]; } _cardControllerInstance = FindObjectOfType<CardController>(); _player1 = new Player(fort1); _player2 = new Player(fort2); _activePlayer = _player1; _player1.Fort.myWinLose += OnWinLoseCondition; _player2.Fort.myWinLose += OnWinLoseCondition; }
public void PlayCard(GameObject g) { Debug.Log("CHAMOU METODO CURAR CARTA"); if (parent.selected == true) { if (cardcontroller == null) { cardcontroller = (CardController)parent.GetComponent("CardController"); } Debug.Log("CARTA CURA CARTA"); if (podeUsar == true) { Debug.Log("ESTA CURANDO"); podeUsar = false; parent.PlayCard(); parent.Deselect(); target = g; Debug.Log(target); CardController status = (CardController)target.GetComponent("CardController"); CardController statusparent = (CardController)parent.GetComponent("CardController"); status.defesa = status.defesa+4; EventManager.Instance.OnTargetSelect -= PlayCard; if (player1 != null) { GameObject carta = player1.campo[parent.position]; player1.campo.RemoveAt(parent.position); Destroy (carta); player1.OrganizeCards(); Debug.Log ("RETIRANDO BARRICADA DO CAMPO"); } if (player2 != null) { GameObject carta = player2.campo[parent.position]; player2.campo.RemoveAt(parent.position); Destroy (carta); player2.OrganizeCards(); Debug.Log ("RETIRANDO BARRICADA DO CAMPO 2"); } } } }
public void Attack(CardController card) { card.model.Damage(at); }
// Update is called once per frame void Update() { if (_playerCamera.isActiveAndEnabled) { Ray ray; RaycastHit hit; ray = _playerCamera.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(ray, out hit)) { //Debug.Log("hit: " + hit.collider.name); CardController cardController = hit.collider.gameObject.GetComponent<CardController>(); if (cardController != null) { if (cardController.Card != null && cardController.Card.Controller == _player) { // my card if (_selectedCard != null && cardController != _selectedCard) { _selectedCard.CardEndHover(); _selectedCard = null; } if (cardController != null && cardController != _selectedCard) { cardController.CardHover(); _selectedCard = cardController; } } else { // opponent card } } } if (hit.collider == null && _selectedCard != null) { _selectedCard.CardEndHover(); _selectedCard = null; } if (_isCurrentTurn) { if (Input.GetMouseButtonDown(0)) { // mouse down if (_selectedCard != null) { _screenPoint = Camera.main.WorldToScreenPoint(_selectedCard.transform.position); _offset = _selectedCard.transform.position - _playerCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, _screenPoint.z)); _selectedCard.CardStartDraging(_offset); } } if (Input.GetMouseButtonUp(0)) { // mouse up if (_selectedCard != null) { ZoneControllerAbstract releasedInZone = null; if(Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.GetMask("Zones"))) { releasedInZone = hit.collider.gameObject.GetComponent<ZoneControllerAbstract>(); } if (releasedInZone != null) { TryToPlayCardToZone(_selectedCard, releasedInZone); } else { Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, _screenPoint.z); Vector3 curPosition = _playerCamera.ScreenToWorldPoint(curScreenPoint); _selectedCard.CardEndDraging(curPosition); } _selectedCard = null; } } if (Input.GetMouseButton(0)) { // mouse drag if (_selectedCard != null) { Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, _screenPoint.z); Vector3 curPosition = _playerCamera.ScreenToWorldPoint(curScreenPoint); _selectedCard.CardDragged(curPosition); } } } } }
protected virtual void RegisterToCardEvents(CardController card) { card.OnCardClicked += HandleOnCardClicked; card.OnCardIsDragged += HandleOnCardDragged; card.OnCardHover += HandleOnCardHover; card.OnCardEndHover += HandleOnCardEndHover; card.OnCardStartDraging += HandleOnCardStartDraging; card.OnCardEndDraging += HandleOnCardEndDraging; }
public void GenerateFieldCard() { lackCostTextObject.SetActive(false); decideTextObject.SetActive(false); CleanField(); CardController[] mixCardController = new CardController[2] { null, null }; CardController eatCardController; for (int i = 0; i < 2; i++) { mixCardController[i] = null; } for (int i = 0; i < 2; i++) { if (selectCardController[i] != null) { mixCardController[i] = cardGenerator.CreateCard(false, selectCardController[i].model.cardID, selectCardController[i].model.cost, selectCardController[i].model.isRare, mixFieldTransform[i]); mixCardController[i].model.cal = selectCardController[i].model.cal; //mixCardController[i].view.SetCard(mixCardController[i].model); mixCardController[i].GetComponent <CardView>().SetCard(mixCardController[i].model); } } //if (cardID[0] == -1) //{ // uiManager.decideButtonObj.SetActive(false); // return; //} //合成チェック if (mixCardController[1] != null) { if (mixCardController[0].model.kind == mixCardController[1].model.kind) { //合成不可 //uiManager.decideButtonObj.SetActive(false); return; } else { //Debug.Log("aaa"); //合成 int mixCardID = cardGenerator.SpecialMix(mixCardController[0], mixCardController[1]); Debug.Log(mixCardID); eatCardController = cardGenerator.CreateEatCard(true, mixCardID, 0, false, mixFieldTransform[2]); //eatCardController.eatView.SetEatCard(eatCardController.model); eatCardController.GetComponent <EatCardView>().SetEatCard(eatCardController.model); //コストがある時 if (player.cost >= 3) { decideTextObject.SetActive(true); } else { lackCostTextObject.SetActive(true); } } } else if (mixCardController[0] != null) { //uiManager.decideButtonObj.SetActive(true); eatCardController = cardGenerator.CreateEatCard(false, mixCardController[0].model.cardID, mixCardController[0].model.cost, mixCardController[0].model.isRare, mixFieldTransform[2]); eatCardController.model.cal = mixCardController[0].model.cal; eatCardController.model.cost = mixCardController[0].model.cost; //eatCardController.eatView.SetEatCard(eatCardController.model); eatCardController.GetComponent <EatCardView>().SetEatCard(eatCardController.model); decideTextObject.SetActive(true); } else { return; } }
// Start is called before the first frame update void Awake() { thisCard = new CardController(); //lineRenderer = GetComponent<LineRenderer>(); }
void TimBai() { Debug.Log("TimBai"); Debug.Log("CCCCCCCCCCCC" + Controller.CardOnDesk.Count); if (Controller.CardOnDesk.Count == 1) { Debug.Log("CardOnDesk = 1"); foreach (var a in Controller.CardOnDesk) { cardOnDesk = a; _cardOnDeskController = cardOnDesk.GetComponent <CardController>(); } foreach (var a in Controller.CardsComputer) { CardController _cardController = a.GetComponent <CardController>(); _cardController.AddGiaTri((a.name).Trim()); if (_cardController.tenChat == _cardOnDeskController.tenChat && int.Parse(_cardController.giaTri) > int.Parse(_cardOnDeskController.giaTri)) { lstCard.Add(a); } } if (lstCard.Count != 0) { objMin = TimGiaTriNhoNhat(lstCard); objMinController = objMin.GetComponent <CardController>(); objMin.GetComponent <SpriteRenderer>().sortingOrder = Controller.thutuhabai; Controller.thutuhabai++; switch (objMinController.tenChat) { case "C": objMin.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Co/" + objMin.name); break; case "D": objMin.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Do/" + objMin.name); break; case "B": objMin.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Bich/" + objMin.name); break; case "N": objMin.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Nhep/" + objMin.name); break; } Controller.CardComputerOnDesk.Add(objMin); lstHaBai.Add(objMin); Controller.CardsComputer.Remove(objMin); } else { GameObject.Find("Canvas").GetComponent <BoLuotScript>().BoLuot(); } GameObject.Find("Canvas").GetComponent <HaBaiScript>().MoveCard(lstHaBai); lstCard.Clear(); Controller.CardOnDesk.Clear(); Controller.Turn = 1; } else if (Controller.CardOnDesk.Count == 0) { Debug.Log("CardOnDesk = 0"); objMin = TimGiaTriNhoNhat(Controller.CardsComputer); objMinController = objMin.GetComponent <CardController>(); objMin.GetComponent <SpriteRenderer>().sortingOrder = Controller.thutuhabai; Controller.thutuhabai++; switch (objMinController.tenChat) { case "C": objMin.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Co/" + objMin.name); break; case "D": objMin.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Do/" + objMin.name); break; case "B": objMin.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Bich/" + objMin.name); break; case "N": objMin.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Nhep/" + objMin.name); break; } Controller.CardComputerOnDesk.Add(objMin); lstHaBai.Add(objMin); GameObject.Find("Canvas").GetComponent <HaBaiScript>().MoveCard(lstHaBai); lstCard.Clear(); Controller.CardOnDesk.Clear(); Controller.CardsComputer.Remove(objMin); Controller.Turn = 1; } lstHaBai.Clear(); }
// Use this for initialization void Start() { cardController = GetComponent<CardController>(); }
public void PutCardInResource(CardController card) { if (OnPutCardInResource != null) { OnPutCardInResource(this, card); } }
private void PlayCard(CardController card) { if (OnPlayCard != null) { OnPlayCard(this, card); } }
private void HandlePlayCard(PlayerController playerController, CardController cardController) { _netherWarsEngine.PlayCard(playerController.Player, cardController.Card); }
private bool HandleOnCanPutCardInResources(PlayerController playerController, CardController cardController) { return _netherWarsEngine.CanPutCardInResources(playerController.Player, cardController.Card); }
public override void SwapHand(CardController newCard) { base.SwapHand(newCard); MyPerceptor.UpdateOwnHand(newCard, justDrawn); }
// Use this for initialization void Start() { Screen.orientation = ScreenOrientation.Portrait; AudioSource[] audios = GetComponents <AudioSource> (); foreach (AudioSource au in audios) { if (au.clip.name.Equals("camera-click-nikon")) { audioPressButton = au; } else if (au.clip.name.Equals("dealing-card")) { audioDealingCard = au; } else if (au.clip.name.Equals("card-flip")) { audioFlipCard = au; } else if (au.clip.name.Equals("error")) { audioError = au; } else if (au.clip.name.Equals("coinclap")) { audioCoinClap = au; } else if (au.clip.name.Equals("cheap-flash-game-tune")) { musicScene = au; } else if (au.clip.name.Equals("piglevelwin2")) { endGameAudio = au; } } timeToWait = 1; timeToCancelOperation = -10; matChoosePanel.gameObject.SetActive(true); matChoosePanel.open(); matCampInitied = false; fadePlane.gameObject.SetActive(true); operationManager.gameObject.SetActive(true); activeScore = true; timeToActiveScore = -10; score = 0; currentScore = 0; timeToAddScore = 0.2f; textScore = scorePanel.transform.Find("Score").gameObject.GetComponent <Text>(); timeScoreToWhite = 0; timeToOpenEndGameWindow = -10; totalTime = 0; if (Player.instance == null) { new Player(0, 0, 0); } Player.instance.initPlayer(); if (Player.instance.getSprtCashier() != null) { cashier.GetComponent <SpriteRenderer> ().sprite = Player.instance.getSprtCashier(); } if (Player.instance.getSprtCard() != null) { CardController pf_card = prefabCard.GetComponent <CardController> (); prefabCard.GetComponent <SpriteRenderer> ().sprite = Player.instance.getSprtCard(); pf_card.back = Player.instance.getSprtCard(); } totalTime = -10; }
public IEnumerator EnemyTurn() { Debug.Log("Enemyのターン"); // フィールドのカードを攻撃可能にする CardController[] enemyFieldCardList = gameManager.enemyFieldTransform.GetComponentsInChildren <CardController>(); gameManager.SettingCanAttackView(enemyFieldCardList, true); yield return(new WaitForSeconds(1)); /* 場にカードをだす */ // 手札のカードリストを取得 CardController[] handCardList = gameManager.enemyHandTransform.GetComponentsInChildren <CardController>(); // コスト以下のカードがあれば、カードをフィールドに出し続ける // 条件:モンスターカードならコストのみ // 条件:スペルならコストと、使用可能かどうか(CanUseSpell) while (Array.Exists(handCardList, card => (card.model.cost <= gameManager.enemy.manaCost) && (!card.IsSpell || (card.IsSpell && card.CanUseSpell())))) { // コスト以下のカードリストを取得 CardController[] selectableHandCardList = Array.FindAll(handCardList, card => (card.model.cost <= gameManager.enemy.manaCost) && (!card.IsSpell || (card.IsSpell && card.CanUseSpell()))); // 場に出すカードを選択 CardController selectCard = selectableHandCardList[0]; // カードを表にする selectCard.Show(); // スペルカードなら使用する if (selectCard.IsSpell) { StartCoroutine(CastSpellOf(selectCard)); } else { // カードを移動 StartCoroutine(selectCard.movement.MoveToField(gameManager.enemyFieldTransform)); selectCard.OnFiled(); } yield return(new WaitForSeconds(1)); handCardList = gameManager.enemyHandTransform.GetComponentsInChildren <CardController>(); } yield return(new WaitForSeconds(1)); /* 攻撃 */ // フィールドのカードリストを取得 CardController[] fieldCardList = gameManager.enemyFieldTransform.GetComponentsInChildren <CardController>(); //攻撃可能カードがあれば攻撃を繰り返す while (Array.Exists(fieldCardList, card => card.model.canAttack)) { // 攻撃可能カードを取得 CardController[] enemyCanAttackCardList = Array.FindAll(fieldCardList, card => card.model.canAttack); // 検索:Array.FindAll CardController[] playerFieldCardList = gameManager.playerFieldTransform.GetComponentsInChildren <CardController>(); // attackerカードを選択 CardController attacker = enemyCanAttackCardList[0]; if (playerFieldCardList.Length > 0) { // defenderカードを選択 // シールドカードのみ攻撃対象にする if (Array.Exists(playerFieldCardList, card => card.model.ability == ABILITY.SHIELD)) { playerFieldCardList = Array.FindAll(playerFieldCardList, card => card.model.ability == ABILITY.SHIELD); } CardController defender = playerFieldCardList[0]; // attackerとdefenderを戦わせる StartCoroutine(attacker.movement.MoveToTarget(defender.transform)); yield return(new WaitForSeconds(0.51f)); gameManager.CardsBattle(attacker, defender); } else { StartCoroutine(attacker.movement.MoveToTarget(gameManager.playerHero)); yield return(new WaitForSeconds(0.25f)); gameManager.AttackToHero(attacker); yield return(new WaitForSeconds(0.25f)); gameManager.CheckHeroHP(); } fieldCardList = gameManager.enemyFieldTransform.GetComponentsInChildren <CardController>(); yield return(new WaitForSeconds(1)); } yield return(new WaitForSeconds(1)); gameManager.ChangeTurn(); }
public int[] SelectCard() { int[] selectCardIndex = new int[2] { -1, -1 }; int cost = player[1].cost; //チュートリアルは一枚だけ選択 if (tutorial) { selectCardIndex[0] = 0; return(selectCardIndex); } if (cpuLevel == 1) { //合成する数 int mixNum = -1; //ランダム if (cost == 6) { mixNum = 2; } else if (cost >= 3) { int num = Random.Range(1, cost); if (num == 1) { mixNum = 1; } else { mixNum = 2; } } else { mixNum = 1; } //単体 if (mixNum == 1) { selectCardIndex[0] = Random.Range(0, 4); } //料理 else { //捨てるレア素材の選択 List <int> cardIndex = new List <int>(); for (int i = 0; i < 4; i++) { cardIndex.Add(i); } for (int i = 0; i < mixNum; i++) { selectCardIndex[i] = cardIndex[Random.Range(0, cardIndex.Count)]; cardIndex.Remove(selectCardIndex[i]); } CardController[] cardController = new CardController[2]; for (int i = 0; i < 2; i++) { cardController[i] = gameManager.handTransform[1, selectCardIndex[i]].transform.GetChild(0).GetComponent <CardController>(); } //同じ属性か料理不可 if (cardController[0].model.kind == cardController[1].model.kind || cardController[0].model.condition == 0 || cardController[1].model.condition == 0) { selectCardIndex[1] = -1; } } } else if (cpuLevel == 2) { //合成する数 int mixNum = -1; //ランダム if (cost == 6) { mixNum = 2; } else if (cost >= 3) { int num = Random.Range(1, cost); if (num == 1) { mixNum = 1; } else { mixNum = 2; } } else { mixNum = 1; } //単体 if (mixNum == 1) { bool bad = false; //悪い食材を優先 for (int i = 0; i < 4; i++) { if (gameManager.handTransform[1, i].GetChild(0).GetComponent <CardController>().model.condition == 0) { selectCardIndex[0] = i; bad = true; break; } } if (!bad) { selectCardIndex[0] = Random.Range(0, 4); } } //料理 else { //レア素材を探す int rareIndex = -1; for (int i = 0; i < 4; i++) { if (gameManager.handTransform[1, i].GetChild(0).GetComponent <CardController>().model.condition == 2) { rareIndex = i; break; } } //捨てるレア素材の選択 List <int> cardIndex = new List <int>(); //レアあり if (rareIndex != -1) { //レア以外入れる for (int i = 0; i < 4; i++) { if (i == rareIndex) { continue; } cardIndex.Add(i); } int a = Random.Range(0, cardIndex.Count); selectCardIndex[1] = cardIndex[a]; selectCardIndex[0] = rareIndex; } else { for (int i = 0; i < 4; i++) { cardIndex.Add(i); } for (int i = 0; i < mixNum; i++) { selectCardIndex[i] = cardIndex[Random.Range(0, cardIndex.Count)]; cardIndex.Remove(selectCardIndex[i]); } } CardController[] cardController = new CardController[2]; for (int i = 0; i < 2; i++) { cardController[i] = gameManager.handTransform[1, selectCardIndex[i]].transform.GetChild(0).GetComponent <CardController>(); } //同じ属性か料理不可 if (cardController[0].model.kind == cardController[1].model.kind || cardController[0].model.condition == 0 || cardController[1].model.condition == 0) { selectCardIndex[1] = -1; } } } else if (cpuLevel == 3) { //合成する数 int mixNum = -1; //即合成 if (cost >= 4) { mixNum = 2; } else if (cost >= 3) { int num = Random.Range(1, cost); if (num == 1) { mixNum = 1; } else { mixNum = 2; } } else { mixNum = 1; } //単体 if (mixNum == 1) { bool bad = false; //悪い食材を優先 for (int i = 0; i < 4; i++) { if (gameManager.handTransform[1, i].GetChild(0).GetComponent <CardController>().model.condition == 0) { selectCardIndex[0] = i; bad = true; break; } } if (!bad) { selectCardIndex[0] = Random.Range(0, 4); } } //料理 else { CardController[] cardController = new CardController[4]; for (int i = 0; i < 4; i++) { cardController[i] = gameManager.handTransform[1, i].GetChild(0).GetComponent <CardController>(); } //bad以外を入れる //List<int> cardIndex = new List<int>(); //for (int i = 0; i < 4; i++) //{ // if (cardController[i].model.condition == 0) // { // continue; // } // cardIndex.Add(i); //} int maxCal = -1; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { if (cardController[i].model.condition == 0 || cardController[j].model.condition == 0) { continue; } if (cardController[i].model.kind == cardController[j].model.kind) { continue; } int mixCardID = cardGenerator.SpecialMix(cardController[i], cardController[j]); CardEntity cardEntity = Resources.Load <CardEntity>("CardEntityList/Dishes/Card" + mixCardID); int cal = cardEntity.cal; if (cal > maxCal) { maxCal = cal; selectCardIndex[0] = i; selectCardIndex[1] = j; } } } if (maxCal < 0) { selectCardIndex[0] = 0; } cardController[0] = null; cardController[1] = null; for (int i = 0; i < 2; i++) { cardController[i] = gameManager.handTransform[1, selectCardIndex[i]].GetChild(0).GetComponent <CardController>(); } //同じ属性か料理不可 if (cardController[0].model.kind == cardController[1].model.kind || cardController[0].model.condition == 0 || cardController[1].model.condition == 0) { selectCardIndex[1] = -1; } } } return(selectCardIndex); }
public void GenerateFieldCard() { CleanField(); messageTextObj[0].SetActive(false); messageTextObj[1].SetActive(false); CardController[] mixCardController = new CardController[2] { null, null }; CardController eatCardController; for (int i = 0; i < 2; i++) { mixCardController[i] = null; } for (int i = 0; i < 2; i++) { if (selectCardController[i] != null) { mixCardController[i] = cardGenerator.CreateCard(false, selectCardController[i].model.cardID, selectCardController[i].model.cost, selectCardController[i].model.condition, mixFieldTransform[i]); mixCardController[i].model.cal = selectCardController[i].model.cal; mixCardController[i].GetComponent <CardView>().SetCookingCard(mixCardController[i].model); mixCardController[i].GetComponent <CanvasGroup>().blocksRaycasts = false; } } //合成チェック if (mixCardController[1] != null) { if (mixCardController[0].model.kind == mixCardController[1].model.kind) { //合成不可 messageTextObj[1].SetActive(true); return; } else { //合成 int mixCardID = cardGenerator.SpecialMix(mixCardController[0], mixCardController[1]); bool isStrong = false; if (mixCardController[0].model.condition == 2 || mixCardController[1].model.condition == 2) { isStrong = true; } //チュートリアル if (GameManager.instance.tutorial) { if (GameManager.instance.tutorialNum == 0) { messageTextObj[0].SetActive(true); messageTextObj[0].GetComponent <TextMeshProUGUI>().text = "食材を1つ" + "\nえらぼう!"; return; } //レア以外を使っている場合 else if (GameManager.instance.tutorialNum == 2) { if (!isStrong) { messageTextObj[0].SetActive(true); messageTextObj[0].GetComponent <TextMeshProUGUI>().text = "レア食材を" + "\n材料にしよう!"; return; } } } eatCardController = cardGenerator.CreateEatCard(true, mixCardID, 0, 0, mixFieldTransform[2]); eatCardController.model.isStrong = isStrong; eatCardController.GetComponent <EatCardView>().SetEatCard(eatCardController.model); //コストがあってBadでない if (player.cost >= 3 && mixCardController[0].model.condition > 0 && mixCardController[1].model.condition > 0) { //eatCardController.model.canSelected = true; eatCardController.GetComponent <CanvasGroup>().blocksRaycasts = true; eatCardController.GetComponent <EatCardView>().SetErrorMessage(2); eatCardController.GetComponent <EatCardView>().StartBlinking(); } else { eatCardController.GetComponent <EatCardView>().StopBlinking(); //eatCardController.model.canSelected = false; eatCardController.GetComponent <CanvasGroup>().blocksRaycasts = false; if (player.cost < 3) { eatCardController.GetComponent <EatCardView>().SetErrorMessage(0); } else { eatCardController.GetComponent <EatCardView>().SetErrorMessage(1); } } } } else if (mixCardController[0] != null) { //チュートリアル中に単体で押せないように if (GameManager.instance.tutorial) { //bottomText.text = "好きな食材を" + "\nえらぼう!"; if (GameManager.instance.tutorialNum == 1 || GameManager.instance.tutorialNum == 2) { messageTextObj[0].SetActive(true); messageTextObj[0].GetComponent <TextMeshProUGUI>().text = "食材を2つ" + "\nえらぼう!"; return; } } eatCardController = cardGenerator.CreateEatCard(false, mixCardController[0].model.cardID, mixCardController[0].model.cost, mixCardController[0].model.condition, mixFieldTransform[2]); eatCardController.model.cal = mixCardController[0].model.cal; eatCardController.model.cost = mixCardController[0].model.cost; eatCardController.GetComponent <EatCardView>().SetEatCard(eatCardController.model); eatCardController.GetComponent <EatCardView>().StartBlinking(); //eatCardController.model.canSelected = true; eatCardController.GetComponent <CanvasGroup>().blocksRaycasts = true; eatCardController.GetComponent <EatCardView>().SetErrorMessage(2); } else { messageTextObj[0].GetComponent <TextMeshProUGUI>().text = "好きな食材を" + "\nえらぼう!"; messageTextObj[0].SetActive(true); return; } }
protected abstract void PlaceCardInZone(CardController cardController, bool animated = true);
public override float TakeDamage(float damage, Elements element, DamageType damageType, CardController other) { if (element == Elements.Wind) { Destroy(this.gameObject); } ; return(damage); }
protected virtual void UnregisterFromCardEvents(CardController card) { card.OnCardClicked -= HandleOnCardClicked; card.OnCardIsDragged -= HandleOnCardDragged; card.OnCardHover -= HandleOnCardHover; card.OnCardEndHover -= HandleOnCardEndHover; card.OnCardStartDraging -= HandleOnCardStartDraging; card.OnCardEndDraging -= HandleOnCardEndDraging; }
protected override void OnCardSent(CardController sentCard) { base.OnCardSent(sentCard); UpdatePileSizeText(); }
public void OnEndDrag(PointerEventData eventData) { Vector3 worldPosition1; //Vector3 mousePos = Input.mousePosition; transform.position = new Vector3(transform.position.x, transform.position.y, 1); // important pour detecter la zone if (Camera.main != null) { worldPosition1 = Camera.main.ScreenToWorldPoint(Input.mousePosition); worldPosition1.z = -1 * worldPosition1.z; print(-1 * Vector2.up); print(Vector2.up); RaycastHit2D hit = Physics2D.Raycast(worldPosition1, -Vector2.up); if (hit.collider != null) { print(hit.collider.name); if (hit.collider.name == "ZoneNormal(Clone)(Clone)") { ZoneController zc = hit.collider.GetComponent <ZoneController>(); zc.onDropOn(); zc.onDropOnCard(cardName); if (cardName == TresorCard.TresorCardName.Sandbag) { if (zc.GetZone().getEtat() == Etat.EtatName.Inondee) { zc.GetZone().setEtat(Etat.EtatName.Normale); //TODO GERER ICI LE SANDBAG, JE LE DEFAUSSE PAS JE LE LAISSE LA this.p.defausseCard(cardName); } } else if (cardName == TresorCard.TresorCardName.Helicopter) { this.p.movePlayer(zc.GetZone(), zc); this.p.defausseCard(cardName); //TODO GERER ICI helicopter } //print(hit.collider.GetComponent<ZoneController>().GetZone().getPosition().ToString()); // ici je recupere un composant de la zaone // il suffit alors de faire ce que tu as à faire... } } print(hit.normal); print(hit.centroid); // transform.position = new Vector3(transform.position.x, transform.position.y, 10); // important pour detecter la zone if (hit.collider.name == "Card(Clone)(Clone)") { print(hit.collider.name); print("CARTE DONENEEEE"); PanelCardController p = hit.collider.transform.parent.GetComponent <PanelCardController>(); CardController cc = hit.collider.transform.GetComponent <CardController>(); if (this.cardName != TresorCard.TresorCardName.Empty && p.p != this.p) { exchangeCard(cc, p); } //p.transform = p.initPos; /* pos.localPosition = new Vector3(pos.localPosition.x, * 0 , * pos.localPosition.z );*/ // pos = hit.collider.transform.parent.GetComponent<PanelCardController>(); /*PanelCardController p = hit.collider.transform.parent.GetComponent<PanelCardController>(); * print( p.p.ToString()); */ } if (pbc != null) { pbc.showPanel(); } transform.position = new Vector3(transform.position.x, transform.position.y, -5); // important pour detecter la zone transform.localPosition = initPos; } }
private void TryToPlayCardToZone(CardController card, ZoneControllerAbstract zone) { switch (zone.ZoneType) { case eZoneType.Battlefield: { if (CanPlayCard(card)) { PlayCard(card); } else { card.CardEndDraging(Vector3.zero); } break; } case eZoneType.ResourcePool: { if (CanPutCardInResource(card)) { PutCardInResource(card); } else { card.CardEndDraging(Vector3.zero); } break; } default: { break; } } }
/// <summary> /// Print out a card and its content /// </summary> /// <param name="card">The card to print out</param> public void card(Card card, CardController controller) { cardHeadline(card.name); Console.WriteLine(); if (!card.description.Equals("")) { Console.WriteLine(EyeCandy.indent(6) + card.description); } else { EyeCandy.color("yellow"); Console.WriteLine(EyeCandy.indent(6) + "[ Use --description to add a description ]"); EyeCandy.reset(); } Console.WriteLine(); Console.WriteLine(); if (controller.getChecklists(card.id).Count == 0) { EyeCandy.color("yellow"); Console.WriteLine(EyeCandy.indent(6) + "[ Use --new-check to add a new checklist ]"); EyeCandy.reset(); } // Checklist section int br = 0; int brChk = 0; foreach (Checklist checklist in controller.getChecklists(card.id)) { brChk++; Console.WriteLine("[" + brChk + "] " + checklist.name); if (!controller.getChecklistPoints(checklist.id).Any()) { EyeCandy.color("yellow"); Console.WriteLine(EyeCandy.indent(6) + "[ Use --new-point to add a new checklist point ]"); EyeCandy.reset(); } // Checklist points foreach (ChecklistPoint point in controller.getChecklistPoints(checklist.id)) { br++; string outCountP = "[" + br + "] "; // Colors, colors everywhere! if (point.isCheck) { EyeCandy.color("green"); } Console.WriteLine(EyeCandy.indent(2) + outCountP + point.name); EyeCandy.reset(); } Console.WriteLine(); } Console.WriteLine(); comments(controller.getComments(card.id)); }
/// <summary> /// Constructor method will find CardController and MatchController scripts. /// </summary> // Use this for initialization void Start() { cardController = FindObjectOfType(typeof(CardController)) as CardController; matchController = FindObjectOfType(typeof(MatchController)) as MatchController; }
static void Main(string[] args) { ICardController cardController = new CardController(); cardController.Run(); }
public override Power GetGrantedPower(CardController cardController) { return(new Power(cardController.HeroTurnTakerController, this, $"{cardController.Card.Title} deals 1 target 6 energy damage.", UseGrantedPower(), 0, null, cardController.GetCardSource())); }
//合成予測を出す public void SelectCard(CardController cardController, bool isSelected) { //選択した時 if (isSelected) { //何も選択されていない if (selectCardController[0] == null) { selectCardController[0] = cardController; } //2つ目に選択 else if (selectCardController[1] == null) { selectCardController[1] = cardController; } //2つ目と入れ替え else { selectCardController[1].model.isSelected = false; selectCardController[1] = cardController; } } //キャンセルした時 else { //1枚目に選択してた時 if (selectCardController[0] == cardController) { //2枚目に選択してたカードなし if (selectCardController[1] == null) { selectCardController[0] = null; } //2枚目に選択したカードを1枚目にする else { selectCardController[0] = selectCardController[1]; selectCardController[1] = null; } } //2枚目に選択してた時 else { selectCardController[1] = null; } } //選択カーソル for (int i = 0; i < 4; i++) { cursorObj[i].SetActive(false); } for (int i = 0; i < 2; i++) { if (selectCardController[i] != null) { cursorObj[selectCardController[i].model.index].SetActive(true); cursorObj[selectCardController[i].model.index].transform.GetChild(1).GetComponent <Image>().sprite = numberSprite[i]; } } GenerateFieldCard(); }
public void ReturnToPool(CardController card) { card.gameObject.SetActive(false); card.GetComponent <RectTransform>().rotation = Quaternion.identity; cards.Enqueue(card); }
public void FillCardData(CardController card) { }
public void Delete() => CardController.Delete(Thootle);
protected override void OnCardRecieveTweenFinished(CardController card) { base.OnCardRecieveTweenFinished(card); UpdatePileSizeText(); }
public void Edit() => CardController.Edit(Thootle);
private void HandleOnPutCardInResource(PlayerController playerController, CardController cardController) { _netherWarsEngine.PutCardInResources(playerController.Player, cardController.Card); }
private void Awake() { _instance = this; }
private bool HandleOnCanPlayCard(PlayerController playerController, CardController card) { return _netherWarsEngine.CanPlayCard(playerController.Player, card.Card); }
public void OnDespawn() { Controller = null; // Release the reference for GC. }
public void DiscardCard(CardController card) { // TODO: lerp this into the discard pile DestroyImmediate(card.gameObject); }
/// <summary> /// Initialize card UI /// </summary> /// <param name="card">Card model for initialize</param> /// <param name="cardController">Card controller of this card</param> public void Initialize(Card card, CardController cardController) { LoadArtImage(); SetTexts(card); this.cardController = cardController; }
public void SetCard(CardController card, bool dynamicNumbers = true) { thisCard = card; Card.CasterColor casterColor; if (card.GetCard().manaCost == 0) { switch (card.GetCard().casterColor) { case (Card.CasterColor.Blue): cardBack.sprite = blueAttackBack; casterColor = Card.CasterColor.Blue; break; case (Card.CasterColor.Red): cardBack.sprite = redAttackBack; casterColor = Card.CasterColor.Red; break; case (Card.CasterColor.Green): cardBack.sprite = greenAttackBack; casterColor = Card.CasterColor.Green; break; case (Card.CasterColor.Enemy): cardBack.sprite = blackCardBack; casterColor = Card.CasterColor.Enemy; break; default: cardBack.sprite = greyCardBack; casterColor = Card.CasterColor.Gray; break; } } else { switch (card.GetCard().casterColor) { case (Card.CasterColor.Blue): cardBack.sprite = blueSkillBack; casterColor = Card.CasterColor.Blue; break; case (Card.CasterColor.Red): cardBack.sprite = redSkillBack; casterColor = Card.CasterColor.Red; break; case (Card.CasterColor.Green): cardBack.sprite = greenSkillBack; casterColor = Card.CasterColor.Green; break; case (Card.CasterColor.Enemy): cardBack.sprite = blackCardBack; casterColor = Card.CasterColor.Enemy; break; default: cardBack.sprite = greyCardBack; casterColor = Card.CasterColor.Gray; break; } } art.sprite = card.GetCard().art; outline.sprite = cardBack.sprite; cardGreyOut.sprite = cardBack.sprite; cardName.text = card.GetCard().name; //Resolve energy and mana cost int netManaCost = card.GetCard().manaCost; int netEnergyCost = card.GetCard().energyCost; if (dynamicNumbers) { try { netManaCost = card.GetNetManaCost(); netEnergyCost = card.GetNetEnergyCost(); } catch { } } manaCost.text = netManaCost.ToString(); energyCost.text = netEnergyCost.ToString(); if (netManaCost < card.GetCard().manaCost) { manaCost.color = Color.green; } else if (netManaCost > card.GetCard().manaCost) { manaCost.color = Color.red; } else { manaCost.color = Color.white; } if (netEnergyCost < card.GetCard().energyCost) { energyCost.color = Color.green; } else if (netEnergyCost > card.GetCard().energyCost) { energyCost.color = Color.red; } else { energyCost.color = Color.white; } if (casterColor != Card.CasterColor.Enemy && casterColor != Card.CasterColor.Gray) { foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Player")) { if (obj.GetComponent <PlayerController>().GetColorTag() == casterColor) { card.SetCaster(obj); break; } } } description.text = card.GetCard().description.Replace('|', '\n'); if (dynamicNumbers) { string descriptionText = description.text; while (descriptionText.IndexOf("<s>") != -1) { int start = descriptionText.IndexOf("<s>"); int end = descriptionText.IndexOf("</s>"); string attackText = descriptionText.Substring(start, end - start + 4); int percentage = 100; int.TryParse(descriptionText.Substring(start + 3, descriptionText.IndexOf("%") - start - 3), out percentage); string finalText = ""; int bonusAttack = 0; finalText = (Mathf.CeilToInt(GetComponent <CardController>().FindCaster(thisCard.GetCard()).GetComponent <HealthController>().GetAttack() * percentage / 100.0f)).ToString(); bonusAttack = GetComponent <CardController>().FindCaster(thisCard.GetCard()).GetComponent <HealthController>().GetBonusAttack(); if (bonusAttack > 0) { finalText = "*" + finalText + "*"; } else if (bonusAttack < 0) { finalText = "-" + finalText + "-"; } descriptionText = descriptionText.Replace(attackText, finalText); } while (descriptionText.IndexOf("<c>") != -1) { int start = descriptionText.IndexOf("<c>"); int end = descriptionText.IndexOf("</c>"); string cardText = descriptionText.Substring(start, end - start + 4); string newCardText = cardText.Replace("x", TurnController.turnController.GetNumerOfCardsPlayedInTurn().ToString()) .Replace("<c>", "") .Replace("</c>", ""); descriptionText = descriptionText.Replace(cardText, newCardText); } while (descriptionText.IndexOf("<ba>") != -1) { int start = descriptionText.IndexOf("<ba>"); int end = descriptionText.IndexOf("</ba>"); string cardText = descriptionText.Substring(start, end - start + 5); string newCardText = cardText.Replace("x", card.GetCaster().GetComponent <HealthController>().GetBonusShield().ToString()) .Replace("<ba>", "") .Replace("</ba>", ""); descriptionText = descriptionText.Replace(cardText, newCardText); } description.text = descriptionText; } else { description.text = description.text.Replace("<s>", "").Replace("</s>", ""); int start = description.text.IndexOf("<c>"); int end = description.text.IndexOf("</c>"); if (start != -1) { description.text = description.text.Replace(description.text.Substring(start, end - start + 4), ""); } start = description.text.IndexOf("<ba>"); end = description.text.IndexOf("</ba>"); if (start != -1) { description.text = description.text.Replace(description.text.Substring(start, end - start + 5), ""); } } }
protected virtual void HandleOnCardClicked(CardController card) { }
public void GenerateMana(CardController card, BoardEntity board) { board.mana.model.greenMana.Value += card.model.greenPerTurn.Value; board.mana.model.blueMana.Value += card.model.bluePerTurn.Value; board.mana.model.redMana.Value += card.model.redPerTurn.Value; }
protected virtual void HandleOnCardDragged(CardController card, Vector3 mousePosition) { }
public override IEnumerator UsePower(int index = 0) { IEnumerator coroutine; List <int> powerNumerals = new List <int>() { GetPowerNumeral(0, 3), GetPowerNumeral(1, 1) }; List <DiscardCardAction> storedResults = new List <DiscardCardAction>(); string spacedPrefixTitle = ""; string spacedSuffixTitle = ""; CardSource cardSource = this.GetCardSource(); // Only fetch once to pass through all references. // Discard prefix. coroutine = this.GameController.SelectAndDiscardCards(this.DecisionMaker, 1, false, 0, storedResults, false, cardCriteria: new LinqCardCriteria((Card c) => c.DoKeywordsContain("prefix"), "prefix"), cardSource: cardSource); if (this.UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } if (storedResults.Count > 0 && storedResults.FirstOrDefault().IsSuccessful) { Card c = storedResults.FirstOrDefault().CardToDiscard; CardController cc = this.FindCardController(c); if (cc is SpellforgeSharedModifierCardController) { // Type matches, everything should be implemented now! SpellforgeSharedModifierCardController wcc = (SpellforgeSharedModifierCardController)this.FindCardController(c); this.AddToTemporaryTriggerList(wcc.AddModifierTrigger(cardSource)); spacedPrefixTitle = c.Definition.AlternateTitle + " "; } } // Discard suffix. storedResults.Clear(); coroutine = this.GameController.SelectAndDiscardCards(this.DecisionMaker, 1, false, 0, storedResults, false, cardCriteria: new LinqCardCriteria((Card c) => c.DoKeywordsContain("suffix"), "suffix"), cardSource: cardSource); if (this.UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } if (storedResults.Count > 0 && storedResults.FirstOrDefault().IsSuccessful) { Card c = storedResults.FirstOrDefault().CardToDiscard; CardController cc = this.FindCardController(c); if (cc is SpellforgeSharedModifierCardController) { // Type matches, everything should be implemented now! SpellforgeSharedModifierCardController wcc = (SpellforgeSharedModifierCardController)this.FindCardController(c); this.AddToTemporaryTriggerList(wcc.AddModifierTrigger(cardSource)); spacedSuffixTitle = " " + c.Definition.AlternateTitle; } } if (spacedPrefixTitle.Length > 0 || spacedSuffixTitle.Length > 0) { coroutine = this.GameController.SendMessageAction("{Spellforge} uses " + spacedPrefixTitle + this.CharacterCard.Definition.Body.FirstOrDefault() + spacedSuffixTitle + "!", Priority.Low, cardSource); if (this.UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } } // Deal up to 3 targets 1 infernal (as a base). coroutine = this.GameController.SelectTargetsAndDealDamage(this.DecisionMaker, new DamageSource(this.GameController, this.CharacterCard), powerNumerals[1], DamageType.Infernal, powerNumerals[0], false, 0, false, false, false, null, null, null, null, null, false, null, null, false, null, cardSource); if (this.UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } // Clear all temporary triggers created by this card. this.RemoveTemporaryTriggers(); }
protected virtual void HandleOnCardHover(CardController card) { }
public MemorizeState(CardController cardController, float memorizeTime) : base(cardController) { this.memorizeTime = memorizeTime; }
protected virtual void HandleOnCardStartDraging(CardController card, Vector3 mousePosition) { }