コード例 #1
0
        //update every second
        public override void Update(float deltaTime)
        {
            //check if player 1
            if (Parent is Tank)
            {
                Tank player = Parent as Tank;
                if (player.getPlayerNum() == 1)
                {
                    //bind player one's barrel controls to q and e and space
                    p1BarrelConrols(deltaTime);
                }
            }

            //check if player 2
            if (Parent is Tank)
            {
                Tank player = Parent as Tank;
                if (player.getPlayerNum() == 2)
                {
                    //bind player two's barrel controls to 7 and 9 and 0
                    p2BarrelConrols(deltaTime);
                }
            }
            base.Update(deltaTime);
        }
コード例 #2
0
        //creates bullet and sends it in the direction the barrel is facing
        public override void Fire()
        {
            if (Parent is Tank)
            {
                Tank       player = Parent as Tank;
                SansBullet bullet = new SansBullet(XAbsolute, YAbsolute, player.getPlayerNum(), "Bone44x12.png");

                Parent.Parent.AddChild(bullet);
                bullet.SetRotate(GetRotation() + (float)Math.PI);
                bullet.XVelocity = (float)Math.Cos(bullet.GetRotation() - (float)Math.PI * 0.5f) * 100;
                bullet.YVelocity = (float)Math.Sin(bullet.GetRotation() - (float)Math.PI * 0.5f) * 100;
            }
        }
コード例 #3
0
        //creates bullet and sends it in the direction the barrel is facing
        public virtual void Fire()
        {
            if (Parent is Tank)
            {
                Tank   player = Parent as Tank;
                Bullet bullet = new Bullet(XAbsolute, YAbsolute, player.getPlayerNum(), "bulletSand1_outline.png");

                Parent.Parent.AddChild(bullet);
                bullet.SetRotate(GetRotation() + (float)Math.PI);
                bullet.XVelocity = (float)Math.Cos(bullet.GetRotation() - (float)Math.PI * 0.5f) * 100;
                bullet.YVelocity = (float)Math.Sin(bullet.GetRotation() - (float)Math.PI * 0.5f) * 100;
            }
        }