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; }
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 }
//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)); }
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)); } }
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; } }
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"); } }
public override void EnterState(NPC_FSM NPC) { //Debug.Log("Crowley is in idle state"); }
public override void OnCollisionExit(NPC_FSM NPC) { }
private void Start() { player = FindObjectOfType <PlayerController_FSM>(); NPC = FindObjectOfType <NPC_FSM>(); }
public abstract void OnCollisionExit(NPC_FSM NPC);
//Useful condition that activate on collision eg colliding with player avatar public abstract void OnCollisionEnter(NPC_FSM NPC);
public override void Update(NPC_FSM NPC) { }
public override void OnCollisionEnter(NPC_FSM NPC) { }
private void Awake() { anima = new NPCAnimation(GetComponent <Animator>()); FSM = new NPC_FSM(new NPCIdle(FSM), this); }
public NPCMoveHome(NPC_FSM _FSM) { this._FSM = _FSM; _FSM.NPC_Obj.anima.Run(); _FSM.NPC_Obj.meshAgent.SetDestination(_FSM.NPC_Obj.commender.position); }
public override void OnCollisionExit(NPC_FSM NPC) { NPC.TransitionToState(NPC.idleState); //Change back to idle state when finished kissing Debug.Log("Kiss ended"); }
//When the state activate, it will begin with EnterState function public abstract void EnterState(NPC_FSM NPC);
//Update the state if there are any specific condition(s) placed public abstract void Update(NPC_FSM NPC);
public NPCIdle(NPC_FSM _FSM) { this._FSM = _FSM; }