private void DrawMagicCircle(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource, bool newState) { // Always allow us to stop showing the magic circle if (!newState) { magicCircleSpriteRenderer.enabled = false; spellLineRenderer.enabled = false; // When the magic circle goes away, enable the selected spell if (selectedSpell != null) { selectedSpell.OnSelected(hand); } return; } // When the magic circle comes up, deselect the active spell if (selectedSpell != null) { selectedSpell.OnDeselected(); selectedSpell = null; } // Only draw the magic circle if we're not in the middle of a conversation if (dialogInteractor.activeDialogManager == null || !dialogInteractor.activeDialogManager.isDialogActive) { magicCircleSpriteRenderer.enabled = true; Vector3 dirFromEyeToHand = hand.transform.position - Player.instance.hmdTransform.transform.position; transform.position = hand.transform.position + (dirFromEyeToHand.normalized * spawnDistance); transform.LookAt(Player.instance.hmdTransform, Vector3.up); } }
public void AddSpellToHand(BaseSpell spell) { SpellInHand = spell; GameObject spellPrefab = GameController.Instance.SpellController.GetSpellPrefabByType(spell.SpellType); SpellPrefab = Instantiate(spellPrefab, transform); }
/// <summary> /// Plays a spell /// </summary> /// <param name="spell">The spell to play</param> /// <param name="subTarget">The sub target for this spell card if applicable</param> /// <param name="cardEffect">The card effect to use</param> public void PlaySpell(BaseSpell spell, IDamageableEntity subTarget = null, CardEffect cardEffect = CardEffect.NONE) { if (subTarget != null && subTarget is BaseMinion) { if (((BaseMinion)subTarget).IsImmuneToSpellTarget || ((BaseMinion)subTarget).IsStealthed) { throw new InvalidOperationException("Can't target minion that is immune to spell targeting or is stealthed"); } } // Remove it from the player's hand this.hand.Remove(spell); // Remove mana from the player this.Mana -= spell.CurrentManaCost; // Fire spell casting event bool shouldAbort; GameEventManager.SpellCasting(spell, subTarget, out shouldAbort); // Check if we need to abort the spell or redirect if (!shouldAbort) { spell.Activate(subTarget, cardEffect); } // Fire spell casted event (if we need to) }
public int CalculateDamage(BaseSpell spell) { var values = Enum.GetValues(typeof(Element)); int totalDamage = 0; foreach (Element e in values) { int partialDamage = spell.Damage[e]; if (partialDamage > 0) { for (int i = 0; i < this.slots; i++) { int gemDefense = gems[i].Damage[e]; if (gemDefense > 0) { partialDamage = Mathf.Clamp(partialDamage - gemDefense, 0, partialDamage); gems[i] = null; } } totalDamage += partialDamage; } } return(totalDamage); }
public void AddSpellToPlayer(SpellType spell, PlayerController player) { Debug.Log("Spell" + spell + " has added to player."); BaseSpell spellObject = GetSpellByType(spell); player.PlayerHand.AddSpellToHand(spellObject); }
public BaseSpell DetectSpell() { if (spellPlane.availableSpells.Count == 0) { return(null); } float minDistance = 9999f; BaseSpell detectedSpell = spellPlane.availableSpells[0]; float currentDistance; foreach (BaseSpell spell in spellPlane.availableSpells) { currentDistance = CalculateDistance(spell.sigil); if (currentDistance < minDistance) { minDistance = currentDistance; detectedSpell = spell; } } return(detectedSpell); }
/// <summary> /// 打出一张法术牌 /// </summary> /// <param name="spell"></param> /// <param name="target"></param> public void CastSpell(BaseSpell spell, int target) { var currentUserContext = GameContext.GetActivationUserContext(); //var enenmyUserContext = gameContext.GetNotActivationUserContext(); currentUserContext.Power -= spell.Cost < 0 ? 0 : spell.Cost; //currentUserContext.HandCards.Remove(spell); GameContext.CastCardCount++; spell.CastIndex = GameContext.CastCardCount; GameContext.ParachuteCard = spell; spell.CardLocation = CardLocation.降落伞; Card triggerCard = null; if (target > -1) { triggerCard = GameContext.DeskCards[target]; } var para = new ActionParameter() { GameContext = GameContext, PrimaryCard = spell, SecondaryCard = triggerCard, }; GameContext.EventQueue.AddLast(new BeforeICastSpellEvent() { EventCard = spell, Parameter = para }); GameContext.AddActionStatement(spell.CardAbility, para); GameContext.AddActionStatement(new ComboOnAction(), para); // spell.CardAbility.Action(para); spell.CardLocation = CardLocation.灵车; GameContext.HearseCards.AddLast(spell); GameContext.EventQueue.AddLast(new PrimaryPlayerPlayCardEvent() { EventCard = spell, Parameter = new ActionParameter() { GameContext = GameContext, PrimaryCard = spell, SecondaryCard = triggerCard, } }); GameContext.EventQueue.AddLast(new AfterICastSpellEvent() { EventCard = spell, Parameter = para }); GameContext.Settlement(); _gameCache.SetContext(GameContext); }
private void OnSpellCasting(BaseSpell spell, IDamageableEntity target, out bool shouldAbort) { if (spell.Owner == this.Owner) { var fireball = HearthEntityFactory.CreateCard<Fireball> (); this.Owner.AddCardToHand (fireball); } shouldAbort = false; }
public void RemoveSpell() { if (SpellPrefab != null) { Destroy(SpellPrefab); } SpellInHand = null; }
static void CastOnAll(BaseEntity attacker, List <BaseEntity> defenders, Random r) { BaseSpell spell = attacker.Spells.Keys.ElementAt(r.Next(0, attacker.Spells.Keys.Count)); foreach (BaseEntity defender in defenders) { Console.WriteLine(attacker.Name + " cast " + spell.Name + " on " + defender.Name + " for " + attacker.CastSpell(spell, defender, r)); } }
private void OnSpellCasting(BaseSpell spell, IDamageableEntity target, out bool shouldAbort) { if (spell.Owner == this.Owner) { var fireball = HearthEntityFactory.CreateCard <Fireball> (); this.Owner.AddCardToHand(fireball); } shouldAbort = false; }
public void Setup(BaseSpell data) { if (data.Action != null) { actionReceiver = gameObject.AddComponent(data.Action.GetType()) as IActionReceiver; actionReceiver.Setup(data.Action as IActionReceiver); actionReceiver.Action(transform.position, 0f); } }
public override void Init() { _image = GetComponent <Image>(); _spell = SpellsCollection.Instance.GetSpell(_spellType); _spell.CooldownStarted += EmptiedDisplay; _spell.CooldownUpdated += UpdateDisplay; _spell.CooldownFinished += FillDisplay; }
public override void OnInspectorGUI() { DrawDefaultInspector(); if (serializedObject.FindProperty("warhead").hasMultipleDifferentValues) { return; } BaseSpell spell = (BaseSpell)target; spell.warhead = DrawSelector(spell.warhead); }
void ToggleChosen(BaseSpell spell) { if (_activeSpells.Contains(spell)) { _activeSpells.Remove(spell); } else { _activeSpells.Add(spell); } UpdatePanel(); }
public static void OnSpellCasting(BaseSpell spell, IDamageableEntity target, out bool shouldAbort) { shouldAbort = false; if (!_spellCastingListeners.Any()) { return; } // Listeners for this are called in the order in which they were played on the board var sortedListeners = _spellCastingListeners.OrderBy(kvp => kvp.Item1.TimePlayed).ToList(); foreach (var handler in sortedListeners.Select(kvp => kvp.Item2)) { handler(spell, target, out shouldAbort); } }
private void OnTriggerEnter2D(Collider2D obj) { if (obj.CompareTag("SpellItem")) { SpellItem spell = obj.gameObject.GetComponent <SpellItem>(); if (spell == null) { Debug.LogError("SpellItem component is null"); return; } spell.SpellCollected(this, spell.SpellType); } else if (obj.CompareTag("Hand")) { if (obj.transform.childCount > 0) { GameController.Instance.SpellController.StaticSpell(this, obj.gameObject.GetComponentInParent <PlayerController>()); } else { Debug.LogError("It shouldnt enter here"); } } else if (obj.CompareTag("Spell")) { PlayerController sender = obj.gameObject.GetComponentInParent <PlayerController>(); PlayerController receiver = this; BaseSpell usedSpell = obj.gameObject.GetComponentInParent <BaseSpell>(); if (usedSpell.SpellType == SpellType.Taser) { TaserSpell asd = (TaserSpell)usedSpell; asd.UseSpell(sender, receiver); } } }
public Spells() { Items = new List <BaseSpell>(); goblinWave = new GoblinWave(); Items.Add(goblinWave); wolfPack = new WolfPack(); Items.Add(wolfPack); siege = new Siege(); Items.Add(siege); orcWave = new OrcWave(); Items.Add(orcWave); trollWave = new TrollWave(); Items.Add(trollWave); blackHorsemen = new BlackHorsemen(); Items.Add(blackHorsemen); giant = new Giant(); Items.Add(giant); dragon = new Dragon(); Items.Add(dragon); spark = new Spark(); Items.Add(spark); eletroCharge = new EletroCharge(); Items.Add(eletroCharge); lightning = new Lightning(); Items.Add(lightning); discharge = new Discharge(); Items.Add(discharge); thunderShock = new ThunderShock(); Items.Add(thunderShock); thunderBolt = new ThunderBolt(); Items.Add(thunderBolt); lightningStorm = new LightningStorm(); Items.Add(lightningStorm); thunder = new Thunder(); Items.Add(thunder); mudStrike = new MudStrike(); Items.Add(mudStrike); rockThrow = new RockThrow(); Items.Add(rockThrow); vineWhip = new VineWhip(); Items.Add(vineWhip); razorLeaf = new RazorLeaf(); Items.Add(razorLeaf); seedBombs = new SeedBombs(); Items.Add(seedBombs); rockBlast = new RockBlast(); Items.Add(rockBlast); photosynthesis = new Photosynthesis(); Items.Add(photosynthesis); earthQuake = new Earthquake(); Items.Add(earthQuake); wave = new Wave(); Items.Add(wave); whirlwind = new Whirlwind(); Items.Add(whirlwind); icyspikes = new IcySpikes(); Items.Add(icyspikes); ringoffrost = new RingOfFrost(); Items.Add(ringoffrost); frozenPillar = new FrozenPillar(); Items.Add(frozenPillar); frostWave = new FrostWave(); Items.Add(frostWave); storm = new Storm(); Items.Add(storm); blizzard = new Blizzard(); Items.Add(blizzard); fireball = new Fireball(); Items.Add(fireball); firewave = new Firewave(); Items.Add(firewave); imoloate = new Imoloate(); Items.Add(imoloate); fireblast = new FireBlast(); Items.Add(fireblast); ringoffire = new RingOfFire(); Items.Add(ringoffire); lavastrike = new LavaStrike(); Items.Add(lavastrike); dragonBreath = new DragonBreath(); Items.Add(dragonBreath); }
public void Discard(BaseSpell s) { hand.Remove(s); }
private void Cast(BaseSpell spell) { BaseSpell spawnedSpell = Instantiate(spell); spawnedSpell.gameObject.SetActive(true); }
public void Add_Spell(BaseSpell c) { spell_inventory.Add(c); }
public abstract void LaunchSpell(BasePlayer enemy, BaseSpell spell);
public abstract void ReceiveDamage(BaseSpell spell);
public void Select_Finisher(string spell) { switch(spell) { case "combo": player_choice = combo_finisher_spell; break; case "reflect": player_choice = reflect_finisher_spell; break; case "affliction": player_choice = affliction_finisher_spell; break; } current_state = BattleStates.ENEMYCHOICE; }
// Update is called once per frame void Update() { switch (current_state) { case BattleStates.START: if (!start_phase) { start_phase = true; // Opening animation // Player draws opening hand player.Player_Spell_Book.Draw_Hand(); enemy.Player_Spell_Book.Draw_Hand(); // Display information to player Display_Spells(); current_state = BattleStates.BEGIN; } break; case BattleStates.BEGIN: if (!begin_phase) { begin_phase = true; //player.Players_Summon.Poison = 10; //player.Players_Summon.Burn = 10; player_choice = null; enemy_choice = null; player_made_choice = false; remove_indexs = new List<int>(); string ppd = (-Poisoned(player)).ToString(); string epd = (-Poisoned(enemy)).ToString(); string pbd = (-Burned(player)).ToString(); string ebd = (-Burned(enemy)).ToString(); poison_dmg.GetComponentInChildren<Text>().text = "Poison: " + ppd; burn_dmg.GetComponentInChildren<Text>().text = "Burn: " + pbd; Setup_Burn_Text(pbd, ebd); Start_Burn_Text(); Setup_Poison_Text(ppd, epd); Start_Poison_Text(); Display_Results(); if(Game_Over()) { break; } Reset_Spell_Buttons(); current_state = BattleStates.PLAYERCHOICE; } break; case BattleStates.PLAYERCHOICE: if (!player_phase) { player_phase = true; Enable_Spells(); Disable_Finishers(); if (Paralyzed(player)) { if (UnityEngine.Random.Range(0, 101) < 50) { //Player is paralyzed message Debug.Log("Player is paralyzed and can't move"); paralyze_dmg.GetComponentInChildren<Text>().text = "Paralyze: true"; current_state = BattleStates.ENEMYCHOICE; break; } } paralyze_dmg.GetComponentInChildren<Text>().text = "Paralyze: false"; // Draw for turn left_log.GetComponentsInChildren<Text>()[0].text = "Select a spell to cast"; Draw(); Display_Spells(); } break; case BattleStates.ENEMYCHOICE: if (!enemy_phase) { enemy_phase = true; if (Paralyzed(enemy)) { if (UnityEngine.Random.Range(0, 101) < 50) { current_state = BattleStates.RESULTS; break; } } enemy_cast(); current_state = BattleStates.RESULTS; } break; case BattleStates.RESULTS: if (!results_phase) { results_phase = true; Thread.Sleep(500); Calculate_Results(); Display_Results(); if(Game_Over()) { break; } //current_state = BattleStates.RESET; } break; case BattleStates.RESET: begin_phase = false; player_phase = false; enemy_phase = false; results_phase = false; current_state = BattleStates.BEGIN; break; case BattleStates.LOSE: if (!lose_phase) { lose_phase = true; if(GameManager.instance.tournament_mode) { Tournament.instance.Player_Lost(); finish_window.GetComponentsInChildren<Button>()[0].onClick.RemoveAllListeners(); finish_window.GetComponentsInChildren<Button>()[0].onClick.AddListener(() => { Return_To_Tournament(); }); } player_summon_sprite.layer = 9; enemy_summon_sprite.layer = 9; Lose_Popup(); } break; case BattleStates.WIN: if (!win_phase) { win_phase = true; if (GameManager.instance.tournament_mode) { Tournament.instance.Player_Won(); finish_window.GetComponentsInChildren<Button>()[0].onClick.RemoveAllListeners(); finish_window.GetComponentsInChildren<Button>()[0].onClick.AddListener(() => { Return_To_Tournament(); }); } player_summon_sprite.layer = 9; enemy_summon_sprite.layer = 9; Win_Popup(); } break; case BattleStates.TIE: if (!tie_phase) { tie_phase = true; if (GameManager.instance.tournament_mode) { Tournament.instance.Player_Lost(); finish_window.GetComponentsInChildren<Button>()[0].onClick.RemoveAllListeners(); finish_window.GetComponentsInChildren<Button>()[0].onClick.AddListener(() => { Return_To_Tournament(); }); } player_summon_sprite.layer = 9; enemy_summon_sprite.layer = 9; Tie_Popup(); } break; } }
static void PrintSpell(BaseEntity attacker, BaseEntity defender, Random r) { BaseSpell spell = attacker.Spells.Keys.ElementAt(r.Next(0, attacker.Spells.Keys.Count)); Console.WriteLine(attacker.Name + " cast " + spell.Name + " on " + defender.Name + " for " + attacker.CastSpell(spell, defender, r)); }
public void Select_Spell(string spell) { switch(spell) { case "Spell_1": if(player_made_choice) { spell_1.GetComponentsInChildren<Image>()[0].color = red; spell_1.GetComponentsInChildren<Button>()[0].interactable = false; remove_indexs.Add(0); break; } spell_1.GetComponentsInChildren<Image>()[0].color = green; spell_1.GetComponentsInChildren<Button>()[0].interactable = false; left_log.GetComponentsInChildren<Text>()[0].text = "Select a spell to discard"; player_choice = player.Player_Spell_Book.Hand[0]; remove_indexs.Add(0); break; case "Spell_2": if (player_made_choice) { spell_2.GetComponentsInChildren<Image>()[0].color = red; spell_2.GetComponentsInChildren<Button>()[0].interactable = false; remove_indexs.Add(1); break; } spell_2.GetComponentsInChildren<Image>()[0].color = green; spell_2.GetComponentsInChildren<Button>()[0].interactable = false; left_log.GetComponentsInChildren<Text>()[0].text = "Select a spell to discard"; player_choice = player.Player_Spell_Book.Hand[1]; remove_indexs.Add(1); break; case "Spell_3": if (player_made_choice) { spell_3.GetComponentsInChildren<Image>()[0].color = red; spell_3.GetComponentsInChildren<Button>()[0].interactable = false; remove_indexs.Add(2); break; } spell_3.GetComponentsInChildren<Image>()[0].color = green; spell_3.GetComponentsInChildren<Button>()[0].interactable = false; left_log.GetComponentsInChildren<Text>()[0].text = "Select a spell to discard"; player_choice = player.Player_Spell_Book.Hand[2]; remove_indexs.Add(2); break; case "Spell_4": if (player_made_choice) { spell_4.GetComponentsInChildren<Image>()[0].color = red; spell_4.GetComponentsInChildren<Button>()[0].interactable = false; remove_indexs.Add(3); break; } spell_4.GetComponentsInChildren<Image>()[0].color = green; spell_4.GetComponentsInChildren<Button>()[0].interactable = false; left_log.GetComponentsInChildren<Text>()[0].text = "Select a spell to discard"; player_choice = player.Player_Spell_Book.Hand[3]; remove_indexs.Add(3); break; } if(player_made_choice) { remove_indexs.Sort(); player.Player_Spell_Book.Discard(remove_indexs[0]); player.Player_Spell_Book.Discard(remove_indexs[1]-1); current_state = BattleStates.ENEMYCHOICE; } player_made_choice = true; }
/* * Dumb AI */ private void enemy_cast() { int r = UnityEngine.Random.Range(0, 101); if(r <= 25) { enemy_choice = enemy.Player_Spell_Book.Hand[0]; } else if (r <= 50) { enemy_choice = enemy.Player_Spell_Book.Hand[1]; } else if (r <= 75) { enemy_choice = enemy.Player_Spell_Book.Hand[2]; } else { enemy_choice = enemy.Player_Spell_Book.Hand[3]; } enemy.Player_Spell_Book.Discard(0); enemy.Player_Spell_Book.Discard(0); enemy.Player_Spell_Book.Draw_For_Turn(); }
// Use this for initialization void Start() { player = GameManager.instance.player; enemy = GameManager.instance.enemy; player_summon_image.GetComponentsInChildren<Image>()[0].sprite = Load_Summon_Image(player); enemy_summon_image.GetComponentsInChildren<Image>()[0].sprite = Load_Summon_Image(enemy); player_summon_image.SetActive(false); enemy_summon_image.SetActive(false); player_summon_sprite = Load_Summon_Sprite(player); enemy_summon_sprite = Load_Summon_Sprite(enemy); player_summon_sprite = (GameObject)Instantiate(player_summon_sprite, new Vector3(-3.5f, 1.5f, -1), Quaternion.identity); player_summon_sprite.GetComponent<Transform>().localScale = new Vector3(3, 3, 1); enemy_summon_sprite = (GameObject)Instantiate(enemy_summon_sprite, new Vector3(3.5f, 1.5f, -1), Quaternion.identity); enemy_summon_sprite.GetComponent<Transform>().localScale = new Vector3(-3, 3, 1); player_made_choice = false; start_phase = false; begin_phase = false; player_phase = false; lose_phase = false; win_phase = false; tie_phase = false; position_1 = spell_1.transform.localPosition; position_2 = spell_2.transform.localPosition; position_3 = spell_3.transform.localPosition; position_4 = spell_4.transform.localPosition; finish_window_position = finish_window.transform.localPosition; off_screen = new Vector2(1000, 1000); Setup_Finishers(); Setup_Spell_Font(); green = new UnityEngine.Color(0, 214, 0); red = new UnityEngine.Color(255, 0, 0); start_height = player_hp_bar.GetComponent<Image>().rectTransform.rect.height; player_hp_text.GetComponent<Text>().fontSize = (int)(Screen.width * 0.018f); enemy_hp_text.GetComponent<Text>().fontSize = (int)(Screen.width * 0.018f); left_log.GetComponent<Text>().fontSize = (int)(Screen.width * 0.014f); poison_dmg.GetComponent<Text>().fontSize = (int)(Screen.width * 0.014f); burn_dmg.GetComponent<Text>().fontSize = (int)(Screen.width * 0.014f); paralyze_dmg.GetComponent<Text>().fontSize = (int)(Screen.width * 0.014f); finish_window.GetComponentsInChildren<Text>()[0].fontSize = (int)(Screen.width * 0.03f); finish_window.GetComponentsInChildren<Text>()[1].fontSize = (int)(Screen.width * 0.02f); finish_window.GetComponentsInChildren<Text>()[2].fontSize = (int)(Screen.width * 0.02f); finish_window.GetComponentsInChildren<Text>()[3].fontSize = (int)(Screen.width * 0.02f); finish_window.GetComponentsInChildren<Text>()[4].fontSize = (int)(Screen.width * 0.02f); finish_window.GetComponentsInChildren<Text>()[5].fontSize = (int)(Screen.width * 0.02f); player_names.GetComponentsInChildren<Text>()[0].fontSize = (int)(Screen.width * 0.02f); string pvp = player.Player_Name + " VS. " + enemy.Player_Name; player_names.GetComponentsInChildren<Text>()[0].text = pvp; toggle_page.GetComponentsInChildren<Text>()[0].fontSize = (int)(Screen.width * 0.016f); finish_window.transform.localPosition = off_screen; Disable_Finishers(); combo_finisher_spell = new FinalStrike(); reflect_finisher_spell = new DamageReflection(); affliction_finisher_spell = new GreatAffliction(); player_damage_text_start = player_damage_text.transform.position; enemy_damage_text_start = enemy_damage_text.transform.position; current_state = BattleStates.START; }
public void Add_Spell(BaseSpell s) { spell_list.Add(s); }
public override void ReceiveDamage(BaseSpell spell) { this.life -= this.tower.CalculateDamage(spell); }
public override void LaunchSpell(BasePlayer enemy, BaseSpell spell) { gc.ActionsDone++; spell.ApplyEffect(enemy, this); enemy.ReceiveDamage(spell); }