コード例 #1
0
ファイル: ActorBase.cs プロジェクト: mengtest/demo_tankWar3D
 protected void InitFsm()
 {
     FsmState <ActorBase>[] states =
     {
         new ActorEmptyFsm(ActorFsmStateType.FSM_EMPTY),
         new ActorIdleFsm(ActorFsmStateType.FSM_IDLE),
         new ActorRunFsm(ActorFsmStateType.FSM_RUN),
         new ActorWalkFsm(ActorFsmStateType.FSM_WALK),
         new ActorTurnFsm(ActorFsmStateType.FSM_TURN),
         new ActorDeadFsm(ActorFsmStateType.FSM_DEAD),
         new ActorSkillFsm(ActorFsmStateType.FSM_SKILL),
         new ActorBeatFlyFsm(ActorFsmStateType.FSM_BEATFLY),
         new ActorBeatBackFsm(ActorFsmStateType.FSM_BEATBACK),
         new ActorBeatDownFsm(ActorFsmStateType.FSM_BEATDOWN),
         new ActorWoundFsm(ActorFsmStateType.FSM_WOUND),
         new ActorStunFsm(ActorFsmStateType.FSM_STUN),
         new ActorFrostFsm(ActorFsmStateType.FSM_FROST),
         new ActorFixBodyFsm(ActorFsmStateType.FSM_FIXBODY),
         new ActorFearFsm(ActorFsmStateType.FSM_FEAR),
         new ActorVariationFsm(ActorFsmStateType.FSM_VARIATION),
         new ActorJumpFsm(ActorFsmStateType.FSM_JUMP),
         new ActorRebornFsm(ActorFsmStateType.FSM_REBORN),
         new ActorCollectMineFsm(ActorFsmStateType.FSM_MINE),
         new ActorInteractiveFsm(ActorFsmStateType.FSM_INTERACTIVE),
     };
     m_FsmName  = GlobalTools.Format("ActorFsm[{0}][{1}]", Id, EntityId);
     m_ActorFsm = GameEntry.Fsm.CreateFsm(m_FsmName, this, states);
     m_ActorFsm.Start <ActorIdleFsm>();
 }
コード例 #2
0
        protected override void OnOpen(object userData)
        {
            base.OnOpen(userData);
            m_Data = userData as BoardFormData;
            if (m_Data == null)
            {
                Log.Error("Open Board fail");
                return;
            }

            SetTarget(m_Data.CacheTransform);
            m_Height = m_Data.Height + 0.3f;

            if (m_Data.ActorType == ActorType.Player)
            {
                m_Name.color    = Color.green;
                m_HpBar.visible = false;
            }
            else if (m_Data.ActorType == ActorType.Monster)
            {
                m_Name.color    = Color.red;
                m_HpBar.visible = true;
            }
            else
            {
                m_Name.color    = Color.blue;
                m_HpBar.visible = false;
            }

            m_Name.text = GlobalTools.Format("Lv.{0} {1}", m_Data.Level, m_Data.Name);
        }
コード例 #3
0
        public void ShowSkill(SkillTree skill)
        {
            if (skill.Pos == SkillPosType.Skill_0)
            {
                m_Normal.visible = true;
                m_Skill.visible  = false;
            }
            else
            {
                m_Normal.visible = false;
                m_Skill.visible  = true;
            }

            string iconPath = AssetUtility.GetSkillIconAsset(skill.Id);

            if (m_Icon.url != iconPath)
            {
                m_Icon.url = iconPath;
            }

            if (Math.Abs(skill.GetLeftTime()) < float.Epsilon)
            {
                m_Title.visible = false;
                m_Mask.visible  = false;
            }
            else
            {
                m_Title.visible   = true;
                m_Mask.visible    = true;
                m_Title.text      = GlobalTools.Format("{0}{1}", skill.GetLeftTime().ToString("F1"), "s");
                m_Mask.fillAmount = skill.GetLeftTime() / skill.CD;
            }
        }
コード例 #4
0
        public void ShowBuff(BuffBase buff)
        {
            if (buff?.Data == null)
            {
                Log.Error("buff is invalid.");
                return;
            }
            if (m_Buff != null)
            {
                UpdateBuff();
                return;
            }

            m_Buff = buff;
            if (m_Buff.GetLeftTime() < float.Epsilon)
            {
                HideBuff();
                return;
            }

            if (m_Buff.Data.Icon == 0)
            {
                return;
            }

            this.visible = true;
            string iconPath = AssetUtility.GetBuffIconAsset(m_Buff.Data.Icon);

            m_Icon.url        = iconPath;
            m_Title.text      = GlobalTools.Format("{0}{1}", m_Buff.GetLeftTime().ToString("F1"), "s");
            m_Mask.fillAmount = m_Buff.GetLeftTime() / m_Buff.Data.LifeTime;
        }
コード例 #5
0
ファイル: HomeForm.cs プロジェクト: mengtest/demo_tankWar3D
        private void RefreshHeroInfo(object sender, GameEventArgs e)
        {
            RefreshHeroInfoEventArgs ne = e as RefreshHeroInfoEventArgs;

            switch (ne.Type)
            {
            case RefreshType.Name:
                m_Name.text = ne.Name;
                break;

            case RefreshType.Level:
                m_Level.text = GlobalTools.Format("LV.{0}", ne.Level);
                break;

            case RefreshType.Hp:
                if (ne.MaxHp != 0)
                {
                    m_Hp.value = 100 * (float)ne.CurHp / ne.MaxHp;
                    m_Hp.GetChild("title").asTextField.text = GlobalTools.Format("{0}/{1}", ne.CurHp, ne.MaxHp);
                }
                break;

            case RefreshType.Mp:
                if (ne.MaxMp != 0)
                {
                    m_Mp.value = 100 * (float)ne.CurMp / ne.MaxMp;
                    m_Mp.GetChild("title").asTextField.text = GlobalTools.Format("{0}/{1}", ne.CurMp, ne.MaxMp);
                }
                break;

            case RefreshType.Exp:
                if (ne.MaxExp != 0)
                {
                    m_Exp.fillAmount = (float)ne.CurExp / ne.MaxExp;
                }
                break;

            case RefreshType.All:
                m_Name.text  = ne.Name;
                m_Level.text = GlobalTools.Format("LV.{0}", ne.Level);
                if (ne.MaxHp != 0)
                {
                    m_Hp.value = 100 * (float)ne.Attribute.Hp / ne.Attribute.MaxHp;
                    m_Hp.GetChild("title").asTextField.text = GlobalTools.Format("{0}/{1}", ne.Attribute.Hp, ne.Attribute.MaxHp);
                }
                if (ne.MaxMp != 0)
                {
                    m_Mp.value = 100 * (float)ne.Attribute.Mp / ne.Attribute.MaxMp;
                    m_Mp.GetChild("title").asTextField.text = GlobalTools.Format("{0}/{1}", ne.Attribute.Mp, ne.Attribute.MaxMp);
                }
                if (ne.MaxExp != 0)
                {
                    m_Exp.fillAmount = (float)ne.CurExp / ne.MaxExp;
                }
                break;
            }
        }
コード例 #6
0
        public void Refresh(int curHp, int maxHp, int level)
        {
            if (maxHp == 0)
            {
                return;
            }

            m_HpBar.value  = 100 * (float)curHp / maxHp;
            m_Name.text    = GlobalTools.Format("Lv.{0} {1}", level, m_Data.Name);
            m_BarText.text = GlobalTools.Format("{0}/{1}", curHp, maxHp);
        }
コード例 #7
0
        protected override void OnOpen(object userData)
        {
            base.OnOpen(userData);

            m_Data = userData as FlyWordData;
            if (m_Data == null)
            {
                Log.Error("userData is invlid.");
                return;
            }

            switch (m_Data.Type)
            {
            case FlyWordType.NormalHurt:
                m_Ctrl.selectedIndex = 0;
                m_Normal.text        = GlobalTools.Format("-{0}", m_Data.Value);
                m_Normal.color       = Color.red;
                break;

            case FlyWordType.CritHurt:
                m_Ctrl.selectedIndex = 3;
                m_Crit.text          = GlobalTools.Format("-{0}", m_Data.Value);
                m_Crit.color         = Color.yellow;
                break;

            case FlyWordType.HpHeal:
                m_Ctrl.selectedIndex = 0;
                m_Normal.text        = GlobalTools.Format("+{0}", m_Data.Value);
                m_Normal.color       = Color.green;
                break;

            case FlyWordType.MpHeal:
                m_Ctrl.selectedIndex = 0;
                m_Normal.text        = GlobalTools.Format("+{0}", m_Data.Value);
                m_Normal.color       = Color.blue;
                break;

            case FlyWordType.Miss:
                m_Ctrl.selectedIndex = 1;
                break;

            case FlyWordType.Parry:
                m_Ctrl.selectedIndex = 2;
                break;
            }

            m_Transition.Stop();

            if (UI != null && UI.visible)
            {
                m_Transition.Play();
            }
        }
コード例 #8
0
ファイル: ActorFsmAI.cs プロジェクト: mengtest/demo_tankWar3D
        public ActorFsmAI(ActorBase owner, AIModeType mode, float atkDist, float followDist, float waringDist, float findEnemyInterval)
            : base(owner, mode, atkDist, followDist, waringDist, findEnemyInterval)
        {
            m_FsmName = GlobalTools.Format("ActorAIFsm[{0}][{1}]", Owner.Id, owner.EntityId);

            FsmState <ActorBase>[] states =
            {
                new AIEmptyState(AIStateType.Empty),
                new AIIdleState(AIStateType.Idle),
                new AIFollowState(AIStateType.Follow),
                new AIFleeState(AIStateType.Flee),
                new AIPatrolState(AIStateType.Patrol),
                new AIEscapeState(AIStateType.Escape),
                new AIBackState(AIStateType.Back),
                new AIFightState(AIStateType.Fight),
                new AIDeadState(AIStateType.Dead),
                new AIChaseState(AIStateType.Chase),
            };
            m_AIFsm = GameEntry.Fsm.CreateFsm(m_FsmName, Owner as ActorBase, states);
        }
コード例 #9
0
        private void ExportAll()
        {
            string fsPath = AssetUtility.GetLevelConfigPath();

            if (!Directory.Exists(fsPath))
            {
                Directory.CreateDirectory(fsPath);
            }
            string    path = GlobalTools.Format("{0}/{1}.xml", fsPath, GameEntry.Level.LevelID);
            MapConfig data = Export();

            if (!File.Exists(path))
            {
                FileStream fs = File.Create(path);
                fs.Close();
                fs.Dispose();
            }
            data.Save(path);

            Debug.Log("导出关卡数据:" + fsPath);
        }
コード例 #10
0
 public static string GetDictionaryAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/Localization/{0}/Dictionaries/{1}.xml", GameEntry.Localization.Language.ToString(), assetName));
 }
コード例 #11
0
 public static string GetFontAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/Localization/{0}/Fonts/{1}.ttf", GameEntry.Localization.Language.ToString(), assetName));
 }
コード例 #12
0
 public static string GetSceneAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/Scenes/{0}.unity", assetName));
 }
コード例 #13
0
        public static void Write(TextWriter os, string name, Vector3 x)
        {
            string s = GlobalTools.Format("({0},{1},{2})", x.x.ToString("0.00"), x.y.ToString("0.00"), x.z.ToString("0.00"));

            os.WriteLine("<{0}>{1}</{0}>", name, s);
        }
コード例 #14
0
 public static string GetMusicAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/Music/{0}.mp3", assetName));
 }
コード例 #15
0
 public static string GetFairyGuiPackageAsset(string packageName)
 {
     return(GlobalTools.Format("Assets/GameMain/UI/UIPackage/{0}", packageName));
 }
コード例 #16
0
        public override void OnInspectorGUI()
        {
            LevelEvent pElem = target as LevelEvent;

            MapTriggerType pType = (MapTriggerType)EditorGUILayout.EnumPopup("触发事件类型", pElem.Type);

            if (pType != pElem.Type)
            {
                pElem.Type = pType;
                pElem.SetName();
            }

            int pTypeId = EditorGUILayout.IntField("触发事件类型ID", pElem.TypeId);

            if (pTypeId != pElem.TypeId)
            {
                pElem.TypeId = pTypeId;
                pElem.SetName();
            }

            bool pActive = EditorGUILayout.Toggle("激活或者销毁", pElem.Active);

            if (pActive != pElem.Active)
            {
                pElem.Active = pActive;
            }

            ConditionRelationType pR1 = (ConditionRelationType)EditorGUILayout.EnumPopup("首次触发条件之间关系", pElem.Relation1);

            if (pR1 != pElem.Relation1)
            {
                pElem.Relation1 = pR1;
            }

            float pTriggerDelay = EditorGUILayout.FloatField("触发延迟", pElem.TriggerDelay);

            if (pElem.TriggerDelay != pTriggerDelay)
            {
                pElem.TriggerDelay = pTriggerDelay;
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("首次触发条件");
            if (UnityEngine.GUILayout.Button("添加"))
            {
                pElem.Conditions1.Add(new MapEventCondition());
            }
            EditorGUILayout.EndHorizontal();

            int pDeleteIndex1 = -1;

            for (int i = 0; i < pElem.Conditions1.Count; i++)
            {
                EditorGUILayout.Space();
                EditorGUIUtility.labelWidth = 100;
                MapEventCondition data = pElem.Conditions1[i];
                EditorGUILayout.LabelField("条件" + (i + 1));
                EditorGUIUtility.labelWidth = 100;
                TriggerConditionType p = (TriggerConditionType)EditorGUILayout.EnumPopup("类型", data.Type);
                if (p != data.Type)
                {
                    data.Type = p;
                }

                EditorGUILayout.BeginHorizontal();
                EditorGUIUtility.labelWidth = 100;
                string s = EditorGUILayout.TextField("参数", data.Args);
                if (s != data.Args)
                {
                    data.Args = s;
                }

                if (UnityEngine.GUILayout.Button("删除"))
                {
                    pDeleteIndex1 = i;
                }
                EditorGUILayout.EndHorizontal();
            }

            if (pDeleteIndex1 >= 0)
            {
                pElem.Conditions1.RemoveAt(pDeleteIndex1);
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            bool pUseTriggerInterval = EditorGUILayout.Toggle("是否间隔触发", pElem.UseIntervalTrigger);

            if (pElem.UseIntervalTrigger != pUseTriggerInterval)
            {
                pElem.UseIntervalTrigger = pUseTriggerInterval;
            }
            if (pElem.UseIntervalTrigger == false)
            {
                return;
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("间隔触发条件");
            if (UnityEngine.GUILayout.Button("添加"))
            {
                pElem.Conditions2.Add(new MapEventCondition());
            }
            EditorGUILayout.EndHorizontal();

            int pTriggerNum = EditorGUILayout.IntField("间隔触发次数(<=0代表无限)", pElem.TriggerNum);

            if (pElem.TriggerNum != pTriggerNum)
            {
                pElem.TriggerNum = pTriggerNum;
            }

            float pTriggerInterval = EditorGUILayout.FloatField("触发间隔时间", pElem.TriggerInterval);

            if (pElem.TriggerInterval != pTriggerInterval)
            {
                pElem.TriggerInterval = pTriggerInterval;
            }

            int pDeleteIndex2 = -1;

            for (int i = 0; i < pElem.Conditions2.Count; i++)
            {
                EditorGUILayout.Space();
                MapEventCondition    data = pElem.Conditions2[i];
                TriggerConditionType p    = (TriggerConditionType)EditorGUILayout.EnumPopup(GlobalTools.Format("条件{0}:  类型", i + 1), data.Type);
                if (p != data.Type)
                {
                    data.Type = p;
                }
                string s = EditorGUILayout.TextField("参数", data.Args);
                if (s != data.Args)
                {
                    data.Args = s;
                }

                if (UnityEngine.GUILayout.Button("删除"))
                {
                    pDeleteIndex2 = i;
                }
            }

            if (pDeleteIndex2 >= 0)
            {
                pElem.Conditions2.RemoveAt(pDeleteIndex2);
            }
        }
コード例 #17
0
 public static string GetLevelObjectAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/Entities/Level/{0}.prefab", assetName));
 }
コード例 #18
0
 public static string GetLevelConfigAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/Configs/Level/{0}.xml", assetName));
 }
コード例 #19
0
 private void LoadTaskScriptByTaskID(ref TaskData data, int pTaskID)
 {
     data.SubTasks.Clear();
     data.Load(GlobalTools.Format("Text/Task/{0}", pTaskID));
 }
コード例 #20
0
 public static string GetLuaAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/Lua/{0}.txt", assetName));
 }
コード例 #21
0
 public static string GetDataTableAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/DataTables/{0}.txt", assetName));
 }
コード例 #22
0
 public static string GetBuffIconAsset(int id)
 {
     return(GlobalTools.Format("Assets/GameMain/Textures/Buff/{0}.png", id));
 }
コード例 #23
0
 public static string GetSoundAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/Sounds/{0}.wav", assetName));
 }
コード例 #24
0
 public static string GetSkillScriptAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/Configs/ActorSkill/{0}.xml", assetName));
 }
コード例 #25
0
 public static string GetUIFormAsset(string assetName)
 {
     return(GlobalTools.Format("Assets/GameMain/UI/UIForms/{0}.prefab", assetName));
 }