当前位置: 首页>>代码示例>>C#>>正文


C# Spell.CanCast方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:Deus0,项目名称:Zeltex,代码行数:101,代码来源:BaseCharacter.cs


注:本文中的Spell.CanCast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。