Example #1
0
        protected static Ball create_ball_for(GameStateMatch g, Player p, float duration, GameEventModifyPlayer onball_hit)
        {
            bool isp1 = g.isPlayer1(p);

            g.newBall(p.thePad.Center + Vector3.UnitX * (isp1 ? -1 : +1) * g.Balls[0].Size.X, Vector3.UnitX * (isp1 ? -1 : +1) * Ball.TypicalSpeed * 2.1f, (int)(duration * yPhysics.Instance.fps), onball_hit);
            return(g.Balls[g.Balls.Length - 1]);
        }
Example #2
0
 public override void Apply(GameStateMatch g, Player p)
 {
     for (int i = 0; i < g.Balls.Length; i++)
     {
         g.Balls[i].Speed = Vector3.Zero;
     }
 }
Example #3
0
 public override void Apply(GameStateMatch g, Player p)
 {
     foreach (PongMove m in moves)
     {
         m.Apply(g, p);
     }
 }
Example #4
0
        public override void Apply(GameStateMatch g, Player p)
        {
            bool isp1   = g.isPlayer1(p);
            Pad  thepad = g.Pads[isp1 ? 0 : 1];

            thepad.F += movement;
        }
Example #5
0
 public override void Apply(GameStateMatch g, Player p)
 {
     if ((p.thePad.Center.X < 0 && p.thePad.Center.X > -g.theLevel.SizeX / 2 && g.isPlayer1(p)) || (p.thePad.Center.X > 0 && p.thePad.Center.X < g.theLevel.SizeX / 2 && !g.isPlayer1(p)))
     {
         p.thePad.setCenter(p.thePad.Center + (g.isPlayer1(p) ? +1 : -1) * Vector3.UnitX * g.theLevel.SizeX / 2);
     }
 }
Example #6
0
 public void object_enters(GameStateMatch g, Box b)
 {
     if (eenter != null)
     {
         eenter.apply(b, g);
     }
 }
Example #7
0
 public void object_stays(GameStateMatch g, Box b)
 {
     if (estay != null)
     {
         estay.apply(b, g);
     }
 }
Example #8
0
        public void newTime(int time, GameStateMatch g)
        {
            int i = 0;

            while (i < fields.Count)
            {
                Field f = fields.ElementAt(i);

                if (!f.check_expires())  //CheckTimeAndFire(time))
                {
                    if (f.AffectPads)
                    {
                        for (int k = 0; k < g.Pads.Length; k++)
                        {
                            f.apply_field(g, g.Pads[k]);
                        }
                    }

                    if (f.AffectBalls)
                    {
                        for (int k = 0; k < g.Balls.Length; k++)
                        {
                            f.apply_field(g, g.Balls[k]);
                        }
                    }

                    i++;
                }
                else
                {
                    fields.Remove(f);
                }
            }
        }
Example #9
0
 public override void Apply(GameStateMatch g, Player p)
 {
     foreach (Ball b in g.Balls)
     {
         b.setSpeed(-b.Speed);
     }
 }
Example #10
0
        public override void Apply(GameStateMatch g, Player p)
        {
            Player target = g.isPlayer1(p) ? g.Player2 : g.Player1;

            g.theEvents.addEvent(new GameEventPlayerChangeFriction(6.0f, target, target.thePad.FrictionConstant));
            target.thePad.FrictionConstant = 4 * target.thePad.FrictionConstant;
        }
Example #11
0
 public void object_exits(GameStateMatch g, Box b)
 {
     if (eexit != null)
     {
         eexit.apply(b, g);
     }
 }
Example #12
0
 public override void Apply(GameStateMatch g, Player p)
 {
     for (int s = -1; s <= +1; s += 2)
     {
         Ball b = create_ball_for(g, p, 4.0f);
         b.setCenter(b.Center + new Vector3(0, s * p.thePad.Size.Y / 2 * 0.7f, 0));
     }
 }
Example #13
0
 public override void apply(Box target, GameStateMatch g)
 {
     if (target.Visible)
     {
         target.Visible = false;
         g.theEvents.addEvent(new GameEventVisibilize(yPhysics.Instance.DT * 3, target, true));
     }
 }
Example #14
0
        public override void Apply(GameStateMatch g, Player p)
        {
            p.Healthbar.HP += (int)(p.theCharacter.MaxHp * 0.10f);

            if (p.Healthbar.HP > p.Healthbar.MAXHP)
            {
                p.Healthbar.HP = p.Healthbar.MAXHP;
            }
        }
Example #15
0
        //public override bool hitWall(GameStateMatch game, Box collidingObj) { return false; }    // return true to delete ball
        public override bool hitPlayer(GameStateMatch game, Player targetplayer)
        {
            Age = 1;

            theevent.Target = targetplayer;
            theevent.Apply();

            return(true);    // return true to delete ball
        }
Example #16
0
        public override void Apply(GameStateMatch g, Player p)
        {
            Ball b = create_ball_for(g, p, 0);

            float len   = b.Speed.Length / 1.5f;
            float angle = (float)(-Math.PI / 4 + Math.PI / 2 * yPhysics.Random()) + (float)Math.PI * (g.isPlayer1(p) ? 0 : 1);

            b.setSpeed(new Vector3(-len * (float)Math.Cos(angle), len * (float)Math.Sin(angle), 0));
        }
Example #17
0
        public override void Apply(GameStateMatch g, Player p)
        {
            int limit = g.Balls.Length;

            for (int i = 0; i < limit; i++)
            {
                Ball b = create_ball_for(g, p, g.Balls[i].Age * yPhysics.Instance.DT);
                b.setCenter(new Vector3(-g.Balls[i].Center.X, g.Balls[i].Center.Y, g.Balls[i].Center.Z));
                b.setSpeed(new Vector3(-g.Balls[i].Speed.X, g.Balls[i].Speed.Y, g.Balls[i].Speed.Z));
            }
        }
Example #18
0
        public override void Apply(GameStateMatch g, Player p)
        {
            bool isp1 = g.isPlayer1(p);

            foreach (Ball b in g.Balls)
            {
                if (b.Speed.X * (isp1 ? +1 : -1) > 0)
                {
                    b.setSpeed(new Vector3(-b.Speed.X, b.Speed.Y, b.Speed.Z));
                }
            }
        }
Example #19
0
        public override void Apply(GameStateMatch g, Player p)
        {
            const float duration = 8.0f;

            float angle = (float)(2 * Math.PI * yPhysics.Random());
            float len   = 7.0f;

            for (int i = 0; i < 4; i++)
            {
                g.newBall(Vector3.Zero, new Vector3(len * (float)Math.Cos(angle + i * Math.PI / 2), len * (float)Math.Sin(angle + i * Math.PI / 2), 0), (int)(duration * yPhysics.Instance.fps));
            }
        }
Example #20
0
File: Player.cs Project: LMY/yuPong
        public Player(GameStateMatch g, Character c, Pad p, Input i, Appearance app)
        {
            game = g;

            character            = c;
            thePad               = p;
            input                = i;
            thePad.theAppearance = app;
            cooldowns            = new int[character.SpecialMovesN];

            healthbar = null;
        }
Example #21
0
        public override void Apply(GameStateMatch g, Player p)
        {
            const float lendiff = 1.2f;
            const float F       = 60.0f;

            bool    isp1 = g.isPlayer1(p);
            Vector3 pmin = new Vector3(p.thePad.MaxPoint.X - g.theLevel.SizeX, p.thePad.MinPoint.Y - lendiff * p.thePad.Size.Y, p.thePad.MinPoint.Z);
            Vector3 pmax = new Vector3(p.thePad.MaxPoint.X, p.thePad.MaxPoint.Y + lendiff * p.thePad.Size.Y, p.thePad.MaxPoint.Z);

            FieldEventForceConst fe = new FieldEventForceConst(new Vector3((isp1 ? -1 : +1) * F, 0, 0));

            g.theFieldlist.addField(new FieldBox(1.0f, fe, fe, fe, pmin, pmax));
        }
Example #22
0
File: Player.cs Project: LMY/yuPong
        public PongMove getInput(GameStateMatch game, KeyboardDevice Keyboard)
        {
            // decrease cooldowns
            for (int i = 0; i < cooldowns.Length; i++)
            {
                if (cooldowns[i] > 0)
                {
                    cooldowns[i]--;
                }
            }

            return(theInput.GetInput(game, this, character, cooldowns, Keyboard, yPhysics.Instance.FrameN));
        }
Example #23
0
        public override void Apply(GameStateMatch g, Player p)
        {
            const float lendiff = 1.2f;

            bool    isp1 = g.isPlayer1(p);
            Vector3 pmin = new Vector3(p.thePad.MaxPoint.X - g.theLevel.SizeX, p.thePad.MinPoint.Y - lendiff * p.thePad.Size.Y, p.thePad.MinPoint.Z);
            Vector3 pmax = new Vector3(p.thePad.MaxPoint.X, p.thePad.MaxPoint.Y + lendiff * p.thePad.Size.Y, p.thePad.MaxPoint.Z);


            FieldEventInvisible finside = new FieldEventInvisible();
            FieldEventVisible   finexit = new FieldEventVisible();

            g.theFieldlist.addField(new FieldRadial(6.0f, finside, finexit, finside, Vector3.Zero, g.theLevel.SizeY / 3));
        }
Example #24
0
        public Keypress[] translateInput(GameStateMatch game, KeyboardDevice keyboard)
        {
            Keypress[] cmds = new Keypress[keys.Length];
            int        i    = 0; // length/first_free index in cmds array

            for (int k = 0; k < keys.Length; k++)
            {
                if (keyboard[keys[k]])
                {
                    if (kxpressed[k])
                    {
                        cmds[i++] = new Keypress(commands[k], Keypress.KeypressState.HOLD);
                    }
                    else
                    {
                        kxpressed[k] = true;
                        cmds[i++]    = new Keypress(commands[k], Keypress.KeypressState.PRESS);
                    }
                }
                else
                {
                    if (kxpressed[k])
                    {
                        kxpressed[k] = false;
                        cmds[i++]    = new Keypress(commands[k], Keypress.KeypressState.RELEASE);
                    }
                }
            }

            if (i == 0)
            {
                return(null);
            }

            Keypress[] cmds2 = new Keypress[i];
            int        p     = 0;

            for (int k = 0; k < keys.Length; k++)
            {
                if (cmds[k] != null)
                {
                    cmds2[p++] = cmds[k];
                }
            }

            return(cmds2);
        }
Example #25
0
        public override void Apply(GameStateMatch g, Player p)
        {
            Ball b = create_ball_for(g, p, 10.0f);

            float len   = b.Speed.Length / 1.5f;
            float angle = (float)(-Math.PI / 4 + Math.PI / 2 * yPhysics.Random()) + (float)Math.PI * (g.isPlayer1(p) ? 0 : 1);

            b.setSpeed(new Vector3(-len * (float)Math.Cos(angle), len * (float)Math.Sin(angle), 0));

            foreach (Ball ba in g.Balls)
            {
                if (ba.Age < yPhysics.Instance.fps * 10.0f && ba.Age >= 0)
                {
                    ba.Age = (int)(yPhysics.Instance.fps * 10.0f);
                }
            }
        }
Example #26
0
        public void apply_field(GameStateMatch g, Box b)
        {
            bool was_inside = is_inside(b.Center0);
            bool now_inside = is_inside(b.Center);

            if (!was_inside && now_inside)
            {
                object_enters(g, b);
            }
            else if (was_inside && !now_inside)
            {
                object_exits(g, b);
            }
            else if (was_inside && now_inside)
            {
                object_stays(g, b);
            }
        }
Example #27
0
        public override void Apply(GameStateMatch g, Player p)
        {
            /*
             * foreach (Ball b in g.Balls)
             * {
             *  if ((b.Center.X > 0 && b.Center.X < g.theLevel.SizeX / 2 && g.isPlayer1(p)) || (b.Center.X < 0 && b.Center.X > -g.theLevel.SizeX / 2 && !g.isPlayer1(p)))
             *  {
             *      b.Center = new Vector3(-b.Center.X, b.Center.Y, b.Center.Z);
             *      b.Speed = new Vector3(-b.Speed.X, b.Speed.Y, b.Speed.Z);
             *  }
             * }*/

            bool        p1     = g.isPlayer1(p);
            Player      target = p1 ? g.Player2 : g.Player1;
            const float border = 1.2f;

            float randx = (p1?-1:+1) * g.theLevel.SizeX / 4 + 2 * (yPhysics.Random() - 1) * (g.theLevel.SizeX / 2 - target.thePad.Size.X / 2 - border);
            float randy = +2 * (yPhysics.Random() - 1) * (g.theLevel.SizeY / 2 - target.thePad.Size.Y / 2 - border);

            Ball b = create_ball_for(g, p, 3.0f, new GameEventTeleportInOwnSpace(0, target, g));
        }
Example #28
0
 public override void apply(Box target, GameStateMatch g)
 {
     target.F += force;
 }
Example #29
0
 public override void apply(Box target, GameStateMatch g)
 {
 }
Example #30
0
 public GameEventSlowForPeriod(float trigger_time, Player targetplayer, GameStateMatch thegame, float theperiod)
     : base(trigger_time, targetplayer)
 {
     game = thegame; period = theperiod;
 }