object BuildAOEMessage(UnitySpellDefinition spellDefinition, double timeInMiliSeconds) { RaycastHit hit = new RaycastHit(); Ray mouseRay = InGameWrapper.instance.camera.ScreenPointToRay(Input.mousePosition); var player = InGameWrapper.instance.playersWrapper.GetOnlyLocalPlayer(); var playerGmj = player.GetGmj(); Vector3 direction; if (Physics.Raycast(mouseRay, out hit, 100f, InGameWrapper.instance.playersWrapper.playerData.groundMask)) { direction = hit.point - playerGmj.transform.position; } else { hit.point = playerGmj.transform.position; Debug.Log("ERROR"); Debug.Log("Raycast didnt hit anything for spell!"); } var msg = new Message_ClientRequest_CreateSpellInStaticPosition() { ownerGUID = player.GetOwnerID(), spellType = spellDefinition.type, spellXPos = hit.point.x, spellZPos = hit.point.z, playerXPos = playerGmj.transform.position.x, playerZPos = playerGmj.transform.position.z, rank = spellDefinition.rank, TimeStartedCasting = timeInMiliSeconds }; return(msg); }
public SpellController_Explode(Message_ServerResponse_CreateSpellInStaticPosition spell, UnitySpellDefinition definition) : base(spell.request.TimeStartedCasting, definition.GetCastTimeInSeconds(spell.request.rank)) { this.spell = spell; this.unityDefinition = definition; InGameWrapper.instance.playersWrapper.GetPlayerByOwnerGUID(spell.request.ownerGUID).spellCaster.CastSpell(this, spell.request.playerXPos, spell.request.playerZPos); }
public SpellControllers_HitDetection(SpellType spellType, UnitySpellDefinition unitySpellDefinition, Vector3 spawnPos, double timeStartedCasting, Vector3 playerCastPos, int ownerGUID, int rank) : base(timeStartedCasting, unitySpellDefinition.GetCastTimeInSeconds(rank)) { projectile = (GameObject)GameObject.Instantiate(unitySpellDefinition.projectilePrefab, new Vector3(spawnPos.x, spawnPos.y, spawnPos.z), Quaternion.identity); hitRange = InGameWrapper.instance.spellsWrapper.spellData.GetSpellDefinition(spellType).GetHitRange(rank); pushBackMultiplier = InGameWrapper.instance.spellsWrapper.spellData.GetSpellDefinition(spellType).GetPushBackMultiplier(rank); }
public SpellController_Fireball(Message_ServerResponse_CreateSpellWithDirection spell, UnitySpellDefinition definition) : base(spell.request.spellType, definition, new Vector3(spell.request.spellXPos, UnityStaticValues.StaticYPos, spell.request.playerZPos), spell.request.TimeStartedCasting, new Vector3(spell.request.playerXPos, UnityStaticValues.StaticYPos, spell.request.playerZPos), spell.request.ownerGUID, spell.request.rank) { this.spell = spell; direction = new Vector3(spell.request.spellXDir, 0f, spell.request.spellZDir); unityDefinition = InGameWrapper.instance.spellsWrapper.spellData.GetSpellDefinition(SpellType.Fireball); InGameWrapper.instance.playersWrapper.GetPlayerByOwnerGUID(spell.request.ownerGUID).spellCaster.CastSpell(this, spell.request.playerXPos, spell.request.playerZPos); }
/// <summary> /// Creates a spell controller for a given spell using a ISpellFactory /// </summary> /// <param name="unitySpellDefinition">Information about the spell in general</param> /// <param name="spell">Can be either Message_ServerResponse_CreateSpellInStaticPosition or Message_ServerResponse_CreateSpellWithDirection</param> /// <returns></returns> public ISpellController CreateSpell(UnitySpellDefinition unitySpellDefinition, object spell) { if (spell.GetType() == typeof(Message_ServerResponse_CreateSpellInStaticPosition)) { return(staticSpellsFactory[((Message_ServerResponse_CreateSpellInStaticPosition)spell).request.spellType].CreateSpellController((Message_ServerResponse_CreateSpellInStaticPosition)spell, unitySpellDefinition)); } else //Message_ServerResponse_CreateSpellInStaticPosition { return(directionSpellsFactory[((Message_ServerResponse_CreateSpellWithDirection)spell).request.spellType].CreateSpellController((Message_ServerResponse_CreateSpellWithDirection)spell, unitySpellDefinition)); } }
private void UpdateGeneralFields(ShopDefinition shopDefinition, UnitySpellDefinition spellInfo) { titleText.text = spellInfo.name; image.sprite = spellInfo.UISprite; if (spellInfo.rank + 1 < spellInfo.upgrades.Count) { buttonText.text = spellInfo.upgrades[spellInfo.rank + 1].costToUpgrade.ToString(); } else { buttonText.text = ""; } }
/// <summary> /// Builds a message for a given spell /// </summary> /// <param name="spell">Definition of the spell</param> /// <returns>The message request to be send</returns> public object BuildMessage(UnitySpellDefinition spell, Vector3 spawnPos) { var timeInMiliSeconds = InGameWrapper.instance.clockWrapper.GetTimeInMiliSeconds(); InGameWrapper.instance.playersWrapper.GetOnlyLocalPlayer().spellCaster.SpellRequestSend(); switch (spell.spellMovementType) { case UnitySpellDefinition.SpellMovementType.Direction: return(BuildProjectileMessage(spell, spawnPos, timeInMiliSeconds)); case UnitySpellDefinition.SpellMovementType.AOE: return(BuildAOEMessage(spell, timeInMiliSeconds)); } throw new Exception("No SpellMovementType found for the given spell"); }
public void UpgradeSpell(UnitySpellDefinition spellInfo) { int cost = spellInfo.upgrades[spellInfo.rank + 1].costToUpgrade; if (!InGameWrapper.instance.currencyWrapper.CanAfford(cost)) { return; } InGameWrapper.instance.currencyWrapper.ChangeCurrency(-cost); spellInfo.rank++; if (spellInfo.rank == UnitySpellDefinition.FirstRank) { UISpellButtonWrapper.instance.NewSpell(spellInfo); } UpdateUI(cachedShopDefinition); }
private void ShowAsNewItem(ShopDefinition shopDefinition, UnitySpellDefinition spellInfo) { bool affordable = CanAfford(spellInfo.upgrades[UnitySpellDefinition.FirstRank].costToUpgrade); button.interactable = affordable; button.onClick.RemoveAllListeners(); if (affordable) { SetupButtonBehavior(button, shopDefinition, spellInfo); } rankText.text = "UKNOWN SPELL"; descriptionText.text = ""; var thisRank = spellInfo.upgrades[UnitySpellDefinition.FirstRank]; descriptionText.text += "Damage " + GetAsBlueText(thisRank.damage) + GetTapString(); descriptionText.text += "Cooldown " + GetAsBlueText(thisRank.Cooldown) + System.Environment.NewLine; descriptionText.text += "PushBack " + GetAsBlueText(thisRank.pushBackMultiplier) + GetTapString(); descriptionText.text += "CastTime " + GetAsBlueText(thisRank.CastTime) + System.Environment.NewLine; descriptionText.text += "Travel speed " + GetAsBlueText(thisRank.moveSpeed); }
private void ShowAsUpdateItem(ShopDefinition shopDefinition, UnitySpellDefinition spellInfo) { bool affordable = CanAfford(spellInfo.upgrades[spellInfo.rank + 1].costToUpgrade); button.interactable = affordable; button.onClick.RemoveAllListeners(); if (affordable) { SetupButtonBehavior(button, shopDefinition, spellInfo); } rankText.text = "RANK " + (spellInfo.rank + 1); descriptionText.text = ""; var thisRank = spellInfo.upgrades[spellInfo.rank]; var upgradedRank = spellInfo.upgrades[spellInfo.rank + 1]; if (!FloatEqual(thisRank.damage, upgradedRank.damage)) { descriptionText.text += "Damage increased from " + thisRank.damage + " to " + GetAsBlueText(upgradedRank.damage) + System.Environment.NewLine; } if (!FloatEqual(thisRank.pushBackMultiplier, upgradedRank.pushBackMultiplier)) { descriptionText.text += "Pushback increased from " + thisRank.pushBackMultiplier + " to " + GetAsBlueText(upgradedRank.pushBackMultiplier) + System.Environment.NewLine; } if (!FloatEqual(thisRank.Cooldown, upgradedRank.Cooldown)) { descriptionText.text += "Cooldown decreased from " + thisRank.Cooldown + " to " + GetAsBlueText(upgradedRank.Cooldown) + System.Environment.NewLine; } if (FloatEqual(thisRank.moveSpeed, upgradedRank.moveSpeed)) { descriptionText.text += "Travel speed increased from " + thisRank.moveSpeed + " to " + GetAsBlueText(upgradedRank.moveSpeed) + System.Environment.NewLine; } if (FloatEqual(thisRank.CastTime, upgradedRank.CastTime)) { descriptionText.text += "Cast Time decreased from " + thisRank.CastTime + " to " + GetAsBlueText(upgradedRank.CastTime) + System.Environment.NewLine; } }
public ISpellController CreateSpellController(Message_ServerResponse_CreateSpellInStaticPosition spell, UnitySpellDefinition definition) { return(new SpellController_Teleport(spell, definition)); }
private void ShowAsFullyUpgradedItem(ShopDefinition shopDefinition, UnitySpellDefinition spellInfo) { button.interactable = false; rankText.text = "MAX RANK"; descriptionText.text = "Fully upgraded"; }
private void SetupButtonBehavior(Button button, ShopDefinition shopDefinition, UnitySpellDefinition spellInfo) { button.onClick.AddListener(delegate { UpgradeSpell(spellInfo); }); }
public void NewSpell(UnitySpellDefinition newSpell) { Setup(); }
public ISpellController CreateSpellController(Message_ServerResponse_CreateSpellWithDirection spellResponse, UnitySpellDefinition definition) { return(new SpellController_Fireball(spellResponse, definition)); }