예제 #1
0
        private static bool h_collideCondition(BaseActor baseActor, BaseActor actorTmp)
        {
            var teams = Teams;
            bool finded = false;
            int index;
            for (index = 0; index < teams.Count; index++)
            {
                for (int i = 0; i < teams[index].Length; i++)
                {
                    if (baseActor.ActorType == teams[index][i])
                    {
                        finded = true;
                        break;
                    }
                }
                if (finded)
                {
                    break;
                }
            }

            bool issameteam = false;
    
            for (int i = 0; i < teams[index].Length; i++) 
            {
                if (actorTmp.ActorType == teams[index][i])
                {
                    issameteam = true;
                    break;
                }
            }
            return baseActor != actorTmp
                   && issameteam == false
                   && h_collidedWith(actorTmp, baseActor);
        }
예제 #2
0
파일: LevelOne.cs 프로젝트: LKND/galaxy1
        public override void Update()
        {
            m_frameCount++;
              h_dispatchKey();

              base.Update();

              IEnumerable<BaseActor> killedActors = CollisionChecher.GetAllCollisions(Actors);

              foreach (BaseActor killedActor in killedActors)
              {
            if (killedActor.IsAlive)
              killedActor.IsAlive = false;
              }

              List<BaseActor> toRemove = Actors.Where(actor => actor.CanDrop).ToList();
              BaseActor[] actors = new BaseActor[toRemove.Count()];
              toRemove.CopyTo(actors);

              foreach (BaseActor actor in actors.Where(actor => actor.CanDrop))
              {
            Actors.Remove(actor);
              }

              if (Player.CanDrop)
            Failed = true;

              //has no enemy
              if (Actors.All(actor => actor.ActorType != ActorType.Enemy))
            Success = true;
        }
예제 #3
0
 public LightingBullet(ILevelInfo info, BaseActor owner) : base (info, owner)
 {
     Speed = 20;
     Width = 30;
     Height = 30;
     ActorType = ActorType.LightWeapon;
 }
예제 #4
0
 public PlayerBullet(ILevelInfo info, BaseActor owner) : base(info)
 {
     Speed = 10;
     Width = 3;
     Height = 6;
     var point = new Point();
     point.X = owner.Position.X + owner.Width / 2;
     point.Y = owner.Position.Y;
     ActorType = ActorType.PlayerWeapon;
     Position = point;
 }
예제 #5
0
        private static bool h_collidedWith(BaseActor actor1, BaseActor actor2)
        {
            Rectangle rectangle1;
              {
            int actorX = (int) actor1.Position.X;
            int actorY = (int) actor1.Position.Y;
            rectangle1 = new Rectangle(actorX, actorY, actor1.Width, actor1.Height);
              }

              Rectangle rectangle2;
              {
            int actorX = (int) actor2.Position.X;
            int actorY = (int) actor2.Position.Y;
            rectangle2 = new Rectangle(actorX, actorY, actor2.Width, actor2.Height);
              }

              return rectangle1.IntersectsWith(rectangle2);
        }
예제 #6
0
 private static bool h_collideCondition(BaseActor baseActor, BaseActor actorTmp)
 {
     return baseActor != actorTmp
            && baseActor.ActorType != actorTmp.ActorType
            && h_collidedWith(actorTmp, baseActor);
 }
예제 #7
0
 /// <summary>
 /// /
 /// </summary>
 /// <param name="pEnemyBullet"></param>
 public void AddBullet(BaseActor pEnemyBullet)
 {
     Actors.Add(pEnemyBullet);
 }
예제 #8
0
 public virtual void Update()
 {
     BaseActor[] actors = new BaseActor[Actors.Count];
     Actors.CopyTo(actors);
     foreach (BaseActor baseActor in actors)
     {
         baseActor.Update();
     }
 }
예제 #9
0
 ////<summary>
 /////
 ////</summary>
 public void AddBullet(BaseActor pBulletER)
 {
     Actors.Add(pBulletER);
 }
예제 #10
0
        public override void Update()
        {
            m_frameCount++;
              h_dispatchKey();
              t_TimeEnemyBul();

              base.Update();

              IEnumerable<BaseActor> killedActors = CollisionChecher.GetAllCollisions(Actors.Where((actor)=>actor.IsAlive).ToList());// отфильтровал уже убитых врагов.

              foreach (BaseActor killedActor in killedActors)
              {
            if (killedActor.IsAlive)
              killedActor.IsAlive = false;
              }

              List<BaseActor> toRemove = Actors.Where(actor => actor.CanDrop).ToList();
              BaseActor[] actors = new BaseActor[toRemove.Count()];
              toRemove.CopyTo(actors);

              foreach (BaseActor actor in actors.Where(actor => actor.CanDrop))
              {
            Actors.Remove(actor);
              }

              if (Player.CanDrop)
            Failed = true;

              //has no enemy
              //if (Actors.All(actor => actor.ActorType != ActorType.Enemy))
              if (Actors.Where((actor) => actor is Ship || actor is Ships111).ToList().Count == 0)
            Success = true;
        }