private static Asteroid CreateAsteroidControls(ServerMgr mgr, Asteroid s) { NewtonianMovementControl nmc = new NewtonianMovementControl(); nmc.Speed = mgr.GetRandomGenerator().Next(SharedDef.MIN_ASTEROID_SPEED * 10, SharedDef.MAX_ASTEROID_SPEED * 10) / 10.0f; s.AddControl(nmc); LinearRotationControl lrc = new LinearRotationControl(); lrc.RotationSpeed = mgr.GetRandomGenerator().Next(SharedDef.MIN_ASTEROID_ROTATION_SPEED, SharedDef.MAX_ASTEROID_ROTATION_SPEED) / 10.0f; s.AddControl(lrc); s.AddControl(new StickySphereCollisionShapeControl()); return(s); }
private void Slow(Asteroid ast, bool exact) { IMovementControl c = ast.GetControlOfType <IMovementControl>(); LinearRotationControl c1 = ast.GetControlOfType <LinearRotationControl>(); if (c == null || c1 == null) { return; } float time = exact ? 1.5f * exactBonus : 1.5f; List <IControl> controls = new List <IControl>(); controls.Add(c); controls.Add(c1); AsteroidFreezeControl removal = new AsteroidFreezeControl(); removal.SetControlsForDisable(controls); removal.Time = time; ast.AddControl(removal); // led je posunut o pulku radiusu doleva Vector p = new Vector(ast.Position.X - (ast.Radius / 2), ast.Position.Y - (ast.Radius / 2)); // potom jeho sirka musi byt prumer + 2 * posunuti (vlevo a vpravo) => r * (2 + 0.5 + 0.5) IceSquare s = SceneObjectFactory.CreateIceSquare(SceneMgr, p, new Size(ast.Radius * 3, ast.Radius * 3)); s.AddControl(new LimitedLifeControl(time)); SceneMgr.DelayedAttachToScene(s); }
private void ProcessStep() { switch (step) { case 1: { ParticleEmmitor fireEmmitor = ParticleEmmitorFactory.CreateBasicFire(me.SceneMgr, Color.FromArgb(40, 255, 60, 0)); fireEmmitor.Amount = 20; fireEmmitor.MinLife = 0.3f; fireEmmitor.MaxLife = 0.4f; fireEmmitor.MinSize = asteroid.Radius / 5.0f; fireEmmitor.MaxSize = asteroid.Radius / 6.0f; fireEmmitor.Infinite = true; meNode.AddEmmitor(fireEmmitor, new Vector(0, 0), false); } break; case 2: { asteroid.AddControl(new ShakingControl(1, true, 0.05f)); } break; case 3: break; } }
public void SpawnAsteroid() { if (AsteroidSpawned) { return; } AsteroidSpawned = true; me.RemoveControlsOfType <HighlightingControl>(); Asteroid ast = new Asteroid(me.SceneMgr, IdMgr.GetNewId(me.SceneMgr.GetCurrentPlayer().GetId())); ast.Gold = 0; ast.Radius = 20; ast.Position = new Vector(me.Position.X - ast.Radius, me.Position.Y - ast.Radius); ast.Direction = (me as IMovable).Direction; ast.AsteroidType = AsteroidType.NORMAL; ast.TextureId = me.SceneMgr.GetRandomGenerator().Next(1, 18); SphereCollisionShape cs = new SphereCollisionShape(); cs.Center = ast.Center; cs.Radius = ast.Radius; ast.CollisionShape = cs; ast.SetGeometry(SceneGeometryFactory.CreateAsteroidImage(ast)); me.SceneMgr.DelayedAttachToScene(ast); collided.Add(ast.Id); ast.AddControl(new StickySphereCollisionShapeControl()); NewtonianMovementControl nmc = new NewtonianMovementControl(); nmc.Speed = me.SceneMgr.GetCurrentPlayer().Data.MineFallingSpeed; ast.AddControl(nmc); NetOutgoingMessage msg = me.SceneMgr.CreateNetMessage(); ast.WriteObject(msg); me.SceneMgr.SendMessage(msg); }