protected override Hook CreateHook(Point point)
        {
            Hook hook = SceneObjectFactory.CreateHook(SceneMgr, point, Owner);

            hooks.Add(new HookData(hook, Owner.Data.HookCooldown));
            return(hook);
        }
示例#2
0
        public override void StartAction(List <Asteroid> afflicted, bool exact)
        {
            int   radius   = 100;
            float lifeTime = 2;
            Color color    = new Color();

            color.A = 35;
            color.R = 80;
            color.G = 255;
            color.B = 80;
            field   = SceneObjectFactory.CreateSphereField(SceneMgr, Owner.Device.Center - new Vector(radius, radius), radius, color);

            StaticFieldControl control = new StaticFieldControl();

            control.Force    = 140;
            control.LifeTime = lifeTime;
            control.Radius   = radius;

            RippleEffectControl rippleControl = new RippleEffectControl();

            rippleControl.Speed = 15;

            Owner.Device.AddControl(control);
            field.AddControl(rippleControl);
            field.AddControl(new LimitedLifeControl(lifeTime));
            field.AddControl(new CenterCloneControl(Owner.Device));

            SceneMgr.DelayedAttachToScene(field);
        }
        protected override ISceneObject SpawnMine(Point point)
        {
            SingularityMine mine = SceneObjectFactory.CreateAsteroidDroppingSingularityMine(SceneMgr, point, Owner);
            Vector          dir  = new Vector(endPoint.X - startPoint.X, endPoint.Y - startPoint.Y);

            dir.Normalize();
            mine.Direction = dir;

            LinearMovementControl c = mine.GetControlOfType <LinearMovementControl>();

            c.Speed = Owner.Data.MineFallingSpeed * SharedDef.MINE_LAUNCHER_SPEED_MODIFIER;

            if (SceneMgr.GameType != Gametype.SOLO_GAME)
            {
                NetOutgoingMessage msg = SceneMgr.CreateNetMessage();
                (mine as ISendable).WriteObject(msg);
                SceneMgr.SendMessage(msg);
            }

            HighlightingControl hc = new HighlightingControl();

            mine.AddControl(hc);

            lastMine = mine;
            SceneMgr.DelayedAttachToScene(mine);

            return(mine);
        }
        private void SpawnNewBullet(ISceneObject target, ISceneObject ignored = null)
        {
            SingularityExplodingBullet bullet = new SingularityExplodingBullet(me.SceneMgr, IdMgr.GetNewId(me.SceneMgr.GetCurrentPlayer().GetId()));

            Vector targettedPosition = AIUtils.ComputeDestinationPositionToHitTarget(target, meBullet.Owner.Data.BulletSpeed, me.Center, me.SceneMgr.GetRandomGenerator());

            SceneObjectFactory.InitSingularityBullet(bullet, me.SceneMgr, targettedPosition, me.Position, meBullet.Owner);

            PointCollisionShape cs = new PointCollisionShape();

            cs.Center             = bullet.Center;
            bullet.CollisionShape = cs;

            ExcludingExplodingSingularityBulletControl c = new ExcludingExplodingSingularityBulletControl();

            c.Speed        = SharedDef.BULLET_EXPLOSION_SPEED;
            c.Strength     = SharedDef.BULLET_EXPLOSION_STRENGTH;
            c.StatReported = true;
            if (ignored != null)
            {
                c.IgnoredObjects.Add(ignored.Id);
            }
            bullet.AddControl(c);

            bullet.AddControl(new StickyPointCollisionShapeControl());

            NetOutgoingMessage msg = me.SceneMgr.CreateNetMessage();

            (bullet as ISendable).WriteObject(msg);
            me.SceneMgr.SendMessage(msg);

            me.SceneMgr.DelayedAttachToScene(bullet);
        }
        protected override ISceneObject SpawnBullet(Point point)
        {
            if (lastBullet != null)
            {
                lastBullet.GetControlOfType <HighlightingControl>().Enabled = false;
            }

            if (point.Y > Owner.GetBaseLocation().Y)
            {
                point.Y = Owner.GetBaseLocation().Y;
            }

            lastBullet = SceneObjectFactory.CreateSingularityBouncingBullet(SceneMgr, point, Owner);

            NetOutgoingMessage msg = SceneMgr.CreateNetMessage();

            lastBullet.WriteObject(msg);
            SceneMgr.SendMessage(msg);

            HighlightingControl hc = new HighlightingControl();

            lastBullet.AddControl(hc);

            SceneMgr.DelayedAttachToScene(lastBullet);
            return(lastBullet);
        }
        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);
        }
示例#7
0
 private void FormMain_Load(object sender, EventArgs e)
 {
     //this.scientificCanvas.Scene.RootObject.Children.ItemAdded += RootObject.Children_ItemAdded;
     //this.scientificCanvas.Scene.RootObject.Children.ItemRemoved += RootObject.Children_ItemRemoved;
     {
         SceneObject groundObj = SceneObjectFactory.GetBuildInSceneObject(BuildInSceneObject.Ground);
         {
             BoundingBoxRenderer boxRenderer = groundObj.Renderer.GetBoundingBoxRenderer();
             SceneObject         boxObj      = boxRenderer.WrapToSceneObject(new ModelScaleScript());
             groundObj.Children.Add(boxObj);
         }
         this.scientificCanvas.Scene.RootObject.Children.Add(groundObj);
         //TreeNode groundTreeNode = this.objectsTreeView.Nodes.Add(groundObj.Name);
         //groundTreeNode.Tag = groundObj;
         TreeNode groundTreeNode = DumpTreeNode(groundObj);
         this.objectsTreeView.Nodes.Add(groundTreeNode);
     }
     {
         SceneObject axisObj = SceneObjectFactory.GetBuildInSceneObject(BuildInSceneObject.Axis);
         {
             BoundingBoxRenderer boxRenderer = axisObj.Renderer.GetBoundingBoxRenderer();
             SceneObject         boxObj      = boxRenderer.WrapToSceneObject(new ModelScaleScript());
             axisObj.Children.Add(boxObj);
         }
         this.scientificCanvas.Scene.RootObject.Children.Add(axisObj);
         //TreeNode axisTreeNode = this.objectsTreeView.Nodes.Add(axisObj.Name);
         //axisTreeNode.Tag = axisObj;
         TreeNode axisTreeNode = DumpTreeNode(axisObj);
         this.objectsTreeView.Nodes.Add(axisTreeNode);
         this.objectsTreeView.ExpandAll();
     }
     Application.Idle += Application_Idle;
 }
示例#8
0
        public override void OnAttach()
        {
            overlay = SceneObjectFactory.CreateAsteroidOverlay(SceneMgr, this);
            SceneMgr.DelayedAttachToScene(overlay);

            effects = SceneObjectFactory.CreateAsteroidEffects(SceneMgr, this);
            SceneMgr.DelayedAttachToScene(effects);
        }
        /// <summary>
        /// vytvori hraci action bar, input manager a zbrane a bazi nebo mining module
        /// </summary>
        /// <param name="p">hrac kteremu se maji vytvorit objekty</param>
        private void CreateActiveObjectsOfPlayer(Player p)
        {
            if (p.IsActivePlayer())
            {
                p.CreateWeapons();

                p.Baze = SceneObjectFactory.CreateBase(this, p);

                BaseIntegrityBar ellipse = SceneObjectFactory.CreateBaseIntegrityBar(this, p);

                HpBarControl control = new HpBarControl(ellipse);
                p.Baze.AddControl(control);

                DelayedAttachToScene(ellipse);
                DelayedAttachToScene(p.Baze);
            }
            else
            {
                if (p.Device == null)
                {
                    MiningModule obj = SceneObjectFactory.CreateMiningModule(this, p.Data.MiningModuleStartPos, p);
                    DelayedAttachToScene(obj);
                    DelayedAttachToScene(SceneObjectFactory.CreateMiningModuleIntegrityBar(this, obj, p));

                    p.Device = obj;
                }
            }

            if (p.IsCurrentPlayer())
            {
                actionBarMgr = new ActionBarMgr(this);
                StateMgr.AddGameState(actionBarMgr);

                if (p.IsActivePlayer())
                {
                    inputMgr = new PlayerInputMgr(p, this, actionBarMgr);
                    actionBarMgr.CreateActionBarItems(p.GetActions <IPlayerAction>(), false);
                    InitAutomaticMineLauncher();
                }
                else
                {
                    if (p.Device.HasControlOfType <MiningModuleControl>())
                    {
                        return;
                    }

                    MiningModuleControl mc = new MiningModuleControl();
                    mc.Owner = p;
                    p.Device.AddControl(mc);

                    inputMgr = new SpectatorInputMgr(p, this, p.Device, actionBarMgr);
                    actionBarMgr.CreateActionBarItems(p.GetActions <ISpectatorAction>(), true);
                    SceneObjectFactory.CreateSpectatorActionReadinessIndicators(p);
                }
            }
        }
示例#10
0
        private void SpawnNewEllipse()
        {
            OrbitEllipse ellipse = SceneObjectFactory.CreateOrbitEllipse(me.SceneMgr, line.End, 2.5f, 2.5f, Colors.Black);

            MiningEllipseControl control = new MiningEllipseControl();

            control.LineToFollow = line;

            ellipse.AddControl(control);

            me.SceneMgr.DelayedAttachToScene(ellipse);
        }
示例#11
0
        protected virtual ISceneObject SpawnMine(Point point)
        {
            SingularityMine mine = SceneObjectFactory.CreateDroppingSingularityMine(SceneMgr, point, Owner);

            if (SceneMgr.GameType != Gametype.SOLO_GAME)
            {
                NetOutgoingMessage msg = SceneMgr.CreateNetMessage();
                (mine as ISendable).WriteObject(msg);
                SceneMgr.SendMessage(msg);
            }

            SceneMgr.DelayedAttachToScene(mine);
            return(mine);
        }
示例#12
0
        private void addSceneObjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BuildInSceneObject type = (BuildInSceneObject)Enum.Parse(typeof(BuildInSceneObject),
                                                                     (sender as ToolStripItem).Text);
            SceneObject obj = SceneObjectFactory.GetBuildInSceneObject(type);

            obj.Children.ItemAdded   += Children_ItemAdded;
            obj.Children.ItemRemoved += Children_ItemRemoved;
            var node = new TreeNode(obj.ToString());

            node.Tag = obj;
            obj.Tag  = node;
            this.scene.RootObject.Children.Add(obj);
            this.treeView1.Nodes.Add(node);
        }
示例#13
0
        protected override Hook CreateHook(Point point)
        {
            if (lastHook != null)
            {
                lastHook.GetControlOfType <HighlightingControl>().Enabled = false;
            }

            lastHook = SceneObjectFactory.CreatePowerHook(SceneMgr, point, Owner);

            HighlightingControl hc = new HighlightingControl();

            lastHook.AddControl(hc);

            hooks.Add(new HookData(lastHook, Owner.Data.HookCooldown));
            return(lastHook);
        }
        protected override ISceneObject SpawnBullet(Point point)
        {
            if (point.Y > Owner.GetBaseLocation().Y)
            {
                point.Y = Owner.GetBaseLocation().Y;
            }

            SingularityExplodingBullet bullet = SceneObjectFactory.CreateSingularityExploadingBullet(SceneMgr, point.ToVector(), Owner);

            NetOutgoingMessage msg = SceneMgr.CreateNetMessage();

            (bullet as ISendable).WriteObject(msg);
            SceneMgr.SendMessage(msg);

            SceneMgr.DelayedAttachToScene(bullet);

            return(bullet);
        }
示例#15
0
        void FormMain_Load(object sender, EventArgs e)
        {
            //this.scientificCanvas.Scene.RootObject.Children.ItemAdded += RootObject.Children_ItemAdded;
            //this.scientificCanvas.Scene.RootObject.Children.ItemRemoved += RootObject.Children_ItemRemoved;
            SceneObject ground = SceneObjectFactory.GetBuildInSceneObject(BuildInSceneObject.Ground);

            this.scientificCanvas.Scene.RootObject.Children.Add(ground);
            TreeNode groundTreeNode = this.objectsTreeView.Nodes.Add(ground.Name);

            groundTreeNode.Tag = ground;
            SceneObject axis = SceneObjectFactory.GetBuildInSceneObject(BuildInSceneObject.Axis);

            this.scientificCanvas.Scene.RootObject.Children.Add(axis);
            TreeNode axisTreeNode = this.objectsTreeView.Nodes.Add(axis.Name);

            axisTreeNode.Tag = axis;

            Application.Idle += Application_Idle;
        }
        protected virtual ISceneObject SpawnBullet(Point point)
        {
            if (point.Y > Owner.GetBaseLocation().Y)
            {
                point.Y = Owner.GetBaseLocation().Y;
            }

            SingularityBullet bullet = SceneObjectFactory.CreateSingularityBullet(SceneMgr, point, Owner);

            if (SceneMgr.GameType != Gametype.SOLO_GAME)
            {
                NetOutgoingMessage msg = SceneMgr.CreateNetMessage();
                (bullet as ISendable).WriteObject(msg);
                SceneMgr.SendMessage(msg);
            }

            SceneMgr.DelayedAttachToScene(bullet);
            return(bullet);
        }
        private void CreateShard(Vector dir, int text, double rotation, double angle)
        {
            IceShard s = SceneObjectFactory.CreateIceShard(me.SceneMgr, me.Position, new System.Windows.Size(20, 20), text + 1);

            s.Direction = dir.Rotate(angle * (Math.PI / 4));

            LinearRotationControl rc = new LinearRotationControl();

            rc.RotationSpeed = (float)(Math.PI / 8 * rotation);
            s.AddControl(rc);

            LinearMovementControl mc = new LinearMovementControl();

            mc.Speed = 20;
            s.AddControl(mc);

            s.AddControl(new LimitedLifeControl(4));

            me.SceneMgr.DelayedAttachToScene(s);
        }
        private void ReceivedMinorAsteroidSpawnMsg(NetIncomingMessage msg)
        {
            float  speed       = msg.ReadFloat();
            int    radius      = msg.ReadInt32();
            Vector direction   = msg.ReadVector();
            Vector center      = msg.ReadVector();
            int    rot         = msg.ReadInt32();
            int    textureId   = msg.ReadInt32();
            int    destoryerId = msg.ReadInt32();

            MinorAsteroid a1 = SceneObjectFactory.CreateSmallAsteroid(this, direction, center, rot, textureId, radius, speed, Math.PI / 12);

            a1.Id = msg.ReadInt64();
            MinorAsteroid a2 = SceneObjectFactory.CreateSmallAsteroid(this, direction, center, rot, textureId, radius, speed, 0);

            a2.Id = msg.ReadInt64();
            MinorAsteroid a3 = SceneObjectFactory.CreateSmallAsteroid(this, direction, center, rot, textureId, radius, speed, -Math.PI / 12);

            a3.Id = msg.ReadInt64();

            long             parentId = msg.ReadInt64();
            UnstableAsteroid p        = GetSceneObject(parentId) as UnstableAsteroid;

            if (p == null)
            {
                p = new UnstableAsteroid(this, parentId);
            }
            p.Destroyer = destoryerId;

            a1.Parent = p;
            a2.Parent = p;
            a3.Parent = p;

            DelayedAttachToScene(a1);
            DelayedAttachToScene(a2);
            DelayedAttachToScene(a3);

            SyncReceivedObject(a1, msg);
            SyncReceivedObject(a2, msg);
            SyncReceivedObject(a3, msg);
        }
示例#19
0
        private void SpawnSmallMeteors(int radius)
        {
            if (SceneMgr.GetPlayer(Destroyer) == null || !SceneMgr.GetPlayer(Destroyer).IsCurrentPlayerOrBot())
            {
                return;
            }

            int   rotation  = SceneMgr.GetRandomGenerator().Next(360);
            int   textureId = SceneMgr.GetRandomGenerator().Next(1, 18);
            float speed     = GetControlOfType <NewtonianMovementControl>().Speed / 2;

            MinorAsteroid a1 = SceneObjectFactory.CreateSmallAsteroid(SceneMgr, Direction, Center, rotation, textureId, radius, speed, Math.PI / 12);
            MinorAsteroid a2 = SceneObjectFactory.CreateSmallAsteroid(SceneMgr, Direction, Center, rotation, textureId, radius, speed, 0);
            MinorAsteroid a3 = SceneObjectFactory.CreateSmallAsteroid(SceneMgr, Direction, Center, rotation, textureId, radius, speed, -Math.PI / 12);

            a1.Parent = this;
            a2.Parent = this;
            a3.Parent = this;

            SceneMgr.DelayedAttachToScene(a1);
            SceneMgr.DelayedAttachToScene(a2);
            SceneMgr.DelayedAttachToScene(a3);

            NetOutgoingMessage message = SceneMgr.CreateNetMessage();

            message.Write((int)PacketType.MINOR_ASTEROID_SPAWN);
            message.Write(speed);
            message.Write(radius);
            message.Write(Direction);
            message.Write(Center);
            message.Write(rotation);
            message.Write(textureId);
            message.Write(Destroyer);
            message.Write(a1.Id);
            message.Write(a2.Id);
            message.Write(a3.Id);
            message.Write(Id);

            SceneMgr.SendMessage(message);
        }
示例#20
0
        public override void DoCollideWith(ISceneObject other, float tpf)
        {
            // jinak by mohly miny kolidovat navzajem a spawnovat dalsi a dalsi powerless miny
            if (other is SingularityMine)
            {
                return;
            }

            if (collided.Contains(other.Id))
            {
                return;
            }

            collided.Add(other.Id);

            base.DoCollideWith(other, tpf);

            SingularityMine mine = SceneObjectFactory.CreatePowerlessMine(me.SceneMgr, me.Position, meMine.Direction, meMine.Owner);

            collided.Add(mine.Id);
            me.SceneMgr.DelayedAttachToScene(mine);
        }
示例#21
0
 protected virtual Hook CreateHook(Point point)
 {
     return(SceneObjectFactory.CreateHook(SceneMgr, point, Owner));
 }