Example #1
0
        public virtual UnitPosition Select(IEventArgs args)
        {
            UnitPosition up = pos.Select(args);

            if (up != null)
            {
                Adjust(up, args);
            }
            return(up);
        }
Example #2
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));
        }
Example #3
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);
        }
Example #4
0
        public override UnitPosition Select(IEventArgs args)
        {
            UnitPosition up = pos.Select(args);

            Vector3 fromV = UnityPositionUtil.ToVector3(up);

            Vector3 toV = new Vector3(up.GetX(), -10000, up.GetZ());

            Ray r = new Ray(fromV, new Vector3(toV.x - fromV.x, toV.y - fromV.y, toV.z - fromV.z));

            RaycastHit hitInfo;
            bool       hited = Physics.Raycast(r, out hitInfo);

            if (hited)
            {
                if (SingletonManager.Get <MapConfigManager>().InWater(new Vector3(hitInfo.point.x,
                                                                                  hitInfo.point.y - 0.1f, hitInfo.point.z)))
                {
                    hitInfo.point = new Vector3(fromV.x, hitInfo.point.y - waterDelta, fromV.z);
                }

                //Debug.LogFormat("hit {0},{1},{2}", hitInfo.point.x, hitInfo.point.y, hitInfo.point.z);

                return(UnityPositionUtil.FromVector(hitInfo.point));
            }

            return(up);
        }
Example #5
0
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            if (StringUtil.IsNullOrEmpty(count) || count.Equals("0"))
            {
                count = INI_COUNT;
            }
            int      c    = FreeUtil.ReplaceInt(count, args);
            FreeItem item = FreeItemManager.GetItem(fr, FreeUtil.ReplaceVar(key, args), c);

            if (item != null)
            {
                if (!StringUtil.IsNullOrEmpty(time))
                {
                    ((FreeGameItem)item).SetTime(time);
                }
                item.Drop(fr, pos.Select(args));
                if (action != null)
                {
                    args.TempUse(ParaConstant.PARA_ITEM, item);
                    action.Act(args);
                    args.Resume(ParaConstant.PARA_ITEM);
                }
            }
        }
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity player  = GetPlayerEntity(args);
            Vector3      dropPos = UnityPositionUtil.ToVector3(pos.Select(args));

            if (player != null)
            {
                RaycastHit hit;
                Ray        ray = new Ray(player.position.Value, dropPos);
                if (Physics.Raycast(ray, out hit, Vector3.Distance(player.position.Value, dropPos), UnityLayers.SceneCollidableLayerMask))
                {
                    RaycastHit vhit;
                    if (Physics.Raycast(hit.point, Vector3.down, out vhit, 10000, UnityLayers.SceneCollidableLayerMask))
                    {
                        dropPos = vhit.point;
                    }
                    else
                    {
                        dropPos = hit.point;
                    }
                }
            }
            SceneObjectEntity entity = (SceneObjectEntity)args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(
                (Assets.XmlConfig.ECategory)FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args), dropPos);

            if (entity != null && !string.IsNullOrEmpty(time))
            {
                entity.AddLifeTime(DateTime.Now, args.GetInt(time));
            }
            Debug.LogFormat("create item {0},{1},{2}", FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args));
        }
        public override UnitPosition Select(IEventArgs args)
        {
            UnitPosition up       = pos.Select(args);
            Vector3      position = UnityPositionUtil.ToVector3(up);

            RaycastHit hitInfo;

            if (SingletonManager.Get <MapConfigManager>().InWater(position))
            {
                Ray  ray = new Ray(position, Vector3.up);
                bool hit = Physics.Raycast(ray, out hitInfo, 10000, UnityLayerManager.GetLayerMask(EUnityLayerName.WaterTrigger));
                if (hit)
                {
                    return(UnityPositionUtil.FromVector(hitInfo.point - new Vector3(0, waterDelta, 0)));
                }
            }
            else
            {
                Ray  ray = new Ray(position, Vector3.down);
                bool hit = Physics.Raycast(ray, out hitInfo, 10000, UnityLayers.SceneCollidableLayerMask | UnityLayerManager.GetLayerMask(EUnityLayerName.WaterTrigger));
                if (hit)
                {
                    if (hitInfo.collider.transform.gameObject.layer == UnityLayerManager.GetLayerIndex(EUnityLayerName.WaterTrigger))
                    {
                        return(UnityPositionUtil.FromVector(hitInfo.point - new Vector3(0, waterDelta, 0)));
                    }
                    else
                    {
                        return(UnityPositionUtil.FromVector(hitInfo.point));
                    }
                }
            }
            return(up);
        }
Example #8
0
        public override void DoAction(IEventArgs args)
        {
            var contexts = args.GameContext;
            var player   = GetPlayerEntity(args);

            var  factory          = contexts.session.entityFactoryObject.SceneObjectEntityFactory;
            var  slot             = (EWeaponSlotType)slotIndex;
            var  lastWeaponScan   = player.WeaponController().GetWeaponAgent(slot).ComponentScan;
            bool generateSceneObj = player.WeaponController().DropWeapon(slot);

            //     var lastWeaponScan = player.WeaponController().HeldWeaponAgent.ComponentScan;
            if (!generateSceneObj || lastWeaponScan.IsUnSafeOrEmpty())
            {
                return;
            }
            var unitPos = pos.Select(args);
            var weapon  = factory.CreateDropSceneWeaponObjectEntity(lastWeaponScan, new UnityEngine.Vector3(unitPos.GetX(), unitPos.GetY(), unitPos.GetZ()), args.GetInt(lifeTime)) as SceneObjectEntity;

            if (null != weapon)
            {
                TriggerArgs ta = new TriggerArgs();
                ta.AddPara(new IntPara("weaponId", lastWeaponScan.ConfigId));
                ta.AddPara(new FloatPara("weaponx", weapon.position.Value.x));
                ta.AddPara(new FloatPara("weapony", weapon.position.Value.y));
                ta.AddPara(new FloatPara("weaponz", weapon.position.Value.z));
                ta.AddUnit("current", (FreeData)player.freeData.FreeData);
                args.Trigger(FreeTriggerConstant.WEAPON_DROP, ta);
            }
        }
Example #9
0
 protected override void BuildMessage(IEventArgs args)
 {
     builder.Key = FreeMessageConstant.PlaySound;
     if (null == pos)
     {
         if (play)
         {
             builder.Ks.Add(2);
             builder.Ins.Add(sound);
             builder.Bs.Add(self);
         }
         else
         {
         }
     }
     else
     {
         UnitPosition up = pos.Select(args);
         if (up != null)
         {
             builder.Ks.Add(3);
             builder.Fs.Add(up.GetX());
             builder.Fs.Add(up.GetY());
             builder.Fs.Add(up.GetZ());
             builder.Ins.Add(sound);
         }
     }
 }
Example #10
0
        public override void DoAction(IEventArgs args)
        {
            int realType = args.GetInt(type);
            int dis      = args.GetInt(distance);

            int i = 1;

            UnitPosition up     = pos.Select(args);
            Vector3      target = new Vector3(up.GetX(), up.GetY(), up.GetZ());

            foreach (MapConfigPoints.ID_Point p in FreeMapPosition.GetPositions(args.GameContext.session.commonSession.RoomInfo.MapId).IDPints)
            {
                if (p.ID == realType)
                {
                    foreach (MapConfigPoints.SavedPointData v in p.points)
                    {
                        if (IsNear(v.pos, target, dis))
                        {
                            TriggerArgs ta = new TriggerArgs();
                            ta.AddPara(new FloatPara("x", v.pos.x));
                            ta.AddPara(new FloatPara("y", v.pos.y));
                            ta.AddPara(new FloatPara("z", v.pos.z));
                            ta.AddPara(new FloatPara("index", i++));

                            args.Act(action, ta);
                        }
                    }
                }
            }
        }
Example #11
0
        public virtual UnitPosition Select(IEventArgs args)
        {
            IPosSelector pos = args.ComponentMap.GetPos(name);

            if (pos != null)
            {
                return(pos.Select(args));
            }
            else
            {
                if (defaultPos != null)
                {
                    return(defaultPos.Select(args));
                }
            }
            return(null);
        }
Example #12
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));
        }
Example #13
0
        public override void DoAction(IEventArgs args)
        {
            Vector3 fromV = UnityPositionUtil.ToVector3(from.Select(args));
            Vector3 toV   = UnityPositionUtil.ToVector3(to.Select(args));

            Ray r = new Ray(fromV, new Vector3(toV.x - fromV.x, toV.y - fromV.y, toV.z - fromV.z));

            RaycastHit hitInfo;
            bool       hited = Physics.Raycast(r, out hitInfo);

            if (type == (int)TraceType.Water)
            {
                float sur = SingletonManager.Get <MapConfigManager>().DistanceAboveWater(fromV);
                if (sur > 0)
                {
                    hitInfo.point = new Vector3(fromV.x, fromV.y - sur, fromV.z);
                    hited         = true;
                }
            }

            args.GetDefault().GetParameters().TempUse(new FloatPara("fx", fromV.x));
            args.GetDefault().GetParameters().TempUse(new FloatPara("fy", fromV.y));
            args.GetDefault().GetParameters().TempUse(new FloatPara("fz", fromV.z));
            args.GetDefault().GetParameters().TempUse(new FloatPara("tx", toV.x));
            args.GetDefault().GetParameters().TempUse(new FloatPara("ty", toV.y));
            args.GetDefault().GetParameters().TempUse(new FloatPara("tz", toV.z));

            if (hited)
            {
                args.GetDefault().GetParameters().TempUse(new FloatPara("x", hitInfo.point.x));
                args.GetDefault().GetParameters().TempUse(new FloatPara("y", hitInfo.point.y));
                args.GetDefault().GetParameters().TempUse(new FloatPara("z", hitInfo.point.z));

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

                args.GetDefault().GetParameters().Resume("x");
                args.GetDefault().GetParameters().Resume("y");
                args.GetDefault().GetParameters().Resume("z");
            }
            else
            {
                if (noHitAction != null)
                {
                    noHitAction.Act(args);
                }
            }

            args.GetDefault().GetParameters().Resume("fx");
            args.GetDefault().GetParameters().Resume("fy");
            args.GetDefault().GetParameters().Resume("fz");
            args.GetDefault().GetParameters().Resume("tx");
            args.GetDefault().GetParameters().Resume("ty");
            args.GetDefault().GetParameters().Resume("tz");
        }
Example #14
0
        public override void DoAction(IEventArgs args)
        {
            Vector3 p           = UnityPositionUtil.ToVector3(pos.Select(args));
            string  realName    = FreeUtil.ReplaceVar(name, args);
            var     groupEntity = args.GameContext.freeMove.CreateEntity();

            groupEntity.AddEntityKey(new EntityKey(args.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove));
            groupEntity.AddPosition();
            groupEntity.position.Value = new Vector3(p.x, p.y, p.z);
            groupEntity.AddFreeData("", null);
            groupEntity.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, 1000);
            groupEntity.freeData.Value = "";
            if (type == 1)
            {
                groupEntity.freeData.Cat = FreeEntityConstant.DeadBoxGroup;
            }
            else if (type == 2)
            {
                groupEntity.freeData.Cat = FreeEntityConstant.DropBoxGroup;
            }
            groupEntity.isFlagSyncNonSelf = true;

            if (string.IsNullOrEmpty(id))
            {
                ItemDrop[] list = FreeItemDrop.GetDropItems(FreeUtil.ReplaceVar(cat, args), FreeUtil.ReplaceInt(count, args), args.GameContext.session.commonSession.RoomInfo.MapId);
                foreach (ItemDrop drop in list)
                {
                    CreateItemFromItemDrop(args, p, drop, realName);
                    List <ItemDrop> extra = FreeItemDrop.GetExtraItems(drop);
                    foreach (ItemDrop e in extra)
                    {
                        CreateItemFromItemDrop(args, p, e, realName);
                    }
                }
            }
            else
            {
                PlayerEntity player = args.GameContext.player.GetEntityWithEntityKey(new EntityKey(FreeUtil.ReplaceInt(id, args), (short)EEntityType.Player));
                if (player != null)
                {
                    groupEntity.freeData.IntValue = player.entityKey.Value.EntityId;
                    groupEntity.freeData.Value    = realName;
                    realName = player.playerInfo.PlayerName;
                    FreeData fd = ((FreeData)player.freeData.FreeData);
                    foreach (string inv in fd.GetFreeInventory().GetInventoryManager().GetInventoryNames())
                    {
                        ItemInventory ii = fd.GetFreeInventory().GetInventoryManager().GetInventory(inv);
                        if (ii.name != ChickenConstant.BagDefault)
                        {
                            CreateItemFromInventory(args, fd, ii, p, realName);
                        }
                    }
                    CreateItemFromInventory(args, fd, fd.GetFreeInventory().GetInventoryManager().GetDefaultInventory(), p, realName);
                }
            }
        }
Example #15
0
        public override void DoAction(IEventArgs args)
        {
            UnitPosition up = pos.Select(args);

            Contexts con = args.GameContext;

            VehicleEntityUtility.CreateNewVehicle(con.vehicle, FreeUtil.ReplaceInt(carId, args),
                                                  con.session.commonSession.EntityIdGenerator.GetNextEntityId(),
                                                  map.position.UnityPositionUtil.ToVector3(up));
        }
Example #16
0
        public virtual void Start(FreeRuleEventArgs args, FreeMoveEntity entity)
        {
            startTime = args.Rule.ServerTime;

            UnitPosition up = startPos.Select(args);

            entity.position.Value = new Vector3(up.GetX(), up.GetY(), up.GetZ());

            StartMove(args, entity);
        }
Example #17
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);
        }
 public virtual string GetXyz(IEventArgs args)
 {
     if (selector != null)
     {
         UnitPosition up = selector.Select(args);
         if (up != null)
         {
             return(up.GetX() + "," + up.GetY() + "," + up.GetZ());
         }
     }
     return(string.Empty);
 }
        public override void DoAction(IEventArgs args)
        {
            if (count == 0)
            {
                count = 1;
            }
            UnitPosition[] ups = null;
            if (count == 1)
            {
                UnitPosition sub = pos.Select(args);
                if (sub == null)
                {
                    throw new GameActionExpception("找不到pos点[" + pos.ToString() + "]");
                }

                ups = new UnitPosition[] { sub };
            }
            else
            {
                ups = pos.Select(args, count);
            }
            int index = 0;

            foreach (UnitPosition up in ups)
            {
                args.GetDefault().GetParameters().TempUse(new FloatPara("x", up.GetX()));
                args.GetDefault().GetParameters().TempUse(new FloatPara("y", up.GetY()));
                args.GetDefault().GetParameters().TempUse(new FloatPara("z", up.GetZ()));
                args.GetDefault().GetParameters().TempUse(new IntPara("index", ++index));
                args.GetDefault().GetParameters().TempUse(new BoolPara("invalid", up.GetInvalid()));
                args.GetDefault().GetParameters().TempUse(new IntPara("randomindex", up.GetRandomindex()));
                action.Act(args);
                args.GetDefault().GetParameters().Resume("x");
                args.GetDefault().GetParameters().Resume("y");
                args.GetDefault().GetParameters().Resume("z");
                args.GetDefault().GetParameters().Resume("index");
                args.GetDefault().GetParameters().Resume("invalid");
                args.GetDefault().GetParameters().Resume("randomindex");
            }
        }
Example #20
0
        public bool Meet(IEventArgs args)
        {
            UnitPosition up = pos.Select(args);

            if (useOut)
            {
                return(!region.In(args, up));
            }
            else
            {
                return(region.In(args, up));
            }
        }
Example #21
0
        public override void DoAction(IEventArgs args)
        {
            var contexts = args.GameContext;
            var p        = pos.Select(args);
            var entity   = contexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateCastEntity(new UnityEngine.Vector3(p.GetX(), p.GetY(), p.GetZ()),
                                                                                                          size, key, tip);
            var sceneObjectEntity = entity as SceneObjectEntity;

            if (null != sceneObjectEntity && castflag != 0)
            {
                sceneObjectEntity.AddCastFlag(castflag);
            }
        }
Example #22
0
        protected override void BuildMessage(IEventArgs args)
        {
            this.scope = "4";

            builder.Key = FreeMessageConstant.PoisonCircle;
            UnitPosition from = pos.Select(args);

            builder.Ks.Add(1);
            builder.Fs.Add(from.GetX());
            builder.Fs.Add(from.GetZ());

            builder.Ins.Add(FreeUtil.ReplaceInt(radius, args));
        }
        public override void DoAction(IEventArgs args)
        {
            ItemDrop[] list = FreeItemDrop.GetDropItems(FreeUtil.ReplaceVar(cat, args), FreeUtil.ReplaceInt(count, args), args.GameContext.session.commonSession.RoomInfo.MapId);

            if (list != null)
            {
                Vector3 p = UnityPositionUtil.ToVector3(pos.Select(args));
                foreach (ItemDrop drop in list)
                {
                    args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.
                    CreateSimpleEquipmentEntity((ECategory)drop.cat, drop.id, drop.count, new Vector3(p.x + RandomUtil.Random(-100, 100) / 100f, p.y, p.z + RandomUtil.Random(-100, 100) / 100f));
                }
            }
        }
Example #24
0
        public override void DoAction(IEventArgs args)
        {
            SceneObjectEntity entity = (SceneObjectEntity)args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(
                (Assets.XmlConfig.ECategory)FreeUtil.ReplaceInt(cat, args),
                FreeUtil.ReplaceInt(id, args),
                FreeUtil.ReplaceInt(count, args),
                UnityPositionUtil.ToVector3(pos.Select(args)));

            if (entity != null && !string.IsNullOrEmpty(time))
            {
                entity.AddLifeTime(DateTime.Now, args.GetInt(time));
            }
            Debug.LogFormat("create item {0},{1},{2}", FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args));
        }
Example #25
0
        public override void DoAction(IEventArgs args)
        {
            if (string.IsNullOrEmpty(player))
            {
                player = "current";
            }
            PlayerEntity entity = GetPlayerEntity(args);

            if (entity != null)
            {
                UnitPosition up    = pos.Select(args);
                float        toYaw = (float)(Math.Atan2(up.Vector3.x - entity.position.Value.x, up.Vector3.z - entity.position.Value.z) * 180 / Math.PI);

                double deltaYaw = toYaw - entity.orientation.Yaw;

                if (Math.Abs(deltaYaw) < 3)
                {
                    args.FreeContext.AiSuccess = true;
                }
                else
                {
                    Debug.LogFormat("face delta:{0}, from:{1} {3}, to:{2} {4}", deltaYaw, entity.orientation.Yaw, toYaw, entity.position.Value, up.Vector3);
                }

                if (startTime > 0)
                {
                    float time = args.Rule.ServerTime - startTime;

                    if (deltaYaw > 0)
                    {
                        entity.orientation.Yaw += rotationSpeed * time / 1000;
                        if (entity.orientation.Yaw > toYaw)
                        {
                            entity.orientation.Yaw = toYaw;
                        }
                    }
                    else
                    {
                        entity.orientation.Yaw -= rotationSpeed * time / 1000;
                        if (entity.orientation.Yaw < toYaw)
                        {
                            entity.orientation.Yaw = toYaw;
                        }
                    }
                }
            }

            startTime = args.Rule.ServerTime;
        }
Example #26
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);
                    }
                }
            }
        }
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;
            IParable          pe = args.GetUnit(item);

            if (pe != null && pe is FreeItem)
            {
                FreeItem fi = (FreeItem)pe;
                if (!StringUtil.IsNullOrEmpty(time))
                {
                    ((FreeGameItem)fi).SetTime(time);
                }
                fi.Drop(fr, pos.Select(args));
            }
        }
        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));
            }
        }
Example #29
0
        public override void DoAction(IEventArgs args)
        {
            if (string.IsNullOrEmpty(player))
            {
                player = "current";
            }

            if (DateTime.Now.Ticks - startTime < 10000 * 200)
            {
                return;
            }
            startTime = DateTime.Now.Ticks;

            PlayerEntity entity = GetPlayerEntity(args);

            if (entity != null)
            {
                UnitPosition target = pos.Select(args);
                Vector3      from   = entity.position.Value;
                Vector3      to     = AutoMoveUtil.GetGround(target.Vector3).point;

                float dis = Vector3.Distance(from, to);

                Debug.LogFormat("dis:{0} to:{1}, from:{2}", dis, to, from);

                if (dis < 2)
                {
                    args.FreeContext.AiSuccess = true;
                    Debug.LogFormat("arrive");

                    PlayerInterceptCommands.DoNothing(entity);

                    if (action != null)
                    {
                        action.Act(args);
                    }
                }
                else
                {
                    Vector3 v = GetNextPoint(entity, from, to, dis);
                    Debug.LogFormat("move to {0}", v);
                    //player.orientation.Yaw = player.orientation.Yaw + Vector3.Angle(from, v);

                    PlayerInterceptCommands.WalkTo(entity, v);
                }
            }
        }
 public override void DoAction(IEventArgs args)
 {
     foreach (FreeMoveEntity freeMoveEntity in args.GameContext.freeMove.GetEntities())
     {
         if (freeMoveEntity.freeData.Key == FreeMove)
         {
             UnitPosition aimPos = targetPos.Select(args);
             if (!freeMoveEntity.hasFreeMoveController)
             {
                 freeMoveEntity.AddFreeMoveController();
             }
             freeMoveEntity.freeMoveController.FocusOnPosition =
                 new Vector3(aimPos.GetX(), aimPos.GetY(), aimPos.GetZ()).ShiftedToFixedVector3();
             freeMoveEntity.freeMoveController.ControllType = (byte)EFreeMoveControllType.FixFocusPos;
         }
     }
 }