Пример #1
0
 public AircraftController(AircraftView aircraftViewPrefab, Transform graphicElementsHolder, Vector2 screenSize)
 {
     Debug.LogWarning(" AircraftController start");
     _screenSize   = screenSize;
     _aircraftView = MonoBehaviour.Instantiate(aircraftViewPrefab);
     _aircraftView.transform.parent     = graphicElementsHolder;
     _aircraftView.transform.localScale = new Vector3(1 / graphicElementsHolder.transform.localScale.x, 1 / graphicElementsHolder.transform.localScale.x, 1 / graphicElementsHolder.transform.localScale.x);
     _aircraftView.transform.name       = "aircraft";
     _aircraftView.gameObject.SetActive(false);
     _scheduledTask.Elapsed += (sender, args) => Runnable();
     _trajectoryFactory      = new TrajectoryFactory(_screenSize);
 }
Пример #2
0
        public MainChar(Drawable d, BulletStyle sty, double x0, double y0, double s = 20, GraphicsStyle g = null) : base(0, null, d, new Point(2), new EntityClass("MainChar", "Character"), null, g)
        {
            speed    = s;
            this.x0  = x0;
            this.y0  = y0;
            vxf      = new PolyFunc <double, double>(0);
            vyf      = new PolyFunc <double, double>(0);
            xp       = t => x0;
            yp       = t => y0;
            Position = new Particle(t => xp(t), t => yp(t));
            BulletEmission em = new BulletEmission(0, 0.25,
                                                   sty,
                                                   TrajectoryFactory.SimpleVel(2, -40, 5),
                                                   TrajectoryFactory.SimpleVel(-2, -40, -5)
                                                   );

            BulletPattern pat = new BulletPattern(new EntityClass("MainCharBullet", "Bullet"), em);

            Emitter = new BulletEmitter(-1, pat);
            Time    = 0;
        }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        Vector3 launch = TrajectoryFactory.HitTargetAtTime(transform.position, Target.position, Physics.gravity, TimeToTarget);

        GetComponent <Rigidbody>().AddForce(launch, ForceMode.VelocityChange);
    }
Пример #4
0
        public MainForm()
        {
            InitializeComponent();
            entSpawn = new EntitySpawner();

            hitby = new DefaultValueDictionary <Entity, bool>(false);

            double border = 40;

            Particle boxC  = (Particle)(new Vector <double>((double)ClientRectangle.Width / 2, (double)ClientRectangle.Height / 2));
            Particle boxR  = (Particle)(new Vector <double>((double)ClientRectangle.Width / 2 + border, (double)ClientRectangle.Height / 2 + border));
            Box      bgbox = new Box(boxR);

            EntityClass bgClass = new EntityClass("Background");

            bg = new Entity(0, boxC, bgbox, new GraphicsStyle(Brushes.Black), bgClass);

            bsm = new BulletStyleManager();
            InitializeBulletStyles();

            keyMan = new KeyManager();

            InitializeKeyManager();

            int vx = 1, vx2 = 2;
            int vy = 2, vy2 = 4;

            Drawable mchar = DrawableFactory.MakeCircle(8, new GraphicsStyle(Brushes.Orange, Pens.Red));

            game = new Game(new MainChar(mchar, bsm["MainChar"], ClientRectangle.Width / 2, ClientRectangle.Height - 20, 40));
            InitializePhysicsManager(game.PhysicsManager);
            InitializeRenderManager(game.RenderManager);

            Particle p1 = new Particle(x => vx * x, y => vy * y);
            Particle p2 = new Particle(Utils.MakeClosure <double, double, double>(ClientRectangle.Width, (w, x) => w - vx2 * x), y => vy2 * y);

            Particle q = new Particle(t => 7 * t + 10 * Utils.FastCos(t), t => 3 * t + 10 * Utils.FastSin(t));

            Ellipse entEl = new Ellipse(7);

            o1 = entEl.MakeDrawable(new GraphicsStyle(Brushes.Green));

            double FULL    = 2 * Math.PI;
            double cd      = 1;
            int    perCirc = 12;
            int    offsets = 6;

            BulletEmission[] bEms = new BulletEmission[offsets], bEms2 = new BulletEmission[offsets];
            double           DOWN = Math.PI / 2;

            // Makes the spiral pattern with bullets of shape o2
            Trajectory[][] arrs = new Trajectory[offsets][];
            for (int i = 0; i < offsets; i++)
            {
                arrs[i] = new Trajectory[perCirc];
            }
            for (int i = 0; i < perCirc; i++)
            {
                for (int j = 0; j < offsets; j++)
                {
                    arrs[j][i] = TrajectoryFactory.AngleMagVel((i * offsets + j) * (FULL / offsets / perCirc) + DOWN, 10);
                }
            }
            for (int i = 0; i < offsets; i++)
            {
                bEms[i] = new BulletEmission(cd, 0, arrs[i], bsm["OrangeRed_5"]);
            }
            // Same as above, but we're gonna change the shape
            for (int i = 0; i < offsets; i++)
            {
                arrs[i] = new Trajectory[perCirc];
            }
            for (int i = 0; i < perCirc; i++)
            {
                for (int j = 0; j < offsets; j++)
                {
                    arrs[j][i] = TrajectoryFactory.AngleMagVel((i * offsets + j) * (FULL / offsets / perCirc) + DOWN, 10);
                }
            }
            for (int i = 0; i < offsets; i++)
            {
                bEms2[i] = new BulletEmission(cd, 0, arrs[i], bsm["Azure_5"]);
            }
            // Same as above, but we're gonna change the shape again and the path
            BulletEmission[] bEms3 = new BulletEmission[offsets];
            for (int i = 0; i < offsets; i++)
            {
                arrs[i] = new Trajectory[perCirc];
            }
            for (int i = 0; i < perCirc; i++)
            {
                for (int j = 0; j < offsets; j++)
                {
                    arrs[j][i] = TrajectoryFactory.SpinningLinearAMVel((i * offsets + j) * (FULL / offsets / perCirc) + DOWN, 7 /*3*/, 0.5, 20);
                }
            }
            for (int i = 0; i < offsets; i++)
            {
                bEms3[i] = new BulletEmission(cd, 0, arrs[i], bsm["HotPink_5"]);
            }

            EntityClass enemyBullet = new EntityClass("EnemyBullet", "Bullet");
            EntityClass enemy       = new EntityClass("Enemy", "Character");

            BulletEmitter em  = new BulletEmitter(new BulletPattern(bEms, enemyBullet));
            BulletEmitter em2 = new BulletEmitter(new BulletPattern(bEms2, enemyBullet));
            BulletEmitter em3 = new BulletEmitter(new BulletPattern(bEms3, enemyBullet));

            entSpawn.MakeType("RedSpiral", null, o1, entEl, enemy, em);

            e  = entSpawn.Build("RedSpiral", 0, p1);
            e2 = entSpawn.Build("RedSpiral", 0, p2);

            Particle p3 = new Particle(x => 0.5 * x + 500, y => 3 * y);
            Entity   e3 = entSpawn.Build("RedSpiral", 0, p3);

            Particle p4 = new Particle(x => - 0.25 * x + 300, y => 3.5 * y);
            Entity   e4 = entSpawn.Build("RedSpiral", 0, p4);

            Particle p5 = new Particle(x => - 0.4 * x + 800, y => 2 * y);
            Entity   e5 = entSpawn.Build("RedSpiral", 0, p5);


            game += bg;
            game  = game + e + e2 + e3 + e4 + e5;

            entSpawn["WhiteSpiral"] = entSpawn["RedSpiral"].ChangeEmitter(em2, true);
            entSpawn["PinkWaves"]   = entSpawn["RedSpiral"].ChangeEmitter(em3, true);
            //entSpawn.MakeType("WhiteSpinningSpiral",null, o1, entEl, enemy, em2);

            Entity e6 = entSpawn.Build("WhiteSpiral", 0, q);

            game += e6;

            Particle r  = new Particle(Utils.MakeClosure <double, double, double>((double)ClientRectangle.Width / 3, (w, t) => w + 3 * t), t => 5 * t);
            Entity   e7 = entSpawn.Build("PinkWaves", 0, r);

            game += e7;
            game.ResetTime();
            BufferedGraphicsContext c = BufferedGraphicsManager.Current;

            buff = c.Allocate(CreateGraphics(), ClientRectangle);
        }