private bool IsCollisionPossible(GunBullet bullet, Vector2 point)
        {
            var xPositions = new float[]
            {
                bullet.Position.X,
                bullet.Position.X - bullet.Size,
                bullet.NewPosition.X,
                bullet.NewPosition.X - bullet.Size
            };
            var xMax = xPositions.Max();
            var xMin = xPositions.Min();

            var yPositions = new float[]
            {
                bullet.Position.Y,
                bullet.Position.Y - bullet.Size,
                bullet.NewPosition.Y,
                bullet.NewPosition.Y - bullet.Size
            };
            var yMax = yPositions.Max();
            var yMin = yPositions.Min();

            return(point.X <= xMax && point.X >= xMin &&
                   point.Y <= yMax && point.Y >= yMin);
        }
Exemple #2
0
        public static void RunTests()
        {
            GunBullet b  = new GunBullet("BULLETNAME", "fdfd", 4);
            GunBullet bb = new GunBullet("BB", "fdfd", 4);
            GunClip   c  = new GunClip("C10", "ddddd", 10, new List <string>()
            {
                "BULLETNAME", "B"
            });
            VampireGun g = new VampireGun("GUNNAME", "DFDF", 1, 2, 50, 1, new List <string>()
            {
                "C8", "C10"
            });

            g.OnShoot += G_OnShoot;

            g.PutClip(c);
            Console.WriteLine(g.Shoot());
            var clip = g.TakeOutClip();

            clip.ChargeClip(bb);
            var bullets = new List <IShootable>();

            for (int i = 0; i < 5; i++)
            {
                bullets.Add(b);
            }
            clip.ChargeClip(bullets);
            g.PutClip(clip);

            Console.WriteLine(g.BulletsLeft());
            g.Shoot();
            Console.WriteLine(g.BulletsLeft());
        }
Exemple #3
0
        public void BulletInteractionTest()
        {
            //organization
            Ufo       firstUfo    = new Ufo(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(1, 1));
            Ufo       secondUfo   = new Ufo(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(1, 1));
            AEntity   laserBullet = new LaserBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(1, 1));
            GunBullet gunBullet   = new GunBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(1, 1));

            List <AEntity> bigAsteroidIntResult = new List <AEntity>();

            bigAsteroidIntResult.Add(new Asteroid(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(2, 1), 1));
            bigAsteroidIntResult.Add(new Asteroid(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(0, 1), 1));

            //activity
            List <AEntity> laserSmalInteraction = firstUfo.Interaction(laserBullet);
            List <AEntity> gunSmalInteraction   = secondUfo.Interaction(gunBullet);

            //assertion


            Assert.AreEqual(laserSmalInteraction, null);
            Assert.AreEqual(gunSmalInteraction, null);

            Assert.IsTrue(firstUfo.WasKilled);
            Assert.IsTrue(secondUfo.WasKilled);
        }
 public bool IsCollisionPossible(GunBullet bullet, MovableGameObject movableGameObject)
 {
     return(IsCollisionPossible(bullet, movableGameObject.NewPosition) ||
            IsCollisionPossible(bullet, new Vector2(
                                    movableGameObject.NewPosition.X - movableGameObject.Size,
                                    movableGameObject.NewPosition.Y - movableGameObject.Size)) ||
            IsCollisionPossible((MovableGameObject)bullet, movableGameObject));
 }
 public bool IsCollisionPossible(GunBullet bullet, NotMovableGameObject notMovableGameObject)
 {
     return(IsCollisionPossible(bullet, notMovableGameObject.Position) ||
            IsCollisionPossible(bullet, new Vector2(
                                    notMovableGameObject.Position.X - notMovableGameObject.Size,
                                    notMovableGameObject.Position.Y - notMovableGameObject.Size)) ||
            IsCollisionPossible((MovableGameObject)bullet, notMovableGameObject));
 }
        public bool IsCollisionPossible(GunBullet bullet, GamePhysicalObject gamePhysicalObject)
        {
            if (gamePhysicalObject is MovableGameObject)
            {
                return(IsCollisionPossible(bullet, (MovableGameObject)gamePhysicalObject));
            }

            return(IsCollisionPossible(bullet, (NotMovableGameObject)gamePhysicalObject));
        }
 private void Attack()
 {
     if (Input.GetMouseButtonDown(0) && Time.time - lastAttackTime >= 100 / attackSpeed)
     {
         lastAttackTime = Time.time;
         GunBullet newBullet = Instantiate(bulletPrefab, bulletPoint.position, bulletPoint.rotation, bulletPoint.transform.parent);
         newBullet.SetDamage(ATK);
         newBullet.Fire();
     }
 }
        public void AddBullet(Vector2 position, Vector2 heading, float rotationAngle)
        {
            GunBullet bullet = new GunBullet(Game);
            bullet.Initialize();
            bullet.Position = new Vector2(position.X, position.Y);
            bullet.Heading = heading;
            bullet.RotationAngle = rotationAngle;

            Bullets.Add(bullet);
        }
Exemple #9
0
 private void pushBullet(Vector2 position, float direction)
 {
     for (int i = 0; i < bulletCount; i++)
     {
         if (!bullets[i].active)
         {
             bullets[i] = new GunBullet(position, direction);
             return;
         }
     }
 }
 private void pushBullet(Vector2 position, float direction)
 {
     for (int i = 0; i < bulletCount; i++)
     {
         if (!bullets[i].active)
         {
             bullets[i] = new GunBullet(position, direction + (float)(Math.PI / 9 * Game1.rand.NextDouble() - (Math.PI / 18)));
             AudioLib.playSoundEffect(machineGunSoundEffect);
             return;
         }
     }
 }
Exemple #11
0
        /// <summary>
        /// Próbuje zaatkaowaæ samolot gracza. Najpierw sprawdza mo¿liwoœæ ataku rakiet¹
        /// a póŸniej dzia³kiem.
        /// </summary>
        private void AttackUserPlane(Plane userPlane, float scaleFactor)
        {
            //return; //chwilowo do testów
            //sprawdzam czy samolot nie jest za daleko, ¿eby atakowaæ

            UpdateDebugInfo("AttackUserPlane", true.ToString());

            // staraj sie dogonic samolot gracza
            if (IsTurnedTowardsUserPlane(userPlane) && Speed < GetConsts().Speed * 1.4f)
            {
                Speed += 0.8f * scaleFactor;
            }

            if (!IsTurnedTowardsUserPlane(userPlane) && Speed > minFlyingSpeed)
            {
                Speed -= 0.8f * scaleFactor;
            }


            if (Math.Abs(Center.X - level.UserPlane.Center.X) > GetConsts().ViewRange)
            {
                return;
            }

            UpdateDebugInfo("AttackUserPlane-Distance", true.ToString());


            if (this.weaponManager.RocketCount > 0 && Rocket.CanHitEnemyPlane(this, level.UserPlane, 100 - GetConsts().Accuracy, false) != MissileBase.CollisionDirectionLocation.NONE) //najpierw próbuje strzeliæ rakiet¹
            {
                if (warCryTimer > warCryTimerMin)
                {
                    level.Controller.OnWarCry(this);
                    warCryTimer = 0;
                }
                FireRocket();
            }
            else
            {
                UpdateDebugInfo("AttackUserPlane-GunAiming", true.ToString());

                MissileBase.CollisionDirectionLocation coll = GunBullet.CanHitEnemyPlane(this, level.UserPlane, 100 - GetConsts().Accuracy, this.HasBiDirectionalGun);
                if (coll != MissileBase.CollisionDirectionLocation.NONE)
                {
                    if (warCryTimer > warCryTimerMin)
                    {
                        level.Controller.OnWarCry(this);
                        warCryTimer = 0;
                    }
                    //Console.WriteLine(this.Name + ": AttackUserPlane -> can hit");
                    weaponManager.FireAtAngle(Angle, WeaponType.Gun, this.locationState == LocationState.AirTurningRound, coll);
                }
            }
        }
Exemple #12
0
        public void MoutionTest()
        {
            GunBullet testedGunBullet = new GunBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1));

            for (int i = 2; i <= 5; i++)
            {
                testedGunBullet.ChengeState(new CoupleDouble(100, 100));
                CoupleDouble expected = new CoupleDouble(i, i);

                Assert.AreEqual(expected, testedGunBullet.Pos);
            }
        }
Exemple #13
0
        public void Attack()
        {
            var a = _body.RigidBody.GetBody().GetAngle() + Angle; // + (-45.0f / (180.0f * Math.PI));
            var x = (float)Math.Cos(a + (float)Math.PI / 2);
            var y = (float)Math.Sin(a + (float)Math.PI / 2);

            var dx = _body.RigidBody.GetX();
            var dy = _body.RigidBody.GetY();


            var b = new GunBullet(_engine, dx + x, dy + y, 5);

            b.RigidBody.GetBody().ApplyImpulse(new Vec2(x * 10, y * 10), b.RigidBody.GetBody().GetPosition());
            Bullets.Add(b);
        }
Exemple #14
0
        public void BulletInteractionTest()
        {
            GunBullet testedBullet = new GunBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1));

            GunBullet someGunBullet   = new GunBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1));
            AEntity   someLaserBullet = new LaserBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1));

            List <AEntity> gunBullIntRes   = testedBullet.Interaction(someGunBullet);
            List <AEntity> laserBullIntRes = testedBullet.Interaction(someLaserBullet);


            Assert.AreEqual(null, gunBullIntRes);
            Assert.AreEqual(null, laserBullIntRes);

            Assert.IsFalse(testedBullet.WasKilled);
        }
Exemple #15
0
        public void EnemyInteractionTest()
        {
            GunBullet firstTestedGunBullet  = new GunBullet(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1));
            GunBullet secondTestedGunBullet = new GunBullet(new CoupleDouble(2, 2), new CoupleDouble(2, 2), new CoupleDouble(-1, -1));

            Ufo      someUfo      = new Ufo(new CoupleDouble(1, 1), new CoupleDouble(1, 1), new CoupleDouble(-1, -1));
            Asteroid someAsteroid = new Asteroid(new CoupleDouble(2, 2), new CoupleDouble(2, 2), new CoupleDouble(-1, -1));

            List <AEntity> interUfoResult    = firstTestedGunBullet.Interaction(someUfo);
            List <AEntity> interaAsterResult = secondTestedGunBullet.Interaction(someAsteroid);

            Assert.AreEqual(null, interUfoResult);
            Assert.AreEqual(null, interaAsterResult);

            Assert.IsTrue(firstTestedGunBullet.WasKilled);
            Assert.IsTrue(secondTestedGunBullet.WasKilled);
        }
Exemple #16
0
    private void ShootBullet()
    {
        GameObject ins = Instantiate(bullet_prefab, bullet_start_pos.transform.position, Quaternion.identity);

        GunBullet bull = ins.GetComponent <GunBullet>();

        if (bull != null)
        {
            PlayerStats owner = GetGrabbedBy();

            if (owner != null)
            {
                PlayerActions pa = owner.gameObject.GetComponent <PlayerActions>();

                bull.SetMovementData(pa.GetItemAngle(), pa.GetItemDirectionVector(), bullet_speed);
                bull.SetShooter(owner);

                used = true;
            }
        }
    }
Exemple #17
0
        public override void refreshPosition()
        {
            if (ammunition != null)
            {
                Vector3 axis;
                if (ammunition.Direction == Direction.Right)
                {
                    axis = Vector3.NEGATIVE_UNIT_Y;
                }
                else
                {
                    axis = Vector3.UNIT_Y;
                }


                GunBullet gb = ammunition as GunBullet;
                Vector2   v  = UnitConverter.LogicToWorldUnits(ammunition.Center);
                ammunitionNode.Orientation = gb.LaunchOrientation;
                ammunitionNode.SetPosition((float)(v.x), (float)(v.y), gb.Position3.z);
            }
        }
        public override void update(GameTime currentTime)
        {
            animation_time      += currentTime.ElapsedGameTime.Milliseconds;
            deadCushySoundTimer += currentTime.ElapsedGameTime.Milliseconds;


            if (guardState == PatrolGuardState.InvalidState)
            {
                throw new Exception("Patrol Guard went into invalid state");
            }
            else if (guardState == PatrolGuardState.MoveWait)
            {
                moveWaitTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (moveWaitStepping)
                {
                    switch (direction_facing)
                    {
                    case GlobalGameConstants.Direction.Up:
                        velocity = new Vector2(0.0f, -patrolMoveSpeed);
                        break;

                    case GlobalGameConstants.Direction.Down:
                        velocity = new Vector2(0.0f, patrolMoveSpeed);
                        break;

                    case GlobalGameConstants.Direction.Left:
                        velocity = new Vector2(-patrolMoveSpeed, 0.0f);
                        break;

                    case GlobalGameConstants.Direction.Right:
                        velocity = new Vector2(patrolMoveSpeed, 0.0f);
                        break;
                    }

                    directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("run");
                }
                else
                {
                    velocity = Vector2.Zero;

                    directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("idle");
                }

                if (moveWaitTimer > (moveWaitStepping ? moveStepTime : moveStepWaitTime))
                {
                    moveWaitStepping = !moveWaitStepping;
                    moveWaitTimer    = 0.0f;

                    if (moveWaitStepping)
                    {
                        direction_facing = (GlobalGameConstants.Direction)(((int)direction_facing + ((Game1.rand.Next() % 3) - 1) + 4) % 4);
                    }
                }

                if (target == null)
                {
                    sightBox        = new GunBullet();
                    sightBox.hitbox = new Vector2(100, 100);
                    switch (direction_facing)
                    {
                    case GlobalGameConstants.Direction.Down:
                        sightBox.position.X = CenterPoint.X - 50;
                        sightBox.position.Y = position.Y + dimensions.Y;
                        sightBox.hitbox.Y   = 150;
                        break;

                    case GlobalGameConstants.Direction.Up:
                        sightBox.position.X = CenterPoint.X - 50;
                        sightBox.position.Y = position.Y - 120;
                        sightBox.hitbox.Y   = 150;
                        break;

                    case GlobalGameConstants.Direction.Right:
                        sightBox.position.X = position.X + dimensions.X;
                        sightBox.position.Y = CenterPoint.Y - 50;
                        sightBox.hitbox.X   = 120;
                        break;

                    case GlobalGameConstants.Direction.Left:
                        sightBox.position.X = position.X - 120;
                        sightBox.position.Y = CenterPoint.Y - 50;
                        sightBox.hitbox.X   = 120;
                        break;
                    }

                    for (int it = 0; it < parentWorld.EntityList.Count; it++)
                    {
                        if (parentWorld.EntityList[it].Enemy_Type == Entity.EnemyType.Guard || parentWorld.EntityList[it] is Coin || parentWorld.EntityList[it] is Pickup || parentWorld.EntityList[it] is BetaEndLevelFag)
                        {
                            continue;
                        }

                        if (Vector2.Distance(parentWorld.EntityList[it].CenterPoint, chunkCenter) > 1000)
                        {
                            continue;
                        }

                        if (Vector2.Distance(parentWorld.EntityList[it].CenterPoint, CenterPoint) > GlobalGameConstants.TileSize.X * 10)
                        {
                            continue;
                        }

                        if (!sightBox.hitTestBullet(parentWorld.EntityList[it]))
                        {
                            continue;
                        }

                        if (parentWorld.EntityList[it].Enemy_Type != enemy_type || parentWorld.EntityList[it].Enemy_Type != EnemyType.NoType)
                        {
                            if (GameCampaign.PlayerAllegiance > 0.7f && parentWorld.EntityList[it] is Player)
                            {
                                continue;
                            }
                            else
                            {
                                target = parentWorld.EntityList[it];
                            }
                        }

                        else if (parentWorld.EntityList[it] is ShopKeeper)
                        {
                            target = parentWorld.EntityList[it];
                        }
                    }

                    if (target != null)
                    {
                        chaseWaitTime = 0f;
                        guardState    = PatrolGuardState.Chase;
                    }
                }
                else
                {
                    target = null;
                }

                if (Vector2.Distance(CenterPoint, chunkCenter) > 1000)
                {
                    guardState = PatrolGuardState.RetreatToCenter;
                }
            }
            else if (guardState == PatrolGuardState.RetreatToCenter)
            {
                retreatTimer += currentTime.ElapsedGameTime.Milliseconds;

                if (Vector2.Distance(CenterPoint, chunkCenter) < 350 || retreatTimer > retreatMaxTime)
                {
                    guardState   = PatrolGuardState.MoveWait;
                    retreatTimer = 0;
                    return;
                }

                double theta = Math.Atan2(CenterPoint.Y - chunkCenter.Y, CenterPoint.X - chunkCenter.X);

                if (theta < Math.PI / 4 || theta > (Math.PI * 2) - (Math.PI / 4))
                {
                    direction_facing = GlobalGameConstants.Direction.Down;
                }
                else if (theta > Math.PI / 4 && theta < Math.PI - (Math.PI / 4))
                {
                    direction_facing = GlobalGameConstants.Direction.Left;
                }
                else if (theta > Math.PI - (Math.PI / 4) / 4 && theta < Math.PI + (Math.PI / 4))
                {
                    direction_facing = GlobalGameConstants.Direction.Right;
                }
                else if (theta > Math.PI + (Math.PI / 4) / 4 && theta < (Math.PI * 2) - (Math.PI / 4))
                {
                    direction_facing = GlobalGameConstants.Direction.Up;
                }

                velocity = -patrolMoveSpeed * new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta));

                directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("run");
            }
            else if (guardState == PatrolGuardState.Chase)
            {
                //this employs short-circut evaluation for safe code, which I'm not sure if is a good idea
                if (target == null || target.Remove_From_List == true || target.Death == true)
                {
                    guardState = PatrolGuardState.MoveWait;

                    target = null;

                    return;
                }

                if (Vector2.Distance(target.CenterPoint, chunkCenter) > 1000)
                {
                    guardState = PatrolGuardState.RetreatToCenter;
                    target     = null;
                    return;
                }

                double theta = Math.Atan2(target.CenterPoint.Y - CenterPoint.Y, target.CenterPoint.X - CenterPoint.X);

                if (Math.Abs(Math.Sin(theta)) > Math.Abs(Math.Cos(theta)))
                {
                    if (Math.Sin(theta) < 0)
                    {
                        direction_facing = GlobalGameConstants.Direction.Up;
                    }
                    else
                    {
                        direction_facing = GlobalGameConstants.Direction.Down;
                    }
                }
                else
                {
                    if (Math.Cos(theta) < 0)
                    {
                        direction_facing = GlobalGameConstants.Direction.Left;
                    }
                    else
                    {
                        direction_facing = GlobalGameConstants.Direction.Right;
                    }
                }

                //approach player, but keep a distance
                float dist = Vector2.Distance(CenterPoint, target.CenterPoint);
                if (dist < GlobalGameConstants.TileSize.X * 3)
                {
                    //chaseWaitTime -= currentTime.ElapsedGameTime.Milliseconds;

                    velocity = -patrolChaseSpeed * new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta));

                    if (direction_facing == GlobalGameConstants.Direction.Up || direction_facing == GlobalGameConstants.Direction.Down)
                    {
                        if (Math.Abs(CenterPoint.X - target.CenterPoint.X) > 10.0f)
                        {
                            if (CenterPoint.X < target.CenterPoint.X)
                            {
                                velocity.X += patrolChaseSpeed / 8;
                            }
                            else if (CenterPoint.X > target.CenterPoint.X)
                            {
                                velocity.X -= patrolChaseSpeed / 8;
                            }
                        }
                    }

                    if (direction_facing == GlobalGameConstants.Direction.Left || direction_facing == GlobalGameConstants.Direction.Right)
                    {
                        if (Math.Abs(CenterPoint.Y - target.CenterPoint.Y) > 10.0f)
                        {
                            if (CenterPoint.Y < target.CenterPoint.Y)
                            {
                                velocity.Y += patrolChaseSpeed / 8;
                            }
                            else if (CenterPoint.Y > target.CenterPoint.Y)
                            {
                                velocity.Y -= patrolChaseSpeed / 8;
                            }
                        }
                    }
                }
                else if (dist > GlobalGameConstants.TileSize.X * 4)
                {
                    //chaseWaitTime -= currentTime.ElapsedGameTime.Milliseconds;

                    velocity = patrolChaseSpeed * new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta));

                    if (direction_facing == GlobalGameConstants.Direction.Up || direction_facing == GlobalGameConstants.Direction.Down)
                    {
                        if (Math.Abs(CenterPoint.X - target.CenterPoint.X) > 10.0f)
                        {
                            if (CenterPoint.X < target.CenterPoint.X)
                            {
                                velocity.X += patrolChaseSpeed / 8;
                            }
                            else if (CenterPoint.X > target.CenterPoint.X)
                            {
                                velocity.X -= patrolChaseSpeed / 8;
                            }
                        }
                    }

                    if (direction_facing == GlobalGameConstants.Direction.Left || direction_facing == GlobalGameConstants.Direction.Right)
                    {
                        if (Math.Abs(CenterPoint.Y - target.CenterPoint.Y) > 10.0f)
                        {
                            if (CenterPoint.Y < target.CenterPoint.Y)
                            {
                                velocity.Y += patrolChaseSpeed / 8;
                            }
                            else if (CenterPoint.Y > target.CenterPoint.Y)
                            {
                                velocity.Y -= patrolChaseSpeed / 8;
                            }
                        }
                    }
                }
                else
                {
                    chaseWaitTime += currentTime.ElapsedGameTime.Milliseconds;

                    velocity = Vector2.Zero;

                    if (chaseWaitTime > chaseWaitDuration)
                    {
                        chaseWaitTime  = 0.0f;
                        guardState     = PatrolGuardState.WindUp;
                        animation_time = 0.0f;
                    }
                }

                if (chaseWaitTime < 0)
                {
                    chaseWaitTime = 0f;
                }

                directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("chase");
            }
            else if (guardState == PatrolGuardState.WindUp)
            {
                velocity = Vector2.Zero;

                windUpTime += currentTime.ElapsedGameTime.Milliseconds;

                if (windUpTime > windUpDuration)
                {
                    windUpTime     = 0.0f;
                    animation_time = 0.0f;
                    guardState     = PatrolGuardState.Shooting;

                    for (int i = 0; i < bulletSupply; i++)
                    {
                        if (!(bullets[i].active))
                        {
                            AudioLib.playSoundEffect("pistolTEST");
                            parentWorld.Particles.pushBulletCasing(new Vector2(directionAnims[(int)direction_facing].Skeleton.FindBone("gun").WorldX, directionAnims[(int)direction_facing].Skeleton.FindBone("gun").WorldY));
                            Vector2 muzzleLocation = new Vector2(directionAnims[(int)direction_facing].Skeleton.FindBone("muzzle").WorldX, directionAnims[(int)direction_facing].Skeleton.FindBone("muzzle").WorldY);
                            bullets[i] = new GunBullet(muzzleLocation, direction_facing, this);

                            parentWorld.Particles.pushPistolFlash(muzzleLocation, Color.White, direction_facing);

                            break;
                        }
                    }
                }

                directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("windUp");
            }
            else if (guardState == PatrolGuardState.Shooting)
            {
                windUpTime += currentTime.ElapsedGameTime.Milliseconds;

                directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("attack");

                if (windUpTime > windUpDuration)
                {
                    windUpTime     = 0.0f;
                    animation_time = 0.0f;
                    guardState     = PatrolGuardState.Chase;

                    directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("chase");
                }
            }
            else if (guardState == PatrolGuardState.KnockBack)
            {
                if (health < 0)
                {
                    remove_from_list = true;
                    return;
                }

                directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("hurt");

                knockBackTime += currentTime.ElapsedGameTime.Milliseconds;

                if (knockBackTime > knockBackDuration)
                {
                    //target = null;

                    guardState = PatrolGuardState.Chase;
                }
            }
            else if (guardState == PatrolGuardState.Dying)
            {
                directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation("die");

                death = true;

                velocity = Vector2.Zero;
            }

            Vector2 newPos   = position + (currentTime.ElapsedGameTime.Milliseconds * velocity);
            Vector2 finalPos = parentWorld.Map.reloactePosition(position, newPos, dimensions);

            position = finalPos;

            for (int i = 0; i < bulletSupply; i++)
            {
                bullets[i].update(parentWorld, currentTime);
            }

            directionAnims[(int)direction_facing].Animation.Apply(directionAnims[(int)direction_facing].Skeleton, animation_time / 1000f, (guardState == PatrolGuardState.MoveWait || guardState == PatrolGuardState.Chase || guardState == PatrolGuardState.RetreatToCenter) ? true : false);
        }
 public void OnRegisterGunBullet(GunBullet gunBullet)
 {
 }
Exemple #20
0
 public void OnRegisterGunBullet(GunBullet gunBullet)
 {
     AddJob(MethodBase.GetCurrentMethod().Name, new object[] { gunBullet });
 }
 public GamePhysicalObject GetNearestObjectInPath(GunBullet bullet)
 {
     return(GetNearestObjectInPath(bullet, bullet.DirectionX, bullet.DirectionY));
 }
 public void ProcessCollision(GunBullet bullet, GamePhysicalObject gamePhisicalObject)
 {
     bullet.GetDamage();
     gamePhisicalObject.GetDamage();
 }