Ejemplo n.º 1
0
    /// <summary>
    /// 私有的函数执行过程
    /// </summary>
    /// <param name="commands"></param>
    private void executeCommand(string[] commands)
    {
        LoggerHelper.Warning("executeCommand :" + commands.PackArray());
        switch (commands[0])
        {
        case "CreateModel":
        {
            var     list1 = commands[5].Split(new char[] { ',' });
            Vector3 vec   = new Vector3(float.Parse(list1[0]), float.Parse(list1[1]), float.Parse(list1[2]));
            if (commands.Length > 6 && commands[6].Equals("false"))
            {
                CreateModel(Int32.Parse(commands[1]), Int32.Parse(commands[2]), Int32.Parse(commands[3]), Int32.Parse(commands[4]), vec, false);
            }
            else
            {
                CreateModel(Int32.Parse(commands[1]), Int32.Parse(commands[2]), Int32.Parse(commands[3]), Int32.Parse(commands[4]), vec);
            }

            break;
        }

        case "DestroyModel":
        {
            int id = Int32.Parse(commands[1]);
            AssetCacheMgr.ReleaseInstance(m_entityList[id].GameObject);
            BillboardLogicManager.Instance.RemoveBillboard(m_entityList[Int32.Parse(commands[1])].ID);
            EventDispatcher.RemoveEventListener <GameObject, Vector3>(MogoMotor.ON_MOVE_TO, m_entityList[Int32.Parse(commands[1])].OnMoveTo);
            m_entityList.Remove(id);
            break;
        }

        case "PlayAction":
        {
            int id = Int32.Parse(commands[1]);
            PlayAction(id, Int32.Parse(commands[2]));
            break;
        }

        case "PlayOneAction":
        {
            int id = Int32.Parse(commands[1]);
            PlayAction(id, Int32.Parse(commands[2]));
            m_entityList[id].AddCallbackInFrames <EntityParent>((ent) => { ent.SetAction(0); }, m_entityList[id]);
            break;
        }

        case "StopAction":
        {
            int id = Int32.Parse(commands[1]);
            m_entityList[id].AddCallbackInFrames <EntityParent>((ent) => { ent.SetAction(0); }, m_entityList[id]);
            break;
        }

        case "PlaySfx":
        {
            if (commands.Length > 3)
            {
                var     list1 = commands[4].Split(new char[] { ',' });
                Vector3 vec   = new Vector3(float.Parse(list1[0]), float.Parse(list1[1]), float.Parse(list1[2]));
                PlaySfx(Int32.Parse(commands[1]), Int32.Parse(commands[2]), Int32.Parse(commands[3]), vec);
            }
            else
            {
                PlaySfx(Int32.Parse(commands[1]), Int32.Parse(commands[2]));
            }

            break;
        }

        case "StopSfx":
            if (commands.Length > 2)
            {
                StopSfx(Int32.Parse(commands[1]), Int32.Parse(commands[2]));
            }
            else
            {
                StopSfx(Int32.Parse(commands[1]));
            }
            break;

        case "MoveCamera":
            if (commands.Length == 5)
            {
                var list1 = commands[2].Split(new char[] { ',' });
                var list2 = commands[3].Split(new char[] { ',' });
                MoveCamera(Int32.Parse(commands[1]), float.Parse(list1[0]), float.Parse(list2[0]), float.Parse(list1[1]), float.Parse(list2[1]),
                           float.Parse(list1[2]), float.Parse(list2[2]), float.Parse(list1[3]), float.Parse(list2[3]), float.Parse(commands[4]));
            }
            else if (commands.Length == 6)
            {
                var     list1 = commands[2].Split(new char[] { ',' });
                var     list2 = commands[3].Split(new char[] { ',' });
                var     list3 = commands[5].Split(new char[] { ',' });
                Vector3 vec   = new Vector3(float.Parse(list3[0]), float.Parse(list3[1]), float.Parse(list3[2]));
                MoveCamera(Int32.Parse(commands[1]), float.Parse(list1[0]), float.Parse(list2[0]), float.Parse(list1[1]), float.Parse(list2[1]),
                           float.Parse(list1[2]), float.Parse(list2[2]), float.Parse(list1[3]), float.Parse(list2[3]), float.Parse(commands[4]), vec);
            }
            else
            {
                MogoMainCamera.Instance.PlayCGAnim(commands[1]);
            }
            break;

        case "SetPosition":
        {
            int id = Int32.Parse(commands[1]);
            if (!m_entityList.ContainsKey(id))
            {
                LoggerHelper.Debug("id not exist in list");
            }
            else
            {
                var list1 = commands[2].Split(new char[] { ',' });
                m_entityList[id].SetPositon(float.Parse(list1[0]), float.Parse(list1[1]), float.Parse(list1[2]));
            }
            break;
        }

        case "SetRotation":
        {
            int id = Int32.Parse(commands[1]);
            if (!m_entityList.ContainsKey(id))
            {
                LoggerHelper.Debug("id not exist in list");
            }
            else
            {
                var list1 = commands[2].Split(new char[] { ',' });
                m_entityList[id].SetRotation(float.Parse(list1[0]), float.Parse(list1[1]), float.Parse(list1[2]));
            }
            break;
        }

        case "ShakeCamera":
            if (commands.Length > 3)
            {
                var list1 = commands[1].Split(new char[] { ',' });
                var vec   = new Vector3(float.Parse(list1[0]), float.Parse(list1[1]), float.Parse(list1[2]));
                var list2 = commands[2].Split(new char[] { ',' });
                ShakeCamera(vec, Int32.Parse(list2[0]), Int32.Parse(list2[1]), Int32.Parse(list2[2]), float.Parse(commands[3]) / 1000);
            }
            else
            {
                ShakeCamera(Int32.Parse(commands[1]), float.Parse(commands[2]) / 1000);
            }
            break;

        case "WhiteCamera":
        {
            var     list1 = commands[1].Split(new char[] { ',' });
            Vector2 vec   = new Vector2(float.Parse(list1[0]), float.Parse(list1[1]));
            MogoMainCamera.Instance.FadeToAllWhite(vec, float.Parse(commands[2]) / 1000);
            break;
        }

        case "NormalCamera":
        {
            var     list1 = commands[1].Split(new char[] { ',' });
            Vector2 vec   = new Vector2(float.Parse(list1[0]), float.Parse(list1[1]));
            MogoMainCamera.Instance.FadeToNoneWhite(vec, float.Parse(commands[2]) / 1000);
            break;
        }

        case "MoveTo":
        {
            int id    = Int32.Parse(commands[1]);
            var list1 = commands[2].Split(new char[] { ',' });
            m_entityList[id].MoveTo(float.Parse(list1[0]), float.Parse(list1[1]), float.Parse(list1[2]));
            break;
        }

        case "ShowDialog":
        {
            var list1 = (from x in commands[1].Split(new char[] { ',' }) select LanguageData.GetContent(Int32.Parse(x)).Replace("{0}", MogoWorld.thePlayer.name)).ToArray();
            var list2 = (from x in commands[2].Replace("{0}", IconData.GetPortraitByVocation(MogoWorld.thePlayer.vocation)).Split(new char[] { ',' }) select IconData.dataMap.Get(Int32.Parse(x)).path).ToArray();
            var list3 = (from x in commands[3].Split(new char[] { ',' }) select FormatTaskText(LanguageData.GetContent(Int32.Parse(x)))).ToArray();
            GuideSystem.Instance.IsGuideDialog = true;
            if (m_currentStoryID != 0)
            {
                //CG
                MogoUIManager.Instance.ShowMogoTaskUI(TaskUILogicManager.Instance.SetTaskInfo, list1, list2, list3, MogoUIManager.Instance.m_MainUI);
            }
            else
            {
                MogoUIManager.Instance.ShowGuideTaskUI(DialogUILogicManager.Instance.SetDialogInfo, list1, list2, list3);
            }
            break;
        }

        case "Subtitle":
        {
            MogoUIManager.Instance.ShowSubtitle(LanguageData.GetContent(Int32.Parse(commands[1])), float.Parse(commands[2]), float.Parse(commands[3]));
            break;
        }

        case "ZoomCamera":
        {
            int id   = Int32.Parse(commands[1]);
            var list = commands[3].Split(new char[] { ',' });
            MogoMainCamera.Instance.CloseToTarget(m_entityList[id].Transform, float.Parse(commands[2]), float.Parse(list[1]), float.Parse(list[0]), float.Parse(commands[4]) / 1000, float.Parse(commands[5]) / 1000);
            break;
        }

        case "LockSight":
        {
            MogoMainCamera.Instance.LockSight();
            break;
        }

        case "SetFocus":
        {
            if (commands.Length > 4)
            {
                TeachUILogicManager.Instance.SetTeachUIFocus(Int32.Parse(commands[1]), LanguageData.GetContent(Int32.Parse(commands[2])), false, Int32.Parse(commands[3]), MogoUIManager.Instance.m_MainUI);
                //TeachUILogicManager.Instance.ShowFingerAnim(true);
            }
            else
            {
                TeachUILogicManager.Instance.SetTeachUIFocus(Int32.Parse(commands[1]), LanguageData.GetContent(Int32.Parse(commands[2])), false, Int32.Parse(commands[3]));
                //TeachUILogicManager.Instance.ShowFingerAnim(true);
            }
            break;
        }

        case "SetItemFocus":
        {
            var itemIDs = commands[1].Split(new char[] { ',' }).Select(x => Int32.Parse(x));
            foreach (var item in itemIDs)
            {
                if (InventoryManager.Instance.GetItemNumById(item) > 0)
                {
                    LoggerHelper.Warning("SetItemFocus" + item);
                    TeachUILogicManager.Instance.SetItemFocus(item, LanguageData.GetContent(Int32.Parse(commands[2])), Int32.Parse(commands[3]));
                    break;
                }
            }
            //TeachUILogicManager.Instance.ShowFingerAnim(true);
            break;
        }

        case "SetNonFocus":
        {
            if (commands.Length > 4)
            {
                TeachUILogicManager.Instance.SetTeachUIFocus(Int32.Parse(commands[1]), LanguageData.GetContent(Int32.Parse(commands[2])), true, Int32.Parse(commands[3]), MogoUIManager.Instance.m_MainUI);
                TeachUILogicManager.Instance.ShowFingerAnim(true);
            }
            else
            {
                TeachUILogicManager.Instance.SetTeachUIFocus(Int32.Parse(commands[1]), LanguageData.GetContent(Int32.Parse(commands[2])), true, Int32.Parse(commands[3]));
                TeachUILogicManager.Instance.ShowFingerAnim(true);
            }

            break;
        }

        case "OpenBillboard":
        {
            MogoUIManager.Instance.ShowBillboardList(true);
            break;
        }

        case "CloseBillboard":
        {
            MogoUIManager.Instance.ShowBillboardList(false);
            break;
        }

        case "OpenUI":
        {
            if (commands.Length == 2)
            {
                var type   = typeof(MainUIViewManager);
                var method = type.GetMethod("Show" + commands[1]);
                method.Invoke(MainUIViewManager.Instance, new object[] { true });
            }
            else if (commands.Length == 3)
            {
                var type   = typeof(MainUIViewManager);
                var method = type.GetMethod("Show" + commands[1]);
                method.Invoke(MainUIViewManager.Instance, new object[] { true, Int32.Parse(commands[2]) });
            }
            else
            {
                MogoUIManager.Instance.ShowUI(true);
            }

            break;
        }

        case "CloseUI":
        {
            if (commands.Length == 2)
            {
                var type   = typeof(MainUIViewManager);
                var method = type.GetMethod("Show" + commands[1]);
                method.Invoke(MainUIViewManager.Instance, new object[] { false });
            }
            else if (commands.Length == 3)
            {
                var type   = typeof(MainUIViewManager);
                var method = type.GetMethod("Show" + commands[1]);
                method.Invoke(MainUIViewManager.Instance, new object[] { false, Int32.Parse(commands[2]) });
            }
            else
            {
                MogoUIManager.Instance.ShowUI(false);
                MogoUIManager.Instance.ShowBillboardList(false);
            }

            break;
        }

        case "AddPointer":
        {
            LoggerHelper.Debug("AddPointerToTarget");
            Vector3 point = new Vector3();
            MogoUtils.GetPointInTerrain(float.Parse(commands[1]), float.Parse(commands[2]), out point);
            MogoFXManager.Instance.AddPointerToTarget(MogoWorld.thePlayer.Transform.gameObject, MogoWorld.thePlayer.ID, point);
            break;
        }

        case "Sleep":
        {
            TimerHeap.AddTimer(UInt32.Parse(commands[1]), 0, () => { EventDispatcher.TriggerEvent <SignalEvents>(Events.CommandEvent.CommandEnd, SignalEvents.Sleep); });
            break;
        }

        case "End":
        {
            //结束CG
            FinishCG();
            break;
        }

        case "UnlockQueue":
        {
            MogoUIQueue.Instance.IsLocking = false;
            MogoUIQueue.Instance.Locked    = false;
            MogoUIQueue.Instance.CheckQueue();
            Debug.Log("Unlocking by StoryManager...................................");
            break;
        }

        case "StartGuideUI":
        {
            Mogo.Util.LoggerHelper.Debug("Start GuideUI @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
            TeachUIViewManager.Instance.PrepareShowTeachUI();
            break;
        }

        case "ResetControlStick":
        {
            if (ControlStick.instance != null)
            {
                MogoWorld.thePlayer.Idle();
                MogoWorld.thePlayer.motor.StopNav();
                ControlStick.instance.Reset();
            }
            else
            {
                MogoWorld.thePlayer.Idle();
                MogoWorld.thePlayer.motor.StopNav();
            }
            break;
        }

        case "Gear":
        {
            ClientEventData.TriggerGearEvent(Int32.Parse(commands[1]));
            break;
        }

        case "RemoveEntities":
        {
            MogoWorld.RemoveEntitiesPos();
            break;
        }

        case "ResetEntities":
        {
            MogoWorld.ResetEntitiesPos();
            break;
        }

        default:
            break;
        }
    }