大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全家桶1年46,售后保障稳定
一个任务的fungus
声明fungus 设置一个开关,当触发碰撞器时,将开关打开,当在持续碰撞时如是碰到的是人物,并且按下空格且开关为开,就执行对话重载名字并且关闭开关//多个任务的时候就是加个else 其他都一样
using System;
using System.Collections;
using System.Collections.Generic;
using Fungus;
using UnityEngine;
public class FungunNpcGrandFather : MonoBehaviour
{
private AllTask _allTask;
private Flowchart flowChart;
private bool _canSay;
private void Start()
{
_allTask = GameObject.Find("CanvasScene").transform.GetChild(0).GetChild(7).GetComponent<AllTask>();
flowChart = GameObject.Find("Flowchart").GetComponent<Flowchart>();
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
_canSay = true;
}
}
private void OnTriggerStay(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
if (Input.GetKeyDown(KeyCode.Space))
{
if (_allTask.enemyNum>=50&&_canSay)
{
//执行对话
flowChart.ExecuteBlock("Task4");
_canSay = false;
}
else if (_canSay)
{
//执行对话
flowChart.ExecuteBlock("Task3");
_canSay = false;
}
}
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices.ComTypes;
using Fungus;
using UnityEngine;
using UnityEngine.EventSystems;
using Collision = UnityEngine.Collision;
public class FungusNpc : MonoBehaviour
{
public string chatName;
private bool _canSay;
private Flowchart _flowChart;
private void Start()
{
_flowChart = GameObject.Find("Flowchart").GetComponent<Flowchart>();
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
_canSay = true;
}
}
private void OnTriggerStay(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
if (Input.GetKeyDown(KeyCode.Space))
{
if (_canSay)
{
//执行对话
_flowChart.ExecuteBlock(chatName);
_canSay = false;
}
}
}
}
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/210189.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...