Beispiel #1
0
        public override void Update()
        {
            A10   a10         = World.GetEntities <A10>().First();
            float a10Distance = Vector2.Distance(a10.PositionVector, PositionVector);

            if (State == SamState.Closed)
            {
                if (a10Distance < Range)
                {
                    State             = SamState.Opening;
                    StateChangedTicks = World.Ticks;
                }
            }
            else if (State == SamState.Opening)
            {
                if (World.Ticks - StateChangedTicks >= TicksToOpen)
                {
                    State             = SamState.Open;
                    StateChangedTicks = World.Ticks;
                }
            }
            else if (State == SamState.Open)
            {
                if (a10Distance < Range)
                {
                    Rotation = VectorHelpers.GetRotationToFace(PositionVector, a10.PositionVector) ?? Rotation;

                    if (World.Ticks - LastShotTicks > TicksBetweenShots)
                    {
                        World.AddProjectile(new Patriot(World, Player, Position, a10));
                        World.AddExplosion(new SamMuzzle(World, this, Rotation));
                        Sounds.Rocket1.Play();
                        LastShotTicks = World.Ticks;
                    }
                }
                else
                {
                    State             = SamState.Closing;
                    StateChangedTicks = World.Ticks;
                }
            }
            else if (State == SamState.Closing)
            {
                if (World.Ticks - StateChangedTicks >= TicksToClose)
                {
                    State             = SamState.Closed;
                    StateChangedTicks = World.Ticks;
                }
            }
            else
            {
                throw new Exception("what");
            }


            base.Update();
        }
Beispiel #2
0
        public override void Update()
        {
            A10   a10           = World.GetEntities <A10>().First();
            float a10Distance   = Vector2.Distance(a10.PositionVector, PositionVector);
            float rotationToA10 = VectorHelpers.GetRotationToFace(PositionVector, a10.PositionVector) ?? Rotation;

            if (a10Distance < ShootRange && State != InfantryState.Shoot && World.Ticks >= LastShotTicks + TicksBetweenShots)
            {
                State             = InfantryState.Shoot;
                EnteredStateTicks = World.Ticks;
                LastShotTicks     = World.Ticks;
            }
            else if (a10Distance < ShootRange && State != InfantryState.Shoot && State != InfantryState.Aiming && World.Ticks < LastShotTicks + TicksBetweenShots)
            {
                State             = InfantryState.Aiming;
                EnteredStateTicks = World.Ticks;
            }
            else if (a10Distance < ChaseRange && State == InfantryState.Stand)
            {
                State             = InfantryState.Run;
                EnteredStateTicks = World.Ticks;
            }
            else if (a10Distance < ChaseRange && a10Distance > ShootRange && (State == InfantryState.Shoot || State == InfantryState.Aiming))
            {
                State             = InfantryState.Run;
                EnteredStateTicks = World.Ticks;
            }
            else if (a10Distance > ChaseRange && State != InfantryState.Stand)
            {
                State             = InfantryState.Stand;
                EnteredStateTicks = World.Ticks;
                Rotation          = MathHelper.Pi;
            }

            if (State == InfantryState.Stand)
            {
                // ?
            }
            else if (State == InfantryState.Run)
            {
                Rotation       = rotationToA10;
                PositionVector = VectorHelpers.MoveInDirection(PositionVector, Rotation, MovementPerTick);
            }
            else if (State == InfantryState.Aiming)
            {
                Rotation = rotationToA10;
            }
            else if (State == InfantryState.Shoot)
            {
                Rotation = rotationToA10;
                if ((World.Ticks - EnteredStateTicks) % 64 == 48)
                {
                    Point        missileStartPosition = new Point(Position.X, Position.Y - 6);
                    SmallMissile smallMissile         = new SmallMissile(World, Player.Two, missileStartPosition, a10);
                    World.AddProjectile(smallMissile);
                    Sounds.Bazooka.Play();
                }
                if ((World.Ticks - EnteredStateTicks) % 64 == 63)
                {
                    State = InfantryState.Aiming;
                }
            }
        }