private bool CheckSide(CardLine nextLine) { bool lineEmpty = true; switch (nextLine) { case CardLine.LEFT: lineEmpty = leftCastSpot.childCount <= 0; Game.Instance.RemoveObject(leftCastSpot.GetChild(0).GetComponent <EntityObject>()); break; case CardLine.CENTER: lineEmpty = centerCastSpot.childCount <= 0; Game.Instance.RemoveObject(centerCastSpot.GetChild(0).GetComponent <EntityObject>()); break; case CardLine.RIGHT: lineEmpty = rightCastSpot.childCount <= 0; Game.Instance.RemoveObject(rightCastSpot.GetChild(0).GetComponent <EntityObject>()); break; default: lineEmpty = false; break; } return(lineEmpty); }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); Destroy(this.gameObject, data.lifeTime); }
public void PlaceCardInLine(OCard card, CardLine line) { /* * * Debug.LogWarning("Check for Silence first"); * float castTime = card.CastTime; * foreach (var listener in castListiners) * { * var i = listener.Oncast(card, line); * if (i <= 0) return; * castTime *= i; * } * Debug.LogWarning(string.Format("cast time {0} ignored",castTime)); * * try * { * card.script.direction = 1; * card.script.Cast(line, 0, card.script.direction); * } * catch (Exception e) * { * ExceptionOperations eo = engine.GetService<ExceptionOperations>(); * string error = eo.FormatException(e); * Debug.LogError(string.Format("Error from {0} at \n{1}", card.Title,error)); * } */ }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); this.damage = data.damage; StartCoroutine(DoDamage(this, data.lifeTime)); }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); var fissures = FindObjectsOfType <Fisure.FisureController>(); foreach (var fiss in fissures) { switch (fiss.line) { case CardLine.LEFT: Instantiate(fiss, fiss.owner.centerCastSpot, false); Instantiate(fiss, fiss.owner.rightCastSpot, false); break; case CardLine.CENTER: Instantiate(fiss, fiss.owner.leftCastSpot, false); Instantiate(fiss, fiss.owner.rightCastSpot, false); break; case CardLine.RIGHT: Instantiate(fiss, fiss.owner.leftCastSpot, false); Instantiate(fiss, fiss.owner.centerCastSpot, false); break; } } if (fissures != null && fissures.Length > 0) { this.damage += 10; } Destroy(this.gameObject, 1.0f); }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); targets = new List <CardController>(); foreach (var c in FindObjectsOfType <CardController>()) { if (c.owner == this.owner) { continue; } var mage = c.GetComponent <MageCardController>(); if (mage != null) { mage.owner.Silence(0.5f); } targets.Add(c); } Destroy(this.gameObject, data.lifeTime); }
public OCard CreateCard(ScriptableCard nextCard, CardLine line, Mage owner) { OCard card = Instantiate(nextCard.logic).Setup(nextCard, line, owner); //engine.Execute(nextCard.logic.ToString(), card.script); return(card); }
public virtual OCard Setup(ScriptableCard staticData, CardLine line, Mage owner) { this.data = staticData; IsCastCompleted = false; this.ChoosedLine = line; this.Owner = owner; this.Title = staticData.title; return(this); }
public float GetXFromLine(CardLine line) { float x = 0; x = line.HasFlag(CardLine.LEFT) ? -1.5f : x; x = line.HasFlag(CardLine.CENTER) ? 0 : x; x = line.HasFlag(CardLine.RIGHT) ? 1.5f : x; x = line.HasFlag(CardLine.MAGE) ? 0f : x; return(x); }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); this.speed = data.speed; if (line == CardLine.CENTER) { this.damage = data.damage; } else { this.damage = data.lateralDamage; } }
// Update is called once per frame void Update() { var viewport = camera.ScreenToViewportPoint(Input.mousePosition); dragable.rectTransform.position = Input.mousePosition; dragable.textMesh.text = string.Format("{0:0}/{1:0}", player.mana, cardMana); //dragable.textMesh.color = cardMana >= player.mana ? highManaColor : lowManaColor; dragable.textMesh.faceColor = Color.Lerp(lowManaColor, highManaColor, player.mana / cardMana); LinePanel.gameObject.SetActive(highlight); if (viewport.x < 0.33f) { line = CardLine.LEFT; } else if (viewport.x >= 0.33f && viewport.x < 0.66f) { line = CardLine.CENTER; } else { line = CardLine.RIGHT; } animator.SetFloat("left", acceptableLines.HasFlag(CardLine.LEFT) && line == CardLine.LEFT ? 1 : 0); animator.SetFloat("center", acceptableLines.HasFlag(CardLine.CENTER) && line == CardLine.CENTER ? 1 : 0); animator.SetFloat("right", acceptableLines.HasFlag(CardLine.RIGHT) && line == CardLine.RIGHT ? 1 : 0); if (acceptableLines.HasFlag(CardLine.MAGE)) { line = CardLine.MAGE; } else if (acceptableLines.HasFlag(CardLine.ENEMY)) { line = CardLine.ENEMY; } animator.SetFloat("mage", acceptableLines.HasFlag(CardLine.MAGE) && line == CardLine.MAGE ? 1 : 0); animator.SetFloat("enemy", acceptableLines.HasFlag(CardLine.ENEMY) && line == CardLine.ENEMY ? 1 : 0); if (Input.GetMouseButtonUp(0)) { this.gameObject.SetActive(false); dragable.gameObject.SetActive(false); cardsOnHandViewer.SelectLine(line); } }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); this.speed = data.speed; if (line == CardLine.CENTER) { this.damage = data.damage; } else { this.damage = data.lateralDamage; } StartCoroutine(DoDamage(this, data.lifeTime)); }
public void Cast(ScriptableCard nextCard, CardLine line, Mage owner, Action <OCard> OnCastEnd) { var card = CreateCard(nextCard, line, owner); //var card = new Card(nextCard,line); card.SetCastCallBack(OnCastEnd); inCast.Add(card); if (owner.tag.Equals("Player")) { Array.ForEach(castTimerGroup, (c) => c.blocksRaycasts = true); Array.ForEach(castTimerImage, (c) => c.fillAmount = 1); } }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); var mages = FindObjectsOfType <Mage>(); if (mages[0] == this.owner) { enemy = mages[1]; } else { enemy = mages[0]; } this.speed = data.speed; }
public virtual void Setup(ScriptableCard data, CardLine line, Mage owner) { this.data = data; this.owner = owner; this.line = line; this.damage = data.damage; Transform lineTransform; switch (line) { case CardLine.LEFT: lineTransform = owner.leftCastSpot; break; case CardLine.CENTER: lineTransform = owner.centerCastSpot; break; case CardLine.RIGHT: lineTransform = owner.rightCastSpot; break; case CardLine.MAGE: lineTransform = owner.mage; break; case CardLine.ENEMY: lineTransform = owner.enemy; break; default: lineTransform = owner.centerCastSpot; break; } this.transform.position = lineTransform.position; this.transform.rotation = lineTransform.rotation; var rb = this.gameObject.AddComponent <Rigidbody>(); rb.useGravity = false; rb.isKinematic = false; var source = this.gameObject.AddComponent <AudioSource>(); AudioManager.PlayFromSourceInLocation(data.castClip, source, transform); }
public void ShowFor(CardLine acceptableLines, ScriptableCard card) { this.acceptableLines = acceptableLines; this.gameObject.SetActive(true); animator.SetFloat("left", acceptableLines.HasFlag(CardLine.LEFT) ? 0 : 0); animator.SetFloat("center", acceptableLines.HasFlag(CardLine.CENTER) ? 0 : 0); animator.SetFloat("right", acceptableLines.HasFlag(CardLine.RIGHT) ? 0 : 0); animator.SetFloat("mage", acceptableLines.HasFlag(CardLine.MAGE) ? 0 : 0); animator.SetFloat("enemy", acceptableLines.HasFlag(CardLine.ENEMY) ? 0 : 0); line = 0; dragable.gameObject.SetActive(true); dragable.sprite = card.icon; cardMana = card.mana; }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); this.damage = data.damage; //Debug.LogWarning("FindObjectsOfType in setup is a bad idea!!!"); var cards = FindObjectsOfType <CardController>(); this.damage -= 5 * cards.Length - 1; foreach (var c in cards) { c.TakeDamage(damage, data.element, DamageType.Direct, this); } }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); Destroy(this.gameObject, data.lifeTime); var cards = FindObjectsOfType <CardController>(); foreach (var c in cards) { if (c.owner == this.owner) { continue; } c.TakeDamage(data.damage, data.element, DamageType.Direct, this); } }
public float Oncast(OCard card, CardLine line) { /* * try * { * //return castCallBack?.Invoke(this.script, card.script, card.element, Game.Instance.GetXFromLine(line)); * return 0; * } * catch (Exception e) * { * //ExceptionOperations eo = engine.GetService<ExceptionOperations>(); * //string error = eo.FormatException(e); * Debug.LogError(string.Format("card {0} error \n {1}",card.Title,error)); * return 0; * } */ return(0); }
private void ChooseSide() { CardLine line; bool lineChoosed = false; do { int side = Random.Range(0, 5); switch (side) { case 0: line = CardLine.LEFT; break; case 1: line = CardLine.CENTER; break; case 2: line = CardLine.RIGHT; break; case 3: line = CardLine.MAGE; break; case 4: line = CardLine.ENEMY; break; default: line = CardLine.LEFT; break; } if (handCards[nextCard].acceptableLines.HasFlag(line)) { nextLine = line; lineChoosed = true; } } while (!lineChoosed); }
public void SelectLine(CardLine line) { var slot = transform.GetChild(lastCardIndex); slot.transform.GetChild(0).GetComponent <Image>().sprite = cardsOnHands[lastCardIndex].icon; var acceptableLines = cards[lastCardIndex].acceptableLines; if (!acceptableLines.HasFlag(line)) { return; } Vector2 point; RectTransformUtility.ScreenPointToLocalPointInRectangle(blockArea, Input.mousePosition, null, out point); if (point.y > (blockArea.rect.y + blockArea.rect.height) || point.y < 0 || point.x < blockArea.rect.x || point.x > (blockArea.rect.x + blockArea.rect.width)) { player.CastCard(lastCardIndex, line); LoadHands(); } }
public void CastCard(int nextCard, CardLine nextLine) { if (this.mana < handCards[nextCard].mana) { if (lowManaAudio != null) { audioSource.PlayOneShot(lowManaAudio); } return; } ; if (this.silence > 0) { return; } //CheckSide(nextLine); lineSelectionEvent?.FireEvent(nextLine); manager.Cast(handCards[nextCard], nextLine, this, OnCastEnd); animator.SetBool("isCasting", true); animator.SetFloat("Blend", (int)handCards[nextCard].animation); canCast = false; this.mana -= handCards[nextCard].mana; lastCard = handCards[nextCard]; handCards[nextCard] = null; cardChoosed = false; this.nextCard = nextCard; castStartEvent?.FireEvent(lastCard.cast); DrawCard(); }
public void AddObject(CardLine line, float y, int dir, float delay, Action <object> callback, dynamic scope) { /* * Debug.Log("AddObject"); * Transform lineTransform; * * switch (line) * { * case CardLine.LEFT: * lineTransform = scope.Card.Owner.leftCastSpot; * break; * case CardLine.CENTER: * lineTransform = scope.Card.Owner.centerCastSpot; * break; * case CardLine.RIGHT: * lineTransform = scope.Card.Owner.rightCastSpot; * break; * default: * lineTransform = scope.Card.Owner.centerCastSpot; * break; * } * * * * EntityObject entiy = GameObject.Instantiate<EntityObject>(entityPrefab,lineTransform.position, lineTransform.rotation); * entiy.transform.SetParent(lineTransform); * * * entiy.direction = dir; * entiy.engine = engine; * entiy.script = scope; * entitys.Add(entiy); * OCard card = scope.Card as OCard; * theCard = card; * card.entities.Add(entiy); * entiy.Owner = card.Owner; * * try * { * callback.Invoke(entiy); * } * catch (Exception e) * { * ExceptionOperations eo = engine.GetService<ExceptionOperations>(); * string error = eo.FormatException(e); * Debug.LogError(error); * } * entiy.audioSource.clip = card.staticData.castClip; * entiy.audioSource.Play(); * entiy.script.Card = card; * entiy.name = card.Title; * entiy.GetComponentInChildren<TextMeshProUGUI>().text = card.Title; * * entiy.GetComponentInChildren<Canvas>().transform.LookAt(Camera.main.transform); * * if (card.staticData.impactClip != null) * { * entiy.AddColisionCallback((d1,d2)=> { audioManager.PlayFromSourceInLocation(card.staticData.impactClip, entiy.audioSource,entiy.transform); }); * } * */ }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); this.life = data.blood; }
public override void Setup(ScriptableCard data, CardLine line, Mage owner) { base.Setup(data, line, owner); this.speed = data.speed; this.damage = data.damage / 3; }