Пример #1
0
        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);
        }
Пример #2
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);
        }
Пример #3
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()));
        }
Пример #4
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);
        }