Ejemplo n.º 1
0
        public override void Execute(float delta_time)
        {
            bool flag = this.collTarget == null;

            if (flag)
            {
                foreach (MonsterRole current in MonsterMgr._inst.m_mapMonster.Values)
                {
                    bool flag2 = current is CollectRole && ModelBase <A3_TaskModel> .getInstance().IfCurrentCollectItem(current.monsterid);

                    if (flag2)
                    {
                        CollectRole collectRole = current as CollectRole;
                        bool        flag3       = !collectRole.becollected;
                        if (flag3)
                        {
                            this.collTarget = collectRole;
                            break;
                        }
                    }
                }
                bool flag4 = this.collTarget != null;
                if (flag4)
                {
                    SelfRole._inst.TurnToPos(this.collTarget.m_curModel.transform.position);
                    SelfRole._inst.SetDestPos(this.collTarget.m_curModel.transform.position);
                    bool flag5 = !SelfRole._inst.m_moveAgent.hasPath;
                    if (flag5)
                    {
                        SelfRole._inst.m_moveAgent.ResetPath();
                        SelfRole._inst.m_moveAgent.Stop();
                        return;
                    }
                    SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, true);
                }
            }
            bool flag6 = this.collTarget == null;

            if (flag6)
            {
                SelfRole._inst.m_moveAgent.ResetPath();
                SelfRole._inst.m_moveAgent.Stop();
                SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
            }
            else
            {
                bool flag7 = !this.collecting;
                if (flag7)
                {
                    bool flag8 = Vector3.Distance(this.collTarget.m_curModel.transform.position, SelfRole._inst.m_curModel.transform.position) <= 2f;
                    if (flag8)
                    {
                        this.collTarget.onClick();
                        this.collecting = true;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public override void Exit()
 {
     SelfRole._inst.m_moveAgent.ResetPath();
     SelfRole._inst.m_moveAgent.Stop();
     SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
     this.collecting          = false;
     SelfRole.fsm.AutoCollect = false;
     this.collTarget          = null;
 }
Ejemplo n.º 3
0
 public override void Execute(float delta_time)
 {
     if (collTarget == null)
     {
         foreach (MonsterRole m in MonsterMgr._inst.m_mapMonster.Values)
         {
             if (m is CollectRole && A3_TaskModel.getInstance().IfCurrentCollectItem(m.monsterid))
             {
                 var vv = m as CollectRole;
                 if (!vv.becollected)
                 {
                     collTarget = vv;
                     break;
                 }
             }
         }
         if (collTarget != null)
         {
             SelfRole._inst.TurnToPos(collTarget.m_curModel.transform.position);
             SelfRole._inst.SetDestPos(collTarget.m_curModel.transform.position);
             if (!SelfRole._inst.m_moveAgent.hasPath)
             {
                 SelfRole._inst.m_moveAgent.ResetPath();
                 SelfRole._inst.m_moveAgent.Stop();
                 return;
             }
             else
             {
                 SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, true);
                 SelfRole.ChangeRideAniState(true);
             }
         }
     }
     if (SelfRole._inst.m_curModel == null)
     {
         return;                                   //加载模型时
     }
     if (collTarget == null)
     {
         SelfRole._inst.m_moveAgent.ResetPath();
         SelfRole._inst.m_moveAgent.Stop();
         SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
         SelfRole.ChangeRideAniState(false);
     }
     else if (!collecting)
     {
         if (Vector3.Distance(collTarget.m_curModel.transform.position, SelfRole._inst.m_curModel.transform.position) <= 2)
         {
             SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
             SelfRole.ChangeRideAniState(false);
             collTarget.onClick();
             collecting = true;
         }
         else
         {
             SelfRole._inst.TurnToPos(collTarget.m_curModel.transform.position);
             SelfRole._inst.SetDestPos(collTarget.m_curModel.transform.position);
             SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, true);
             SelfRole.ChangeRideAniState(true);
         }
     }
 }
Ejemplo n.º 4
0
    public MonsterRole AddMonster(int id, Vector3 pos, uint serverid = 0, float roatate = 0, int boset_num = 0, int carr = 0, string name = null)
    {
        init();
        if (m_mapMonster.ContainsKey(serverid))
        {
            return(m_mapMonster[serverid]);
        }

        MonsterRole mon = null;
        //if (monID == 1)
        //{
        SXML  xml    = dMon[id];
        int   tempid = xml.getInt("obj");
        float scale  = xml.getFloat("scale");

        //用来给美术测试新加的怪物用的
        if (serverid <= 0)
        {
            if (Globle.m_nTestMonsterID > 0)
            {
                tempid = Globle.m_nTestMonsterID;
            }
        }

        bool isCollect = xml.getInt("collect_tar") > 0;

        bool isboxCollect = xml.getInt("collect_box") > 0;   // 判断这个宝箱是不是采集用的    > 0 则是采集的用宝箱

        //Type TCls;
        //if (Globle.isHardDemo)
        //    TCls = getTypeHandle("Md" + tempid);
        //else
        //{
        //    if (isCollect)
        //    {
        //        if (tempid == 122 && !isboxCollect)
        //        {
        //            TCls = System.Type.GetType("CollectBox");
        //        }
        //        else TCls = System.Type.GetType("CollectRole");
        //    }
        //    else
        //    {
        //        TCls = System.Type.GetType("M" + tempid);
        //    }
        //}
        //if (id == 4002 || carr == 2) TCls = System.Type.GetType("M000P2");
        //else if (id == 4003 || carr == 3) TCls = System.Type.GetType("M000P3");
        //else if (id == 4005 || carr == 5) TCls = System.Type.GetType("M000P5");

        //if (TCls == null)
        //{
        //    TCls = System.Type.GetType("M00000");
        //}

        //mon = (MonsterRole)Activator.CreateInstance(TCls);

        if (isCollect)
        {
            if (tempid == 122)
            {
                mon = new CollectBox();
            }
            else
            {
                mon = new CollectRole();
            }
        }
        if (id == 4002 || carr == 2)
        {
            mon = new M000P2();
        }
        else if (id == 4003 || carr == 3)
        {
            mon = new M000P3();
        }
        else if (id == 4005 || carr == 5)
        {
            mon = new M000P5();
        }
        if (mon == null)
        {
            mon = new M00000();
        }


        if (name != null)
        {
            mon.ownerName = name;
        }
        if (carr == 0)
        {
            mon.roleName = xml.getString("name");
        }
        mon.tempXMl = xml;

        mon.m_circle_type = xml.getInt("boss_circle");
        if (xml.getFloat("boss_circle_scale") == -1)
        {
            mon.m_circle_scale = 1;
        }
        else
        {
            mon.m_circle_scale = xml.getFloat("boss_circle_scale");
        }

        mon.isBoos   = xml.getInt("boss") == 1;
        mon.isBoss_c = xml.getInt("boss_c") == 1;
        if (scale > 0f)
        {
            mon.scale = scale;
        }

        if (serverid > 0)
        {
            mon.m_unIID = serverid;
            m_mapMonster.Add(serverid, mon);
        }
        else
        {
            mon.isfake  = true;
            mon.m_unIID = idIdx;
            m_mapFakeMonster.Add(idIdx, mon);

            idIdx++;
        }

        if (mon != null)
        {
            if (id == 4002 || carr == 2)
            {
                mon.Init("profession_warrior_inst", EnumLayer.LM_MONSTER, pos, roatate);
            }
            else if (id == 4003 || carr == 3)
            {
                mon.Init("profession_mage_inst", EnumLayer.LM_MONSTER, pos, roatate);
            }
            else if (id == 4005 || carr == 5)
            {
                mon.Init("profession_assa_inst", EnumLayer.LM_MONSTER, pos, roatate);
            }
            else if (isCollect)
            {
                mon.Init("npc_" + tempid, EnumLayer.LM_MONSTER, pos, roatate);
            }
            else
            {
                mon.Init("monster_" + tempid, EnumLayer.LM_MONSTER, pos, roatate);
            }
            mon.monsterid = id;

            if (boset_num > 0)
            {
                PlayerNameUIMgr.getInstance().show(mon);
                PlayerNameUIMgr.getInstance().seticon_forDaobao(mon, boset_num);
            }

            if (A3_ActiveModel.getInstance().mwlr_map_info.Count > 0)
            {
                PlayerNameUIMgr.getInstance().seticon_forMonsterHunter(mon, A3_ActiveModel.getInstance().mwlr_map_info[0]["target_mid"] != id);
            }


            //if (GRMap.grmap_loading == false)
            //    mon.refreshViewType(2);
        }


        m_listMonster.Add(mon);


        //}
        //else if (monID == 2)
        //{
        //    mon = new M10002Srg();

        //    mon.Init("monster/10002", EnumLayer.LM_MONSTER, bornpt);
        //    m_mapMonster.Add(idIdx, mon);
        //}
        //else if (monID == 3)
        //{
        //    mon = new M10003Stl();

        //    mon.Init("monster/10003", EnumLayer.LM_MONSTER, bornpt);
        //    m_mapMonster.Add(idIdx, mon);
        //}
        //if (mon != null)
        //{
        //    MonsterData dta = new MonsterData();
        //    dta.roleId = idIdx;
        //    dta.monid = monID;
        //    mon.monsterDta = dta;
        //}

        //idIdx++;

        if (mon != null)
        {
            dispatchEvent(GameEvent.Create(MonsterMgr.EVENT_MONSTER_ADD, this, mon));
        }

        return(mon);
    }