fungus插件任务

一个任务的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;
                }
            }
        }
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

故渊9527

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值