コード例 #1
0
ファイル: Mind.cs プロジェクト: ReidGiles/2D-Game-Engine
 /// <summary>
 /// called when a collision event occures
 /// </summary>
 /// <param name="args"></param>
 /// <returns></returns>
 public virtual bool OnNewCollision(ICollisionInput args)
 {
     // check if the entity has any colliders
     if (_colliders != null)
     {
         // find which collider in the _colliders is colliding
         foreach (ICreateCollider i in _colliders)
         {
             // set _colliderThis and _collided with
             if (i.GetTag() == args.GetCollided()[0])
             {
                 _collidedThis    = args.GetCollided()[0];
                 _collidedWith    = args.GetCollided()[1];
                 _collidedThisUID = args.GetUID()[0];
                 _collidedWithUID = args.GetUID()[1];
             }
             else if (i.GetTag() == args.GetCollided()[1])
             {
                 _collidedThis    = args.GetCollided()[1];
                 _collidedWith    = args.GetCollided()[0];
                 _collidedThisUID = args.GetUID()[1];
                 _collidedWithUID = args.GetUID()[0];
             }
             _overlap = args.GetOverlap();
             _cNormal = args.GetCNormal();
         }
     }
     //return whether the entity should kill itself
     return(false);
 }
コード例 #2
0
 public void OnNewCollision(object sender, ICollisionInput args)
 {
     // Check if this entity is the one colliding
     if (_uid == args.GetUID()[0] || _uid == args.GetUID()[1])
     {
         // If entity is not flagged for the removal from the scene using _killSelf
         if (!_killSelf)
         {
             //set _killSelf to the result of the collision method in the mind
             this._killSelf = _mind.OnNewCollision(args);
         }
     }
 }