Exemple #1
0
    public NPCCollect(Transform target, NPC_FSM _FSM)
    {
        this._FSM   = _FSM;
        this.target = target.GetComponent <Collect>();
        switch (_FSM.NPC_Obj.collectType)
        {
        case CollectType.石头:
            _FSM.NPC_Obj.anima.Mine();
            break;

        case CollectType.木头:
            _FSM.NPC_Obj.anima.Lumbering();
            break;

        case CollectType.食物:
            _FSM.NPC_Obj.anima.Gather();
            break;

        case CollectType.回复药:
            _FSM.NPC_Obj.anima.Gather();
            break;

        default:
            break;
        }
        _FSM.NPC_Obj.itemData         = new ItemData(this.target.collectType.ToString(), 0);
        this.target.OncollectDestroy += Finish;
    }
Exemple #2
0
    public override void EnterState(NPC_FSM NPC)
    {
        NPC.anim.Play("Base Layer.NPCTalkingStateAnim");

        //Based on Jistyles. (2014) Coroutine without MonoBehaviour. [online] Unity Answers. Available at: https://answers.unity.com/questions/161084/coroutine-without-monobehaviour.html. [Accessed on: 10th May 2021].
        NPC.StartingCoroutine(WaitForClip(NPC, 2f));
    }
    public override void OnCollisionExit(NPC_FSM NPC)
    {
        NPC.snakeSprite.color  = new Color(1, 1, 1, 0); //Render snake sprite invisible
        NPC.bodyRender.enabled = true;                  //Reactivate gameobject mesh renderer
        NPC.wingSprite.gameObject.SetActive(true);      //Reactivate wings to show them

        NPC.TransitionToState(NPC.idleState);           //Change back to idle state when finished tranforming
    }
Exemple #4
0
    //Based on Jistyles. (2014) Coroutine without MonoBehaviour. [online] Unity Answers. Available at: https://answers.unity.com/questions/161084/coroutine-without-monobehaviour.html. [Accessed on: 10th May 2021].
    private IEnumerator WaitForClip(NPC_FSM NPC, float timer)
    {
        Debug.Log("Started timing kiss: " + Time.deltaTime);

        yield return(new WaitForSeconds(timer));

        NPC.player.SendMessage("Idling");

        Debug.Log("Ended timing kiss: " + Time.deltaTime);
    }
    //Based on Jistyles. (2014) Coroutine without MonoBehaviour. [online] Unity Answers. Available at: https://answers.unity.com/questions/161084/coroutine-without-monobehaviour.html. [Accessed on: 10th May 2021].
    private IEnumerator WaitForClip(NPC_FSM NPC, float timer)
    {
        Debug.Log("Started timing uncomfortable: " + Time.deltaTime);

        yield return(new WaitForSeconds(timer));

        NPC.TransitionToState(NPC.idleState);

        Debug.Log("Ended timing uncomfortable: " + Time.deltaTime);
    }
    public override void EnterState(NPC_FSM NPC)
    {
        NPC.snakeSprite.color  = new Color(1, 1, 1, 1); //Render snake sprite visible
        NPC.bodyRender.enabled = false;                 //Deactivate the gameobject mesh renderer
        NPC.wingSprite.gameObject.SetActive(false);     //Deactivate wings to hide them
        Debug.Log("Transformed into a snake");


        //NPC.anim.Play("Base Layer.NPCKissingStateAnim");
        NPC.player.SendMessage("Worried");

        //Based on Jistyles. (2014) Coroutine without MonoBehaviour. [online] Unity Answers. Available at: https://answers.unity.com/questions/161084/coroutine-without-monobehaviour.html. [Accessed on: 10th May 2021].
        // NPC.StartingCoroutine(WaitForClip(NPC, 4f));
    }
Exemple #7
0
 public NPCMoveCollect(Transform target, NPC_FSM _FSM)
 {
     this._FSM = _FSM;
     _FSM.NPC_Obj.anima.Run();
     this.target = target;
     try
     {
         _FSM.NPC_Obj.meshAgent.SetDestination(target.position);
         target.GetComponent <Collect>().OncollectDestroy += Finish;
     }
     catch (MissingReferenceException)
     {
         _FSM.SetState(new NPCMoveHome(_FSM));
     }
 }
Exemple #8
0
    public NPCFindCollect(NPC_FSM _FSM)
    {
        this._FSM = _FSM;
        _FSM.NPC_Obj.anima.Find();
        _FSM.NPC_Obj.shoulder.sharedMesh = ResourcePath.Single.emptyBasket.GetComponent <MeshFilter>().sharedMesh;
        if (_FSM.NPC_Obj.tool != null)
        {
            GameObject.Destroy(_FSM.NPC_Obj.tool);
            _FSM.NPC_Obj.tool = null;
        }
        // 根据物资查找类型更换对应的物资工具,并且确定要搜索的物资列表
        switch (_FSM.NPC_Obj.collectType)
        {
        case CollectType.石头:
            collects          = _FSM.NPC_Obj.environmentCreate.stoneListPosition;
            _FSM.NPC_Obj.tool = GameObject.Instantiate(ResourcePath.Single.pickaxe, _FSM.NPC_Obj.hend);
            _FSM.NPC_Obj.tool.transform.position = _FSM.NPC_Obj.hend.position;
            break;

        case CollectType.木头:
            collects          = _FSM.NPC_Obj.environmentCreate.woodListPosition;
            _FSM.NPC_Obj.tool = GameObject.Instantiate(ResourcePath.Single.axe, _FSM.NPC_Obj.hend);
            _FSM.NPC_Obj.tool.transform.position = _FSM.NPC_Obj.hend.position;
            break;

        case CollectType.食物:
            collects = _FSM.NPC_Obj.environmentCreate.foodListPosition;
            // 空手
            break;

        case CollectType.回复药:
            collects = _FSM.NPC_Obj.environmentCreate.medicineListPosition;
            // 空手
            break;

        default:
            break;
        }
    }
Exemple #9
0
    public override void OnCollisionEnter(NPC_FSM NPC)
    {
        randomNumber = Random.Range(1, 10); //When collided with player avatar, a random number is polled which will then become the condition to execute one of following options:
        //Debug.Log("Random number is: " + randomNumber);

        //If the random number polled is 8 or higher, do this
        if (randomNumber > 7)
        {
            NPC.TransitionToState(NPC.kissingState); //Transition to kissing state
            //Debug.Log("Kissing time!");
        }
        //If the random number is between 1 and 4, do this
        else if (randomNumber > 0 && randomNumber < 5)
        {
            NPC.TransitionToState(NPC.transformingState); //Transition to transforming state
            //Debug.Log("Transforming time!");
        }
        else
        {
            NPC.TransitionToState(NPC.talkingState);
            //If draw a number without set condition, do nothing
            Debug.Log("Failed roll");
        }
    }
Exemple #10
0
 public override void EnterState(NPC_FSM NPC)
 {
     //Debug.Log("Crowley is in idle state");
 }
Exemple #11
0
 public override void OnCollisionExit(NPC_FSM NPC)
 {
 }
Exemple #12
0
 private void Start()
 {
     player = FindObjectOfType <PlayerController_FSM>();
     NPC    = FindObjectOfType <NPC_FSM>();
 }
Exemple #13
0
 public abstract void OnCollisionExit(NPC_FSM NPC);
Exemple #14
0
 //Useful condition that activate on collision eg colliding with player avatar
 public abstract void OnCollisionEnter(NPC_FSM NPC);
Exemple #15
0
 public override void Update(NPC_FSM NPC)
 {
 }
Exemple #16
0
 public override void OnCollisionEnter(NPC_FSM NPC)
 {
 }
Exemple #17
0
 private void Awake()
 {
     anima = new NPCAnimation(GetComponent <Animator>());
     FSM   = new NPC_FSM(new NPCIdle(FSM), this);
 }
Exemple #18
0
 public NPCMoveHome(NPC_FSM _FSM)
 {
     this._FSM = _FSM;
     _FSM.NPC_Obj.anima.Run();
     _FSM.NPC_Obj.meshAgent.SetDestination(_FSM.NPC_Obj.commender.position);
 }
Exemple #19
0
 public override void OnCollisionExit(NPC_FSM NPC)
 {
     NPC.TransitionToState(NPC.idleState); //Change back to idle state when finished kissing
     Debug.Log("Kiss ended");
 }
Exemple #20
0
 //When the state activate, it will begin with EnterState function
 public abstract void EnterState(NPC_FSM NPC);
Exemple #21
0
 //Update the state if there are any specific condition(s) placed
 public abstract void Update(NPC_FSM NPC);
Exemple #22
0
 public NPCIdle(NPC_FSM _FSM)
 {
     this._FSM = _FSM;
 }