public void ActiveScriptGameWait() { if (IsScriptMainRunning) { return; } int mapIdx = AutoTileMap_Editor.Instance.MapIdxSelect; var script = GetRawScript(mapIdx, mIdxScriptWait); if (script == null) { return; } //Pause target ScriptGame s_from_npc = GetScriptGameCache_NPC_Begin(mTargetWait, false); AddScriptNeedResume(s_from_npc); // var target = mTargetWait; var tdxScript = mIdxScriptWait; // Reset Wait mTargetWait = null; mIdxScriptWait = -1; ResetObjInteraction(); ResetLogChat(); InputFieldHelper.Instance.Hide_Menu_BtTalk(); ScriptMain = GetScriptGameCache_NPC_Ingame(target, true); ScriptMain.StartOnMain(mapIdx, tdxScript, script, target, (ScriptGame scriptGame) => { ResumeAndClearScriptWait(); ClearNpcHasAdd(); ScriptMain = null; }); }
public ControllerTrashCan() { classTrashCan = GameObject.Find("Player/Trash Can").GetComponent <ClassTrashCan>(); scriptGame = GameObject.FindGameObjectWithTag("SceneManager").GetComponent <ScriptGame>(); classTrashCan.controllerTrashCan = this; earth = GameObject.Find("Earth"); }
public void AddScriptNeedResume(ScriptGame s) { if (s != null && s.IsRun) { s.PauseAction(); mScriptsWaitResume.Add(s); } }
private void RemoveScriptWaitResume(ScriptGame s) { if (s != null) { mScriptsWaitResume.Remove(s); s.ResumeAction(); } }
public void StartMsg(ScriptGame scriptGame, ScriptGui.ActionData msg, int countStack) { Debug.Log("StartMsg"); mScriptGameMSG = scriptGame; mMsgboxChat = msg; mIndextChat = 0; // StopMainChar(); SetupChoise(countStack); }
public void EndMsg() { Debug.Log("EndMsg"); var scriptGameMSG = mScriptGameMSG; mScriptGameMSG = null; mMsgboxChat = null; // ResumeMainChar(); scriptGameMSG.EndAction(); }
public void OnNPCEnter(GameObject npcTarget, int refNPCTarget) { // Check Wait InteractionNPC if (mOnInteractionNPC != null && !string.IsNullOrEmpty(mNPCRefWait) && npcTarget.name.IndexOf(mNPCRefWait) == 0) { var action = mOnInteractionNPC; mOnInteractionNPC = null; mNPCRefWait = null; if (action(refNPCTarget)) { return; } } if (IsScriptMainRunning || mTargetWait != null) { return; } if (refNPCTarget >= 0 && refNPCTarget < AutoTileMap_Editor.Instance.MapSelect.NPCData.Count) { // if(nav.hasPath == false){ // return; // } var npc = AutoTileMap_Editor.Instance.MapSelect.NPCData[refNPCTarget]; if (npc.RunScript && npc.IdxScript >= 0 && npc.IdxScript < AutoTileMap_Editor.Instance.MapSelect.ScriptData.Count) { string btTextWait; if (npc.nameNpc != null && npc.nameNpc.Length > 0) { btTextWait = "Talk to " + npc.nameNpc; } else { btTextWait = "Talk"; } mTargetWait = npcTarget; mIdxScriptWait = npc.IdxScript; CreateObjInteractionNPC(npcTarget); // Pause target int mapIdx = AutoTileMap_Editor.Instance.MapIdxSelect; ScriptGame s_from_npc = GetScriptGameCache_NPC_Begin(npcTarget, false); AddScriptNeedResume(s_from_npc); // Lock to NPC NpcLookatDCallback.InstanceOf(npcTarget).LookTo(AutoTileMap_Editor.Instance.Agent.transform, null); // Stop MainChar var nav = AutoTileMap_Editor.Instance.Agent.GetComponent <NavMeshAgentCallback>(); nav.ResetPath(); // InputFieldHelper.Instance.Show_Menu_BtTalk(btTextWait, () => { ActiveScriptGameWait(); }); } } }
public bool WaitEnterHouse(ScriptGame scriptGame, ScriptGui.MainCharAction data, OnMainCharEnterHouse callBack) { if (IsMainChar_Wait_To_Interaction()) { return(false); } GameObject prefab = Resources.Load <GameObject>("OBJ/CheckPoint"); if (prefab == null) { return(false); } List <GameObject> checkPointList = new List <GameObject>(); { // Add CheckPoint var triggerNode = AutoTileMap_Editor.Instance.TriggerNode; string hash = "House_" + data.IdHouse; for (int i = 0; i < triggerNode.childCount; i++) { var c = triggerNode.GetChild(i); Debug.Log(c.name); if (c.name.IndexOf(hash) >= 0) { var obj = GameObject.Instantiate(prefab); obj.transform.parent = c; obj.transform.localRotation = Quaternion.identity; obj.transform.localPosition = new Vector3(0, 0, 0); checkPointList.Add(obj); } } } if (checkPointList.Count == 0) { return(false); } houseRefWait = data.IdHouse; mOnWaitMainCharEnterHouse = ( int houseRef) => { while (checkPointList.Count > 0) { var o = checkPointList[0]; checkPointList.RemoveAt(0); o.transform.parent = null; GameObject.Destroy(o); } callBack(houseRef); }; return(true); }
public bool WaitInteractionNPC(ScriptGame scriptGame, ScriptGui.MainCharAction data, OnInteractionNPC callBack) { if (IsMainChar_Wait_To_Interaction()) { return(false); } ResetObjInteraction(); mNPCRefWait = eSlotAonTypeObj.Person + "_" + data.IdNpc + "_" + AutoTileMap_Editor.Instance.MapIdxSelect; CreateObjInteractionNPC(mNPCRefWait); mOnInteractionNPC = ( int refNPCTarget) => { ResetObjInteraction(); return(callBack(refNPCTarget)); }; return(true); }
public bool WaitGoToCheckPoint(ScriptGame scriptGame, int x, int y, OnMainCharWasToCheckPoint callBack) { if (IsMainChar_Wait_To_Interaction()) { return(false); } var packageWaitCheckPoint = new PackageWaitCheckPoint { ScriptGame = scriptGame, X = x, Y = y, Callback = callBack }; return(CreateWaitGoToCheckPoint(packageWaitCheckPoint)); }
// public void OnItemEnter( GameObject itemTarget, string itemName){ // Debug.Log("OnItemEnter: " + itemName); // if(itemName == "WaitMoveToPos"){ // //Get Main ScriptGame // ScriptGame s = GetScriptGameCache(AutoTileMap_Editor.Instance.Agent.transform); // if(s.Script != null){ // s.OnItemEnter( itemTarget, itemName); // } // } // } public void CallBack_CreateNPC(TriggerDetail detail, int idNpc, GameObject npcTarget, NPC npcData, int tileX, int tileY) { if (detail.isCreateFromMap) { if (npcData.StartScript && npcData.IdxStartScript >= 0 && npcData.IdxStartScript < AutoTileMap_Editor.Instance.MapSelect.ScriptData.Count) { int mapIdx = AutoTileMap_Editor.Instance.MapIdxSelect; var script = GetRawScript(mapIdx, npcData.IdxStartScript); if (script != null) { ScriptGame s = GetScriptGameCache_NPC_Begin(npcTarget, true); s.StartNormal(mapIdx, npcData.IdxStartScript, script, npcTarget); } } } else { ListNpcUsingInMainScript.Add(detail); } if (npcData.RunScript && npcData.IdxScript >= 0 && npcData.IdxScript < AutoTileMap_Editor.Instance.MapSelect.ScriptData.Count) { int mapIdx = AutoTileMap_Editor.Instance.MapIdxSelect; var script = GetRawScript(mapIdx, npcData.IdxScript); if (script != null) { var interaction = npcTarget.GetComponent <InteractionCheck>(); if (interaction == null) { interaction = npcTarget.AddComponent <InteractionCheck>(); interaction.Init(); } var flags = TriggerGame.Instance.ScriptFlag(detail, script); if (flags != null) { flags.AddEventListener_RemoveByFlag(ScriptGuiBase.ScriptYaml.Key_ShowInteractions, () => { interaction.IsShowInteractions = ScriptGuiBase.ScriptYaml.IsShowInteractions(flags); }); } } } // Check Wait InteractionNPC if (mOnInteractionNPC != null && !string.IsNullOrEmpty(mNPCRefWait) && npcTarget.name.IndexOf(mNPCRefWait) == 0) { CreateObjInteractionNPC(npcTarget); } }
/* * public void OnNPCInHouseEnter( int refNPCTarget){ * if(mOnInteractionNPC != null && refNPCTarget == mNPCRefWait){ * var c = mOnInteractionNPC; * mOnInteractionNPC = null; * if(c( refNPCTarget)){ * return; * } * } * if(refNPCTarget >= 0 && refNPCTarget < AutoTileMap_Editor.Instance.MapSelect.NPCData.Count){ * var nav = AutoTileMap_Editor.Instance.Agent.GetComponent<NavMeshAgent>(); * if(nav.hasPath == false){ * return; * } * var npc = AutoTileMap_Editor.Instance.MapSelect.NPCData[refNPCTarget]; * if(npc.RunScript && npc.IdxScript >= 0 && npc.IdxScript < AutoTileMap_Editor.Instance.MapSelect.ScriptData.Count){ * // OnScriptEnter( npc.IdxScript); * var script = GetOnCache( npc.IdxScript); * if(script != null){ * ScriptGame s = GetScriptGameCache(AutoTileMap_Editor.Instance.Agent.transform); * if(s.IsRun == false){ * //Begin script * mScriptMain = s; * s.StartOnMain( npc.IdxScript, script, null, (ScriptGame scriptGame) => { * mScriptMain = null; * }); * } * } * } * } * } */ public void OnNPCExit(GameObject npcTarget) { if (npcTarget != mTargetWait) { return; } if (!IsScriptMainRunning) { //If is not main ScriptActive -> Check and resume Move & Lock for NPC //Resume target int mapIdx = AutoTileMap_Editor.Instance.MapIdxSelect; ScriptGame s_from_npc = GetScriptGameCache_NPC_Begin(mTargetWait, false); RemoveScriptWaitResume(s_from_npc); } // Reset Wait mTargetWait = null; mIdxScriptWait = -1; ResetObjInteraction(); InputFieldHelper.Instance.Hide_Menu_BtTalk(); }
private ScriptGame GetScriptGameCache(ref Dictionary <string, ScriptGame> _s, TriggerDetail t, bool forceCreate) { if (_s == null) { _s = new Dictionary <string, ScriptGame>(); } string key = t.Hash; if (_s.ContainsKey(key)) { return(_s[key]); } if (forceCreate == false) { return(null); } var s = new ScriptGame(t); _s.Add(key, s); return(s); }
private void GoNextChoise(ScriptGui.MsgboxChoise choise, int countStack = 0) { // UI InputFieldHelper.Instance.HidePopupAction(); // InputFieldHelper.Instance.HideChatBottom(); // Logic var scriptGameMSG = mScriptGameMSG; // ResumeMainChar(); mScriptGameMSG = null; mMsgboxChat = null; //Check Action Flag if (choise.Action != null && choise.Action.Key != null && scriptGameMSG.Script.FlagActions.IndexOf(choise.Action) > 0 && scriptGameMSG.Flags != null && scriptGameMSG.Flags.ContainsKey(choise.Action.Key)) { FlagAction.DoFlagAction(scriptGameMSG.Flags, scriptGameMSG.Script.FlagActions, choise.Action); } scriptGameMSG.NextActionTo(choise.Next, countStack); }
// == METHODS ============================================================================================================ public Player(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._type = TileType.TYPE_DYNAMIC; this._faceDirection = TileFaceDirection.RIGHT; this._currentAnimSeq = 0; this._animSpriteSeq = new Sprite[] { this._sprite = Resources.Load <Sprite>("Sprites/WALK01"), this._sprite = Resources.Load <Sprite>("Sprites/WALK02"), this._sprite = Resources.Load <Sprite>("Sprites/WALK03"), this._sprite = Resources.Load <Sprite>("Sprites/WALK04"), this._sprite = Resources.Load <Sprite>("Sprites/WALK05"), this._sprite = Resources.Load <Sprite>("Sprites/WALK06"), this._sprite = Resources.Load <Sprite>("Sprites/WALK07"), this._sprite = Resources.Load <Sprite>("Sprites/WALK08"), this._sprite = Resources.Load <Sprite>("Sprites/WALK09"), }; this._sprite = this._animSpriteSeq[this._currentAnimSeq]; this._playerControls = new PlayerControls(); }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public Power(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._sprite = Resources.Load <Sprite>("Sprites/POWER"); }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public Dirt2(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._sprite = Resources.Load <Sprite>("Sprites/DIRT2"); }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public RubyL(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._currentRollSide = RollSide.LEFT; }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public MarbleRockR(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._currentRollSide = RollSide.RIGHT; }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public Lizard(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._sprite = Resources.Load <Sprite>("Sprites/LIZARD"); }
private void DoActionNPC(int scopeIndext, int countStack, ScriptGuiBase.NPCAction npc) { if (mActionWait != null) { Debug.LogError("Have mActionWait"); return; } mActionWait = null; if (npc.Action == ScriptGui.NPCAction.EAction.Show) { if (npc.UsingNPCTarget) { if (!OBJTarget) { EndAction(); InputFieldHelper.Instance.ShowNoti(string.Format("Error at Script ({0}): : Not found NPC on target", IdxScript)); return; } OBJTarget.gameObject.SetActive(true); AutoTileMap_Editor.Instance.WarpTo(OBJTarget.transform, npc.x, npc.y); } else { TriggerDetail detail = new TriggerDetail() { refMap = IdxMap, typeObj = eSlotAonTypeObj.Person, refId = npc.IdNpc, isCreateFromMap = false, x = npc.x, y = npc.y }; if (AutoTileMap_Editor.Instance.ShowNPC(detail) == null) { EndAction(); return; } } var t = npc.Next; NextActionTo(t, countStack + 1); return; } GameObject npcOBJ = GetNPCTarget(npc); if (npcOBJ == null) { if (mIsMain) { var t = npc.Next; NextActionTo(t, countStack + 1); } else { EndAction(); } return; } if (!npcOBJ.activeSelf) { var t = npc.Next; NextActionTo(t, countStack + 1); return; } if (npcOBJ == OBJTarget) { CLEAR_ALL_ACTION_NPC(npcOBJ); } else { if (mIsMain) { //Pause other NPC ScriptGame s_from_npc = TriggerGame.Instance.GetScriptGameCache_NPC_Begin(npcOBJ, false); TriggerGame.Instance.AddScriptNeedResume(s_from_npc); } } switch (npc.Action) { case ScriptGui.NPCAction.EAction.Show: { // No Check break; } case ScriptGui.NPCAction.EAction.Hide: { if (npc.UsingNPCTarget == false) { AutoTileMap_Editor.Instance.RemoveNPC(npc.IdNpc); } else { if (OBJTarget != null) { OBJTarget.SetActive(false); } } break; } case ScriptGui.NPCAction.EAction.Move: { // AutoTileMap_Editor.Instance.AddNPC( npc.IdNpc, npc.x, npc.y, true); // GameObject npcOBJ = GetNPCTarget(npc); if (npcOBJ != null && npcOBJ.activeSelf) { mActionWait = npc; var high = AutoTileMap_Editor.Instance.MapSelect.GetHighRef(npc.x, npc.y) * 0.5f; var to = new Vector3((0.5f + npc.x) * AutoTileMap_Editor.Instance.CellSize.x, high + 1, -(0.5f + npc.y) * AutoTileMap_Editor.Instance.CellSize.y); var c = npcOBJ.GetComponent <NavMeshAgentCallback>(); if (c == null) { c = npcOBJ.AddComponent <NavMeshAgentCallback>(); } c.WalkTo(1, to, ( NavMeshAgent nav ) => { mActionWait = null; var t = npc.Next; this.NextActionTo(t, 0); }); } break; } case ScriptGui.NPCAction.EAction.LookAtCharacter: { // GameObject npcOBJ = GetNPCTarget(npc); if (npcOBJ != null && npcOBJ.activeSelf) { bool requestLockBack = mIsMain; if (NpcLookatMainCallback.InstanceOf(npcOBJ).LookTo(AutoTileMap_Editor.Instance.Agent, requestLockBack, (NpcLookatMainCallback n) => { mActionWait = null; var t = npc.Next; this.NextActionTo(t, 0); })) { mActionWait = npc; } else { var t = npc.Next; this.NextActionTo(t, 0); } } break; } case ScriptGui.NPCAction.EAction.Animation_Talk: { // GameObject npcOBJ = GetNPCTarget(npc); if (npcOBJ != null && npcOBJ.activeSelf) { var b = npcOBJ.GetComponent <BasicMecanimControl>(); if (b != null) { mActionWait = npc; b.TalkWithAni((BasicMecanimControl bb) => { mActionWait = null; var t = npc.Next; this.NextActionTo(t, 0); }); } } break; } case ScriptGui.NPCAction.EAction.Animation_Face_Down: { doNpcFaceTo(npc, new Vector3(0, 0, -1)); return; } case ScriptGui.NPCAction.EAction.Animation_Face_Up: { doNpcFaceTo(npc, new Vector3(0, 0, 1)); return; } case ScriptGui.NPCAction.EAction.Animation_Face_Left: { doNpcFaceTo(npc, new Vector3(-1, 0, 0)); return; } case ScriptGui.NPCAction.EAction.Animation_Face_Right: { doNpcFaceTo(npc, new Vector3(1, 0, 0)); return; } default: { EndAction(); return; } } if (mActionWait == null) { var t = npc.Next; NextActionTo(t, countStack + 1); } }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public FrogR(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._faceDirection = TileFaceDirection.RIGHT; }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public Lava8(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._movementDelay = 1800; }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public Mole(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._sprite = Resources.Load <Sprite>("Sprites/MOLE"); }
// == METHODS ============================================================================================================ public Heavy(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._type = TileType.TYPE_DYNAMIC; }
// == METHODS ============================================================================================================ public Tile(ScriptGame parent, Vector2 initialPos) { this._parent = parent; this._position = initialPos; }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public Rock1(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._sprite = Resources.Load <Sprite>("Sprites/ROCK1"); }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public TurtleL(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._faceDirection = TileFaceDirection.LEFT; }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public GopherD(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._faceDirection = TileFaceDirection.DOWN; }
// == VAR & CONST ======================================================================================================== // == METHODS ============================================================================================================ public Grout(ScriptGame parent, Vector2 initialPos) : base(parent, initialPos) { this._sprite = Resources.Load <Sprite>("Sprites/GROUT"); }