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


C# Character.GetComponent方法代码示例

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


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

示例1: Activate

 public override void Activate(Character c, object ctx=null)
 {
     if(c == null) { return; }
     RoundPointsCharacter ppc = c.GetComponent<RoundPointsCharacter>();
     int uses = ppc.UsesThisRound;
     if(limitMode == TurnLimitMode.AP) {
         //set C's AP based on uses
         ppc.Limiter = ppc.MaxTurnAP;
     } else if(limitMode == TurnLimitMode.Time) {
         //set timer based on uses
         ppc.Limiter = ppc.MaxTurnTime;
     }
     float downscaleFactor = ppc.TurnDiminishScale;
     ppc.Limiter *= Mathf.Pow(downscaleFactor, uses);
     if(limitMode == TurnLimitMode.AP) {
         //FIXME: It is NOT OKAY for the scheduler to determine the move region's max range?
         //???: What about characters' intrinsic stats and so on?
         //???: may be better to pass this through a param instead...
         // Region ms = c.moveSkill.targetSettings[0].targetRegion;
         // ms.radiusMaxF = Formula.Constant(GetMaximumTraversalDistance(c));
     }
      	//FIXME: can we do something here for time-based traversal distance limitation?
     //???: What about characters' intrinsic movement stats and so on?
     Debug.Log("starting AP: "+ppc.Limiter);
     base.Activate(c, ctx);
     ppc.UsesThisRound = uses+1;
     //(for now): ON `activate`, MOVE
     //	activeCharacter.moveSkill.ActivateSkill();
     pointsRemaining--;
 }
开发者ID:JoeOsborn,项目名称:SRPGCK,代码行数:30,代码来源:TeamRoundsPointsScheduler.cs

示例2: initVariables

    public void initVariables(Character currChar, string side, string itemName1)
    {
        character = currChar;
        animator = character.GetComponent<Animator> ();
        itemName = itemName1;

        targetRightHouse = new Vector3 (16.5f, 0.45f, -6.0f);
        targetLeftHouse = new Vector3 (12.0f, 0.45f, -6.0f);
        targetLeftItemDrop = new Vector3 (14.0f, 0.45f, -6.0f);
        targetRightItemDrop = new Vector3 (15.4f, 0.45f, -6.0f);

        //updateAnimationPoints ();
        animator.SetBool ("insideHouse", true);

        if (side.Contains ("left") && itemName.Contains ("none")) {
            leftToRight = true;
        } else if (side.Contains ("right") && itemName.Contains ("none")) {
            rightToLeft = true;
        } else if (side.Contains ("left")) {
            leftToRightBindle = true;
            animator.SetBool ("bindle", true);
        } else if (side.Contains ("right")) {
            rightToLeftBinle = true;
            animator.SetBool ("bindle", true);
        }
        isInit = true;
    }
开发者ID:polygon-studios,项目名称:unity,代码行数:27,代码来源:InsideHouseMovement.cs

示例3: AddCharacter

 public override void AddCharacter(Character c)
 {
     base.AddCharacter(c);
     if(c.GetComponent<RoundPointsCharacter>() == null) {
         c.gameObject.AddComponent<RoundPointsCharacter>();
     }
 }
开发者ID:JoeOsborn,项目名称:SRPGCK,代码行数:7,代码来源:TeamRoundsPointsScheduler.cs

示例4: CheckIfMatch

	public bool CheckIfMatch(Character character){
		bool match = false;
		List<Transform> list = character.characterData.GetAllContolledParts ();
		AudioSource targetSourceClip = null;
		int matches = 0;
		for (int j = 0; j < list.Count; j++) {
			if(list[j].GetComponent<Animation>().isPlaying){
				if(IsAPartNeedMoving(character,list[j])){
					matches ++;
				}else{
					matches = 0;
					break;
				}
			}
		}
		if (matches == allPartsNeedMoving.Count) {
			match = true;
		}
		if (match && wantedSoundIndex != 0) {
			targetSourceClip = character.GetComponent<AudioSource> ();
			if(targetSourceClip.clip == null 
			   || ((character.GetIndexOfAudio(targetSourceClip.clip) + 1) != wantedSoundIndex 
			    || (character.GetIndexOfAudio(targetSourceClip.clip) + 1) == wantedSoundIndex && !targetSourceClip.isPlaying)){ // BECAUSE 0 == DEFAULT == NO SOUND
				match = false;
			}
		}
		return match;
	}
开发者ID:Darkfafi,项目名称:Global_Game_Jam_2016,代码行数:28,代码来源:SeduceList.cs

示例5: LocationAction

	public override void LocationAction(Character actingCharacter)
	{
		Debug.Log ("Add Work! ");
	    if (OwnerCharacterId == -1 || !actingCharacter.CanWork())
	    {
	        return;
	    }

		// Do work

		float workUpdate = /*0.25f*/CharactersManager.workValue;
		bool doEffect = true;

		// TODO: Bad Calculation! ((workValue * coffee) * smoke)
		//Debug.Log ("Before: " + workUpdate);
		actingCharacter.GetComponent<CoffeeMeter> ().CalcWork (ref workUpdate);
		actingCharacter.GetComponent<SmokeMeter> ().CalcWork (ref workUpdate);
		//Debug.Log ("After: " + workUpdate);

		if (OwnerCharacter == actingCharacter) {
			Debug.Log ("working at my desk! ");
			WorkMeterManager.GetInstance ().AddWork (OwnerCharacter, workUpdate);
		} else {
			//WorkMeterManager.GetInstance ().CanStealWork (actingCharacter, OwnerCharacter);
			float workStolen = WorkMeterManager.GetInstance ().StealWork (actingCharacter, OwnerCharacter, workUpdate * 0.5f);
			if (workStolen == 0.0f) {
				doEffect = false;
			}

			Debug.Log (string.Format("{0} stole {1} work from {2}", 
				actingCharacter.name, workStolen, OwnerCharacter.name));
		}

		if (doEffect) {
			foreach(var o in this.ItemsToShakeWhenWorking) {
				o.Shake();
			}
			
			GetComponent<RandomSoundPlayer>().PlaySound();
			if (useSparksParticles && !sparks.isPlaying)
			{
				sparks.Play();
			}
		}
	}
开发者ID:Natsirtt,项目名称:office-rituals,代码行数:45,代码来源:LocationWorkDesk.cs

示例6: DoCollect

 /// <summary>
 /// Do the collection.
 /// </summary>
 /// <param name="character">Character doing the collection.</param>
 protected override void DoCollect(Character character)
 {
     PowerUpResponder responder = character.GetComponent<PowerUpResponder>();
     if (responder)
     {
         responder.Collect(this);
     }
     base.DoCollect (character);
 }
开发者ID:Connorlc,项目名称:UnityProjects,代码行数:13,代码来源:PowerUp.cs

示例7: FindCharactersInNeighborhood

    public List<Character> FindCharactersInNeighborhood( Character i_character)
    {
        Vector2 center = (Vector2) i_character.GetComponent<Transform>().position;
        List<Character> characterInNeighborhood = new List<Character>();
        foreach (Character character in characters) {
            float distance = Vector2.Distance(center, (Vector2) character.GetComponent<Transform>().position);
            if (distance < neighborRadius) {
                characterInNeighborhood.Add(character);
            }
        }

        return characterInNeighborhood;
    }
开发者ID:ktejas,项目名称:TheRollingJackalope,代码行数:13,代码来源:BoidsController.cs

示例8: OnInteract

    public override void OnInteract( Character character )
    {
        CharacterInteractionModel interactionModel = character.GetComponent<CharacterInteractionModel>();

        if( interactionModel == null )
        {
            return;
        }

        BroadcastMessage( "OnPickupObject", character, SendMessageOptions.DontRequireReceiver );

        interactionModel.PickupObject( this );
    }
开发者ID:dmayfield,项目名称:Series-01-Action-Adventure,代码行数:13,代码来源:InteractablePickup.cs

示例9: Do

	private void Do(Character target)
	{
		var butcher = target.GetComponent<Butcher> ();
		if (null == butcher)
		{
			butcher = target.gameObject.AddComponent<Butcher> ();
			butcher.trap = this;
			butcher.character = target;
			butcher.CheckKill = () =>
			{
				return Check( target );
			};
		}
	}
开发者ID:mysticfarer,项目名称:ggj-color,代码行数:14,代码来源:Trap.cs

示例10: Smoke

	IEnumerator Smoke(float time, Character actingCharacter)
	{
		var smokeMeter = actingCharacter.GetComponent<SmokeMeter> ();
		smokeMeter.DepEnabled  = false;

		actingCharacter.StartSmoke ();
		actingCharacter.setCanMove (false);

		yield return new WaitForSeconds(time);

		actingCharacter.setCanMove (true);

		actingCharacter.EndSmoke (75f);
		smokeMeter.DepEnabled  = true;
	}
开发者ID:Natsirtt,项目名称:office-rituals,代码行数:15,代码来源:LocationSmokeArea.cs

示例11: GetCohensionForce

    public Vector2 GetCohensionForce( Character i_character)
    {
        Vector2 attractiveForce = Vector2.zero;
        List<Character> characterInNeighborhood = FindCharactersInNeighborhood( i_character);
        if (characterInNeighborhood.Count < 1) {
            return Vector2.zero;
        }

        Vector2 sum = Vector2.zero;
        foreach (Character character in characterInNeighborhood) {
            sum += (Vector2) character.GetComponent<Transform>().position;
        }

        attractiveForce = (Vector2)i_character.GetComponent<Transform>().position - sum / characterInNeighborhood.Count;
        return attractiveForce;
    }
开发者ID:ktejas,项目名称:TheRollingJackalope,代码行数:16,代码来源:BoidsController.cs

示例12: addHitEft

    protected void addHitEft(Character c)
    {
        Bug bug = c.GetComponent<Bug>();
        bug.Skill15AHitEftCallback -= addHitEft;
        SkillDef skillDef = SkillLib.instance.getSkillDefBySkillID("BUG30B");
        int time = (int)skillDef.buffDurationTime;
        int skDamage = (int)((Effect)skillDef.activeEffectTable["atk_PHY"]).num;
        float per = ((Effect)skillDef.buffEffectTable["hp"]).num;
        int hp = (int)(targetEnemy.realMaxHp * (per / 100.0f));
        int tempAtk = targetEnemy.getSkillDamageValue(c.realAtk, skDamage);
        targetEnemy.realDamage(tempAtk);

        targetEnemy.addBuff("Skill_BUG30B", time, hp/time, BuffTypes.DE_HP, buffFinish);

        StartCoroutine(delayHitEft());
    }
开发者ID:rogeryuan99,项目名称:Hello,代码行数:16,代码来源:Skill_BUG30B.cs

示例13: CharacterMoved

 public override void CharacterMoved(Character c, Vector3 from, Vector3 to, PathNode endOfPath)
 {
     /*		Debug.Log("moved to "+to);*/
     RoundPointsCharacter ppc = c.GetComponent<RoundPointsCharacter>();
     if(limitMode == TurnLimitMode.AP) {
         float moveAPCost = ppc.PerUnitMovementAPCost;
         float distance = 0;
         if(onlyDrainAPForXYDistance) {
             distance = endOfPath.xyDistanceFromStart;
         } else {
             distance = Mathf.Floor(endOfPath.distance);
         }
         Debug.Log("Distance: "+distance+" from "+from+" to "+to);
         DecreaseAP(moveAPCost * distance);
         Debug.Log("new AP: "+ppc.Limiter);
     }
 }
开发者ID:JoeOsborn,项目名称:SRPGCK,代码行数:17,代码来源:TeamRoundsPointsScheduler.cs

示例14: GetTargetHittability

    public bool GetTargetHittability(Character target)
    {
        GameObject myEyes = _parentCharacter.MyReference.Eyes;
        RaycastHit hit;
        float colliderHeight = target.GetComponent<CapsuleCollider>().height;
        Vector3 rayTarget = target.transform.position + Vector3.up * colliderHeight * 0.66f;
        Ray ray = new Ray(myEyes.transform.position, rayTarget - myEyes.transform.position);
        if(Physics.Raycast(ray, out hit))
        {
            //Debug.Log("raycast hit in sensor: " + hit.collider.name);
            Character hitCharacter = hit.collider.GetComponent<Character>();
            if(hitCharacter == target)
            {
                return true;
            }
        }
        else
        {
            return false;
        }

        return false;
    }
开发者ID:tegates,项目名称:Warzone,代码行数:23,代码来源:AISensor.cs

示例15: showEft

    protected void showEft(Character c)
    {
        Character redKing = c.GetComponent<Character>();
        if (redKing is Hero){
            (redKing as RedKing).showSkill30EftCallback -= showEft;
        }
        else{
            (redKing as Ch3_RedKing).showSkill30EftCallback -= showEft;
        }
        GameObject shieldEftPrefab = Resources.Load("eft/RedKing/SkillEft_RedKing30_ShieldRotationEft") as GameObject;
        shieldEft = Instantiate(shieldEftPrefab) as GameObject;
        shieldEft.transform.parent = c.transform;
        shieldEft.transform.localPosition = new Vector3(0,160,-30);
        shieldEft.transform.localScale = new Vector3(3f,3f,1f);
        SkillEft_RedKing30_ShieldRotationEft s = shieldEft.GetComponent<SkillEft_RedKing30_ShieldRotationEft>();
        if(s != null) StartCoroutine(delayShieldRotation(s));

        GameObject haloEftPrefab = Resources.Load("eft/RedKing/SkillEft_RedKing30_HaloEft") as GameObject;
        haloEft = Instantiate(haloEftPrefab) as GameObject;
        haloEft.transform.parent = c.transform;
        haloEft.transform.localPosition = new Vector3(0,0,1);
        haloEft.transform.localScale = new Vector3(3,3,1);

        GameObject bangEftPrefab = Resources.Load("eft/RedKing/SkillEft_RedKing30_BangEft") as GameObject;
        GameObject bangEft = Instantiate(bangEftPrefab) as GameObject;
        bangEft.transform.parent = c.transform;
        bangEft.transform.localPosition = new Vector3(100,1400,-20);
        bangEft.transform.localScale = new Vector3(8,8,1);

        restoreSelfHp(c);

        StartCoroutine(delayShowPopEft(c));
    }
开发者ID:rogeryuan99,项目名称:Hello,代码行数:33,代码来源:Skill_REDKING30A.cs


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