Example #1
0
        private void NpcSkillAttackInternal(RoleView target, NpcSkillAttackEvent evData)
        {
            var       skillKey  = evData.bUseSkill ? AnimNames.Skill : AnimNames.Attack;
            SkillData skillData = null;

            roleData.skills.TryGetValue(skillKey, out skillData);
            if (skillData != null)
            {
                var targetFrameAction = new FrameActionData();  //被击者
                targetFrameAction.currHp      = evData.currHp;
                targetFrameAction.maxHp       = evData.maxHp;
                targetFrameAction.amount      = evData.amount;
                targetFrameAction.bPlaySound  = evData.bPlaySound;
                targetFrameAction.type        = FrameActionType.Passive;
                targetFrameAction.skillParams = skillData.skillParams;
                target.OnTakeDamage(targetFrameAction);

                var myFrameAction = new FrameActionData();      //攻击者
                myFrameAction.type         = FrameActionType.Active;
                myFrameAction.skillParams  = skillData.skillParams;
                myFrameAction.bPlaySound   = evData.bPlaySound;
                myFrameAction.target       = target;
                myFrameAction.animClipName = evData.bUseSkill ? AnimNames.Skill : AnimNames.Attack;
                timerMgr.CreateTicker(skillData.frameDatas, myFrameAction, OnFrameAction);
            }
            else
            {
                GLogger.Red("!!!NpcSkillAttackInternal:>>" + evData.attackerid + " " + evData.defenderid + " " + evData.bUseSkill);
            }
        }
Example #2
0
        Vector3 FindBattlePos()
        {
            Vector3 currPos = embattlePosMgr.GetBattlePos();

            GLogger.Gray("Find Battle Pos::>" + currPos + " npcid:>" + mynpcId.value);

            var viewPortMargin = LogicConst.Viewport_Margin;

            if (myNpcData.npcType == NpcType.Hero)
            {
                var targetData = npcDataMgr.GetNpcData(targetId.value);
                if (targetData.position.x < myNpcData.position.x)
                {
                    currPos.x -= viewPortMargin / 1.5f - 0.6f;
                }
                else
                {
                    currPos.x += viewPortMargin / 1.5f - 0.6f;
                }
            }
            else
            {
                var v = myNpcData.faceDir == FaceDir.Left ? 1 : -1;
                currPos.x += v * viewPortMargin / 1.5f;
            }
            currPos.y = myNpcData.position.y;
            currPos.z = myNpcData.position.z;
            return(currPos);
        }
Example #3
0
        /// <summary>
        /// 移动NPC事件完成
        /// </summary>
        /// <param name="param"></param>
        private void OnEvMoveNpcOK(object param)
        {
            var npcid = (long)param;

            GLogger.Green("OnEvMoveNpcOK:>" + npcid);

            var npcData = npcDataMgr.GetNpcData(npcid);

            if (npcData != null)
            {
                npcData.npcState = NpcState.Ready;
            }
            if (!npcDataMgr.IsAllNpcStateOK(NpcType.Hero, NpcState.Move))
            {
                return;     //移动还没有全部完成
            }
            if (eventMgr.IsEndTurnEvent())
            {
                Debug.LogError("IsEndTurnEvent EXEC OK!!!");
            }
            else
            {
                eventMgr.NewTurnEvent(delegate(Vector2 pos)
                {
                    Debug.Log("OnNpcMoveOK event at " + pos + " execute ok!!!");
                });
            }
        }
        /// <summary>
        /// 下一个事件
        /// </summary>
        void MoveNextEvent(Vector2 currPos)
        {
            if (events.Count == 0)
            {
                if (execOK != null)
                {
                    execOK(currPos);
                }
                return;
            }
            var evData = events.Dequeue();

            if (evData == null)
            {
                MoveNextEvent(currPos);
                return;
            }
            GLogger.Yellow("MoveNext evType:" + evData.type);

            var currEvent = sceneEvents[evData.type];

            if (currEvent != null)
            {
                if (evData.type == EventsType.MoveNpc || evData.type == EventsType.MoveCamera)
                {
                    currEvent.OnExecute(currPos, evData.value, () => MoveNextEvent(currPos));
                }
                else
                {
                    currEvent.OnExecute(evData.value, () => MoveNextEvent(currPos));
                }
            }
        }
Example #5
0
        public override void Enter()
        {
            base.Enter();
            mynpcId   = npcFsm.GetVar <long>("mynpcId");
            myNpcData = npcDataMgr.GetNpcData(mynpcId.value);
            GLogger.Red(mynpcId.value + " enter Death...");

            DoNpcDeath();
        }
        public override void OnMessage(byte[] bytes)
        {
            //解包读取
            var person = DeSerialize <Person>(bytes);

            GLogger.Log(person.name);

            ///封包发送
            networkMgr.SendData <Person>("Person", person);
        }
Example #7
0
        /// <summary>
        /// 下一个事件
        /// </summary>
        void MoveNextEvent(Vector2 currPos)
        {
            if (events.Count == 0)
            {
                if (execOK != null)
                {
                    execOK(currPos);
                }
                return;
            }
            var evData = events.Dequeue();

            if (evData == null)
            {
                MoveNextEvent(currPos);
                return;
            }
            GLogger.Yellow("MoveNext evType:" + evData.type);

            switch (evData.type)
            {
            case EventsType.SpawnHeroNpc:
                OnEvSpawnHeroNpc(() => MoveNextEvent(currPos));
                break;

            case EventsType.SpawnTeamNpc:
                OnEvSpawnTeamNpc(evData.value, () => MoveNextEvent(currPos));
                break;

            case EventsType.Dungeon:
                OnEvDungeon(evData.value, () => MoveNextEvent(currPos));
                break;

            case EventsType.Dialog:
                OnEvDialog(evData.value, () => MoveNextEvent(currPos));
                break;

            case EventsType.MoveCamera:
                OnEvMoveCamera(currPos, evData.value, () => MoveNextEvent(currPos));
                break;

            case EventsType.MoveNpc:
                OnEvMoveNpc(currPos, evData.value, () => MoveNextEvent(currPos));
                break;

            case EventsType.LoadScene:
                OnEvLoadScene(evData.value, () => MoveNextEvent(currPos));
                break;

            case EventsType.StartFight:
                OnEvStartFight(evData.value, () => MoveNextEvent(currPos));
                break;
            }
        }
Example #8
0
        public override void Enter()
        {
            base.Enter();
            mynpcId  = npcFsm.GetVar <long>("mynpcId");
            targetId = npcFsm.GetVar <long>("targetId");

            myNpcData          = npcDataMgr.GetNpcData(mynpcId.value);
            myNpcData.npcState = NpcState.Attack;

            GLogger.Log(mynpcId.value + " enter Attack...");
            NpcSkillAttack();
        }
Example #9
0
        public override void Enter()
        {
            base.Enter();

            mynpcId        = npcFsm.GetVar <long>("mynpcId");
            targetId       = npcFsm.GetVar <long>("targetId");
            targetId.value = 0;

            myNpcData          = npcDataMgr.GetNpcData(mynpcId.value);
            myNpcData.npcState = NpcState.Search;

            GLogger.Log(mynpcId.value + " enter Search...");
        }
        /// <summary>
        /// 攻击完成
        /// </summary>
        /// <param name="eventId"></param>
        private void OnNpcSkillAttackOK(long eventId)
        {
            var gameEvent = evMappingMgr.Remove(eventId);

            if (gameEvent != null)
            {
                var attackEvent = gameEvent.evParam as NpcSkillAttackEvent;
                if (attackEvent != null)
                {
                    attackEvent.callback(attackEvent.defenderid);
                }
            }
            GLogger.Log("OnNpcSkillAttackOK:" + eventId);
        }
Example #11
0
        public override void OnMessage(byte[] bytes)
        {
            //解包读取
            var person = Person.Parser.ParseFrom(bytes);

            GLogger.Log(person.Name);

            ///封包发送
            using (MemoryStream stream = new MemoryStream())
            {
                // Save the person to a stream
                person.WriteTo(stream);
                bytes = stream.ToArray();
                networkMgr.SendData("Person", bytes);
            }
        }
        IEnumerator OnLoadAssetBundle(string abName, Type type)
        {
            string url = GetAssetFullPath(abName);

            if (m_AssetBundleLoadingList.ContainsKey(url))
            {
                m_AssetBundleLoadingList[url]++;
                yield break;
            }
            m_AssetBundleLoadingList.Add(url, 1);
            GLogger.Gray(url);
            var abUrl   = Application.isEditor ? abName : url;
            var request = AssetBundle.LoadFromFileAsync(url);

            if (abName != AppConst.ResIndexFile)
            {
                string[] dependencies = m_AssetBundleManifest.GetAllDependencies(abName);
                if (dependencies.Length > 0)
                {
                    m_Dependencies.Add(abName, dependencies);
                    for (int i = 0; i < dependencies.Length; i++)
                    {
                        string          depName    = dependencies[i];
                        AssetBundleInfo bundleInfo = null;
                        if (m_LoadedAssetBundles.TryGetValue(depName, out bundleInfo))
                        {
                            bundleInfo.m_ReferencedCount++;
                        }
                        else if (!m_LoadRequests.ContainsKey(depName))
                        {
                            yield return(mResMgr.StartCoroutine(OnLoadAssetBundle(depName, type)));
                        }
                    }
                }
            }
            yield return(request);

            AssetBundle assetObj = request.assetBundle;

            if (assetObj != null)
            {
                var RefCount   = m_AssetBundleLoadingList[url];
                var bundleInfo = new AssetBundleInfo(assetObj, RefCount);
                m_LoadedAssetBundles.Add(abName, bundleInfo);
            }
            m_AssetBundleLoadingList.Remove(url);
        }
Example #13
0
        /// <summary>
        /// 战斗结束
        /// </summary>
        private void OnBattleEnd(GameEventData eventData)
        {
            var battleEndEvent = eventData.evParam as BattleEndEvent;
            var battleType     = battleEndEvent.type;

            if (battleType == BattleType.TurnBase)
            {
                Util.CallLuaMethod("LeaveDungeon", (Action) delegate()
                {
                    GLogger.Red("BattleEnd---->>>" + battleType);
                });
            }
            else
            {
                GLogger.Red("BattleEnd---->>>" + battleType);
            }
        }
Example #14
0
        /// <summary>
        /// 动作剪辑播放完成回调函数
        /// </summary>
        /// <param name="obj"></param>
        private void OnPlayingClipOK(string clip)
        {
            switch (clip)
            {
            case AnimNames.Attack:          //战斗完成
            case AnimNames.Skill:
                OnNpcSkillAttackOK(clip);
                PlayRoleAnim(AnimNames.Idle, true);
                break;

            case AnimNames.Damage:          //被击完成
                if (!bRunning)
                {
                    PlayRoleAnim(AnimNames.Idle, true);
                }
                break;
            }
            GLogger.White("OnPlayingClipOK::>>" + clip);
        }
Example #15
0
        /// <summary>
        /// 动作剪辑播放完成回调函数
        /// </summary>
        /// <param name="obj"></param>
        private void OnPlayingClipOK(string clip)
        {
            switch (clip)
            {
            case AnimNames.Attack:          //战斗完成
            case AnimNames.Skill:
                OnNpcSkillAttackOK();
                PlayRoleAnim(AnimNames.Idle, true);
                break;

            case AnimNames.BeAttacked:          //被击完成
                if (!bRunning)
                {
                    PlayRoleAnim(AnimNames.Idle, true);
                }
                break;
            }
            GLogger.Log("OnPlayingClipOK::>>" + gameObject.name + " " + clip);
        }
        /// <summary>
        /// 受到伤害
        /// </summary>
        private void OnNpcSkillAttack(GameEventData evData)
        {
            var evBattle = evData.evParam as NpcSkillAttackEvent;

            if (evBattle != null)
            {
                var eventid    = evData.eventId;
                var attackerid = evBattle.attackerid;
                var defenderid = evBattle.defenderid;

                var attacker = npcMgr.GetNpc(attackerid) as RoleView;
                var defender = npcMgr.GetNpc(defenderid) as RoleView;
                if (attacker != null && defender != null)
                {
                    GLogger.White("OnAttackNpc:>>eventid:" + eventid + " attacker:" + attackerid + " defender:" + defenderid + " currhp:" + evBattle.currHp + " maxhp:" + evBattle.maxHp);
                    attacker.NpcSkillAttack(defender, evBattle, delegate()
                    {
                        Messenger.Broadcast <long>(EventNames.EvNpcSkillAttackOK, eventid);
                    });
                }
            }
        }
        /// <summary>
        /// 下一波敌人
        /// </summary>
        public void MoveNextTurn()
        {
            var teamCount = CurrHandler?.GetTeamCount();

            GLogger.Gray("MoveNextTurn--------->>>" + teamCount);
            if (teamCount == 0)
            {
                if (npcDataMgr.IsAllNpcStateOK(NpcType.Hero, NpcState.Attack))
                {
                    timerMgr.AddTimer(0.5f, 0, (obj) =>
                    {
                        if (execOK != null)
                        {
                            execOK();
                        }
                    });
                }
            }
            else
            {
                this.SpawnNpcTeam();
                CurrHandler?.MoveNextTurn();
            }
        }
Example #18
0
        /// <summary>
        /// 当载入关卡
        /// </summary>
        static IEnumerator OnLoadLevel(LevelType levelType, LuaTable self, LuaFunction onLeave, LuaFunction onEnter)
        {
            Scene     scene     = SceneManager.GetActiveScene();
            var       levelName = scene.name.FirstCharToUpper();
            LevelType currLevel = (LevelType)Enum.Parse(typeof(LevelType), levelName);

            var op = SceneManager.LoadSceneAsync(levelType.ToString());

            yield return(op);

            yield return(new WaitForSeconds(0.1f));

            if (LevelType.Loader == levelType)
            {
                if (onLeave != null)
                {
                    onLeave.Call <LuaTable, LevelType, Action>(self, currLevel, delegate()
                    {
                        Util.StartCoroutine(OnLoadLevel(newLevel, self, onLeave, onEnter));
                    });
                    onLeave.Dispose();
                    onLeave = null;
                }
            }
            else
            {
                if (onEnter != null)
                {
                    var loadMsg = "OnLoadLevel " + levelType + " OK!!!";
                    onEnter.Call <LuaTable, LevelType, Action>(self, levelType, () => GLogger.Yellow(loadMsg));
                    onEnter.Dispose();
                    onEnter = null;

                    self.Dispose();
                    self = null;
                }
            }
        }
 public void Initialize(Vector2 pos)
 {
     currPos = pos;
     GLogger.Yellow("Initialize Battle Pos====================:>>" + pos);
     embattlePosMgr.Initialize(pos);
 }
Example #20
0
        /// <summary>
        /// 当载入关卡
        /// </summary>
        static IEnumerator OnLoadLevel(LevelType levelType, LuaTable self, LuaFunction onLeave, LuaFunction onEnter)
        {
            int levelid = (int)levelType;
            var op      = SceneManager.LoadSceneAsync(levelid);

            yield return(op);

            yield return(new WaitForSeconds(0.1f));

            if (LevelType.Loader == levelType)
            {
                if (onLeave != null)
                {
                    onLeave.Call <LuaTable, LevelType, Action>(self, levelType, (Action) delegate()
                    {
                        Util.StartCoroutine(OnLoadLevel(newLevel, self, onLeave, onEnter));
                    });
                    onLeave.Dispose();
                    onLeave = null;
                }
            }
            else
            {
                if (onEnter != null)
                {
                    var loadMsg = "OnLoadLevel " + levelType + " OK!!!";
                    onEnter.Call <LuaTable, LevelType, Action>(self, levelType, () => GLogger.Yellow(loadMsg));
                    onEnter.Dispose();
                    onEnter = null;

                    self.Dispose();
                    self = null;
                }
            }
        }
Example #21
0
 public BattleFSM()
 {
     GLogger.Cyan("Current FSM Type:" + LogicConst.BattleType);
 }
Example #22
0
        /// <summary>
        /// 战斗开始
        /// </summary>
        private void OnBattleStart(GameEventData eventData)
        {
            var battleStartEvent = eventData.evParam as BattleStartEvent;

            GLogger.Magenta("BattleStart----->>>" + battleStartEvent.type);
        }