场景类 主要用户查找当前场景Actor等功能
Inheritance: ScriptRuntime.Base
Exemple #1
0
 private static extern void ICall_Scene_Release(Scene self);
Exemple #2
0
 private static extern bool ICall_Scene_RemoveActor(Scene self, Actor pActor);
Exemple #3
0
 private static extern Actor ICall_Scene_GetActor(Scene self, int index);
Exemple #4
0
 private static extern int ICall_Scene_GetActorCount(Scene self);
Exemple #5
0
 private static extern Actor ICall_Scene_FindActorByName(Scene self, String name);
Exemple #6
0
 private static extern Actor[] ICall_Scene_FindActorsByTag(Scene self, UInt32 tagID);
Exemple #7
0
 private static extern Actor ICall_Scene_FindActorByFastID(Scene self, UInt32 fastID);
Exemple #8
0
 private static extern Actor ICall_Scene_FindActorByGuid(Scene self, byte[] guid);
Exemple #9
0
 private static extern bool ICall_Scene_AddActor(Scene self, Actor pActor);
 internal void Init(Scene scene)
 {
     StaticInit();
       m_CurScene = scene;
 }
 internal static void Lookat(Scene scene, EntityInfo obj, Vector3 target)
 {
     if (scene.EntityController.GetEntityType(obj) == (int)EntityTypeEnum.Tower)
         return;
     Vector3 srcPos = obj.GetMovementStateInfo().GetPosition3D();
     obj.GetMovementStateInfo().SetFaceDir(Geometry.GetYRadian(new Vector2(srcPos.X, srcPos.Z), new Vector2(target.X, target.Z)));
 }
 internal static List<EntityInfo> FindTargetInSector(Scene scene, Vector3 center,
                                               float radius,
                                               Vector3 direction,
                                               Vector3 degreeCenter,
                                               float degree)
 {
     List<EntityInfo> result = new List<EntityInfo>();
     scene.KdTree.Query(center.X, center.Y, center.Z, radius, (float distSqr, KdTreeObject kdTreeObj) => {
         ScriptRuntime.Vector3 pos = kdTreeObj.Position;
         Vector3 targetDir = new Vector3(pos.X, pos.Y, pos.Z) - degreeCenter;
         targetDir.Y = 0;
         if (Math.Abs(Vector3.Angle(targetDir, direction)) <= degree) {
             EntityInfo obj = scene.EntityController.GetGameObject(kdTreeObj.Object.GetId());
             result.Add(obj);
         }
     });
     return result;
 }
        public static void AoeQuery(Scene scene, EntityInfo srcObj, EntityInfo targetObj, int aoeType, float range, float angleOrLength, SkillInstance instance, int senderId, int targetType, Vector3 relativeCenter, bool relativeToTarget, MyFunc<float, int, bool> callback)
        {
            float radian;
            Vector3 center;
            Vector3 srcPos = srcObj.GetMovementStateInfo().GetPosition3D();
            if (null != targetObj && relativeToTarget) {
                Vector3 targetPos = targetObj.GetMovementStateInfo().GetPosition3D();
                radian = Geometry.GetYRadian(new ScriptRuntime.Vector2(srcPos.X, srcPos.Z), new ScriptRuntime.Vector2(targetPos.X, targetPos.Z));
                ScriptRuntime.Vector2 newOffset = Geometry.GetRotate(new ScriptRuntime.Vector2(relativeCenter.X, relativeCenter.Z), radian);
                center = targetPos + new Vector3(newOffset.X, relativeCenter.Y, newOffset.Y);
            } else {
                radian = srcObj.GetMovementStateInfo().GetFaceDir();
                ScriptRuntime.Vector2 newOffset = Geometry.GetRotate(new ScriptRuntime.Vector2(relativeCenter.X, relativeCenter.Z), radian);
                center = srcPos + new Vector3(newOffset.X, relativeCenter.Y, newOffset.Y);
            }

            if (aoeType == (int)SkillAoeType.Circle || aoeType == (int)SkillAoeType.Sector) {
                angleOrLength = Geometry.DegreeToRadian(angleOrLength);
                scene.KdTree.Query(center.X, center.Y, center.Z, range, (float distSqr, KdTreeObject kdTreeObj) => {
                    int targetId = kdTreeObj.Object.GetId();
                    if (targetType == (int)SkillTargetType.Enemy && CharacterRelation.RELATION_ENEMY == scene.EntityController.GetRelation(senderId, targetId) ||
                        targetType == (int)SkillTargetType.Friend && CharacterRelation.RELATION_FRIEND == scene.EntityController.GetRelation(senderId, targetId)) {
                        bool isMatch = false;
                        if (aoeType == (int)SkillAoeType.Circle) {
                            isMatch = true;
                        } else {
                            ScriptRuntime.Vector2 u = Geometry.GetRotate(new ScriptRuntime.Vector2(0, 1), radian);
                            isMatch = Geometry.IsSectorDiskIntersect(new ScriptRuntime.Vector2(center.X, center.Z), u, angleOrLength / 2, range, new ScriptRuntime.Vector2(kdTreeObj.Position.X, kdTreeObj.Position.Z), kdTreeObj.Radius);
                        }
                        if (isMatch) {
                            if (!callback(distSqr, kdTreeObj.Object.GetId())) {
                                return false;
                            }
                        }
                    }
                    return true;
                });
            } else {
                ScriptRuntime.Vector2 angleu = Geometry.GetRotate(new ScriptRuntime.Vector2(0, angleOrLength), radian);
                ScriptRuntime.Vector2 c = new ScriptRuntime.Vector2(center.X, center.Z) + angleu / 2;
                scene.KdTree.Query(c.X, 0, c.Y, range + angleOrLength / 2, (float distSqr, GameFramework.KdTreeObject kdTreeObj) => {
                    int targetId = kdTreeObj.Object.GetId();
                    if (targetType == (int)SkillTargetType.Enemy && CharacterRelation.RELATION_ENEMY == scene.EntityController.GetRelation(senderId, targetId) ||
                        targetType == (int)SkillTargetType.Friend && CharacterRelation.RELATION_FRIEND == scene.EntityController.GetRelation(senderId, targetId)) {
                        bool isMatch = false;
                        if (aoeType == (int)SkillAoeType.Capsule) {
                            isMatch = Geometry.IsCapsuleDiskIntersect(new ScriptRuntime.Vector2(center.X, center.Z), angleu, range, new ScriptRuntime.Vector2(kdTreeObj.Position.X, kdTreeObj.Position.Z), kdTreeObj.Radius);
                        } else {
                            ScriptRuntime.Vector2 half = new ScriptRuntime.Vector2(range / 2, angleOrLength / 2);
                            isMatch = Geometry.IsObbDiskIntersect(c, half, radian, new ScriptRuntime.Vector2(kdTreeObj.Position.X, kdTreeObj.Position.Z), kdTreeObj.Radius);
                        }
                        if (isMatch) {
                            if (!callback(distSqr, kdTreeObj.Object.GetId())) {
                                return false;
                            }
                        }
                    }
                    return true;
                });
            }
        }