예제 #1
0
    private void InitProjectile(int id, IPlayerPawn source, IMapProjectileLogic logic, MapProjectileCallback cb)
    {
        ClassID = (AllodsProjectile)id;
        Class   = ProjectileClassLoader.GetProjectileClassById(id);
        if (Class == null)
        {
            // make sure that at least ID is valid
            if (!Enum.IsDefined(typeof(AllodsProjectile), id))
            {
                // otherwise spam log
                Debug.LogFormat("Invalid projectile created (id={0})", id);
                return;
            }
        }

        Source = source;
        Logic  = logic;
        if (Logic != null)
        {
            Logic.SetProjectile(this);
        }
        Callback = cb;

        Width        = 1;
        Height       = 1;
        Alpha        = 1f;
        Color        = new Color(1, 1, 1, 1);
        ZOffset      = 128;
        Scale        = 1;
        DoUpdateView = true;
    }
예제 #2
0
        public bool Process()
        {
            if (!MapLogic.Instance.IsLoaded)
            {
                return(false);
            }

            IPlayerPawn source = null;

            if (SourceTag > 0)
            {
                switch (SourceType)
                {
                case MapObjectType.Human:
                case MapObjectType.Monster:
                    source = MapLogic.Instance.GetUnitByTag(SourceTag);
                    break;

                case MapObjectType.Structure:
                    source = MapLogic.Instance.GetStructureByTag(SourceTag);
                    break;
                }
            }

            MapUnit target = MapLogic.Instance.GetUnitByTag(TargetTag);

            if (target == null)
            {
                return(false);
            }

            Server.SpawnProjectileLightning(source, X, Y, Z, target, Color);

            return(true);
        }
예제 #3
0
    private void InitProjectile(int id, IPlayerPawn source, IMapProjectileLogic logic, MapProjectileCallback cb)
    {
        Class = ProjectileClassLoader.GetProjectileClassById(id);
        if (Class == null)
        {
            Debug.LogFormat("Invalid projectile created (id={0})", id);
            return;
        }

        Source = source;
        Logic  = logic;
        if (Logic != null)
        {
            Logic.SetProjectile(this);
        }
        Callback = cb;

        Width        = 1;
        Height       = 1;
        Alpha        = 1f;
        Color        = new Color(1, 1, 1, 1);
        ZOffset      = 128;
        Scale        = 1;
        DoUpdateView = true;
    }
예제 #4
0
        public bool Process()
        {
            if (!MapLogic.Instance.IsLoaded)
            {
                return(false);
            }

            IPlayerPawn source = null;

            if (SourceTag > 0)
            {
                switch (SourceType)
                {
                case MapObjectType.Human:
                case MapObjectType.Monster:
                    source = MapLogic.Instance.GetUnitByTag(SourceTag);
                    break;

                case MapObjectType.Structure:
                    source = MapLogic.Instance.GetStructureByTag(SourceTag);
                    break;
                }
            }

            Server.SpawnProjectileEOT(TypeID, source, X, Y, Z, Duration, Duration, StartFrames, EndFrames, ZOffset, null, LightLevel);
            return(true);
        }
예제 #5
0
        public bool Process()
        {
            if (!MapLogic.Instance.IsLoaded)
            {
                return(false);
            }

            IPlayerPawn source = null;

            if (SourceTag > 0)
            {
                switch (SourceType)
                {
                case MapObjectType.Human:
                case MapObjectType.Monster:
                    source = MapLogic.Instance.GetUnitByTag(SourceTag);
                    break;

                case MapObjectType.Structure:
                    source = MapLogic.Instance.GetStructureByTag(SourceTag);
                    break;
                }
            }

            Server.SpawnProjectileDirectional(TypeID, source, X, Y, Z, TargetX, TargetY, TargetZ, Speed, (MapProjectile fproj) =>
            {
                fproj.Dispose();
            });

            return(true);
        }
예제 #6
0
        public bool Process()
        {
            if (!MapLogic.Instance.IsLoaded)
            {
                return(false);
            }

            IPlayerPawn source = null;

            if (SourceTag > 0)
            {
                switch (SourceType)
                {
                case MapObjectType.Human:
                case MapObjectType.Monster:
                    source = MapLogic.Instance.GetUnitByTag(SourceTag);
                    break;

                case MapObjectType.Structure:
                    source = MapLogic.Instance.GetStructureByTag(SourceTag);
                    break;
                }
            }

            Server.SpawnProjectileSimple(TypeID, source, X, Y, Z, AnimSpeed, Scale, Start, End);
            return(true);
        }
예제 #7
0
    public static void SpawnProjectileEOT(int id, IPlayerPawn source, float x, float y, float z, int duration, int frequency, int startframes = 0, int endframes = 0, int zoffs = -128, MapProjectileCallback cb = null)
    {
        MapProjectile proj = new MapProjectile(id, source, new MapProjectileLogicEOT(duration, frequency, startframes, endframes), cb);

        proj.ZOffset = zoffs;
        proj.SetPosition(x, y, z);
        MapLogic.Instance.Objects.Add(proj);

        if (NetworkManager.IsServer)
        {
            foreach (ServerClient client in ServerManager.Clients)
            {
                if (client.State != ClientState.Playing)
                {
                    continue;
                }

                Player    p         = MapLogic.Instance.GetNetPlayer(client);
                MapObject sourceObj = (MapObject)source;
                if (sourceObj != null)
                {
                    if (!sourceObj.IsVisibleForNetPlayer(p))
                    {
                        ObjectBecameVisible(p, sourceObj); // force keyframe update for source unit
                    }
                }

                ClientCommands.AddProjectileEOT app;
                app.X          = x;
                app.Y          = y;
                app.Z          = z;
                app.SourceType = (sourceObj != null) ? sourceObj.GetObjectType() : MapObjectType.Object;

                if (app.SourceType == MapObjectType.Human ||
                    app.SourceType == MapObjectType.Monster)
                {
                    app.SourceTag = ((MapUnit)sourceObj).Tag;
                }
                else if (app.SourceType == MapObjectType.Structure)
                {
                    app.SourceTag = ((MapStructure)sourceObj).Tag;
                }
                else
                {
                    app.SourceTag = -1;
                }

                app.TypeID      = id;
                app.Duration    = duration;
                app.StartFrames = startframes;
                app.EndFrames   = endframes;
                app.ZOffset     = zoffs;

                client.SendCommand(app);
            }
        }
    }
예제 #8
0
파일: Server.cs 프로젝트: Logof/UnityAllods
    public static void SpawnProjectileDirectional(int id, IPlayerPawn source, float x, float y, float z, float tgx, float tgy, float tgz, float speed, MapProjectileCallback cb = null)
    {
        MapProjectile proj = new MapProjectile(id, source, new MapProjectileLogicDirectional(tgx, tgy, tgz, speed), cb);

        proj.SetPosition(x, y, z);
        MapLogic.Instance.Objects.Add(proj);
        // todo notify clients

        if (NetworkManager.IsServer)
        {
            foreach (ServerClient client in ServerManager.Clients)
            {
                if (client.State != ClientState.Playing)
                {
                    continue;
                }

                Player    p         = MapLogic.Instance.GetNetPlayer(client);
                MapObject sourceObj = (MapObject)source;
                if (sourceObj != null)
                {
                    if (!sourceObj.IsVisibleForNetPlayer(p))
                    {
                        ObjectBecameVisible(p, sourceObj); // force keyframe update for source unit
                    }
                }

                ClientCommands.AddProjectileDirectional app;
                app.X          = x;
                app.Y          = y;
                app.Z          = z;
                app.TargetX    = tgx;
                app.TargetY    = tgy;
                app.TargetZ    = tgz;
                app.SourceType = (sourceObj != null) ? sourceObj.GetObjectType() : MapObjectType.Object;

                if (app.SourceType == MapObjectType.Human ||
                    app.SourceType == MapObjectType.Monster)
                {
                    app.SourceTag = ((MapUnit)sourceObj).Tag;
                }
                else if (app.SourceType == MapObjectType.Structure)
                {
                    app.SourceTag = ((MapStructure)sourceObj).Tag;
                }
                else
                {
                    app.SourceTag = -1;
                }

                app.Speed  = speed;
                app.TypeID = id;

                client.SendCommand(app);
            }
        }
    }
예제 #9
0
    public static void SpawnProjectileSimple(int id, IPlayerPawn source, float x, float y, float z, float animspeed = 0.5f, float scale = 1f, int start = 0, int end = 0)
    {
        MapProjectile proj = new MapProjectile(id, source, new MapProjectileLogicSimple(animspeed, scale, start, end), null); // this is usually SFX like stuff. projectile plays animation based on typeid and stops.

        proj.SetPosition(x, y, z);
        MapLogic.Instance.Objects.Add(proj);

        if (NetworkManager.IsServer)
        {
            foreach (ServerClient client in ServerManager.Clients)
            {
                if (client.State != ClientState.Playing)
                {
                    continue;
                }

                Player    p         = MapLogic.Instance.GetNetPlayer(client);
                MapObject sourceObj = (MapObject)source;
                if (sourceObj != null)
                {
                    if (!sourceObj.IsVisibleForNetPlayer(p))
                    {
                        ObjectBecameVisible(p, sourceObj); // force keyframe update for source unit
                    }
                }

                ClientCommands.AddProjectileSimple app;
                app.X          = x;
                app.Y          = y;
                app.Z          = z;
                app.SourceType = (sourceObj != null) ? sourceObj.GetObjectType() : MapObjectType.Object;

                if (app.SourceType == MapObjectType.Human ||
                    app.SourceType == MapObjectType.Monster)
                {
                    app.SourceTag = ((MapUnit)sourceObj).Tag;
                }
                else if (app.SourceType == MapObjectType.Structure)
                {
                    app.SourceTag = ((MapStructure)sourceObj).Tag;
                }
                else
                {
                    app.SourceTag = -1;
                }

                app.TypeID    = id;
                app.AnimSpeed = animspeed;
                app.Scale     = scale;
                app.Start     = start;
                app.End       = end;

                client.SendCommand(app);
            }
        }
    }
예제 #10
0
    public static void SpawnProjectileLightning(IPlayerPawn source, float x, float y, float z, MapUnit target, int color, MapProjectileCallback cb = null)
    {
        MapProjectile proj = new MapProjectile(AllodsProjectile.Lightning, source, new MapProjectileLogicLightning(target, color), cb);

        proj.SetPosition(x, y, z);
        MapLogic.Instance.Objects.Add(proj);

        if (NetworkManager.IsServer)
        {
            foreach (ServerClient client in ServerManager.Clients)
            {
                if (client.State != ClientState.Playing)
                {
                    continue;
                }

                Player    p         = MapLogic.Instance.GetNetPlayer(client);
                MapObject sourceObj = (MapObject)source;
                if (sourceObj != null)
                {
                    if (!sourceObj.IsVisibleForNetPlayer(p))
                    {
                        ObjectBecameVisible(p, sourceObj); // force keyframe update for source unit
                    }
                }

                ClientCommands.AddProjectileLightning app;
                app.X          = x;
                app.Y          = y;
                app.Z          = z;
                app.SourceType = (sourceObj != null) ? sourceObj.GetObjectType() : MapObjectType.Object;

                if (app.SourceType == MapObjectType.Human ||
                    app.SourceType == MapObjectType.Monster)
                {
                    app.SourceTag = ((MapUnit)sourceObj).Tag;
                }
                else if (app.SourceType == MapObjectType.Structure)
                {
                    app.SourceTag = ((MapStructure)sourceObj).Tag;
                }
                else
                {
                    app.SourceTag = -1;
                }

                app.TargetTag = target.Tag;
                app.Color     = color;

                client.SendCommand(app);
            }
        }
    }
예제 #11
0
        public bool Process()
        {
            if (!MapLogic.Instance.IsLoaded)
            {
                return(false);
            }

            IPlayerPawn source = null;

            if (SourceTag > 0)
            {
                switch (SourceType)
                {
                case MapObjectType.Human:
                case MapObjectType.Monster:
                    source = MapLogic.Instance.GetUnitByTag(SourceTag);
                    break;

                case MapObjectType.Structure:
                    source = MapLogic.Instance.GetStructureByTag(SourceTag);
                    break;
                }
            }

            MapUnit target = MapLogic.Instance.GetUnitByTag(TargetTag);

            if (target == null)
            {
                return(false);
            }

            Server.SpawnProjectileHoming(TypeID, source, X, Y, Z, target, Speed, (MapProjectile fproj) =>
            {
                fproj.Dispose();
                MapLogic.Instance.Objects.Remove(fproj);
            });

            return(true);
        }
예제 #12
0
 public static void SpawnProjectileSimple(AllodsProjectile id, IPlayerPawn source, float x, float y, float z, float animspeed = 0.5f, float scale = 1f, int start = 0, int end = 0)
 {
     SpawnProjectileSimple((int)id, source, x, y, z, animspeed, scale, start, end);
 }
예제 #13
0
파일: Server.cs 프로젝트: Logof/UnityAllods
 public static void SpawnProjectileSimple(AllodsProjectile id, IPlayerPawn source, float x, float y, float z, float animspeed = 0.5f)
 {
     SpawnProjectileSimple((int)id, source, x, y, z, animspeed);
 }
예제 #14
0
 public static void SpawnProjectileEOT(AllodsProjectile id, IPlayerPawn source, float x, float y, float z, int duration, int frequency, int startframes = 0, int endframes = 0, int zoffs = -128, MapProjectileCallback cb = null)
 {
     SpawnProjectileEOT((int)id, source, x, y, z, duration, frequency, startframes, endframes, zoffs, cb);
 }
예제 #15
0
파일: Server.cs 프로젝트: Logof/UnityAllods
 public static void SpawnProjectileHoming(AllodsProjectile id, IPlayerPawn source, float x, float y, float z, MapUnit target, float speed, MapProjectileCallback cb = null)
 {
     SpawnProjectileHoming((int)id, source, x, y, z, target, speed, cb);
 }
예제 #16
0
파일: Server.cs 프로젝트: Logof/UnityAllods
 public static void SpawnProjectileDirectional(AllodsProjectile id, IPlayerPawn source, float x, float y, float z, float tgx, float tgy, float tgz, float speed, MapProjectileCallback cb = null)
 {
     SpawnProjectileDirectional((int)id, source, x, y, z, tgx, tgy, tgz, speed, cb);
 }
예제 #17
0
 public MapProjectile(int id, IPlayerPawn source = null, IMapProjectileLogic logic = null, MapProjectileCallback cb = null)
 {
     InitProjectile(id, source, logic, cb);
 }
예제 #18
0
 public MapProjectile(AllodsProjectile proj, IPlayerPawn source = null, IMapProjectileLogic logic = null, MapProjectileCallback cb = null)
 {
     InitProjectile((int)proj, source, logic, cb);
 }