Ejemplo n.º 1
0
        public override bool InRectange(FreeUIUtil.Rectangle rec, IEventArgs args)
        {
            if (pos == null || change)
            {
                pos = selector.Select(args);
            }
            int   px = (int)(pos.GetX());
            int   py = (int)(pos.GetY());
            float r  = 0f;

            try
            {
                r = float.Parse(radius);
            }
            catch (Exception)
            {
                r = FreeUtil.ReplaceFloat(radius, args);
            }
            float x1 = rec.x - r;
            float x2 = rec.x + rec.width + r;
            float y1 = rec.y - r;
            float y2 = rec.y + rec.height + r;

            // 圆心在矩形的加上圆半径的范围内
            return(px >= x1 && px <= x2 && py >= y1 && py <= y2);
        }
Ejemplo n.º 2
0
        protected override void BuildMessage(IEventArgs args)
        {
            builder.Key = FreeMessageConstant.DuplicateUI;

            builder.Ss.Add(FreeUtil.ReplaceVar(key, args) + FreeMessageConstant.SpilterField + FreeUtil.ReplaceVar(type, args));

            builder.Fs.Add(FreeUtil.ReplaceFloat(x, args));
            builder.Fs.Add(FreeUtil.ReplaceFloat(y, args));

            builder.Bs.Add(FreeUtil.ReplaceBool(show, args));

            builder.Ks.Add(FreeUtil.ReplaceInt(relative, args));

            if (values != null)
            {
                foreach (IFreeUIValue com in values)
                {
                    builder.Ks.Add(com.GetSeq(args));
                    builder.Ins.Add(com.GetAutoStatus() * 100 + com.GetAutoIndex());
                }
                foreach (IFreeUIValue com_1 in values)
                {
                    object obj = com_1.GetValue(args);
                    if (obj == null)
                    {
                        builder.Ss.Add("null");
                    }
                    else
                    {
                        builder.Ss.Add(obj.ToString());
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

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

            if (player != null)
            {
                if (player.gamePlay.IsDead())
                {
                    return;
                }

                PlayerEntity sourcePlayer = null;
                if (!string.IsNullOrEmpty(source))
                {
                    sourcePlayer = (PlayerEntity)fr.GetEntity(source);
                }

                if (string.IsNullOrEmpty(part))
                {
                    part = ((int)EBodyPart.Chest).ToString();
                }

                PlayerDamageInfo damageInfo = new PlayerDamageInfo(FreeUtil.ReplaceFloat(damage, args),
                                                                   FreeUtil.ReplaceInt(type, args), FreeUtil.ReplaceInt(part, args), 0, false, false, FreeUtil.ReplaceBool(dead, args));

                BulletPlayerUtility.DoProcessPlayerHealthDamage(args.GameContext, (IGameRule)fr.Rule, sourcePlayer, player, damageInfo, null);
            }
        }
Ejemplo n.º 4
0
        public override UnitPosition Select(IEventArgs args)
        {
            IniCon();

            UnitPosition up = new UnitPosition();

            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            if (!string.IsNullOrEmpty(player))
            {
                object obj = fr.GetEntity(player);
                if (obj != null)
                {
                    if (obj is PlayerEntity)
                    {
                        PlayerEntity playerEntity = (PlayerEntity)obj;
                        fr.TempUse("current", (FreeData)playerEntity.freeData.FreeData);

                        UnityPositionUtil.SetPlayerToUnitPosition(playerEntity, up);
                        if (fromEye)
                        {
                            up.SetY(up.GetY() + 1.7f);
                        }

                        fr.Resume("current");
                    }

                    if (obj is FreeMoveEntity)
                    {
                        FreeMoveEntity playerEntity = (FreeMoveEntity)obj;
                        fr.TempUse("current", (FreeEntityData)playerEntity.freeData.FreeData);

                        UnityPositionUtil.SetEntityToUnitPosition(playerEntity.position, up);

                        fr.Resume("current");
                    }
                }
            }
            else if (!string.IsNullOrEmpty(condition))
            {
                if (con == null || con.Meet(args))
                {
                    foreach (PlayerEntity unit in args.GameContext.player.GetInitializedPlayerEntities())
                    {
                        if (unit.hasFreeData)
                        {
                            fr.TempUse("current", (FreeData)unit.freeData.FreeData);

                            UnityPositionUtil.SetPlayerToUnitPosition(unit, up);

                            fr.Resume("current");
                        }
                    }
                }
            }

            return(GetPosition(args, up, FreeUtil.ReplaceFloat(angle, args) + up.GetYaw()));
        }
Ejemplo n.º 5
0
        public override void DoAction(IEventArgs args)
        {
            FreeData fd = GetPlayer(args);

            if (fd != null)
            {
                fd.Player.stateInterface.State.SetSpeedAffect(FreeUtil.ReplaceFloat(speed, args));
            }
        }
Ejemplo n.º 6
0
 public virtual float GetFloat(IEventArgs args)
 {
     if (!initialed || dynamic)
     {
         realValue = FreeUtil.ReplaceFloat(para, args);
         initialed = true;
     }
     return((float)realValue);
 }
Ejemplo n.º 7
0
        public override void StartMove(FreeRuleEventArgs args, FreeMoveEntity entity)
        {
            tempPosition = targetPos.Select(args);
            if (!string.IsNullOrEmpty(useTime))
            {
                realTime = FreeUtil.ReplaceFloat(useTime, args);
            }

            UnityPositionUtil.SetUnitPositionToEntity(entity.position, startPos.Select(args));
        }
Ejemplo n.º 8
0
        public override UnitPosition Select(IEventArgs args)
        {
            UnitPosition up = new UnitPosition();

            up.SetX(FreeUtil.ReplaceFloat(x, args));
            up.SetY(FreeUtil.ReplaceFloat(y, args));
            up.SetZ(FreeUtil.ReplaceFloat(z, args));
            up.SetYaw(FreeUtil.ReplaceFloat(yaw, args));
            up.SetPitch(FreeUtil.ReplaceFloat(pitch, args));
            return(up);
        }
Ejemplo n.º 9
0
        public override UnitPosition Select(IEventArgs args)
        {
            UnitPosition up = pos.Select(args);

            if (up != null)
            {
                return(GetPosition(args, up, FreeUtil.ReplaceFloat(angle, args)));
            }

            return(null);
        }
Ejemplo n.º 10
0
        public override bool IsIn(IEventArgs args, UnitPosition entity)
        {
            if (pos == null || change)
            {
                pos = selector.Select(args);
            }
            float r = 0f;

            try
            {
                r = float.Parse(radius);
            }
            catch (Exception)
            {
                r = FreeUtil.ReplaceFloat(radius, args);
            }

            double dx = MyMath.Abs(entity.GetX() - pos.GetX());

            if (dx > r)
            {
                if (useOut)
                {
                    return(true);
                }
                return(false);
            }
            double dz = MyMath.Abs(entity.GetZ() - pos.GetZ());

            if (dz > r)
            {
                if (useOut)
                {
                    return(true);
                }
                return(false);
            }
            double dy     = MyMath.Abs(entity.GetY() - pos.GetY());
            float  zrange = FreeUtil.ReplaceFloat(zRange, args);

            if (zrange <= 0)
            {
                zrange = 170;
            }

            bool isIn = (dx * dx + dz * dz) <= r * r && (dy < zrange);

            if (useOut)
            {
                return(!isIn);
            }
            return(isIn);
        }
Ejemplo n.º 11
0
        public override UnitPosition Select(IEventArgs args)
        {
            UnitPosition up = new UnitPosition();

            up.SetX(FreeUtil.ReplaceFloat(x, args));
            up.SetY(FreeUtil.ReplaceFloat(y, args));
            up.SetZ(FreeUtil.ReplaceFloat(z, args));
            up.SetYaw(FreeUtil.ReplaceFloat(yaw, args));
            up.SetPitch(FreeUtil.ReplaceFloat(pitch, args));
            up.SetInvalid(FreeUtil.ReplaceBool(invalid, args));
            up.SetRandomindex(FreeUtil.ReplaceInt(randomindex, args));
            return(up);
        }
Ejemplo n.º 12
0
        public override string GetStyle(IEventArgs args)
        {
            string realText = text;

            try
            {
                realText = FreeUtil.ReplaceVar(text, args);
            }
            catch (Exception)
            {
            }
            return(realText + "_$$$_" + FreeUtil.ReplaceFloat(size, args) + "_$$$_" + FreeUtil.ReplaceVar(color, args) + "_$$$_" + bold + "_$$$_" + FreeUtil.ReplaceVar(font, args) + "_$$$_" + hAlign + "_$$$_" + vAlign + "_$$$_" + FreeUtil.ReplaceVar(multiLine
                                                                                                                                                                                                                                                          , args));
        }
Ejemplo n.º 13
0
 private void Adjust(UnitPosition up, IEventArgs args)
 {
     up.SetX(up.GetX() + FreeUtil.ReplaceInt(x, args));
     up.SetY(up.GetY() + FreeUtil.ReplaceInt(y, args));
     up.SetZ(up.GetZ() + FreeUtil.ReplaceInt(z, args));
     if (!StringUtil.IsNullOrEmpty(pitch))
     {
         up.SetPitch(FreeUtil.ReplaceFloat(pitch, args));
     }
     if (!StringUtil.IsNullOrEmpty(yaw))
     {
         up.SetYaw(FreeUtil.ReplaceFloat(yaw, args));
     }
 }
Ejemplo n.º 14
0
 public virtual void Handle(IEventArgs args, SimpleProto b)
 {
     if (changes != null)
     {
         foreach (FreeUISimpleShow.UIChange uc in changes)
         {
             b.Ins.Add(FreeUtil.ReplaceInt(uc.fromTime, args));
             b.Ins.Add(FreeUtil.ReplaceInt(uc.toTime, args));
             b.Fs.Add(FreeUtil.ReplaceFloat(uc.fromValue, args));
             b.Fs.Add(FreeUtil.ReplaceFloat(uc.toValue, args));
             b.Ss.Add(FreeUtil.ReplaceVar(uc.field, args));
         }
     }
 }
Ejemplo n.º 15
0
        public override void DoAction(IEventArgs args)
        {
            UnitPosition up = pos.Select(args);

            float       realRadius = FreeUtil.ReplaceFloat(radius, args);
            float       realDamage = FreeUtil.ReplaceFloat(damage, args);
            EUIDeadType realType   = (EUIDeadType)FreeUtil.ReplaceInt(type, args);

            if (damagePara == null)
            {
                damagePara = new FloatPara("damage", realDamage);
                disPara    = new FloatPara("dis", 0f);
                typePara   = new StringPara("type", FreeUtil.ReplaceVar(type, args));
            }

            if (up != null)
            {
                var bombPos   = new Vector3(up.GetX(), up.GetY(), up.GetZ());
                var colliders = Physics.OverlapSphere(bombPos, realRadius,
                                                      UnityLayerManager.GetLayerMask(EUnityLayerName.Player) | UnityLayerManager.GetLayerMask(EUnityLayerName.UserInputRaycast)
                                                      | UnityLayerManager.GetLayerMask(EUnityLayerName.Vehicle) | UnityLayerManager.GetLayerMask(EUnityLayerName.Glass));

                foreach (var collider in colliders)
                {
                    float trueDamage = CalculateBombDamage(collider.transform, bombPos, realDamage, realType);

                    if (Logger.IsDebugEnabled)
                    {
                        Logger.DebugFormat("Process {0}", collider.name);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.Player))
                    {
                        HandlePlayer(collider, args, args.GameContext, trueDamage, bombPos);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.UserInputRaycast))
                    {
                        HandleFracturedObjects(collider.transform, bombPos, trueDamage);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.Vehicle))
                    {
                        HandleVehicle(collider.transform, trueDamage);
                    }
                    if (collider.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.Glass))
                    {
                        HandleGlass(collider.transform);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public static void Build(SimpleProto b, IEventArgs args, string key, string desc, bool show, bool atBottom, Iterable <IFreeComponent> components)
        {
            b.Key = 50;

            b.Bs.Add(show);
            b.Bs.Add(atBottom);
            b.Ks.Add(0);

            if (desc == null)
            {
                desc = "";
            }

            b.Ss.Add(FreeUtil.ReplaceVar(key, args));
            b.Ss.Add(FreeUtil.ReplaceVar(desc, args));
            if (components != null)
            {
                foreach (IFreeComponent com in components)
                {
                    b.Ks.Add(com.GetKey(args));
                    b.Ins.Add(FreeUtil.ReplaceInt(com.GetWidth(args), args));
                    b.Ins.Add(FreeUtil.ReplaceInt(com.GetHeight(args), args));
                    b.Ins.Add(FreeUtil.ReplaceInt(com.GetRelative(args), args));
                    b.Ins.Add(FreeUtil.ReplaceInt(com.GetParent(args), args));
                    b.Fs.Add(FreeUtil.ReplaceFloat(com.GetX(args), args));
                    b.Fs.Add(FreeUtil.ReplaceFloat(com.GetY(args), args));
                    if (com.GetStyle(args) == null)
                    {
                        b.Ss.Add(string.Empty);
                    }
                    else
                    {
                        b.Ss.Add(com.GetStyle(args));
                    }
                    b.Ss.Add(GetAutoString(com, args));
                    if (com.GetEvent(args) != null)
                    {
                        b.Ss.Add(com.GetEvent(args));
                    }
                    else
                    {
                        b.Ss.Add(string.Empty);
                    }

                    SimpleProto child = com.CreateChildren(args);
                    b.Ps.Add(child);
                }
            }
        }
Ejemplo n.º 17
0
        public bool Meet(IEventArgs args)
        {
            FreeData fd  = (FreeData)args.GetUnit(player);
            object   obj = ((FreeRuleEventArgs)args).GetEntity(entity);

            if (fd != null && obj != null)
            {
                PlayerEntity   playerEntity = fd.Player;
                FreeMoveEntity objEntity    = (FreeMoveEntity)obj;
                float          yaw          = CommonMathUtil.TransComAngle(playerEntity.orientation.Yaw);
                float          ang          = CommonMathUtil.GetAngle(new Vector2(objEntity.position.Value.x, objEntity.position.Value.z), new Vector2(playerEntity.position.Value.x, playerEntity.position.Value.z));
                return(CommonMathUtil.GetDiffAngle(ang, yaw) <= FreeUtil.ReplaceFloat(angle, args) && Vector3.Distance(playerEntity.position.Value, objEntity.position.Value) <= FreeUtil.ReplaceFloat(distance, args));
            }
            return(false);
        }
Ejemplo n.º 18
0
        public override void DoAction(IEventArgs args)
        {
            FreeMoveEntity en = args.GameContext.freeMove.CreateEntity();

            en.AddEntityKey(new EntityKey(args.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
            if (pos == null)
            {
                en.AddPosition();
                en.position.Value = new Vector3(FreeUtil.ReplaceFloat(x, args), FreeUtil.ReplaceFloat(y, args),
                                                FreeUtil.ReplaceFloat(z, args));
            }
            else
            {
                UnitPosition up = pos.Select(args);
                en.AddPosition();
                en.position.Value = new Vector3(up.GetX(), up.GetY(), up.GetZ());
            }

            string realCat = FreeUtil.ReplaceVar(cat, args);

            if (realCat == null)
            {
                realCat = "";
            }
            string realValue = FreeUtil.ReplaceVar(value, args);

            if (realValue == null)
            {
                realValue = "";
            }
            en.AddFreeData(FreeUtil.ReplaceVar(key, args), null);
            en.freeData.Cat      = realCat;
            en.freeData.Value    = realValue;
            en.isFlagSyncNonSelf = true;

            en.AddFlagImmutability(args.GameContext.session.currentTimeObject.CurrentTime);

            if (distance > 0)
            {
                en.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, distance);
            }

            if (!string.IsNullOrEmpty(lifeTime))
            {
                en.AddLifeTime(DateTime.Now, FreeUtil.ReplaceInt(lifeTime, args));
            }
        }
Ejemplo n.º 19
0
        private UnitPosition GetPosition(IEventArgs args, UnitPosition old,
                                         double angle)
        {
            Vector3 dir = new Vector3();
            Vector3 end = new Vector3();

            AnglesToVector(angle, FreeUtil.ReplaceFloat(pitch, args), ref dir);
            Vector3DMA(new Vector3(old.GetX(), old.GetY(), old.GetZ()), FreeUtil.ReplaceFloat(distance, args), dir, ref end);

            UnitPosition up = new UnitPosition();

            up.SetX(end.x);
            up.SetY(end.y + FreeUtil.ReplaceFloat(height, args));
            up.SetZ(end.z);
            up.SetYaw(old.GetYaw());

            return(up);
        }
Ejemplo n.º 20
0
        public override void DoAction(IEventArgs args)
        {
            FreeData fd = GetPlayer(args);

            if (fd != null)
            {
                fd.Player.stateInterface.State.SetSpeedAffect(FreeUtil.ReplaceFloat(speed, args));
                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlayerMoveSpeedSet;
                sp.Fs.Add(FreeUtil.ReplaceFloat(speed, args));
                FreeMessageSender.SendMessage(fd.Player, sp);

                fd.Player.stateInterface.State.SetJumpAffect(FreeUtil.ReplaceFloat(jump, args));
                SimpleProto ps = FreePool.Allocate();
                ps.Key = FreeMessageConstant.PlayerJumpSpeedSet;
                ps.Fs.Add(FreeUtil.ReplaceFloat(jump, args));
                FreeMessageSender.SendMessage(fd.Player, ps);
            }
        }
Ejemplo n.º 21
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

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

            if (player != null)
            {
                if (player.gamePlay.IsDead())
                {
                    return;
                }

                PlayerEntity sourcePlayer = null;
                UnitPosition up           = null;
                try
                {
                    if (!string.IsNullOrEmpty(source))
                    {
                        sourcePlayer = (PlayerEntity)fr.GetEntity(source);
                    }

                    if (string.IsNullOrEmpty(part))
                    {
                        part = ((int)EBodyPart.Chest).ToString();
                    }
                    if (pos != null)
                    {
                        up = pos.Select(args);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error("PlayerHurtAction handle error" + e.Message);
                }

                PlayerDamageInfo damageInfo = new PlayerDamageInfo(FreeUtil.ReplaceFloat(damage, args), FreeUtil.ReplaceInt(type, args), FreeUtil.ReplaceInt(part, args), 0,
                                                                   false, false, FreeUtil.ReplaceBool(dead, args), up != null ? player.position.Value : Vector3.zero, up != null ? player.position.Value - up.Vector3 : Vector3.zero);

                BulletPlayerUtil.DoProcessPlayerHealthDamage(args.GameContext, (IGameRule)fr.Rule, sourcePlayer, player, damageInfo);
            }
        }
Ejemplo n.º 22
0
        public override UnitPosition Select(IEventArgs args)
        {
            UnitPosition up       = pos.Select(args);
            UnitPosition targetUp = targetPos.Select(args);

            if (up != null && targetUp != null)
            {
                Vector3 dir = new Vector3();
                dir.x = targetUp.GetX() - up.GetX();
                dir.y = targetUp.GetY() - up.GetY();
                dir.z = targetUp.GetZ() - up.GetZ();

                dir = UnityPositionUtil.vectorToAngles(dir);

                double angle = FreeUtil.ReplaceDouble(this.angle, args);

                up = UnityPositionUtil.GetAnglePosition(up, angle + dir.x, 0, FreeUtil.ReplaceFloat(radius, args), 0);
            }

            return(up);
        }
Ejemplo n.º 23
0
        protected override void BuildMessage(IEventArgs args)
        {
            this.scope = "4";

            builder.Key = FreeMessageConstant.PoisonCircle;
            builder.Ks.Add(0);

            UnitPosition from = fromPos.Select(args);

            builder.Fs.Add(from.GetX());
            builder.Fs.Add(from.GetY());

            UnitPosition to = toPos.Select(args);

            builder.Fs.Add(to.GetX());
            builder.Fs.Add(to.GetY());

            builder.Fs.Add(FreeUtil.ReplaceFloat(fromRadius, args));
            builder.Fs.Add(FreeUtil.ReplaceFloat(toRadius, args));
            builder.Ins.Add(FreeUtil.ReplaceInt(fromWaitTime, args));
            builder.Ins.Add(FreeUtil.ReplaceInt(fromMoveTime, args));
        }
Ejemplo n.º 24
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity p = GetPlayerEntity(args);

            UnitPosition up = pos.Select(args);

            if (up != null)
            {
                p.position.Value    = new UnityEngine.Vector3(up.GetX(), up.GetY(), up.GetZ());
                p.orientation.Yaw   = up.GetYaw();
                p.orientation.Pitch = FreeUtil.ReplaceFloat(pitch, args);

                p.latestAdjustCmd.SetPos(new UnityEngine.Vector3(up.GetX(), up.GetY(), up.GetZ()));
                p.latestAdjustCmd.ServerSeq = p.userCmdSeq.LastCmdSeq;

//                SimpleProto msg = FreePool.Allocate();
//                msg.Key = FreeMessageConstant.EntityMoveTo;
//                msg.Fs.Add(p.position.Value.x);
//                msg.Fs.Add(p.position.Value.y);
//                msg.Fs.Add(p.position.Value.z);
//                FreeMessageSender.SendMessage(p, msg);
            }
        }
Ejemplo n.º 25
0
        public override string GetStyle(IEventArgs args, string key)
        {
            string spliter = "_$$$_";

            if (StringUtil.IsNullOrEmpty(alpha))
            {
                alpha = "1";
            }
            if (text != null)
            {
                resUrl = text.GetStyle(args).Replace("_$$$_", "|||") + "|||" + FreeUtil.ReplaceInt(text.width, args) + "|||" + FreeUtil.ReplaceInt(text.height, args);
            }
            return(FreeUtil.ReplaceVar(depth, args) + spliter + FreeUtil.ReplaceVar(ptype, args) + spliter + FreeUtil.ReplaceVar(culling, args) + spliter + FreeUtil.ReplaceVar(resUrl, args) + spliter + (model == null ? string.Empty : FreeUtil.ReplaceVar
                                                                                                                                                                                                               (model, args)) + spliter + gtype + spliter + FreeUtil.ReplaceFloat(alpha, args) + spliter + @fixed + spliter + (StringUtil.IsNullOrEmpty(fixPoint) ? "0,0" : FreeUtil.ReplaceVar(fixPoint, args)));
        }
Ejemplo n.º 26
0
        public override string GetStyle(IEventArgs args, string key)
        {
            UnitPosition fromUp = from.Select(args);
            UnitPosition toUp   = to.Select(args);

            return(fromUp.GetX() + "_" + fromUp.GetY() + "_" + fromUp.GetZ() + SPLITER + toUp.GetX() + "_" + toUp.GetY() + "_" + toUp.GetZ() + SPLITER + FreeUtil.ReplaceVar(name, args) + SPLITER + FreeUtil.ReplaceFloat(scale, args) + SPLITER + FreeUtil.
                   ReplaceFloat(adjust, args));
        }
Ejemplo n.º 27
0
 public float GetFloat(string v)
 {
     return(FreeUtil.ReplaceFloat(v, this));
 }