本文整理汇总了C#中Spell.CanCast方法的典型用法代码示例。如果您正苦于以下问题:C# Spell.CanCast方法的具体用法?C# Spell.CanCast怎么用?C# Spell.CanCast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spell
的用法示例。
在下文中一共展示了Spell.CanCast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CastSpell
// need to edit for different spell casting types
public void CastSpell(Spell SpellInUse, Vector3 SpawnPosition, Vector3 SpawnRotation) {
Vector3 TurretSpawnPosition = MouseHit.point;
TurretSpawnPosition = new Vector3 (Mathf.RoundToInt (TurretSpawnPosition.x), (TurretSpawnPosition.y), Mathf.RoundToInt (TurretSpawnPosition.z));
if (SpellInUse.IsInstant) {
SpawnPosition = MouseHit.point;
}
Debug.Log ("Casting spell " + SpellInUse.Name + " using: " + SpellInUse.StatType);
switch (SpellInUse.FunctionIndex) {
case (0): // Projectile
if (MyStats.GetStat (SpellInUse.StatType) > SpellInUse.ManaCost) {
// for instant cast ones
//if ((SpellInUse.SpawnObject.tag == "Turret" && Gold >= GoldCost && WasTerrainHit() // if summoning turret
// && NoTurretInSpawnLocation(TurretSpawnPosition) && MouseHit.normal == new Vector3(0,1,0))
// || (SpellInUse.SpawnObject.tag != "Turret"))
if (SpellInUse.CanCast ())
{
//if (SpellInUse.SpawnObject.tag == "Turret") // special case for turrets mode
{
Gold -= GoldCost;
MyInventory.UnSelectItem();
}
// first charge the character of its stat
MyStats.IncreaseState (SpellInUse.StatType, -SpellInUse.ManaCost);
// Sound effect
//if (SoundSource)
// SoundSource.PlayOneShot (SpellInUse.SpawnSoundEffect, SoundVolume);
// if spawning objects
//if (SpellInUse.SpawnObject != null)
{
GameObject SpawnedObject = new GameObject();
Quaternion TempSpawnQuaternion = SpawnRotationQuaternion;
//Quaternion TempSpawnQuaternion = Quaternion.Euler(ShootForwardVector);
/*if (SpellInUse.SpawnObject.GetComponent<BaseProjectile>())
{
float Accuracy = 0.03f;
TempSpawnQuaternion.eulerAngles += new Vector3(UnityEngine.Random.Range (Accuracy, -Accuracy)*360f,
UnityEngine.Random.Range (Accuracy, -Accuracy)*360f,
UnityEngine.Random.Range (Accuracy, -Accuracy)*360f);
}*/
//if (GetManager.GetNetworkManager ().IsConnected ()) {
// SpawnedObject = (GameObject)Network.Instantiate (SpellInUse.SpawnObject, SpawnPosition, TempSpawnQuaternion, PlayerIndex);
//} else {
// SpawnedObject = (GameObject)Instantiate (SpellInUse.SpawnObject, SpawnPosition, TempSpawnQuaternion);
//}
//
//gameObject.GetComponent<NetworkView>().viewID.
BaseProjectile bullet = SpawnedObject.GetComponent<BaseProjectile> ();
if (bullet != null) {
//LatestSpawnedBullet = SpawnedObject;
// this doesn't get called as BaseCharacter is part of the other client
if (GetManager.GetNetworkManager ().IsConnected () && bullet.GetComponent<NetworkView> ())
bullet.GetComponent<NetworkView> ().RPC ("UpdateDataWithCharacter", RPCMode.All,
PlayerIndex,
ClanIndex,
SpellInUse.Damage,
SpellInUse.TravelSpeed,
SpellInUse.LifeTime);
else
bullet.UpdateDataWithCharacter (PlayerIndex,
ClanIndex,
SpellInUse.Damage,
SpellInUse.TravelSpeed,
SpellInUse.LifeTime);
}
// for summoned monsters
if (SpawnedObject.tag == "Turret") {
SpawnedObject.transform.position = TurretSpawnPosition;
SpawnedObject.transform.eulerAngles = MouseHit.normal;
}
BaseCharacter Minion = SpawnedObject.GetComponent<BaseCharacter>();
if (Minion != null) {
Minion.ClanIndex = ClanIndex;
Minion.MasterCharacter = gameObject;
BotMovement MinionMovement = (SpawnedObject.GetComponent<BotMovement>());
if (MinionMovement != null) {
MinionMovement.Follow (gameObject);
}
}
// Causes bullet to be destroyed in time
}
// this should be cast when pressed and released after animation has passed
//if (MyAnimator != null) {
// MyAnimator.PlayAnimation (SpellInUse.AnimationType);
//}
}
}
break;
case (1): // summoning
break;
case (2): // laser
float LaserDefinition = 16;
float WaveSpeed = 5f;
if (MyLaser == null) {
// initial spawn laser
//.........这里部分代码省略.........