public override void Animate(InGameEngine engine)
 {
     if (AnimatedObject == null)
     {
         return;
     }
     AnimatedObject.Position =
         AnimatedObject.Position.Add(new Coordinate((float)Math.Cos(Physomatik.ToRadian(Direction)) * Speed,
                                                    (float)Math.Sin(Physomatik.ToRadian(Direction)) * Speed));
 }
Beispiel #2
0
        public static bool Cuts(Coordinate startPoint, Coordinate objPosition, Coordinate objSize, float angle, Coordinate flyingObjectSize, float tolerance = 0) //TODO fix
        {
            if (Math.Abs(objSize.Min()) < 0.001)
            {
                return(false);
            }
            var m    = (float)Math.Tan(Physomatik.ToRadian(angle));
            var step = objPosition.X > startPoint.X ? 1 : -1;

            for (var tx = startPoint.X; (objPosition.X > startPoint.X ? tx <objPosition.X : tx> objPosition.X); tx += step)
            {
                var ty = m * (tx - startPoint.X) + startPoint.Y;
                if ((tx + flyingObjectSize.X / 2 + tolerance >= objPosition.X || tx - flyingObjectSize.X / 2 + tolerance >= objPosition.X) &&
                    (tx + flyingObjectSize.X / 2 - tolerance <= objPosition.X + objSize.X || tx - flyingObjectSize.X / 2 - tolerance <= objPosition.X + objSize.X) &&
                    (ty + flyingObjectSize.Y / 2 + tolerance >= objPosition.Y || ty - flyingObjectSize.Y / 2 + tolerance >= objPosition.Y) &&
                    (ty + flyingObjectSize.Y / 2 - tolerance <= objPosition.Y + objSize.Y || ty - flyingObjectSize.Y / 2 - tolerance <= objPosition.Y + objSize.Y))
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #3
0
        public void AddObject(AddableObjects obj, InGameEngine engine, Coordinate position = null, int evilPlayerLevel = 0, Player player = null)
        {
            if (AddableObjectsFunctionality.PositionRequired(obj) && position == null)
            {
                throw new Exception("Position not specified!");
            }
            switch (obj)
            {
            case AddableObjects.MainPlayer:
                Objects.Add(new MainPlayer(new Coordinate(100, 100), new Coordinate(100, 100), 0, 3, new Coordinate(100, 100), engine));
                break;

            case AddableObjects.EvilPlayer:
                switch (evilPlayerLevel)
                {
                case 0:
                    Objects.Add(new EvilPlayer0(position, new Coordinate(100, 100), 0, position, engine, engine.Debugging ? 100 : 1));
                    break;

                case 1:
                    Objects.Add(new EvilPlayer1(position, new Coordinate(100, 100), 0, position, engine, engine.Debugging ? 100 : 1));
                    break;
                }
                break;

            case AddableObjects.NormalBullet:
                player = player ?? GetMainPlayer;
                if (player == null)
                {
                    throw new Exception("No Player defined!");
                }
                var bullet =
                    new NormalBullet(
                        player.Position.Sub(new Coordinate(0, 10))
                        .Add(player.Size.Div(2))
                        .Add(
                            new Coordinate(
                                (float)Math.Cos(Physomatik.ToRadian(player.Rotation)) * (player.Size.Pyth() / 2 + 20),
                                (float)Math.Sin(Physomatik.ToRadian(player.Rotation)) * (player.Size.Pyth() / 2 + 20))),
                        PublicStuff.NormalBulletSize, player.Rotation,
                        engine.CurrentId);
                Objects.Add(bullet);
                engine.Animations.Add(new AngularMoveAnimation(bullet, bullet.Rotation, 10));
                break;

            case AddableObjects.NormalBlock:
                Objects.Add(new Block(position, new Coordinate(100, 100), engine.CurrentId, false, new Colour(Color.FromArgb(-4144960))));
                break;

            case AddableObjects.DestroyableBlock:
                Objects.Add(new Block(position, new Coordinate(100, 100), engine.CurrentId, true, new Colour(Color.FromArgb(173, 102, 31))));
                break;

            case AddableObjects.Hole:
                Objects.Add(new Hole(position, new Coordinate(100, 100), engine.CurrentId));
                break;

            case AddableObjects.NotDestroyingExplosion:
                Objects.Add(new Explosion(position, new Coordinate(1, 1), engine.CurrentId, new Colour(Color.Black), new Colour(Color.Red), false, 5));
                break;

            case AddableObjects.DestroyingExplosion:
                Objects.Add(new Explosion(position, new Coordinate(1, 1), engine.CurrentId, new Colour(Color.Black), new Colour(Color.OrangeRed), true, 5));
                break;

            case AddableObjects.Mine:
                Objects.Add(new Mine(position, new Coordinate(30, 30), engine.CurrentId, 5, new Colour(Color.FromArgb(-256)), new Colour(Color.Orange), new Coordinate(150, 150)));
                engine.Animations.Add(new MineAnimation(Objects.Last(), 2));
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(obj), obj, null);
            }
            Objects = Objects;
        }