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


C# NPC类代码示例

本文整理汇总了C#中NPC的典型用法代码示例。如果您正苦于以下问题:C# NPC类的具体用法?C# NPC怎么用?C# NPC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: startQuest

	//When the quest gets given out it takes in the NPC it is being given to
	public void startQuest (NPC person, NPC person2)
	{
		inUse = true;
		questGiver = person;
		questGiver2 = person2;
		speechCounter = 0;
	}
开发者ID:IzumiMirai,项目名称:CSSeniorProject,代码行数:8,代码来源:Quest.cs

示例2: AttackAction

	public AttackAction (Player p, NPC attacker, NPC target)
	{
		base.name = ATTACK;
		base.p = p;
		this.attacker = attacker;
		this.target = target;
	}
开发者ID:iloled,项目名称:ggj2016,代码行数:7,代码来源:AttackAction.cs

示例3: MoveAction

	public MoveAction (Player p, NPC npc,  int position)
	{
		base.name = MOVE;
		base.p = p;
		this.position = position;
		this.npc = npc;
	}
开发者ID:iloled,项目名称:ggj2016,代码行数:7,代码来源:MoveAction.cs

示例4: init

    public void init(Transform newTarget)
    {
        target = newTarget;

        if (target.GetComponent<NPC>() != null) {
            isNPC = true;
            npc = target.GetComponent<NPC>();
        } else {
            isNPC = false;
            player = target.GetComponent<Player>();
        }

        if (isNPC) {
            name.text = npc.name;

            if (npc.isFriendly) {
                name.color = NamePlate.COLOR_SELECTED;
            } else {
                name.color = NamePlate.COLOR_ENEMY;
            }
        } else {
            name.text = player.name;

            if (player.isFriendly) {
                name.color = NamePlate.COLOR_SELECTED;
            } else {
                name.color = NamePlate.COLOR_ENEMY;
            }
        }

        InvokeRepeating("updateHealth", 1f, 1f);
    }
开发者ID:hefanzhou,项目名称:hogwarts,代码行数:32,代码来源:TargetPanel.cs

示例5: Start

    void Start()
    {
        var audios = gameObject.GetComponents<AudioSource>();
        screamAudio = audios[1];

        npcPrefab = Resources.Load<NPC>("Prefabs/NPC");
        var basementPrefab = Resources.Load<Basement>("Prefabs/Basement");

        npcBodiesPrefabList = new List<GameObject>();

        for (int i = 0; i < 12; i++)
        {
            npcBodiesPrefabList.Add(Resources.Load<GameObject>("Prefabs/NPC/NPCBody_" + i));
        }

        basement = Instantiate<Basement>(basementPrefab);

        var respawners = basement.transform.FindChild("Respawners");

        npcs = new List<NPC>();

        respawnPoints = new List<Transform>();

        var allChildren = respawners.transform.Cast<Transform>().Select(t => t.gameObject).ToArray();
        foreach (GameObject t in allChildren)
        {
            respawnPoints.Add(t.transform);
        }
    }
开发者ID:alexandremuzio,项目名称:yatm,代码行数:29,代码来源:BasementManager.cs

示例6: DecrementPassiveChatTimer

 private void DecrementPassiveChatTimer(NPC npc)
 {
     currentTime = Time.timeSinceLevelLoad;
     timeToDecrement = Mathf.Abs(currentTime - previousTime);
     npc.timeTillPassiveChatAgain -= timeToDecrement;
     previousTime = currentTime;
 }
开发者ID:10DaysLeftToLive,项目名称:TimeWhaleEngine,代码行数:7,代码来源:NPCPassiveConvoCheck.cs

示例7: activate

 public IEnumerator activate(NPC npc, int difficulty, string[] won, string[] lost)
 {
     if (npc.defeated) {
         StartCoroutine(GameEventManager.conversation.speak(new string[] { "You already defeated this challenge!" }));
     } else {
         while (GameEventManager.player.isTalking) {
             yield return null;
         }
         if (this.challenges.Length > 0) {
             Challenge challenge = this.challenges[Random.Range(0, this.challenges.Length)];
             GameEventManager.player.inChallenge = true;
             StartCoroutine(GameEventManager.conversation.speak(challenge.explanation));
             StartCoroutine(challenge.play(this, difficulty));
             while (challenge.active()) {
                 yield return null;
             }
             GameEventManager.player.inChallenge = false;
             if (challenge.won()) {
                 if (won.Length > 0) {
                     StartCoroutine(GameEventManager.conversation.speak(won));
                 }
                 npc.defeated = true;
             } else {
                 if (lost.Length > 0) {
                     StartCoroutine(GameEventManager.conversation.speak(lost));
                 }
             }
         }
     }
     yield return 0;
 }
开发者ID:Tehnix,项目名称:TowerOfPower,代码行数:31,代码来源:ChallengeManager.cs

示例8: PsychopathegeneQuest

	public PsychopathegeneQuest (GameObject questprefab)
	{
		this.questPrefab = questprefab;

		numPsycho = 0;
		inUse = false;
		waitPeriod = 0;
		speechCounter = 0;

		hints = new String[5];
		hints [0] = "If you come close to a true" + "\n" + "psychopath they'll follow you" + 
			"\n" + "around.";
		hints [1] = "True psychopaths don't look" + "\n" + "crazy like other psychopaths.";
		hints [2] = "If you see someone become" + "\n" + "psychotic then the person they were" +
			"\n" + "last near is a psychopath!";
		hints [3] = "I hope my pig Wilbur is" + "\n" + "doing okay in the Wizard Realm.";
		hints [4] = "True pyschopaths will follow" + "\n" + "people close to them.";

		//Find psychos
		GameObject[] npcs = World.map.npcs.ToArray();
		for (int count = 0; count < npcs.Length; count++) {
			NPC temp = npcs [count].GetComponent<NPC>();
			if (temp.personality == Personality.psychotic && !temp.states.Contains (State.psychotic)) {
				if (numPsycho == 0) {
					numPsycho++;
					psycho1 = temp;
				} else {
					numPsycho++;
					psycho2 = temp;
					count = npcs.Length;
				}
			}
		}
	}
开发者ID:IzumiMirai,项目名称:CSSeniorProject,代码行数:34,代码来源:PsychopathegeneQuest.cs

示例9: addNpcToList

    //add data from NPC.xml to NPC list
    public void addNpcToList(XDocument doc)
    {
        string name;
            int strength, weaponSkill, attack, speed, health, level;
            bool isHostile;

            var data = from item in doc.Descendants("NPC")
                       select new
                       {
                           name = item.Element("name").Value,
                           strength = item.Element("strength").Value,
                           weaponSkill = item.Element("weaponSkill").Value,
                           attack = item.Element("attack").Value,
                           speed = item.Element("speed").Value,
                           health = item.Element("health").Value,
                           level = item.Element("level").Value,
                           isHostile = item.Element("isHostile").Value

                       };
            foreach (var p in data)
            {
                name = p.name;
                strength = Convert.ToInt32(p.strength);
                weaponSkill = Convert.ToInt32(p.weaponSkill);
                attack = Convert.ToInt32(p.attack);
                speed = Convert.ToInt32(p.speed);
                health = Convert.ToInt32(p.health);
                level = Convert.ToInt32(p.level);
                isHostile = Convert.ToBoolean(p.isHostile);
                NPC n = new NPC(name, strength, weaponSkill, attack, speed, health, level, isHostile);
                npcList.Add(n);
            }
    }
开发者ID:craigmcmillan01,项目名称:C-sharp-Work,代码行数:34,代码来源:UsefulMethods.cs

示例10: ClearAndReplace

 public void ClearAndReplace(NPC npc, Schedule newSchedule)
 {
     _schedulesToDo.Clear();
     current = null;
     Add(new DefaultSchedule(npc));
     Add(newSchedule);
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例11: InitialEmotionState

        public InitialEmotionState(NPC toControl, string currentDialogue)
            : base(toControl, currentDialogue)
        {
            gaveRose = new Reaction();
            gavePendant = new Reaction();
            gaveSeashell = new Reaction();
            randomMessage = new Reaction();

            gaveRose.AddAction(new NPCCallbackAction(SetSeashell));  // DELETE
            gaveRose.AddAction(new NPCCallbackAction(SetPendant)); // DELETE

            gaveRose.AddAction(new NPCTakeItemAction(toControl));
            gaveRose.AddAction(new NPCCallbackAction(SetRose));
            //gaveRose.AddAction(new UpdateDefaultTextAction(toControl, "new default"));
            gaveRose.AddAction(new UpdateCurrentTextAction(toControl, "My bedroom window when I was little had this bed of peach colored roses, they made my room smell wonderful in the summers."));
            _allItemReactions.Add(StringsItem.Apple,  new DispositionDependentReaction(gaveRose)); // change item to rose

            gavePendant.AddAction(new NPCTakeItemAction(toControl));
            gavePendant.AddAction(new NPCCallbackAction(SetPendant));
            gavePendant.AddAction(new UpdateCurrentTextAction(toControl, "I know this seems just like a silly necklace but your father worked for weeks when we were young to buy this for me. It still makes me smile."));
            _allItemReactions.Add("pendant",  new DispositionDependentReaction(gaveRose));

            gaveSeashell.AddAction(new NPCTakeItemAction(toControl));
            gaveSeashell.AddAction(new NPCCallbackAction(SetSeashell));
            gaveSeashell.AddAction(new UpdateCurrentTextAction(toControl, "Your father and I would spend afternoons looking for shells. He loved to find the shiniest ones he could for me."));
            _allItemReactions.Add("seashell",  new DispositionDependentReaction(gaveRose));

            randomMessage.AddAction(new NPCCallbackAction(RandomMessage));

            SetOnOpenInteractionReaction(new DispositionDependentReaction(randomMessage));

            TempFarmerReturnReaction.AddAction(new UpdateCurrentTextAction(toControl, "Blah"));
            TempFarmerReturnReaction.AddAction(new NPCCallbackAction(TempResponse));
            _allChoiceReactions.Add(TempFarmerReturnChoice,new DispositionDependentReaction(TempFarmerReturnReaction));
        }
开发者ID:10DaysLeftToLive,项目名称:TimeWhaleEngine,代码行数:35,代码来源:MotherMiddle.cs

示例12: MakeSomeDecisions

    void MakeSomeDecisions()
    {
        float sqrDist = ( target.position - myTransform.position ).sqrMagnitude;

        if ( sqrDist > maximumRangeSqr ){
            if ( isNpcChasing ){
                myState = NPC.Chasing;
            }
            else{
                myState = NPC.FreeRoam;
            }
        }
        else if ( sqrDist < minimumRangeSqr ){
            if ( isNpcChasing ){
                myState = NPC.Idle;
            }
            else{
                myState = NPC.RunningAway;
            }
        }
        else{
            if ( isNpcChasing ){
                myState = NPC.Chasing;
            }
            else{
                myState = NPC.RunningAway;
            }
        }
    }
开发者ID:johste93,项目名称:UnityProjects,代码行数:29,代码来源:SlenderNPC.cs

示例13: Awake

    // Use this for initialization
    void Awake()
    {
        myTransform = transform;
        myRigidbody = rigidbody;
        myRigidbody.freezeRotation = true;

        startSpeed = moveSpeed;
        startNextFoot = nextFoot;

        runningSpeed = startSpeed + 2.0f;
        runningNextFoot = nextFoot - 0.25f;

        myState = NPC.Chasing;

        GameObject targetObject = GameObject.Find( "Player" );

        if ( targetObject )
        {
            target = targetObject.transform;

            lanternScript = target.GetComponentInChildren< Lantern >();
        }
        else
        {
            Debug.Log( "no object named player was found" );
        }
    }
开发者ID:johste93,项目名称:UnityProjects,代码行数:28,代码来源:ShadowNPC.cs

示例14: Start

 // Use this for initialization
 void Start()
 {
     animator = this.gameObject.GetComponent<Animator> ();
     nodeQueue = new Queue<Vector3> (nodeList);
     prevNode = this.transform.position;
     npcScript = this.gameObject.GetComponent<NPC> ();
 }
开发者ID:caomw,项目名称:Unity-3D-Tutorials,代码行数:8,代码来源:PathWalker.cs

示例15: ApplyEffect

 public override void ApplyEffect()
 {
     if (isNPC==false)
         {//Apply to player
                 if (GameWorldController.instance.playerUW==null)
                 {
                         GameWorldController.instance.playerUW= this.GetComponent<UWCharacter>();
                 }
                 GameWorldController.instance.playerUW.Paralyzed=true;
         }
         else
         {
             if (npc==null)
             {
                     npc=this.GetComponent<NPC>();
             }
             this.GetComponent<NPC>().Frozen=true;
             state = this.GetComponent<NPC>().state;
             anim = this.GetComponent<NPC>().anim;
             if (anim!=null)
             {
                     anim.enabled=false;
             }
         }
         base.ApplyEffect();
 }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:26,代码来源:SpellEffectParalyze.cs


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