Example #1
0
        public override void Update(GameTime gameTime, float speedAdjust)
        {
            physicalObject.removeTextureSet("Energize");
            if (shieldBattery > 0)
            {
                for (int x = -1; x <= 1; x++)
                {
                    for (int y = -1; y <= 1; y++)
                    {
                        Vector2 newPos = new Vector2(positionIndex.X + x, positionIndex.Y + y);
                        if (parent.isNodeAt(newPos))
                        {
                            CubeNode node = parent.getNodeAt(newPos);
                            if (supplement(node))
                            {
                                parent.currentRound.soundsToPlay[physicalObject.boxGeom] = new PhysicsGame.Game1.RoundSpecific.SoundInfo("shield", 100f, physicalObject.boxGeom);
                                physicalObject.addTextureSet("Energize");
                            }
                        }
                    }
                }
            }

            physicalObject.getTextureSet("Energize").incrementIndex(1.0f);

            defaultAnimationSpeed = shieldBattery / totalShieldBattery;

            base.Update(gameTime, speedAdjust);
        }
Example #2
0
        private bool supplement(CubeNode node)
        {
            float toAdd = node.maxHp - node.hp;

            if (toAdd > 50)
            {
                toAdd = 50;
            }

            node.hp       += toAdd;
            shieldBattery -= toAdd;

            return(toAdd > 0.1);
        }
        public void fire()
        {
            CubeNode node = CubeFactory.createCubeNode(parent.textureStore, physicsController, new CubeDescription(CubeType.BulletCube), new Vector2(20, 20), parent);

            bulletsList.Add(node);
            //BulletCube bullet = new BulletCube();

            //PhysicsGameObject pgo = new PhysicsGameObject(physicsController.physicsSimulator, this.physicalObject.getWidth()/.6f, this.physicalObject.getHeight()/.6f, false);

            node.physicalObject.boxBody.Position = Vector2.Add(this.physicalObject.boxBody.Position,
                                                               Vector2.Transform(new Vector2(this.physicalObject.getWidth() + 15, 0),
                                                                                 Matrix.CreateRotationZ(this.physicalObject.boxBody.Rotation - MathHelper.Pi)));



            //physicsController.nodeLookup[pgo] = bullet;
            //bullet.physicsController = this.physicsController;
            node.parent = this.parent;
            node.hackz0r();
            node.physicalObject.boxBody.ApplyForce(Vector2.Transform(new Vector2(10000, 0), Matrix.CreateRotationZ(this.physicalObject.boxBody.Rotation - MathHelper.Pi)));
        }
Example #4
0
        /* insert other properties here */

        protected bool lulz(Geom g1, Geom g2, ContactList p)
        {
            //ModSound sounds = parent.sound;
            if (physicsController.geomLookup[g1].ID == PhysicsGameObject.PhysicsMapID.player1 &&
                physicsController.geomLookup[g2].ID == PhysicsGameObject.PhysicsMapID.player2
                ||
                physicsController.geomLookup[g2].ID == PhysicsGameObject.PhysicsMapID.player1 &&
                physicsController.geomLookup[g1].ID == PhysicsGameObject.PhysicsMapID.player2
                )
            {
                this.hp -= 20;
                if (this is BulletCube)
                {
                    this.markForDelete = true;
                }

                if (physicsController.geomLookup[g1].ID == this.physicalObject.ID)
                {
                    CubeNode other = physicsController.nodeLookup[
                        physicsController.geomLookup[g2]];
                    other.hp -= 20 * damageMultiplier;

                    if (other is BulletCube)
                    {
                        other.markForDelete = true;
                    }

                    if (PhysicsGameObject.PhysicsMapID.player1 == other.physicalObject.ID)
                    {
                        physicsController.damageTotalPlayer1 += 20 * damageMultiplier;
                        physicsController.damageTotalPlayer2 += 20;
                    }
                }
                else
                {
                    CubeNode other = physicsController.nodeLookup[
                        physicsController.geomLookup[g1]];
                    other.hp -= 20 * damageMultiplier;

                    if (other is BulletCube)
                    {
                        other.markForDelete = true;
                    }

                    if (PhysicsGameObject.PhysicsMapID.player2 == other.physicalObject.ID)
                    {
                        physicsController.damageTotalPlayer2 += 20 * damageMultiplier;
                        physicsController.damageTotalPlayer1 += 20;
                    }
                }
            }

            /*ModSound sounds = parent.sound;
             *
             * Vector2 position = p[0].Normal;
             *
             * float angle = (float)Math.Atan2(position.Y, position.X);
             *
             * Vector2 force = Vector2.Zero;
             * if (angle < 0)
             *  force = new Vector2((float)(Math.Cos(angle) * g2.Body.LinearVelocity.X), (float)Math.Sin(MathHelper.TwoPi + angle) * g2.Body.LinearVelocity.Y);
             * else
             *  force = new Vector2((float)(Math.Cos(angle) * g2.Body.LinearVelocity.X), (float)Math.Sin(MathHelper.TwoPi - angle) * g2.Body.LinearVelocity.Y);
             * //try
             * //{
             *  if (physicalObject.ID == PhysicsGameObject.PhysicsMapID.player1)
             *  {
             *      if (physicsController.geomLookup[g1].ID == PhysicsGameObject.PhysicsMapID.player1 &&
             *          physicsController.geomLookup[g2].ID == PhysicsGameObject.PhysicsMapID.player2)
             *      {
             *          hp -= (int)(damageMultiplier / 500f * force.LengthSquared());
             *          Console.WriteLine("A " + hp);
             *          //Console.WriteLine("some lulz have occurred p1 {0}", physicsController.geomLookup[g1].ID);
             *      }
             *
             *
             *  }
             *  else
             *  {
             *      if (physicsController.geomLookup[g1].ID == PhysicsGameObject.PhysicsMapID.player2 &&
             *          physicsController.geomLookup[g2].ID == PhysicsGameObject.PhysicsMapID.player1)
             *      {
             *          hp -= (int)(damageMultiplier / 500f * force.LengthSquared());
             *          Console.WriteLine("B " + hp);//Console.WriteLine("some lulz have occurred p2 {0}", physicsController.geomLookup[g1].ID);
             *      }
             *  }
             * //}
             * //catch (KeyNotFoundException k)
             * //{
             *
             * }*/
            return(true);
        }
Example #5
0
        public override void Update(GameTime gameTime, float speedAdjust)
        {
            if (hp < 0)
            {
            }


            if (startedCountDown)
            {
                if (activationCountdown <= 0)
                {
                    activate();
                }
                else
                {
                    activationCountdown -= 1 * speedAdjust;
                }
            }

            if (rocketsFireing)
            {
                float forceToApply = 10.0f / speedAdjust;
                physicalObject.boxBody.ApplyForce(Vector2.Transform(new Vector2(100, 0), Matrix.CreateRotationZ(physicalObject.boxBody.Rotation))); // fire ze missiles! (but I am le tired)
            }


            physicalObject.getTextureSet("MainFlame").incrementIndex(1.0f * speedAdjust);

            if (isTempNode) // TODO make use that awesome get set thing of c#'s so don't have to set this each step
            {
                physicalObject.colorValue = new Color(Color.White, 0.25f);
            }
            else
            {
                physicalObject.colorValue = new Color(Color.White, 1.0f);
            }


            if (this.activationCountdown / 40 >= 1)
            {
                physicalObject.getTextureSet("Countdown").currentTextureListIndex = this.activationCountdown / 40 + 1;
            }
            else if (!rocketsFireing)
            {
                physicalObject.getTextureSet("Countdown").currentTextureListIndex = 0;
            }
            else
            {
                physicalObject.getTextureSet("Countdown").currentTextureListIndex = 1;
            }

            physicalObject.getTextureSet("Boom").incrementIndex(1.0f);

            base.Update(gameTime, speedAdjust);


            if (hp < 0)
            {
                physicalObject.addTextureSet("Boom");
                markForDelete = false;
                timeToDelete -= speedAdjust;
                for (int x = -1; x <= 1; x++)
                {
                    for (int y = -1; y <= 1; y++)
                    {
                        Vector2 newPos = new Vector2(positionIndex.X + x, positionIndex.Y + y);
                        if (parent.isNodeAt(newPos))
                        {
                            CubeNode node = parent.getNodeAt(newPos);
                            node.hp -= 2;
                        }
                    }
                }
            }

            if (timeToDelete < 0)
            {
                markForDelete = true;
            }
        }