Ejemplo n.º 1
0
 private bool CheckCollision(Sprite sprite)
 {
     //int minDistance = 35;
     //if (Vector2.Distance(CollisionPolygon.Origin, sprite.CollisionPolygon.Origin) < minDistance)
     //{
     //    return true;
     //}
     //return false;
     return(CollisionPolygon.Intersects(sprite.CollisionPolygon));
 }
Ejemplo n.º 2
0
        public void NodeAtPoint(ScriptThread thread)
        {
            CollisionPolygon polygon = CollisionManager.PolygonAtPoint((int)thread.GetFloatParameter(0), (int)thread.GetFloatParameter(1));

            if (polygon == null || polygon.MetaData == null)
            {
                return;
            }
            thread.SetReturnValue(new SceneNodeScriptObject(polygon.MetaData as SceneNode));
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Called by this entitys collision polygon is colliding with another.
 /// </summary>
 /// <param name="aPolygon">Entity that has touched.</param>
 /// <param name="bPolygon">Entity that is being touched.</param>
 protected void OnColliding(CollisionPolygon aPolygon, CollisionPolygon bPolygon)
 {
     if (_process == null || _process.Process == null || aPolygon.MetaData == null || bPolygon.MetaData == null || _process.Process == null || _enabled == false)
     {
         return;
     }
     _process.Process[0].PassParameter(new SceneNodeScriptObject((SceneNode)aPolygon.MetaData));
     _process.Process[0].PassParameter(new SceneNodeScriptObject((SceneNode)bPolygon.MetaData));
     _process.Process[0].InvokeFunction("OnColliding", true, false);
     // base.OnLeave(aPolygon, bPolygon);
 }
 public void Draw(GraphicsDevice graphicsDevice)
 {
     if (projectile)
     {
         CollisionPolygon.FillPolygon(graphicsDevice, ProjectileTexture);
     }
     else
     {
         CollisionPolygon.FillPolygon(graphicsDevice, BlockTexture);
     }
 }
Ejemplo n.º 5
0
        public Tile(SerializationInputStream Stream, Map Map, TileRuleSet RuleSet, IdGenerator IdGenerator)
        {
            this.Map      = Map;
            Coordinate    = new Coordinate(Stream);
            HexCoordinate = new HexCoordinate(Coordinate);
            Id            = IdGenerator.GenerateId();
            Configuration = new TileConfiguration(Stream);
            Bounds        = CalculateBounds();

            this.RuleSet = RuleSet;
            Rules        = new TileRulesCalculator(this);
            Configuration.OnReconfigure += (sender, e) => Rules.Recalculate();
        }
Ejemplo n.º 6
0
        public Tile(Map Map, Coordinate Coordinate, TileRuleSet RuleSet, IdGenerator IdGenerator)
        {
            this.Map        = Map;
            this.Coordinate = Coordinate;
            this.RuleSet    = RuleSet;
            Id            = IdGenerator.GenerateId();
            HexCoordinate = new HexCoordinate(Coordinate);
            Bounds        = CalculateBounds();

            Configuration = new TileConfiguration();
            Rules         = new TileRulesCalculator(this);
            Configuration.OnReconfigure += (sender, e) => Rules.Recalculate();
        }
        public override List <VisibleTimeline> CreateNewEditorItem(AnimationClass ActiveAnimation, AnimationClass.AnimationLayer ActiveLayer, int KeyFrame, System.Drawing.Point MousePosition)
        {
            List <VisibleTimeline> ReturnValue = new List <VisibleTimeline>();

            Vector2[] LocalPoints = new Vector2[4]
            {
                new Vector2(MousePosition.X - 40, MousePosition.Y - 40),
                new Vector2(MousePosition.X - 40, MousePosition.Y + 40),
                new Vector2(MousePosition.X + 40, MousePosition.Y + 40),
                new Vector2(MousePosition.X + 40, MousePosition.Y - 40),
            };

            List <Polygon>       ListPolygon             = new List <Polygon>();
            CollisionBoxTimeline NewCollisionBoxTimeline = new CollisionBoxTimeline();
            PolygonCutterHelper  NewSpawner = new PolygonCutterHelper(ActiveLayer.renderTarget, ListPolygon, true);

            Polygon NewPolygon = new Polygon(LocalPoints, GameScreen.GraphicsDevice.Viewport.Width, GameScreen.GraphicsDevice.Viewport.Height);

            NewSpawner.PolygonCutterViewer.ListPolygon.Add(NewPolygon);

            if (NewSpawner.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                NewCollisionBoxTimeline.SpawnFrame = KeyFrame;
                NewCollisionBoxTimeline.DeathFrame = KeyFrame + 10;
                NewCollisionBoxTimeline.IsUsed     = true;//Disable the spawner as we spawn the Marker manually.

                Vector2[] NewArrayVertex = new Vector2[NewSpawner.PolygonCutterViewer.ListPolygon[0].ArrayVertex.Length];
                Array.Copy(NewSpawner.PolygonCutterViewer.ListPolygon[0].ArrayVertex, NewArrayVertex, NewSpawner.PolygonCutterViewer.ListPolygon[0].ArrayVertex.Length);

                VisibleAnimationObjectKeyFrame NewPolygonCutterKeyFrame = new VisibleAnimationObjectKeyFrame(NewCollisionBoxTimeline.Position,
                                                                                                             true, -1);

                CollisionPolygon NewKeyFramePolygon = new CollisionPolygon(new Polygon(NewArrayVertex, ActiveLayer.renderTarget.Width, ActiveLayer.renderTarget.Height));

                NewCollisionBoxTimeline.Add(KeyFrame, NewPolygonCutterKeyFrame);
                NewCollisionBoxTimeline.ListCollisionPolygon.Add(NewKeyFramePolygon);
                NewCollisionBoxTimeline.ListOriginalPolygon.Add(new Polygon(NewKeyFramePolygon.ActivePolygon));
                NewKeyFramePolygon.ActivePolygon.UpdateWorldPosition(Vector2.Zero, 0f);

                NewCollisionBoxTimeline.ComputeSourceRectangle();
                ReturnValue.Add(NewCollisionBoxTimeline);
            }

            return(ReturnValue);
        }
Ejemplo n.º 8
0
        private void CheckCollision(Sprite sprite)
        {
            if (CollisionPolygon.Intersects(sprite.CollisionPolygon))
            {
                if (sprite is Character characerSprite)
                {
                    if (characerSprite.Faction != this.Faction)
                    {
                        flyingSound.Stop();
                        hitSound.Update3DEffect();
                        hitSound.Play();
                        int actualDamage = CalculateDamage(Damage, DamageType, characerSprite, out bool isCrit, out bool isBlocked);
                        characerSprite.Health -= actualDamage;

                        if (isBlocked)
                        {
                            characerSprite.CollisionDisplaytList.Add(new CollisionToDisplay("blocked", Color.Snow));
                        }
                        else if (isCrit)
                        {
                            characerSprite.CollisionDisplaytList.Add(new CollisionToDisplay("*" + actualDamage.ToString() + "*", Color.Red));
                        }
                        else
                        {
                            characerSprite.CollisionDisplaytList.Add(new CollisionToDisplay(actualDamage.ToString(), Color.OrangeRed));
                        }
                        ToRemove = true;
                    }
                }
                else
                {
                    flyingSound.Stop();
                    hitSound.Update3DEffect();
                    hitSound.Play();
                    ToRemove = true;
                }
            }
        }
Ejemplo n.º 9
0
 private void Move()
 {
     Position += Direction * Speed;
     CollisionPolygon.Translate(Direction * Speed);
 }
 public CollisionPolygonPointAddedChangedArgs(CollisionPolygon polygon, int index, Vector2 position)
 {
     this.Polygon  = polygon;
     this.Index    = index;
     this.Position = position;
 }
 public CollisionPolygonPointRemovedChangedArgs(CollisionPolygon polygon, int index)
 {
     this.Polygon = polygon;
     this.Index   = index;
 }
Ejemplo n.º 12
0
 private bool CheckCollision(Sprite sprite)
 {
     return(CollisionPolygon.Intersects(sprite.CollisionPolygon) && sprite != this);
 }