Exemplo n.º 1
0
        private void OnEndDragDelegate(PointerEventData eventData)
        {
            ItemComponent item = eventData.pointerDrag.gameObject.GetComponent <ItemComponent>();

            if (item != null)
            {
                eventData.pointerDrag.gameObject.transform.parent = item.ParentTransform;
            }

            SimpleProto data = FreePool.Allocate();

            data.Key = FreeMessageConstant.DragImage;
            ItemComponent fromItem = eventData.pointerDrag.GetComponent <ItemComponent>();
            ItemComponent toItem   = eventData.pointerCurrentRaycast.gameObject.GetComponent <ItemComponent>();

            data.Ss.Add(fromItem.EventKey);
            if (toItem != null)
            {
                data.Ss.Add(toItem.EventKey);
            }
            else
            {
                data.Ss.Add("");
            }

            SingletonManager.Get <FreeUiManager>().Contexts1.session.clientSessionObjects.NetworkChannel.SendReliable((int)EClient2ServerMessage.FreeEvent, data);
            eventData.pointerDrag.gameObject.GetComponent <Image>().raycastTarget = true;
        }
Exemplo n.º 2
0
        public override void DoAction(IEventArgs args)
        {
            if (string.IsNullOrEmpty(player))
            {
                player = "current";
            }

            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            PlayerEntity playerEntity = (PlayerEntity)fr.GetEntity(player);

            IParable item = args.GetUnit("item");

            if (playerEntity != null && item != null)
            {
                SimpleProto message = FreePool.Allocate();
                message.Key = FreeMessageConstant.ChangeAvatar;

                int itemId = FreeUtil.ReplaceInt("{item.itemId}", args);

                playerEntity.WeaponController().PickUpWeapon(WeaponUtil.CreateScan(itemId));
                //playerEntity.bag.Bag.SetWeaponBullet(30);
                //playerEntity.bag.Bag.SetReservedCount(100);

                message.Ins.Add(itemId);

                message.Ks.Add(2);

                playerEntity.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message);
            }
        }
Exemplo n.º 3
0
        private void OnEndCloneDelegate(PointerEventData eventData)
        {
            SimpleProto data = FreePool.Allocate();

            data.Key = FreeMessageConstant.DragImage;
            ItemComponent fromItem = dragObj.GetComponent <ItemComponent>();

            data.Ss.Add(fromItem.EventKey);

            if (eventData.pointerCurrentRaycast.gameObject != null)
            {
                ItemComponent toItem = eventData.pointerCurrentRaycast.gameObject.GetComponent <ItemComponent>();
                if (toItem != null)
                {
                    data.Ss.Add(toItem.EventKey);
                }
                else
                {
                    data.Ss.Add("");
                }
            }
            else
            {
                data.Ss.Add("");
            }

            data.Bs.Add(Input.GetKey(KeyCode.LeftControl));

            SingletonManager.Get <FreeUiManager>().Contexts1.session.clientSessionObjects.NetworkChannel.SendReliable((int)EClient2ServerMessage.FreeEvent, data);

            dragObj.GetComponent <Image>().raycastTarget = true;
            dragObj.transform.parent = null;
        }
Exemplo n.º 4
0
        public void Update(IEventArgs args)
        {
            foreach (string key in currentBufs.Keys)
            {
                List <EffectBuf> list = currentBufs[key];
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    if (args.Rule.ServerTime - list[i].startTime > list[i].time && list[i].time > 0)
                    {
                        list.Remove(list[i]);
                    }
                }
            }

            float[] effects = new float[lastEffects.Length];

            foreach (string key in currentBufs.Keys)
            {
                List <EffectBuf> list = currentBufs[key];
                if (list.Count > 0)
                {
                    EffectBuf buf = currentBufs[key][0];
                    effects[(int)buf.type] += buf.level;
                }
            }

            for (int i = 0; i < effects.Length; i++)
            {
                float last    = lastEffects[i];
                float current = effects[i];
                if (last != current)
                {
                    SimpleProto sp = null;

                    switch ((EffectType)i)
                    {
                    case EffectType.SpeedUp:
                        player.stateInterface.State.SetSpeedAffect(current);
                        sp     = FreePool.Allocate();
                        sp.Key = FreeMessageConstant.PlayerMoveSpeedSet;
                        sp.Fs.Add(current);
                        FreeMessageSender.SendMessage(player, sp);
                        break;

                    case EffectType.SlowDown:
                        player.stateInterface.State.SetSpeedAffect(current * -1);
                        sp     = FreePool.Allocate();
                        sp.Key = FreeMessageConstant.PlayerMoveSpeedSet;
                        sp.Fs.Add(current * -1);
                        FreeMessageSender.SendMessage(player, sp);
                        break;

                    default:
                        break;
                    }
                }
            }

            lastEffects = effects;
        }
Exemplo n.º 5
0
        public override void DoAction(IEventArgs args)
        {
            if (string.IsNullOrEmpty(player))
            {
                player = "current";
            }

            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            PlayerEntity playerEntity = (PlayerEntity)fr.GetEntity(player);

            IParable item = args.GetUnit("item");

            if (playerEntity != null && item != null)
            {
                SimpleProto message = FreePool.Allocate();
                message.Key = FreeMessageConstant.ChangeAvatar;

                int itemId = FreeUtil.ReplaceInt("{item.itemId}", args);

                if (takeoff)
                {
                    TakeOff(playerEntity, itemId);
                }
                else
                {
                    PutOn(playerEntity, itemId);
                }

                ReduceDamageUtil.UpdateArmorAndHelmet((FreeData)playerEntity.freeData.FreeData);
            }
        }
Exemplo n.º 6
0
        private void StopSave(PlayerEntity playerEntity, bool isInterrupted)
        {
            if (SharedConfig.IsServer)
            {
                playerEntity.gamePlay.SaveTime = 0;
                if (playerEntity.gamePlay.IsSave)
                {
                    PlayerAnimationAction.DoAnimation(_contexts, PlayerAnimationAction.RescueEnd, playerEntity, true);
                    playerEntity.gamePlay.IsSave = false;
                }
                if (playerEntity.gamePlay.IsBeSave)
                {
                    if (!isInterrupted)
                    {
                        playerEntity.gamePlay.IsStandPosture = false;
                        //PlayerAnimationAction.DoAnimation(_contexts, PlayerAnimationAction.Revive, playerEntity, true);
                    }
                    playerEntity.gamePlay.IsBeSave = false;
                }

                SimpleProto data = FreePool.Allocate();
                data.Key = FreeMessageConstant.CountDown;
                data.Bs.Add(false);
                data.Fs.Add(0);
                data.Bs.Add(!isInterrupted);
                if (isInterrupted)
                {
                    data.Ins.Add((int)ETipType.CanNotRescure);
                }
                FreeMessageSender.SendMessage(playerEntity, data);
            }
        }
Exemplo n.º 7
0
        protected override void InternalExecute()
        {
            var player     = _contexts.player.flagSelfEntity;
            var controller = player.WeaponController();

            if (!player.gamePlay.IsLifeState(EPlayerLifeState.Alive) || !player.gamePlay.CanAutoPick())
            {
                return;
            }

            Collider[] colliders = Physics.OverlapCapsule(player.position.Value, player.bones.Head.position,
                                                          0.4f, UnityLayerManager.GetLayerMask(EUnityLayerName.UserInputRaycast));
            foreach (Collider collider in colliders)
            {
                var rcTar = collider.transform.GetComponentInParent <RayCastTarget>();
                if (rcTar == null)
                {
                    continue;
                }
                if (SingletonManager.Get <GameModeConfigManager>().GetBagTypeById(_contexts.session.commonSession.RoomInfo.ModeId) == EBagType.Chicken)
                {
                    var target = _contexts.sceneObject.GetEntityWithEntityKey(new EntityKey(rcTar.IdList[1], (short)EEntityType.SceneObject));
                    if (target.simpleItem.Category == (int)ECategory.Weapon && player.WeaponController().FilterAutoPickup(target.simpleItem.Id))
                    {
                        var model = target.hasUnityObject ? target.unityObject.UnityObject : target.multiUnityObject.FirstAsset;
                        if (CommonObjectCastUtil.HasObstacleBetweenPlayerAndItem(player, target.position.Value, model))
                        {
                            continue;
                        }

                        SimpleProto pickUp = FreePool.Allocate();
                        pickUp.Key = FreeMessageConstant.PickUpItem;
                        pickUp.Ins.Add(rcTar.IdList[1]);
                        pickUp.Ins.Add(target.simpleItem.Category);
                        pickUp.Ins.Add(target.simpleItem.Id);
                        pickUp.Ins.Add(1);
                        player.network.NetworkChannel.SendReliable((int)EClient2ServerMessage.FreeEvent, pickUp);
                    }
                }
                else
                {
                    _userCmdGenerator.SetUserCmd((userCmd) =>
                    {
                        if (!userCmd.AutoPickUpEquip.Contains(rcTar.IdList[1]))
                        {
                            userCmd.AutoPickUpEquip.Add(rcTar.IdList[1]);
                        }
                    });
                }
            }

            if (controller.AutoThrowing.HasValue && controller.AutoThrowing.Value)
            {
                if (null != _userCmdGenerator && controller.RelatedThrowAction.IsReady == true)
                {
                    _userCmdGenerator.SetUserCmd((userCmd) => { userCmd.IsThrowing = true; });
                    controller.AutoThrowing = false;
                }
            }
        }
Exemplo n.º 8
0
        public void ReDraw(ISkillArgs args, ItemInventory inventory, bool includeBack)
        {
            SimpleProto sp = FreePool.Allocate();

            sp.Key = FreeMessageConstant.InventoyUI;
            // 0 重绘,1 添加,2 删除, 3 更新
            sp.Ks.Add(0);
            sp.Bs.Add(true);

            sp.Ks.Add(inventory.posList.Count);

            foreach (ItemPosition ip in inventory.posList)
            {
                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey());

                sp.Ins.Add(info.cat);
                sp.Ins.Add(info.id);
                sp.Ins.Add(ip.GetCount());

                sp.Ss.Add(inventory.GetName() + "," + ip.GetX() + "," + ip.GetY());
            }

            FreeData fd = (FreeData)args.GetUnit("current");

            sp.Ks.Add((int)BagCapacityUtil.GetCapacity(fd));
            sp.Ks.Add((int)Math.Ceiling(BagCapacityUtil.GetWeight(fd)));

            SendMessageAction.sender.SendMessage(args, sp, 1, "current");

            ChickenFuncUtil.UpdateBagCapacity(args, (int)Math.Ceiling(BagCapacityUtil.GetWeight(fd)), BagCapacityUtil.GetCapacity(fd));
        }
Exemplo n.º 9
0
 public override void DoAction(IEventArgs args)
 {
     if (inter)
     {
         if (fd != null)
         {
             fd.freeInventory.StopUseItem(args, fd, inter);
             SimpleProto msg = FreePool.Allocate();
             msg.Key = FreeMessageConstant.ChickenTip;
             msg.Ss.Add("word72," + ip.key.GetName());
             FreeMessageSender.SendMessage(fd.Player, msg);
             PlayerAnimationAction.DoAnimation(args.GameContext, PlayerAnimationAction.Stop, fd.Player);
             //FreeSoundUtil.Stop("use", args, fd);
             PlayerStateUtil.RemoveGameState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
             PlayerStateUtil.RemoveGameState(EPlayerGameState.UseItem, fd.Player.gamePlay);
         }
     }
     else
     {
         if (ip != null && fd != null)
         {
             UseItem(ip, fd, (ISkillArgs)args);
             fd.freeInventory.StopUseItem(args, fd, inter);
             PlayerAnimationAction.DoAnimation(args.GameContext, PlayerAnimationAction.Interrupt, fd.Player);
             PlayerStateUtil.RemoveGameState(EPlayerGameState.UseItem, fd.Player.gamePlay);
         }
     }
 }
Exemplo n.º 10
0
        public static void SendMarkMessage(Contexts contexts, Vector2 markPos)
        {
            SimpleProto loginSucess = FreePool.Allocate();

            if (Vector2.Distance(markPos, lastAddMarkPos) > 10 / rate)
            {
                loginSucess.Key = FreeMessageConstant.MarkPos;
                loginSucess.Fs.Add(markPos.x);
                loginSucess.Fs.Add(markPos.y);
                loginSucess.Fs.Add(1);              //add mark
                lastAddMarkPos = markPos;
            }
            else
            {
                loginSucess.Key = FreeMessageConstant.MarkPos;
                loginSucess.Fs.Add(markPos.x);
                loginSucess.Fs.Add(markPos.y);
                loginSucess.Fs.Add(0);              //remove mark
                lastAddMarkPos = Vector2.zero;
            }
            if (contexts.session.clientSessionObjects.NetworkChannel != null)
            {
                contexts.session.clientSessionObjects.NetworkChannel.SendReliable((int)EClient2ServerMessage.FreeEvent, loginSucess);
            }
        }
Exemplo n.º 11
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity player = GetPlayerEntity(args);

            if (player == null)
            {
                return;
            }

            if (args.Rule.ServerTime - player.statisticsData.Statistics.LastDeadTime <= 2900L)
            {
                return;
            }

            int oldObserveId = player.gamePlay.CameraEntityId;

            bool success = ObservePlayer(args, player, args.GetBool(observeEnemy), args.GetBool(wise));

            if (!success)
            {
                if (noOneAction != null)
                {
                    noOneAction.Act(args);
                }
            }

            if (oldObserveId != player.gamePlay.CameraEntityId)
            {
                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlayerObserveTrigger;
                sp.Bs.Add(true);
                FreeMessageSender.SendMessage(player, sp);
            }
        }
        public static void SendOpenSpecifyUIMessageS(PlayerEntity playerEntity)
        {
            SimpleProto sp = FreePool.Allocate();

            sp.Key = FreeMessageConstant.OpenSpecifyUI;
            SendMessage(playerEntity, sp);
        }
Exemplo n.º 13
0
        private void HandleScore(IEventArgs args)
        {
            if (code == "WaitInfo")
            {
                SimpleProto message = FreePool.Allocate();
                message.Key = FreeMessageConstant.ScoreInfo;
                message.Ks.Add(1);

                message.Ins.Add(FreeUtil.ReplaceInt("{playerCount}", args));

                //Debug.Log(message.ToString());

                SendMessageAction.sender.SendMessage(args, message, 4, string.Empty);
            }
            else if (code == "ScoreInfo")
            {
                SimpleProto message = FreePool.Allocate();
                message.Key = FreeMessageConstant.ScoreInfo;
                message.Ks.Add(2);

                message.Bs.Add(true);
                message.Ins.Add(FreeUtil.ReplaceInt("{current.killNum}", args));
                message.Ins.Add(FreeUtil.ReplaceInt("{startPlayerCount}", args));

                //Debug.Log(message.ToString());

                SendMessageAction.sender.SendMessage(args, message, 1, "current");
            }
        }
Exemplo n.º 14
0
        public SimpleProto ToMessage()
        {
            SimpleProto msg = FreePool.Allocate();

            msg.Ins.Add(team);
            msg.Ins.Add(id);
            msg.Ins.Add(honor);
            msg.Ins.Add(kill);
            msg.Ins.Add(dead);
            msg.Ins.Add(assist);
            msg.Ins.Add(damage);
            msg.Ins.Add(ping);
            msg.Ins.Add(c4PlantCount);
            msg.Ins.Add(c4DefuseCount);
            msg.Ins.Add(badgeId);
            msg.Ins.Add(hitDownCount);
            msg.Ins.Add(resqueCount);

            msg.Bs.Add(isDead);
            msg.Bs.Add(hasC4);
            msg.Bs.Add(isHurt);

            msg.Ss.Add(name);
            msg.Ss.Add(teamName);

            return(msg);
        }
Exemplo n.º 15
0
        public override void DoAction(IEventArgs args)
        {
            if (string.IsNullOrEmpty(this.player))
            {
                this.player = "current";
            }
            var unit = GetPlayer(args);

            if (skills != null && unit != null)
            {
                foreach (var skill in skills)
                {
                    unit.GetUnitSkill().AddSkill((ISkill)SerializeUtil.Clone(skill));
                }

                byte[] bs = SerializeUtil.ObjectToByte(skills);

                SimpleProto msg = FreePool.Allocate();
                msg.Key = FreeMessageConstant.ClientSkill;
                for (int i = 0; i < bs.Length; i++)
                {
                    msg.Ins.Add(bs[i]);
                }

                FreeMessageSender.SendMessage(unit.Player, msg);
            }
        }
Exemplo n.º 16
0
        public override SimpleProto CreateChildren(IEventArgs args)
        {
            SimpleProto b = FreePool.Allocate();

            b.Key = 1;
            return(b);
        }
        public static void SendOpenSpecifyUIMessageC(PlayerEntity playerEntity)
        {
            SimpleProto openUIProto = FreePool.Allocate();

            openUIProto.Key = FreeMessageConstant.OpenSpecifyUI;
            SendMessageC(playerEntity, openUIProto);
        }
Exemplo n.º 18
0
        public override SimpleProto CreateChildren(IEventArgs args)
        {
            SimpleProto b = FreePool.Allocate();

            FreeUICreateAction.Build(b, args, "0", "", false, false, list.AsIterable());

            return(b);
        }
Exemplo n.º 19
0
        private void SendCmd(PlayerEntity player)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = FreeMessageConstant.PlayerCmd;
            proto.Ks.Add(0);
            FreeMessageSender.SendMessage(player, proto);
        }
Exemplo n.º 20
0
        public override SimpleProto CreateChildren(IEventArgs args)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = 1;

            return(proto);
        }
Exemplo n.º 21
0
        private void StartCounter(IEventArgs args, int time, FreeData fd, bool start)
        {
            SimpleProto data = FreePool.Allocate();

            data.Key = FreeMessageConstant.CountDown;
            data.Bs.Add(start);
            data.Fs.Add(time);
            fd.Player.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, data);
        }
Exemplo n.º 22
0
        public void SendSplitMessage(int number, string itemKey)
        {
            SimpleProto data = FreePool.Allocate();

            data.Key = FreeMessageConstant.SplitItem;
            data.Ins.Add(number);
            data.Ss.Add(itemKey);
            _contexts.session.clientSessionObjects.NetworkChannel.SendReliable((int)EClient2ServerMessage.FreeEvent, data);
        }
Exemplo n.º 23
0
        public override void DoAction(IEventArgs args)
        {
            SimpleProto builder = FreePool.Allocate();

            builder.Key = FreeMessageConstant.GroupTechStatUI;

            builder.Ins.Add(args.GameContext.player.count);

            List <TechStat> list = new List <TechStat>();

            int  index    = 0;
            bool needSort = true;

            foreach (PlayerEntity p in args.GameContext.player.GetInitializedPlayerEntities())
            {
                TechStat ts = new TechStat(p, index++);
                builder.Ps.Add(ts.ToMessage());
                list.Add(ts);
                if (!p.statisticsData.Statistics.DataCollectSwitch)
                {
                    needSort = false;
                }
            }

            if (needSort)
            {
                list.Sort(KillComparater);
                if (list.Count > 0 && list[0].kill > 0)
                {
                    TechStat ts = list[0];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.Ace);
                }
                if (list.Count > 1 && list[1].kill > 0)
                {
                    TechStat ts = list[1];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.Second);
                }
                if (list.Count > 2 && list[2].kill > 0)
                {
                    TechStat ts = list[2];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.Third);
                }

                list.Sort(KdComparater);
                if (list.Count > 0 && list[0].kd > 0)
                {
                    TechStat ts = list[0];
                    builder.Ps[ts.index].Ins[2] |= (1 << (int)EUIGameTitleType.KdKing);
                }
            }

            foreach (PlayerEntity p in args.GameContext.player.GetInitializedPlayerEntities())
            {
                FreeMessageSender.SendMessage(p, builder);
            }
        }
Exemplo n.º 24
0
        public static void DoNothing(PlayerEntity player)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = FreeMessageConstant.PlayerCmd;
            proto.Ks.Add((int)PlayerActEnum.CmdType.Idle);
            proto.Ks.Add(player.entityKey.Value.EntityId);

            FreeMessageSender.SendMessage(player, proto);
        }
Exemplo n.º 25
0
        private void HandleFrame(IEventArgs args)
        {
            if (code == "RecordFrame")
            {
                SimpleProto message = FreePool.Allocate();
                message.Key = FreeMessageConstant.TestFrame;

                SendMessageAction.sender.SendMessage(args, message, 4, string.Empty);
            }
        }
Exemplo n.º 26
0
        public static void ClickItem(string key, bool right)
        {
            SimpleProto data = FreePool.Allocate();

            data.Key = FreeMessageConstant.ClickImage;
            data.Ss.Add(GetBagKey(key));
            data.Bs.Add(right);
            data.Bs.Add(Input.GetKey(KeyCode.LeftControl));

            SingletonManager.Get <FreeUiManager>().Contexts1.session.clientSessionObjects.NetworkChannel.SendReliable((int)EClient2ServerMessage.FreeEvent, data);
        }
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity playerEntity = GetPlayerEntity(args);

            if (null != playerEntity)
            {
                playerEntity.statisticsData.Battle.Reset();
                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.ResetBattleData;
                FreeMessageSender.SendMessage(playerEntity, sp);
            }
        }
Exemplo n.º 28
0
        public static void AttackPlayer(PlayerEntity player, int targetId)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = FreeMessageConstant.PlayerCmd;
            proto.Ks.Add((int)PlayerActEnum.CmdType.Attack);

            proto.Ks.Add(player.entityKey.Value.EntityId);
            proto.Ks.Add(targetId);

            FreeMessageSender.SendMessage(player, proto);
        }
Exemplo n.º 29
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity player = GetPlayerEntity(args);

            SimpleProto msg = FreePool.Allocate();

            msg.Key = FreeMessageConstant.PlayerPressKey;
            msg.Bs.Add(args.GetBool(press));
            msg.Ss.Add(key);
            msg.Ins.Add(args.GetInt(time));
            FreeMessageSender.SendMessage(player, msg);
        }
Exemplo n.º 30
0
        private void SendCmd(PlayerEntity player, Vector3 v)
        {
            SimpleProto proto = FreePool.Allocate();

            proto.Key = FreeMessageConstant.PlayerCmd;
            proto.Ks.Add(1);
            proto.Fs.Add(v.x);
            proto.Fs.Add(v.y);
            proto.Fs.Add(v.z);

            FreeMessageSender.SendMessage(player, proto);
        }