Exemplo n.º 1
0
        public static DropItem create(DropItemdta item)
        {
            GameObject gameObject = new GameObject();
            DropItem   dropItem   = gameObject.AddComponent <DropItem>();

            dropItem.itemdta = item;
            dropItem.init();
            return(dropItem);
        }
Exemplo n.º 2
0
        public static DropItem getDropItem(Vector3 vec, Vector3 eulerAngles, DropItemdta item, bool isfake = false)
        {
            DropItem dropitem = DropItem.create(item);

            dropitem.lastGetTimer          = 0;
            dropitem.transform.position    = vec;
            dropitem.transform.eulerAngles = dropitem.transform.eulerAngles + eulerAngles;
            dropitem.isFake = isfake;
            return(dropitem);
        }
Exemplo n.º 3
0
 public override void Enter()
 {
     passed   = false;
     nearest  = pickTarget = null;
     priority = SelfRole._inst.m_moveAgent.avoidancePriority;
     //debug.Log("========> Enter AI Pick");
     //if (nextpick > Time.time)
     //{
     //    SelfRole.fsm.RevertToPreviousState();
     //    return;
     //}
     //nextpick = Time.time + StateInit.Instance.PickInterval;
 }
Exemplo n.º 4
0
        public void flygetText(DropItem item)
        {
            bool flag = item.itemdta.tpid == 0;

            if (flag)
            {
                MediaClient.instance.PlaySoundUrl("audio/common/collect_coin", false, null);
                bool flag2 = GameRoomMgr.getInstance().curRoom != null;
                if (flag2)
                {
                    GameRoomMgr.getInstance().curRoom.onPickMoney(item.itemdta.count);
                }
                bool flag3 = a3_insideui_fb.instance != null;
                if (flag3)
                {
                    this.goldnum = (uint)a3_insideui_fb.instance.addmoney;
                }
                else
                {
                    this.goldnum += (uint)item.itemdta.count;
                }
            }
            else
            {
                string @string = item.itemdta.itemXml.getString("item_name");
                int    @int    = item.itemdta.itemXml.getInt("quality");
                flytxt.instance.fly(string.Concat(new object[]
                {
                    ContMgr.getCont("gameroom_pick", null),
                    Globle.getColorStrByQuality(@string, @int),
                    "x",
                    item.itemdta.count
                }), 0, default(Color), null);
                DropItemdta dropItemdta = new DropItemdta();
                dropItemdta.tpid = item.itemdta.itemXml.getInt("id");
                dropItemdta.num  = item.itemdta.count;
                foreach (DropItemdta current in this.list2)
                {
                    bool flag4 = dropItemdta.tpid == current.tpid;
                    if (flag4)
                    {
                        current.num += item.itemdta.count;
                        return;
                    }
                }
                this.list2.Add(dropItemdta);
            }
        }
Exemplo n.º 5
0
        public void flygetText(DropItem item)
        {
            if (item.itemdta.tpid == 0)
            {
                MediaClient.instance.PlaySoundUrl("audio_common_collect_coin", false, null);
                // flytxt.instance.fly("拾取金币 " + item.itemdta.count);
                //已有金币添加飘字
                // if (a3_insideui_fb.instance != null) a3_insideui_fb.instance.SetInfMoney(item.itemdta.count);
                if (GameRoomMgr.getInstance().curRoom != null)
                {
                    GameRoomMgr.getInstance().curRoom.onPickMoney(item.itemdta.count);
                }

                //记录拾取金币
                //goldnum += (uint)item.itemdta.count;
                if (a3_insideui_fb.instance != null)
                {
                    goldnum = (uint)a3_insideui_fb.instance.addmoney;
                }
                else
                {
                    goldnum += (uint)item.itemdta.count;
                }
            }
            else
            {
                string name    = item.itemdta.itemXml.getString("item_name");
                int    quality = item.itemdta.itemXml.getInt("quality");
                flytxt.instance.fly(ContMgr.getCont("gameroom_pick") + Globle.getColorStrByQuality(name, quality) + "x" + item.itemdta.count);

                DropItemdta v = new DropItemdta();

                v.tpid = item.itemdta.itemXml.getInt("id");
                v.num  = item.itemdta.count;
                foreach (var it in list2)
                {
                    if (v.tpid == it.tpid)
                    {
                        it.num += item.itemdta.count;
                        return;
                    }
                }
                list2.Add(v);
            }
        }
Exemplo n.º 6
0
        public override void Execute(float delta_time)
        {
            SelfRole._inst.m_moveAgent.avoidancePriority = 1;
            bool flag = this.passed;

            if (flag)
            {
                this.nearest = (this.pickTarget = null);
            }
            bool flag2 = this.nearest == null || !this.nearest.gameObject;

            if (flag2)
            {
                float num = 3.40282347E+38f;
                Dictionary <uint, DropItem> .Enumerator enumerator = BaseRoomItem.instance.dDropItem_own.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    KeyValuePair <uint, DropItem> current = enumerator.Current;
                    DropItem value = current.Value;
                    bool     flag3 = value != null && value.gameObject;
                    if (flag3)
                    {
                        bool flag4 = value.itemdta.ownerId > 0u;
                        bool flag5 = value.itemdta.ownerId != ModelBase <PlayerModel> .getInstance().cid || (BaseProxy <TeamProxy> .getInstance().MyTeamData != null && value.itemdta.ownerId == BaseProxy <TeamProxy> .getInstance().MyTeamData.teamId);

                        bool flag6 = flag4 & flag5;
                        if (!flag6)
                        {
                            bool flag7 = Vector3.Distance(value.transform.position.ConvertToGamePosition(), SelfRole._inst.m_curModel.transform.position.ConvertToGamePosition()) > StateInit.Instance.PickDistance;
                            if (!flag7)
                            {
                                bool flag8 = ModelBase <a3_BagModel> .getInstance().curi <= ModelBase <a3_BagModel> .getInstance().getItems(false).Count&& (ModelBase <a3_BagModel> .getInstance().getItemNumByTpid((uint)value.itemdta.tpid) == 0 || ModelBase <a3_BagModel> .getInstance().getItemNumByTpid((uint)value.itemdta.tpid) >= ModelBase <a3_BagModel> .getInstance().getItemDataById((uint)value.itemdta.tpid).maxnum) && value.itemdta.tpid != 0;

                                if (!flag8)
                                {
                                    bool flag9 = value.canPick && ModelBase <AutoPlayModel> .getInstance().WillPick((uint)value.itemdta.tpid);

                                    if (flag9)
                                    {
                                        this.pickTarget = value;
                                        bool flag10 = this.nearest == null;
                                        if (flag10)
                                        {
                                            this.nearest = this.pickTarget;
                                        }
                                        float num2   = Vector3.Distance(this.pickTarget.transform.position.ConvertToGamePosition(), SelfRole._inst.m_curModel.transform.position.ConvertToGamePosition());
                                        bool  flag11 = num2 < num;
                                        if (flag11)
                                        {
                                            num          = num2;
                                            this.nearest = this.pickTarget;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                this.calc_ori = SelfRole._inst.m_curModel.transform.position;
                bool flag12 = this.nearest != null;
                if (flag12)
                {
                    SelfRole._inst.SetDestPos(this.nearest.transform.position);
                    this.calc_tar = this.nearest.transform.position;
                    return;
                }
                this.calc_tar = Vector3.zero;
            }
            else
            {
                bool flag13 = this.nearest != null;
                if (flag13)
                {
                    bool flag14 = this.nearest.gameObject != null && Vector3.Distance(SelfRole._inst.m_curModel.position.ConvertToGamePosition(), this.nearest.transform.position.ConvertToGamePosition()) < 0.5f;
                    if (flag14)
                    {
                        this.nearest.PickUpItem();
                    }
                    bool flag15 = Vector3.Distance(this.nearest.transform.position.ConvertToGamePosition(), SelfRole._inst.m_curModel.transform.position.ConvertToGamePosition()) > StateInit.Instance.PickDistance;
                    bool flag16 = !this.passed && !flag15;
                    if (flag16)
                    {
                        SelfRole._inst.TurnToPos(this.nearest.transform.position);
                        SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, true);
                    }
                    else
                    {
                        this.nearest = null;
                        SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                    }
                }
            }
            this.calc_cur = SelfRole._inst.m_curModel.transform.position;
            this.passed   = this.CheckPass(this.calc_ori, this.calc_cur, this.calc_tar);
            bool flag17 = this.nearest == null || this.nearest.gameObject == null;

            if (flag17)
            {
                SelfRole._inst.m_moveAgent.Stop();
                SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                bool autofighting = SelfRole.fsm.Autofighting;
                if (autofighting)
                {
                    SelfRole.fsm.ChangeState(StateAttack.Instance);
                }
                else
                {
                    SelfRole.fsm.ChangeState(StateIdle.Instance);
                }
            }
        }
Exemplo n.º 7
0
 public override void Enter()
 {
     this.passed   = false;
     this.nearest  = (this.pickTarget = null);
     this.priority = SelfRole._inst.m_moveAgent.avoidancePriority;
 }
Exemplo n.º 8
0
        private int showDrop(Vector3 dropPos, int wrongcount, int idx, DropItemdta item, bool isfake = false)
        {
            if (lDropOffset.Count <= idx)
            {
                idx = 0;
            }
            Vector3 vec = dropPos + lDropOffset[idx];
            //  GameObject go = GameObject.Find("coin");
            Vector3 begin = vec;

            begin.y = -99;



            NavMeshHit hit;

            //if (NavMesh.Raycast(begin, vec, out hit, NavMesh.GetNavMeshLayerFromName("Default")))
            NavMesh.SamplePosition(vec, out hit, 100f, NavmeshUtils.allARE);
            Vector3 pos = hit.position;

            if (pos.x == vec.x && pos.z == vec.z)
            {
                vec.y = pos.y;
                DropItem itm = getDropItem(vec, Vector3.zero, item, isfake);

                DropItemUIMgr.getInstance().show(itm, itm.itemdta.getDropItemName());
                if (!isfake)
                {
                    dDropItem[item.dpid] = itm;
                    if (item.ownerId == PlayerModel.getInstance().cid || item.ownerId == 0 ||
                        (TeamProxy.getInstance().MyTeamData != null && item.ownerId == TeamProxy.getInstance().MyTeamData.teamId))
                    {
                        dDropItem_own[item.dpid] = itm;
                    }
                }
                else
                {
                    item.dpid = fakeItemIdx;
                    dDropFakeItem[item.dpid] = itm;
                    fakeItemIdx++;
                }

                return(idx + 1);
            }
            else if (wrongcount >= 3)
            {
                debug.Log(":" + item.dpid);
                DropItem itm = getDropItem(pos, Vector3.zero, item);
                DropItemUIMgr.getInstance().show(itm, itm.itemdta.getDropItemName());

                if (!isfake)
                {
                    dDropItem[item.dpid] = itm;
                    //if (item.ownerId == PlayerModel.getInstance().cid)
                    //{
                    //dDropItem_own[item.dpid] = itm;
                    if (item.ownerId == PlayerModel.getInstance().cid || item.ownerId == 0 ||
                        (TeamProxy.getInstance().MyTeamData != null && item.ownerId == TeamProxy.getInstance().MyTeamData.teamId))
                    {
                        dDropItem_own[item.dpid] = itm;
                    }
                    //}
                }
                else
                {
                    item.dpid = fakeItemIdx;
                    dDropFakeItem[item.dpid] = itm;
                    fakeItemIdx++;
                }
                return(idx + 1);
            }
            wrongcount++;
            return(showDrop(dropPos, wrongcount, idx + 1, item, isfake));
        }
Exemplo n.º 9
0
        private int showDrop(Vector3 dropPos, int wrongcount, int idx, DropItemdta item, bool isfake = false)
        {
            bool flag = this.lDropOffset.Count <= idx;

            if (flag)
            {
                idx = 0;
            }
            Vector3 vector  = dropPos + this.lDropOffset[idx];
            Vector3 vector2 = vector;

            vector2.y = -99f;
            NavMeshHit navMeshHit;

            NavMesh.SamplePosition(vector, out navMeshHit, 100f, NavmeshUtils.allARE);
            Vector3 position = navMeshHit.position;
            bool    flag2    = position.x == vector.x && position.z == vector.z;
            int     result;

            if (flag2)
            {
                vector.y = position.y;
                DropItem dropItem = BaseRoomItem.getDropItem(vector, Vector3.zero, item, isfake);
                DropItemUIMgr.getInstance().show(dropItem, dropItem.itemdta.getDropItemName());
                bool flag3 = !isfake;
                if (flag3)
                {
                    this.dDropItem[item.dpid] = dropItem;
                    bool flag4 = item.ownerId == ModelBase <PlayerModel> .getInstance().cid || item.ownerId == 0u || (BaseProxy <TeamProxy> .getInstance().MyTeamData != null && item.ownerId == BaseProxy <TeamProxy> .getInstance().MyTeamData.teamId);

                    if (flag4)
                    {
                        this.dDropItem_own[item.dpid] = dropItem;
                    }
                }
                else
                {
                    item.dpid = this.fakeItemIdx;
                    this.dDropFakeItem[item.dpid] = dropItem;
                    this.fakeItemIdx += 1u;
                }
                result = idx + 1;
            }
            else
            {
                bool flag5 = wrongcount >= 3;
                if (flag5)
                {
                    debug.Log(":" + item.dpid);
                    DropItem dropItem2 = BaseRoomItem.getDropItem(position, Vector3.zero, item, false);
                    DropItemUIMgr.getInstance().show(dropItem2, dropItem2.itemdta.getDropItemName());
                    bool flag6 = !isfake;
                    if (flag6)
                    {
                        this.dDropItem[item.dpid] = dropItem2;
                        bool flag7 = item.ownerId == ModelBase <PlayerModel> .getInstance().cid || item.ownerId == 0u || (BaseProxy <TeamProxy> .getInstance().MyTeamData != null && item.ownerId == BaseProxy <TeamProxy> .getInstance().MyTeamData.teamId);

                        if (flag7)
                        {
                            this.dDropItem_own[item.dpid] = dropItem2;
                        }
                    }
                    else
                    {
                        item.dpid = this.fakeItemIdx;
                        this.dDropFakeItem[item.dpid] = dropItem2;
                        this.fakeItemIdx += 1u;
                    }
                    result = idx + 1;
                }
                else
                {
                    wrongcount++;
                    result = this.showDrop(dropPos, wrongcount, idx + 1, item, isfake);
                }
            }
            return(result);
        }
Exemplo n.º 10
0
        public override void Execute(float delta_time)
        {
            //if (dropTimer > dropDruation)
            //{//限定拾取不超时
            //    SelfRole.fsm.ChangeState(StateIdle.Instance);
            //    return;
            //}
            //dropTimer += delta_time;
            SelfRole._inst.m_moveAgent.avoidancePriority = 1;
            if (passed)
            {
                nearest        =
                    pickTarget = null;
            }
            if (nearest == null || !nearest.gameObject)
            {//选取一个掉落目标,移动过去
                DropItem drpitm;
                float    min = float.MaxValue;
                Dictionary <uint, DropItem> .Enumerator etor = BaseRoomItem.instance.dDropItem_own.GetEnumerator();
                while (etor.MoveNext())
                {
                    drpitm = etor.Current.Value;
                    if (drpitm != null && drpitm.gameObject)
                    {
                        bool hasOwner = drpitm.itemdta.ownerId != 0,
                             notMine  = drpitm.itemdta.ownerId != PlayerModel.getInstance().cid ||
                                        (TeamProxy.getInstance().MyTeamData != null && drpitm.itemdta.ownerId == TeamProxy.getInstance().MyTeamData.teamId);
                        if (hasOwner && notMine)
                        {
                            continue;
                        }
                        //!--距离超过拾取范围
                        if (Vector3.Distance(drpitm.transform.position.ConvertToGamePosition(), SelfRole._inst.m_curModel.transform.position.ConvertToGamePosition()) > StateInit.Instance.PickDistance)
                        {
                            continue;
                        }
                        //!--如果背包满且不是金币,不捡
                        if (a3_BagModel.getInstance().curi <= a3_BagModel.getInstance().getItems().Count&& (
                                a3_BagModel.getInstance().getItemNumByTpid((uint)drpitm.itemdta.tpid) == 0 ||
                                a3_BagModel.getInstance().getItemNumByTpid((uint)drpitm.itemdta.tpid) >= a3_BagModel.getInstance().getItemDataById((uint)drpitm.itemdta.tpid).maxnum) &&
                            drpitm.itemdta.tpid != 0)
                        {
                            continue;
                        }

                        if (A3_RollModel.getInstance().rollMapping.ContainsKey(drpitm.itemdta.dpid) && !A3_RollModel.getInstance().rollMapping[drpitm.itemdta.dpid].isCanPick)
                        {
                            continue;
                        }

                        else if (drpitm.canPick && AutoPlayModel.getInstance().WillPick((uint)drpitm.itemdta.tpid))
                        {
                            pickTarget = drpitm;
                            if (nearest == null)
                            {
                                nearest = pickTarget;
                            }
                            else
                            {
                                float dis = Vector3.Distance(pickTarget.transform.position.ConvertToGamePosition(), SelfRole._inst.m_curModel.transform.position.ConvertToGamePosition());
                                if (dis < min)
                                {
                                    min     = dis;
                                    nearest = pickTarget;
                                }
                            }
                        }
                        else
                        {
                            pickTarget = null;
                        }
                    }
                }

                calc_ori = SelfRole._inst.m_curModel.transform.position;
                if (nearest != null)
                {
                    //if (A3_RollModel.getInstance().rollMapping.ContainsKey(nearest.itemdta.dpid))  // 该物品是roll点物品
                    //{
                    //    bool isCanPick = A3_RollModel.getInstance().rollMapping[nearest.itemdta.dpid].isCanPick;

                    //    if (!isCanPick)
                    //    {
                    //        nearest = null;
                    //        calc_tar = Vector3.zero;
                    //    }
                    //    else
                    //    {
                    //        SelfRole._inst.SetDestPos(nearest.transform.position);
                    //        calc_tar = nearest.transform.position;
                    //        return;
                    //    }
                    //}
                    //else {

                    SelfRole._inst.SetDestPos(nearest.transform.position);
                    calc_tar = nearest.transform.position;

                    return;
                    //}
                }
                else
                {
                    calc_tar = Vector3.zero;
                }
            }
            else
            {
                //if (nearest != null)
                //{
                if (nearest.gameObject != null && Vector3.Distance(SelfRole._inst.m_curModel.position.ConvertToGamePosition(), nearest.transform.position.ConvertToGamePosition()) < 0.5f)
                {
                    nearest.PickUpItem();
                    SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                    SelfRole.ChangeRideAniState(false);
                    nearest = null;
                }

                if (nearest != null)
                {
                    bool isOutOfTouch = Vector3.Distance(nearest.transform.position.ConvertToGamePosition(), SelfRole._inst.m_curModel.transform.position.ConvertToGamePosition()) > StateInit.Instance.PickDistance;
                    if (!passed && !isOutOfTouch)
                    {
                        SelfRole._inst.TurnToPos(nearest.transform.position);
                        SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, true);
                        SelfRole.ChangeRideAniState(true);
                    }
                    else
                    {
                        nearest = null;
                        SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                        SelfRole.ChangeRideAniState(false);
                    }
                }
                //}
            }


            calc_cur = SelfRole._inst.m_curModel.transform.position;
            passed   = CheckPass(calc_ori, calc_cur, calc_tar);
            if (nearest == null || nearest.gameObject == null)
            {
                SelfRole._inst.m_moveAgent.Stop();
                SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                SelfRole.ChangeRideAniState(false);
                if (SelfRole.fsm.Autofighting)
                {
                    SelfRole.fsm.ChangeState(StateAttack.Instance);
                }
                else
                {
                    SelfRole.fsm.ChangeState(StateIdle.Instance);
                }
                return;
            }
        }