Ejemplo n.º 1
0
        // 执行动作
        // 若为瞬间动作,返回true;
        // 若为持续动作,该函数会每帧被调用,直到返回true
        public override bool Logic()
        {
            //TODO: 获取到世界边界参数,才能做clamp操作
            Pathea.PeEntity entity = PeScenarioUtility.GetEntity(obj);
            if (entity != null && entity.peTrans != null)
            {
                if (pos != Vector3.zero)
                {
                    if (func_pos == EFunc.Plus || func_pos == EFunc.Minus)
                    {
                        entity.peTrans.position = LocalToWorld(entity.peTrans, pos, func_pos);
                    }
                    else
                    {
                        entity.peTrans.position = LocalToWorld(entity.peTrans, pos, EFunc.SetTo);
                    }
                }

                if (rot != Vector3.zero)
                {
                    Quaternion q = Quaternion.identity;
                    q.eulerAngles           = Calculate(entity.peTrans.rotation.eulerAngles, rot, func_rot);
                    entity.peTrans.rotation = q;
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
 // 判断条件
 public override bool?Check()
 {
     if (player.type == OBJECT.OBJECTTYPE.Player && equip.type == OBJECT.OBJECTTYPE.ItemProto)
     {
         Pathea.PeEntity entity = PeScenarioUtility.GetEntity(player);
         if (entity != null && entity.equipmentCmpt != null)
         {
             List <ItemObject> list = entity.equipmentCmpt._ItemList;
             for (int i = 0; i < list.Count; ++i)
             {
                 if (equip.isAnyPrototype)
                 {
                     return(true);
                 }
                 if (equip.isAnyPrototypeInCategory && list[i].protoData.editorTypeId == equip.Group)
                 {
                     return(true);
                 }
                 if (list[i].protoId == equip.Id)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        // 执行动作
        // 若为瞬间动作,返回true;
        // 若为持续动作,该函数会每帧被调用,直到返回true
        public override bool Logic()
        {
            if (Pathea.PeGameMgr.IsMulti)
            {
                byte[] data = PETools.Serialize.Export(w =>
                {
                    BufferHelper.Serialize(w, obj);
                });

                PlayerNetwork.RequestServer(EPacketType.PT_Custom_CancelOrder, data);
            }
            else
            {
                Pathea.PeEntity entity = PeScenarioUtility.GetEntity(obj);
                if (entity != null && entity.requestCmpt != null)
                {
                    if (entity.requestCmpt.Contains(Pathea.EReqType.Dialogue))
                    {
                        entity.requestCmpt.RemoveRequest(Pathea.EReqType.Dialogue);
                    }
                    if (entity.requestCmpt.Contains(Pathea.EReqType.MoveToPoint))
                    {
                        entity.requestCmpt.RemoveRequest(Pathea.EReqType.MoveToPoint);
                    }
                    if (entity.requestCmpt.Contains(Pathea.EReqType.FollowTarget))
                    {
                        entity.requestCmpt.RemoveRequest(Pathea.EReqType.FollowTarget);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
        public void OnGUI()
        {
            if (!_initialized)
            {
                return;
            }

            guiMgr.DrawGUI();

            if (s_ShowTools)
            {
                mNPCid = GUI.TextArea(new Rect(100, 130 + 140, 80, 20), mNPCid);
                if (GUI.Button(new Rect(10, 130 + 140, 70, 20), "EntityId"))
                {
                    OBJECT obj;
                    obj.type  = OBJECT.OBJECTTYPE.WorldObject;
                    obj.Group = 0;
                    obj.Id    = System.Convert.ToInt32(mNPCid);
                    Pathea.PeEntity entity = PeScenarioUtility.GetEntity(obj);
                    if (entity != null)
                    {
                        Vector3 pos = PeCreature.Instance.mainPlayer.position;
                        pos.z += 2;
                        pos.y += 1;

                        entity.peTrans.position      = pos;
                        entity.NpcCmpt.FixedPointPos = pos;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 // 判断条件
 public override bool?Check()
 {
     if (player.type == OBJECT.OBJECTTYPE.Player && item.type == OBJECT.OBJECTTYPE.ItemProto)
     {
         Pathea.PeEntity entity = PeScenarioUtility.GetEntity(player);
         if (entity != null && entity.packageCmpt != null)
         {
             int num = 0;
             if (item.isSpecificPrototype)
             {
                 num = entity.packageCmpt.GetItemCount(item.Id);             //某种item
             }
             else if (item.isAnyPrototypeInCategory)
             {
                 num = entity.packageCmpt.GetCountByEditorType(item.Group);  //某大类item
             }
             else if (item.isAnyPrototype)
             {
                 num = entity.packageCmpt.GetAllItemsCount();                //全部item
             }
             if (Utility.Compare(num, count, comp))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 6
0
 // 判断条件
 public override bool?Check()
 {
     Pathea.PeEntity entity = PeScenarioUtility.GetEntity(player);
     if (entity != null && Pathea.CustomGameData.Mgr.Instance.curGameData.WorldIndex == worldId)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 7
0
 // 判断条件
 public override bool?Check()
 {
     if (player.type == OBJECT.OBJECTTYPE.Player)
     {
         Pathea.PeEntity entity = PeScenarioUtility.GetEntity(player);
         if (entity != null && entity.motionEquipment != null)
         {
             return((entity.motionEquipment.Weapon != null) == state);
         }
     }
     return(!state);
 }
Ejemplo n.º 8
0
        // 执行动作
        // 若为瞬间动作,返回true;
        // 若为持续动作,该函数会每帧被调用,直到返回true
        public override bool Logic()
        {
            if (Pathea.PeGameMgr.IsMulti)
            {
                byte[] data = PETools.Serialize.Export(w =>
                {
                    BufferHelper.Serialize(w, player);
                    BufferHelper.Serialize(w, item);
                    w.Write(count);
                    w.Write((byte)func);
                });

                PlayerNetwork.RequestServer(EPacketType.PT_Custom_ModifyPackage, data);
            }
            else
            {
                if (player.type == OBJECT.OBJECTTYPE.Player && item.type == OBJECT.OBJECTTYPE.ItemProto && item.isSpecificPrototype)
                {
                    Pathea.PeEntity entity = PeScenarioUtility.GetEntity(player);
                    if (entity != null && entity.packageCmpt != null)
                    {
                        int num    = entity.packageCmpt.GetItemCount(item.Id);
                        int result = Utility.Function(num, count, func);
                        if (result > 0)
                        {
                            entity.packageCmpt.Set(item.Id, result);
                        }
                        else
                        {
                            entity.packageCmpt.Destory(item.Id, num);
                            if (result < 0)
                            {
                                Debug.LogWarning(string.Format("Items whose protoID is {0} are not enough.", item.Id));
                            }
                        }

                        if (result - num > 0)
                        {
                            ItemAsset.ItemProto proto = ItemAsset.ItemProto.Mgr.Instance.Get(item.Id);
                            if (proto == null)
                            {
                                return(true);
                            }

                            string msg = proto.GetName() + " X " + (result - num).ToString();
                            new PeTipMsg(msg, proto.icon[0], PeTipMsg.EMsgLevel.Norm, PeTipMsg.EMsgType.Misc);
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 9
0
        // 判断条件
        public override bool?Check()
        {
            PeEntity entity = PeScenarioUtility.GetEntity(obj);

            if (entity != null && entity.skEntity != null)
            {
                if (Utility.Compare(entity.skEntity.GetAttribute((int)stat), amt, comp))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 10
0
 // 判断条件
 public override bool?Check()
 {
     if (player.type == OBJECT.OBJECTTYPE.Player)
     {
         Pathea.PeEntity entity = PeScenarioUtility.GetEntity(player);
         if (entity != null && entity.motionMgr != null)
         {
             if (entity.motionMgr.IsActionRunning(Pathea.PEActionType.Sleep) == state)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 11
0
        // 执行动作
        // 若为瞬间动作,返回true;
        // 若为持续动作,该函数会每帧被调用,直到返回true
        public override bool Logic()
        {
            if (Pathea.PeGameMgr.IsMulti)
            {
                byte[] data = PETools.Serialize.Export(w =>
                {
                    BufferHelper.Serialize(w, obj);
                    BufferHelper.Serialize(w, range);
                });

                PlayerNetwork.RequestServer(EPacketType.PT_Custom_Kill, data);
            }
            else
            {
                if (obj.isPrototype)
                {
                    if (obj.type == OBJECT.OBJECTTYPE.MonsterProto)
                    {
                        foreach (var item in Pathea.EntityMgr.Instance.All)
                        {
                            if (item.commonCmpt.entityProto.proto != Pathea.EEntityProto.Monster)
                            {
                                continue;
                            }
                            if (!PeScenarioUtility.IsObjectContainEntity(obj, item))
                            {
                                continue;
                            }
                            if (!range.Contains(item.position))
                            {
                                continue;
                            }
                            item.SetAttribute(Pathea.AttribType.Hp, 0, false);
                        }
                    }
                }
                else
                {
                    Pathea.PeEntity entity = PeScenarioUtility.GetEntity(obj);
                    if (null != entity && range.Contains(entity.position))
                    {
                        entity.SetAttribute(Pathea.AttribType.Hp, 0, false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 12
0
 // 判断条件
 public override bool?Check()
 {
     Pathea.PeEntity self     = PeScenarioUtility.GetEntity(obj1);
     Pathea.PeEntity attacker = PeScenarioUtility.GetEntity(obj2);
     if (self == null || attacker == null || attacker.target == null)
     {
         return(false);
     }
     if (attacker.target.HasHatred(self))
     {
         return(state);
     }
     else
     {
         return(!state);
     }
 }
Ejemplo n.º 13
0
        // 执行动作
        // 若为瞬间动作,返回true;
        // 若为持续动作,该函数会每帧被调用,直到返回true
        public override bool Logic()
        {
            if (Pathea.PeGameMgr.IsMulti)
            {
                byte[] data = PETools.Serialize.Export(w =>
                {
                    BufferHelper.Serialize(w, obj);
                    w.Write(name);
                });

                PlayerNetwork.RequestServer(EPacketType.PT_Custom_StartAnimation, data);
            }
            else
            {
                Pathea.PeEntity entity = PeScenarioUtility.GetEntity(obj);
                if (null == entity)
                {
                    return(true);
                }

                if (obj.isCurrentPlayer)
                {
                    playerAniming = true;
                    entity.animCmpt.AnimEvtString += OnAnimString;
                }

                string type = name.Split('_')[name.Split('_').Length - 1];
                if (type == "Once")
                {
                    entity.animCmpt.SetTrigger(name);
                }
                else if (type == "Muti")
                {
                    entity.animCmpt.SetBool(name, true);
                }
            }

            return(true);
        }
Ejemplo n.º 14
0
 // 执行动作
 // 若为瞬间动作,返回true;
 // 若为持续动作,该函数会每帧被调用,直到返回true
 public override bool Logic()
 {
     Pathea.PeEntity entity = PeScenarioUtility.GetEntity(obj);
     if (entity != null)
     {
         if ((entity.proto == Pathea.EEntityProto.Npc ||
              entity.proto == Pathea.EEntityProto.RandomNpc ||
              entity.proto == Pathea.EEntityProto.Monster) &&
             entity.requestCmpt != null)
         {
             if (cmd == ECommand.MoveTo)
             {
                 entity.requestCmpt.Register(Pathea.EReqType.MoveToPoint, LocalToWorld(entity.peTrans, pos, func), 1f, true, Pathea.SpeedState.Run);
             }
             else if (cmd == ECommand.FaceAt)
             {
                 entity.requestCmpt.Register(Pathea.EReqType.Dialogue, "", LocalToWorld(entity.peTrans, pos, func));
             }
         }
     }
     return(true);
 }
Ejemplo n.º 15
0
        // 执行动作
        // 若为瞬间动作,返回true;
        // 若为持续动作,该函数会每帧被调用,直到返回true
        public override bool Logic()
        {
            if (Pathea.PeGameMgr.IsMulti)
            {
                byte[] data = PETools.Serialize.Export(w =>
                {
                    BufferHelper.Serialize(w, obj);
                    BufferHelper.Serialize(w, tar);
                    w.Write((byte)cmd);
                });

                PlayerNetwork.RequestServer(EPacketType.PT_Custom_OrderTarget, data);
            }
            else
            {
                Pathea.PeEntity entity = PeScenarioUtility.GetEntity(obj);
                Pathea.PeEntity target = PeScenarioUtility.GetEntity(tar);
                if (entity != null && target != null)
                {
                    if ((entity.proto == Pathea.EEntityProto.Npc ||
                         entity.proto == Pathea.EEntityProto.RandomNpc ||
                         entity.proto == Pathea.EEntityProto.Monster) &&
                        entity.requestCmpt != null)
                    {
                        if (cmd == ECommand.MoveTo)
                        {
                            entity.requestCmpt.Register(Pathea.EReqType.FollowTarget, target.Id);
                        }
                        else if (cmd == ECommand.FaceAt)
                        {
                            entity.requestCmpt.Register(Pathea.EReqType.Dialogue, "", target.peTrans);
                        }
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 16
0
        // 执行动作
        // 若为瞬间动作,返回true;
        // 若为持续动作,该函数会每帧被调用,直到返回true
        public override bool Logic()
        {
            if (Pathea.PeGameMgr.IsMulti)
            {
                byte[] data = PETools.Serialize.Export(w =>
                {
                    BufferHelper.Serialize(w, obj);
                });

                PlayerNetwork.RequestServer(EPacketType.PT_Custom_StopAnimation, data);
            }
            else
            {
                Pathea.PeEntity entity = PeScenarioUtility.GetEntity(obj);
                if (null == entity)
                {
                    return(true);
                }
                //TODO:把ParametersBool设置为false(等待动作表)
                entity.animCmpt.SetTrigger("Custom_ResetAni");
            }

            return(true);
        }
Ejemplo n.º 17
0
        // 执行动作
        // 若为瞬间动作,返回true;
        // 若为持续动作,该函数会每帧被调用,直到返回true
        public override bool Logic()
        {
            if (Pathea.PeGameMgr.IsMulti)
            {
                byte[] data = PETools.Serialize.Export(w =>
                {
                    BufferHelper.Serialize(w, obj);
                    w.Write(amt);
                    w.Write((byte)stat);
                    w.Write((byte)func);
                });

                PlayerNetwork.RequestServer(EPacketType.PT_Custom_ModifyStat, data);
            }
            else
            {
                PeEntity entity = PeScenarioUtility.GetEntity(obj);
                if (entity != null && entity.skEntity != null)
                {
                    float prev  = entity.skEntity.GetAttribute((int)stat);
                    float value = Utility.Function(prev, amt, func);

                    float prev_hp = PeCreature.Instance.mainPlayer.HPPercent;
                    entity.SetAttribute(stat, value);
                    float curr_hp = PeCreature.Instance.mainPlayer.HPPercent;
                    float hp_drop = Mathf.Clamp01(prev_hp - curr_hp) * PeCreature.Instance.mainPlayer.GetAttribute(AttribType.HpMax);

                    // 如果是玩家掉血,则播放摄像机特效
                    if (hp_drop > 0)
                    {
                        PeCameraImageEffect.PlayHitEffect(hp_drop);
                    }
                }
            }
            return(true);
        }