Ejemplo n.º 1
0
 public static void WriteHealthRegenControl(this NetOutgoingMessage msg, HpRegenControl c)
 {
     msg.WriteControl(c);
     msg.Write(c.MaxRegenTime);
     msg.Write(c.RegenSpeed);
     msg.Write(c.RegenTimer);
 }
Ejemplo n.º 2
0
 public static void ReadHealthRegenControl(this NetIncomingMessage msg, HpRegenControl c)
 {
     msg.ReadControl(c);
     c.MaxRegenTime = msg.ReadFloat();
     c.RegenSpeed   = msg.ReadFloat();
     c.RegenTimer   = msg.ReadFloat();
 }
Ejemplo n.º 3
0
        private void ReceiveModuleDamage(NetIncomingMessage msg)
        {
            Player player = GetPlayer(msg.ReadInt32());

            player.Device.GetControlOfType <IHpControl>().Hp = msg.ReadInt32();
            int damage = msg.ReadInt32();

            player.Statistics.DamageTaken += damage;

            HpRegenControl control = player.Device.GetControlOfType <HpRegenControl>();

            if (control != null)
            {
                control.TakeHit();
            }
        }
Ejemplo n.º 4
0
        public static MiningModule CreateMiningModule(SceneMgr mgr, Vector position, Player owner)
        {
            MiningModule module = new MiningModule(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId()), owner);

            module.Position = position;
            module.Radius   = 10;
            module.Color    = Colors.Crimson;


            ModuleDamageControl mc = new ModuleDamageControl();

            mc.MaxHp = SharedDef.SPECTATOR_MAX_HP;
            module.AddControl(mc);

            SphereCollisionShape cs = new SphereCollisionShape();

            cs.Center             = module.Center;
            cs.Radius             = module.Radius;
            module.CollisionShape = cs;

            ControlableDeviceControl dc = new ControlableMiningModuleControl();

            module.AddControl(dc);

            LinearRotationControl rc = new LinearRotationControl();

            rc.RotationSpeed = SharedDef.SPECTATOR_MODULE_ROTATION_SPEED;
            module.AddControl(rc);

            HpRegenControl hc = new HpRegenControl();

            hc.MaxRegenTime = SharedDef.SPECTATOR_HP_REGEN_CD;
            hc.RegenTimer   = SharedDef.SPECTATOR_HP_REGEN_CD;
            hc.RegenSpeed   = SharedDef.SPECTATOR_REGEN_SPEED;
            module.AddControl(hc);

            module.AddControl(new RespawningObjectControl());
            module.AddControl(new StickySphereCollisionShapeControl());

            module.SetGeometry(SceneGeometryFactory.CrateMiningModule(module));

            return(module);
        }
Ejemplo n.º 5
0
        public void ProccessDamage(int damage, ISceneObject causedBy)
        {
            if (!Vulnerable)
            {
                return;
            }

            if (causedBy is SingularityBullet && !(causedBy as SingularityBullet).Owner.IsCurrentPlayerOrBot())
            {
                return;
            }

            module.Owner.Statistics.DamageTaken += damage;

            Hp -= damage;
            HpRegenControl control = module.GetControlOfType <HpRegenControl>();

            if (control != null)
            {
                control.TakeHit();
            }

            NetOutgoingMessage msg = me.SceneMgr.CreateNetMessage();

            msg.Write((int)PacketType.MINING_MODULE_DMG_TAKEN);
            msg.Write(module.Owner.GetId());
            msg.Write(Hp);
            msg.Write(damage);

            me.SceneMgr.SendMessage(msg);
            me.SceneMgr.FloatingTextMgr.AddFloatingText(damage, me.Position, FloatingTextManager.TIME_LENGTH_3, FloatingTextType.DAMAGE, FloatingTextManager.SIZE_SMALL, false, true);

            if (me.SceneMgr.GetCurrentPlayer().Device == module)
            {
                me.SceneMgr.ScreenShakingMgr.Start(ShakePower.WEAK);
            }
        }
Ejemplo n.º 6
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);
        }