示例#1
0
        public void PrepareLine()
        {
            HookControl control = GetControlOfType <HookControl>();

            lineGeom = SceneGeometryFactory.CreateLineGeometry(SceneMgr, Colors.LightSteelBlue, 2, Colors.Black, control.Origin, control.Origin);
            SceneMgr.AttachGraphicalObjectToScene(lineGeom, DrawingCategory.PROJECTILE_BACKGROUND);
        }
示例#2
0
        public static void ReadObjectHookControl(this NetIncomingMessage msg, HookControl c)
        {
            msg.ReadControl(c);

            c.Lenght = msg.ReadInt32();
            c.Origin = msg.ReadVector();
            c.Speed  = msg.ReadInt32();
        }
示例#3
0
        public static void WriteObjectHookControl(this NetOutgoingMessage msg, HookControl c)
        {
            msg.WriteControl(c);

            msg.Write(c.Lenght);
            msg.Write(c.Origin);
            msg.Write(c.Speed);
        }
示例#4
0
        public static Hook CreateHook(SceneMgr mgr, Point point, Player player)
        {
            Vector position  = new Vector(player.GetBaseLocation().X + player.GetBaseLocation().Width / 2, player.GetBaseLocation().Y - 5);
            Vector direction = point.ToVector() - position;

            direction.Normalize();

            Hook hook = new Hook(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId()));

            hook.Owner     = player;
            hook.Radius    = 8;
            position.X    -= hook.Radius;
            position.Y    -= hook.Radius;
            hook.Position  = position;
            hook.Rotation  = (float)Vector.AngleBetween(new Vector(0, -1), direction);
            hook.Direction = direction;
            hook.Color     = player.GetPlayerColor();

            hook.SetGeometry(SceneGeometryFactory.CreateHookHead(hook));

            SphereCollisionShape cs = new SphereCollisionShape();

            cs.Radius           = hook.Radius / 2;
            cs.Center           = hook.Center;
            hook.CollisionShape = cs;

            HookControl hookControl = new HookControl();

            hookControl.Origin = new Vector(hook.Center.X, hook.Center.Y);
            hookControl.Speed  = player.Data.HookSpeed;
            hookControl.Lenght = player.Data.HookLenght;

            hook.AddControl(hookControl);
            hook.AddControl(new StickySphereCollisionShapeControl());

            hook.PrepareLine();

            return(hook);
        }
示例#5
0
        public static IList <IControl> ReadControls(this NetIncomingMessage msg)
        {
            int controlCount          = msg.ReadInt32();
            IList <IControl> controls = new List <IControl>(controlCount);

            for (int i = 0; i < controlCount; ++i)
            {
                int hash = msg.ReadInt32();
                if (hash == typeof(BaseCollisionControl).GUID.GetHashCode())
                {
                    BaseCollisionControl c = new BaseCollisionControl();
                    msg.ReadControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(BouncingSingularityBulletControl).GUID.GetHashCode())
                {
                    BouncingSingularityBulletControl c = new BouncingSingularityBulletControl();
                    msg.ReadObjectExplodingSingularityBulletControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(DroppingSingularityControl).GUID.GetHashCode())
                {
                    DroppingSingularityControl c = new DroppingSingularityControl();
                    msg.ReadObjectDroppingSingularityControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(AsteroidDroppingSingularityControl).GUID.GetHashCode())
                {
                    AsteroidDroppingSingularityControl c = new AsteroidDroppingSingularityControl();
                    msg.ReadObjectDroppingSingularityControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(NewtonianMovementControl).GUID.GetHashCode())
                {
                    NewtonianMovementControl c = new NewtonianMovementControl();
                    msg.ReadObjectNewtonianMovementControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(LinearMovementControl).GUID.GetHashCode())
                {
                    LinearMovementControl c = new LinearMovementControl();
                    msg.ReadObjectLinearMovementControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(LinearRotationControl).GUID.GetHashCode())
                {
                    LinearRotationControl c = new LinearRotationControl();
                    msg.ReadObjectLinearRotationControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(PowerHookControl).GUID.GetHashCode())
                {
                    PowerHookControl c = new PowerHookControl();
                    msg.ReadObjectHookControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(HookControl).GUID.GetHashCode())
                {
                    HookControl c = new HookControl();
                    msg.ReadObjectHookControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(ExplodingSingularityBulletControl).GUID.GetHashCode())
                {
                    ExplodingSingularityBulletControl c = new ExplodingSingularityBulletControl();
                    msg.ReadObjectExplodingSingularityBulletControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(ExcludingExplodingSingularityBulletControl).GUID.GetHashCode())
                {
                    ExcludingExplodingSingularityBulletControl c = new ExcludingExplodingSingularityBulletControl();
                    msg.ReadObjectExcludingExplodingSingularityBulletControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(MinorAsteroidCollisionReactionControl).GUID.GetHashCode())
                {
                    MinorAsteroidCollisionReactionControl c = new MinorAsteroidCollisionReactionControl();
                    msg.ReadControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(SingularityBulletCollisionReactionControl).GUID.GetHashCode())
                {
                    SingularityBulletCollisionReactionControl c = new SingularityBulletCollisionReactionControl();
                    msg.ReadControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(StatPowerUpCollisionReactionControl).GUID.GetHashCode())
                {
                    StatPowerUpCollisionReactionControl c = new StatPowerUpCollisionReactionControl();
                    msg.ReadControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(StickyPointCollisionShapeControl).GUID.GetHashCode())
                {
                    StickyPointCollisionShapeControl c = new StickyPointCollisionShapeControl();
                    msg.ReadControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(StickySphereCollisionShapeControl).GUID.GetHashCode())
                {
                    StickySphereCollisionShapeControl c = new StickySphereCollisionShapeControl();
                    msg.ReadControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(StickySquareCollisionShapeControl).GUID.GetHashCode())
                {
                    StickySquareCollisionShapeControl c = new StickySquareCollisionShapeControl();
                    msg.ReadControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(BaseHealthControl).GUID.GetHashCode())
                {
                    BaseHealthControl c = new BaseHealthControl();
                    msg.ReadHealthControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(DestroyHpControl).GUID.GetHashCode())
                {
                    DestroyHpControl c = new DestroyHpControl();
                    msg.ReadHealthControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(HpRegenControl).GUID.GetHashCode())
                {
                    HpRegenControl c = new HpRegenControl();
                    msg.ReadHealthRegenControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(ModuleDamageControl).GUID.GetHashCode())
                {
                    ModuleDamageControl c = new ModuleDamageControl();
                    msg.ReadModuleDamageControl(c);
                    controls.Add(c);
                }
                else if (hash == typeof(HighlightingControl).GUID.GetHashCode())
                {
                    // skip
                }
                else
                {
                    Logger.Error("Received unsupported control (" + hash + ")!");
                }
            }
            return(controls);
        }
示例#6
0
 public HookTarget(HookControl hook, long target)
 {
     this.hook   = hook;
     this.target = target;
 }