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


C# Move.GetPPCost方法代码示例

本文整理汇总了C#中Move.GetPPCost方法的典型用法代码示例。如果您正苦于以下问题:C# Move.GetPPCost方法的具体用法?C# Move.GetPPCost怎么用?C# Move.GetPPCost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Move的用法示例。


在下文中一共展示了Move.GetPPCost方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UseMove

    public bool UseMove(Vector3 direction, Move move)
    {
        if (move.GetPPCost()>pokemon.pp)	return false;
        string attackChat = "";
        if (pokemon.isPlayer) {
            attackChat = "Your ";
        }
        else {
            attackChat = "Enemy ";
        }
        attackChat += pokemon.name + " used " + move.moveType + "!";

        switch(move.moveType){

        case MoveNames.Growl:{
            if (move.cooldown<1)	return false;
            const float range = 10;
            Attack("Effects/Debuff", false, range, direction, move);
            audio.PlayOneShot((AudioClip)Resources.Load("Audio/Growl"));
            return true;}

        case MoveNames.TailWhip:{
            if (move.cooldown<1)	return false;
            const float range = 10;
            Attack("Effects/Debuff", false, range, direction, move);
            return true;}

        case MoveNames.Tackle:{
            if (move.cooldown<1)	return false;
            const float range = 2;
            Attack("Effects/Bash", true, range, direction, move);
            rigidbody.AddForce(direction*range*rigidbody.mass*500);
            return true;}

        case MoveNames.Scratch:{
            if (move.cooldown<1)	return false;
            const float range = 2;
            Attack("Effects/Scratch", true, range, direction, move);
            return true;}
        }
        gamegui.SetChatWindow (attackChat);
        return false;
    }
开发者ID:Jcary13,项目名称:Unity,代码行数:43,代码来源:PokemonObj.cs

示例2: UseMove

    public bool UseMove(Vector3 direction, Move move)
    {
        if (move.GetPPCost()>pokemon.pp)	return false;
        string attackChat = "";
        if (pokemon.isPlayer) {
            attackChat = "Your ";
        }
        else {
            attackChat = "Enemy ";
        }
        attackChat += pokemon.name + " used " + move.moveType + "!";
        switch(move.moveType){

        case MoveNames.Growl:{
            if (move.cooldown<1)	return false;
            const float range = 10;
            foreach(GameObject enemyObj in GameObject.FindGameObjectsWithTag("pokemon")){
                if (enemyObj!=gameObject){
                    if ((enemyObj.transform.position-transform.position).sqrMagnitude<range*range){
                        GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Debuff"));
                        newEffect.transform.position = enemyObj.transform.position+Vector3.up*0.2f;
                        newEffect.transform.parent = enemyObj.transform;
                    }
                }
            }
            audio.PlayOneShot((AudioClip)Resources.Load("Audio/Growl"));
            move.cooldown = 0;
            pokemon.pp-=move.GetPPCost();
            return true;}

        case MoveNames.TailWhip:{
            if (move.cooldown<1)	return false;
            const float range = 10;
            foreach(GameObject enemyObj in GameObject.FindGameObjectsWithTag("pokemon")){
                if (enemyObj!=gameObject){
                    if ((enemyObj.transform.position-transform.position).sqrMagnitude<range*range){
                        GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Debuff"));
                        newEffect.transform.position = enemyObj.transform.position+Vector3.up*0.2f;
                        newEffect.transform.parent = enemyObj.transform;
                    }
                }
            }
            move.cooldown = 0;
            pokemon.pp-=move.GetPPCost();
            return true;}

        case MoveNames.Tackle:{
            if (move.cooldown<1)	return false;
            const float range = 2;
            RaycastHit[] hits = Physics.SphereCastAll(transform.position+Vector3.up, 1, direction ,range, 1<<10);
            foreach(RaycastHit hit in hits){
                if (hit.collider.gameObject!=gameObject){
                    PokemonObj enemyObj = hit.collider.GetComponent<PokemonObj>();
                    GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Bash"));
                    newEffect.transform.position = hit.point;
                    if (enemyObj){
                        if (enemyObj.pokemon!=null)	enemyObj.pokemon.Damage(pokemon,move);
                        if (GetComponent<PokemonPlayer>())	PokemonPlayer.target = enemyObj.gameObject;
                        PokemonWild wildP = enemyObj.GetComponent<PokemonWild>();
                        if (wildP)	wildP.enemy = gameObject;
                    }
                }
            }
            rigidbody.AddForce(direction*range*rigidbody.mass*500);
            move.cooldown = 0;
            pokemon.pp-=move.GetPPCost();
            return true;}

        case MoveNames.Scratch:{
            if (move.cooldown<1)	return false;
            const float range = 2;
            RaycastHit[] hits = Physics.SphereCastAll(transform.position+Vector3.up, 1, direction ,range, 1<<10);
            foreach(RaycastHit hit in hits){
                if (hit.collider.gameObject!=gameObject){
                    PokemonObj enemyObj = hit.collider.GetComponent<PokemonObj>();
                    GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Scratch"));
                    newEffect.transform.position = hit.point;
                    if (enemyObj){
                        if (enemyObj.pokemon!=null)	enemyObj.pokemon.Damage(pokemon,move);
                        if (GetComponent<PokemonPlayer>())	PokemonPlayer.target = enemyObj.gameObject;
                        PokemonWild wildP = enemyObj.GetComponent<PokemonWild>();
                        if (wildP)	wildP.enemy = gameObject;
                    }
                    move.cooldown = 0;
                    pokemon.pp-=move.GetPPCost();
                    return true;
                }
            }
            GameObject neweffect = (GameObject)Instantiate(Resources.Load("Effects/Scratch"));
            neweffect.transform.position = transform.position+Vector3.up+direction;
            move.cooldown = 0;
            pokemon.pp-=move.GetPPCost();
            return true;}
        }
        gamegui.SetChatWindow (attackChat);
        return false;
    }
开发者ID:nathan87007,项目名称:PokemonNXT,代码行数:97,代码来源:PokemonObj.cs

示例3: Attack

	/** Attack impements an eaiser way to call moves and effects saving ~20 lines of code per move
	 * @string 	effectResources: 	Name of what should be loaded from Resources.Load()
	 * @bool	costHP:				True if its an attack that should cost HP (i.e. Scratch)
	 * @float	range:				Range of the Attack
	 * @Vector3 direction:			Copy of the direction paramater from UseMove
	 * @Move	move:				Copy of the Move paramater from UseMove
	 **/
	private void Attack(string effectResource, bool costHP, float range, Vector3 direction, Move move)
	{	
		move.cooldown = 0;
		pokemon.pp-=move.GetPPCost();
		RaycastHit[] hits = Physics.SphereCastAll(transform.position+Vector3.up, 1, direction ,range, 1<<10);
	
		foreach(RaycastHit hit in hits){
			if (hit.collider.gameObject!=gameObject){
				GameObject newEffect = (GameObject)Instantiate(Resources.Load(effectResource));
				PokemonObj enemyObj = hit.collider.GetComponent<PokemonObj>();
				if(isWild && enemyObj.isWild) //make sure wild pokemon don't attack each other.
					return;
				if(costHP){

					newEffect.transform.position = hit.point;
				}else{
					if ((enemyObj.transform.position-transform.position).sqrMagnitude<range*range){

						newEffect.transform.position = enemyObj.transform.position+Vector3.up*0.2f;
						newEffect.transform.parent = enemyObj.transform;
					}
				}
				if (enemyObj){
					if (enemyObj.pokemon!=null)	
						if (costHP) enemyObj.pokemon.Damage(pokemon,move);
						else enemyObj.pokemon.DeBuff(pokemon,move);
					enemy = enemyObj;
					enemyObj.enemy = this;
				}

			}
		}
	}
开发者ID:Arpit0492,项目名称:Unity,代码行数:40,代码来源:PokemonObj.cs


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